drcrallen commented on a change in pull request #5492: Native parallel batch 
indexing without shuffle
URL: https://github.com/apache/incubator-druid/pull/5492#discussion_r201772643
 
 

 ##########
 File path: 
indexing-service/src/main/java/io/druid/indexing/common/task/ParallelIndexSupervisorTask.java
 ##########
 @@ -0,0 +1,322 @@
+/*
+ * Licensed to Metamarkets Group Inc. (Metamarkets) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. Metamarkets 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 io.druid.indexing.common.task;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import io.druid.client.indexing.IndexingServiceClient;
+import io.druid.data.input.FiniteFirehoseFactory;
+import io.druid.data.input.FirehoseFactory;
+import io.druid.indexer.TaskStatus;
+import io.druid.indexing.common.TaskLock;
+import io.druid.indexing.common.TaskToolbox;
+import io.druid.indexing.common.actions.TaskActionClient;
+import io.druid.indexing.common.stats.RowIngestionMetersFactory;
+import io.druid.indexing.common.task.IndexTask.IndexIngestionSpec;
+import io.druid.indexing.common.task.IndexTask.IndexTuningConfig;
+import io.druid.java.util.common.IAE;
+import io.druid.java.util.common.logger.Logger;
+import io.druid.segment.realtime.firehose.ChatHandler;
+import io.druid.segment.realtime.firehose.ChatHandlerProvider;
+import io.druid.server.security.AuthorizerMapper;
+import org.joda.time.Interval;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+
+/**
+ * ParallelIndexSupervisorTask is capable of running multiple subTasks for 
parallel indexing. This is
+ * applicable if the input {@link FiniteFirehoseFactory} is splittable. While 
this task is running, it can submit
+ * multiple child tasks to overlords. This task succeeds only when all its 
child tasks succeed; otherwise it fails.
+ *
+ * @see ParallelIndexTaskRunner
+ */
+public class ParallelIndexSupervisorTask extends AbstractTask implements 
ChatHandler
+{
+  static final String TYPE = "index_parallel";
+
+  private static final Logger log = new 
Logger(ParallelIndexSupervisorTask.class);
+
+  private final ParallelIndexIngestionSpec ingestionSchema;
+  private final FiniteFirehoseFactory<?, ?> baseFirehoseFactory;
+  private final IndexingServiceClient indexingServiceClient;
+  private final ChatHandlerProvider chatHandlerProvider;
+  private final AuthorizerMapper authorizerMapper;
+  private final RowIngestionMetersFactory rowIngestionMetersFactory;
+
+  private ParallelIndexTaskRunner runner;
+
+  @JsonCreator
+  public ParallelIndexSupervisorTask(
+      @JsonProperty("id") String id,
+      @JsonProperty("resource") TaskResource taskResource,
+      @JsonProperty("spec") ParallelIndexIngestionSpec ingestionSchema,
+      @JsonProperty("context") Map<String, Object> context,
+      @JacksonInject @Nullable IndexingServiceClient indexingServiceClient, // 
null in overlords
+      @JacksonInject @Nullable ChatHandlerProvider chatHandlerProvider,     // 
null in overlords
+      @JacksonInject AuthorizerMapper authorizerMapper,
+      @JacksonInject RowIngestionMetersFactory rowIngestionMetersFactory
+  )
+  {
+    super(
+        getOrMakeId(id, TYPE, ingestionSchema.getDataSchema().getDataSource()),
+        null,
+        taskResource,
+        ingestionSchema.getDataSchema().getDataSource(),
+        context
+    );
+
+    this.ingestionSchema = ingestionSchema;
+
+    final FirehoseFactory firehoseFactory = 
ingestionSchema.getIOConfig().getFirehoseFactory();
+    if (!(firehoseFactory instanceof FiniteFirehoseFactory)) {
+      throw new IAE("[%s] should implement FiniteFirehoseFactory", 
firehoseFactory.getClass().getSimpleName());
+    }
+
+    this.baseFirehoseFactory = (FiniteFirehoseFactory) firehoseFactory;
+    this.indexingServiceClient = indexingServiceClient;
+    this.chatHandlerProvider = chatHandlerProvider;
+    this.authorizerMapper = authorizerMapper;
+    this.rowIngestionMetersFactory = rowIngestionMetersFactory;
+
+    if (ingestionSchema.getTuningConfig().getMaxSavedParseExceptions() > 0) {
+      log.warn("maxSavedParseExceptions is not supported yet");
+    }
+    if (ingestionSchema.getTuningConfig().getMaxParseExceptions() > 0) {
+      log.warn("maxParseExceptions is not supported yet");
+    }
+    if (ingestionSchema.getTuningConfig().isLogParseExceptions()) {
+      log.warn("logParseExceptions is not supported yet");
+    }
+  }
+
+  @Override
+  public int getPriority()
+  {
+    return getContextValue(Tasks.PRIORITY_KEY, 
Tasks.DEFAULT_BATCH_INDEX_TASK_PRIORITY);
+  }
+
+  @Override
+  public String getType()
+  {
+    return TYPE;
+  }
+
+  @JsonProperty("spec")
+  public ParallelIndexIngestionSpec getIngestionSchema()
+  {
+    return ingestionSchema;
+  }
+
+  @VisibleForTesting
+  @Nullable
+  ParallelIndexTaskRunner getRunner()
+  {
+    return runner;
+  }
+
+  @VisibleForTesting
+  AuthorizerMapper getAuthorizerMapper()
+  {
+    return authorizerMapper;
+  }
+
+  @VisibleForTesting
+  ParallelIndexTaskRunner createRunner()
+  {
+    if (ingestionSchema.getTuningConfig().isForceGuaranteedRollup()) {
+      throw new UnsupportedOperationException("Perfect roll-up is not 
supported yet");
+    } else {
+      runner = new SinglePhaseParallelIndexTaskRunner(
+          getId(),
+          getGroupId(),
+          ingestionSchema,
+          getContext(),
+          indexingServiceClient,
+          chatHandlerProvider,
+          authorizerMapper
+      );
+    }
+    return runner;
+  }
+
+  @Override
+  public boolean isReady(TaskActionClient taskActionClient) throws Exception
+  {
+    final Optional<SortedSet<Interval>> intervals = 
ingestionSchema.getDataSchema()
+                                                                   
.getGranularitySpec()
+                                                                   
.bucketIntervals();
+
+    return !intervals.isPresent() || isReady(taskActionClient, 
intervals.get());
+  }
+
+  static boolean isReady(TaskActionClient actionClient, SortedSet<Interval> 
intervals) throws IOException
+  {
+    final List<TaskLock> locks = getTaskLocks(actionClient);
+    if (locks.size() == 0) {
 
 Review comment:
   `isEmpty`

----------------------------------------------------------------
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: dev-unsubscr...@druid.apache.org
For additional commands, e-mail: dev-h...@druid.apache.org

Reply via email to