jsun98 commented on a change in pull request #6304: fixes race condition in 
kafkasupervisor
URL: https://github.com/apache/incubator-druid/pull/6304#discussion_r218210763
 
 

 ##########
 File path: 
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisor.java
 ##########
 @@ -1196,43 +1216,40 @@ public Boolean apply(KafkaIndexTask.Status status)
   private void verifyAndMergeCheckpoints(final TaskGroup taskGroup)
   {
     final int groupId = taskGroup.groupId;
-    // List<TaskId, Map -> {SequenceId, Checkpoints}>
-    final List<Pair<String, TreeMap<Integer, Map<Integer, Long>>>> 
taskSequences = new CopyOnWriteArrayList<>();
+    final List<Pair<String, TreeMap<Integer, Map<Integer, Long>>>> 
taskSequences = new ArrayList<>();
     final List<ListenableFuture<TreeMap<Integer, Map<Integer, Long>>>> futures 
= new ArrayList<>();
+    final List<String> taskIds = new ArrayList<>();
 
     for (String taskId : taskGroup.taskIds()) {
       final ListenableFuture<TreeMap<Integer, Map<Integer, Long>>> 
checkpointsFuture = taskClient.getCheckpointsAsync(
           taskId,
           true
       );
       futures.add(checkpointsFuture);
-      Futures.addCallback(
-          checkpointsFuture,
-          new FutureCallback<TreeMap<Integer, Map<Integer, Long>>>()
-          {
-            @Override
-            public void onSuccess(TreeMap<Integer, Map<Integer, Long>> 
checkpoints)
-            {
-              if (!checkpoints.isEmpty()) {
-                taskSequences.add(new Pair<>(taskId, checkpoints));
-              } else {
-                log.warn("Ignoring task [%s], as probably it is not started 
running yet", taskId);
-              }
-            }
-
-            @Override
-            public void onFailure(Throwable t)
-            {
-              log.error(t, "Problem while getting checkpoints for task [%s], 
killing the task", taskId);
-              killTask(taskId);
-              taskGroup.tasks.remove(taskId);
-            }
-          }
-      );
+      taskIds.add(taskId);
 
 Review comment:
   I think using 2 `List`s would be better since 
`Futures.successfulAsList(futures).get()` returns a list and it would be easier 
for the for loop to iterate both lists to get the taskId and checkpoint.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to