gianm 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_r258299228
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeonV2.java
 ##########
 @@ -0,0 +1,418 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server.coordinator;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorWatcher;
+import org.apache.curator.utils.ZKPaths;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.server.coordination.DataSegmentChangeRequest;
+import org.apache.druid.server.coordination.SegmentChangeRequestDrop;
+import org.apache.druid.server.coordination.SegmentChangeRequestLoad;
+import org.apache.druid.server.coordination.SegmentChangeRequestNoop;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.SegmentId;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.data.Stat;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Use {@link HttpLoadQueuePeon} instead.
+ */
+@Deprecated
+public class CuratorLoadQueuePeonV2 extends LoadQueuePeon
+{
+  private static final EmittingLogger log = new 
EmittingLogger(CuratorLoadQueuePeon.class);
+  private static final int DROP = 0;
+  private static final int LOAD = 1;
+  private final CuratorFramework curator;
+  private final String basePath;
+  private final ObjectMapper jsonMapper;
+  private final ExecutorService processingExecutor;
+  private final ScheduledExecutorService checkNodeRemovedExecutor;
+  private final ExecutorService callBackExecutor;
+  private final DruidCoordinatorConfig config;
+
+  private final AtomicLong queuedSize = new AtomicLong(0);
+  private final AtomicInteger failedAssignCount = new AtomicInteger(0);
+
+  private final ConcurrentSkipListMap<DataSegment, SegmentHolder> 
segmentsToLoad = new ConcurrentSkipListMap<>(
+      DruidCoordinator.SEGMENT_COMPARATOR
+  );
+  private final ConcurrentSkipListMap<DataSegment, SegmentHolder> 
segmentsToDrop = new ConcurrentSkipListMap<>(
+      DruidCoordinator.SEGMENT_COMPARATOR
+  );
+  private final ConcurrentSkipListSet<DataSegment> segmentsMarkedToDrop = new 
ConcurrentSkipListSet<>(
+      DruidCoordinator.SEGMENT_COMPARATOR
+  );
+
+  private static final int MAX_TASK_WAIT = 100;
+
+  CuratorLoadQueuePeonV2(
+      CuratorFramework curator,
+      String basePath,
+      ObjectMapper jsonMapper,
+      ExecutorService processingExecutor,
+      ExecutorService callbackExecutor,
+      DruidCoordinatorConfig config
+  )
+  {
+    this.curator = curator;
+    this.basePath = basePath;
+    this.jsonMapper = jsonMapper;
+    this.callBackExecutor = callbackExecutor;
+    this.processingExecutor = processingExecutor;
+    this.config = config;
+    //TODO: samarth configure the size of this pool
+    this.checkNodeRemovedExecutor = Executors.newScheduledThreadPool(5, new 
ThreadFactoryBuilder().setNameFormat(
 
 Review comment:
   Use `Execs.makeThreadFactory` to make the thread factory; it's shorter and 
makes daemon threads by default. Also, please don't commit "TODO" comments.

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


With regards,
Apache Git Services

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

Reply via email to