dmvk commented on a change in pull request #16464:
URL: https://github.com/apache/flink/pull/16464#discussion_r667992919



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/client/DuplicateJobSubmissionException.java
##########
@@ -25,7 +25,19 @@
  */
 public class DuplicateJobSubmissionException extends JobSubmissionException {
 
-    public DuplicateJobSubmissionException(JobID jobID) {
+    private final boolean terminated;
+
+    public DuplicateJobSubmissionException(JobID jobID, boolean terminated) {

Review comment:
       Agreed with the reasoning, however it also have negatives. Primitive 
boolean is a simple two state flag. Enums can have multiple states, new ones 
can be added over time, so it may actually complicate maintenance and by nature 
they require more sophisticated handling (null checks, unknown states).
   
   If the concern is about "constructor readability", how about replacing this 
with "named constructors"?
   
   `DuplicateJobSubmissionException.of(jobId)`
   `DuplicateJobSubmissionException.ofGloballyTerminated(jobId)`
   
   I have no hard feelings about this one, so if you don't like the proposal, I 
can stick to enums.

##########
File path: 
flink-clients/src/test/java/org/apache/flink/client/deployment/application/ApplicationDispatcherBootstrapTest.java
##########
@@ -650,6 +655,66 @@ public void 
testClusterDoesNOTShutdownWhenApplicationStatusUknown() throws Excep
         assertEquals(exception.getStatus(), ApplicationStatus.UNKNOWN);
     }
 
+    @Test
+    public void testDuplicateJobSubmissionWithTerminatedJobId() throws 
Throwable {
+        final JobID testJobID = new JobID(0, 2);
+        final Configuration configurationUnderTest = getConfiguration();
+        configurationUnderTest.set(
+                PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID, 
testJobID.toHexString());
+        configurationUnderTest.set(
+                HighAvailabilityOptions.HA_MODE, 
HighAvailabilityMode.ZOOKEEPER.name());
+        final TestingDispatcherGateway.Builder dispatcherBuilder =
+                new TestingDispatcherGateway.Builder()
+                        .setSubmitFunction(
+                                jobGraph -> {
+                                    final CompletableFuture<Acknowledge> 
submit =
+                                            new CompletableFuture<>();
+                                    submit.completeExceptionally(
+                                            new 
DuplicateJobSubmissionException(testJobID, true));
+                                    return submit;
+                                })
+                        .setRequestJobStatusFunction(
+                                jobId -> 
CompletableFuture.completedFuture(JobStatus.FINISHED))
+                        .setRequestJobResultFunction(
+                                jobId ->
+                                        CompletableFuture.completedFuture(
+                                                
createSuccessfulJobResult(jobId)));

Review comment:
       Fixed. ApplicationDispatcherBootstrap now returns "unknown" JobResult in 
case job result can no longer be retrieved after fail-over.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to