leventov commented on a change in pull request #7088: Improve parallelism of 
zookeeper based segment change processing
URL: https://github.com/apache/incubator-druid/pull/7088#discussion_r279843928
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java
 ##########
 @@ -219,199 +220,182 @@ public void unmarkSegmentToDrop(DataSegment 
dataSegment)
     segmentsMarkedToDrop.remove(dataSegment);
   }
 
-  private void processSegmentChangeRequest()
+  private class SegmentChangeProcessor implements Runnable
   {
-    if (currentlyProcessing != null) {
-      log.debug(
-          "Server[%s] skipping processSegmentChangeRequest because something 
is currently loading[%s].",
-          basePath,
-          currentlyProcessing.getSegmentId()
-      );
+    private final SegmentHolder segmentHolder;
 
-      return;
-    }
-
-    if (!segmentsToDrop.isEmpty()) {
-      currentlyProcessing = segmentsToDrop.firstEntry().getValue();
-      log.debug("Server[%s] dropping [%s]", basePath, 
currentlyProcessing.getSegmentId());
-    } else if (!segmentsToLoad.isEmpty()) {
-      currentlyProcessing = segmentsToLoad.firstEntry().getValue();
-      log.debug("Server[%s] loading [%s]", basePath, 
currentlyProcessing.getSegmentId());
-    } else {
-      return;
+    private SegmentChangeProcessor(SegmentHolder segmentHolder)
+    {
+      this.segmentHolder = segmentHolder;
     }
 
-    try {
-      final String path = ZKPaths.makePath(basePath, 
currentlyProcessing.getSegmentId().toString());
-      final byte[] payload = 
jsonMapper.writeValueAsBytes(currentlyProcessing.getChangeRequest());
-      curator.create().withMode(CreateMode.EPHEMERAL).forPath(path, payload);
-
-      processingExecutor.schedule(
-          () -> {
-            try {
-              if (curator.checkExists().forPath(path) != null) {
-                failAssign(new ISE("%s was never removed! Failing this 
operation!", path));
+    @Override
+    public void run()
+    {
+      try {
+        final String path = ZKPaths.makePath(basePath, 
segmentHolder.getSegmentIdentifier());
+        final byte[] payload = 
jsonMapper.writeValueAsBytes(segmentHolder.getChangeRequest());
+        curator.create().withMode(CreateMode.EPHEMERAL).forPath(path, payload);
+        log.debug(
+            "ZKNode created for server to [%s] %s [%s]",
+            basePath,
+            segmentHolder.getType() == LOAD ? "load" : "drop",
+            segmentHolder.getSegmentIdentifier()
+        );
+        final ScheduledFuture<?> future = monitorNodeRemovedExecutor.schedule(
 
 Review comment:
   > Refactoring like this doesn't contribute anything to the functionality, 
increases the scope of changes and makes figuring out issues in the code 
through reviews difficult.
   
   These points that you brought are not special to the proposed refactoring - 
they are pretty much by definition of *any* refactoring. So does this mean that 
refactoring shouldn't be done at all? (Making refactoring in separate PRs is 
not a solution as well, at least because in practice, nobody happens to do that 
in Druid, or do very rarely.)
   
   > Comments like these, if need be, should be made towards the start of the 
review
   
   I agree with the point that *all* comments should be preferably made towards 
the start of the review, rather than in small batches. It's a place for 
improvement for me, but we have what we have here already.
   
   So could you please extract the method?

----------------------------------------------------------------
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.
 
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