You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/05/01 06:46:46 UTC

[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7088: Improve parallelism of zookeeper based segment change processing

samarthjain 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_r280013896
 
 

 ##########
 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:
   Done

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org