clintropolis commented on a change in pull request #8107: Add CliIndexer 
process type and initial task runner implementation
URL: https://github.com/apache/incubator-druid/pull/8107#discussion_r305237898
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ThreadingTaskRunner.java
 ##########
 @@ -0,0 +1,710 @@
+/*
+ * 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.indexing.overlord;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.io.ByteSource;
+import com.google.common.io.Files;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.errorprone.annotations.concurrent.GuardedBy;
+import com.google.inject.Inject;
+import org.apache.commons.io.FileUtils;
+import org.apache.druid.guice.annotations.Self;
+import org.apache.druid.indexer.RunnerTaskState;
+import org.apache.druid.indexer.TaskLocation;
+import org.apache.druid.indexer.TaskStatus;
+import org.apache.druid.indexing.common.TaskReportFileWriter;
+import org.apache.druid.indexing.common.TaskToolbox;
+import org.apache.druid.indexing.common.TaskToolboxFactory;
+import org.apache.druid.indexing.common.config.TaskConfig;
+import org.apache.druid.indexing.common.task.Task;
+import org.apache.druid.indexing.overlord.autoscaling.ScalingStats;
+import org.apache.druid.indexing.worker.config.WorkerConfig;
+import org.apache.druid.java.util.common.DateTimes;
+import org.apache.druid.java.util.common.IOE;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.common.Pair;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.concurrent.Execs;
+import org.apache.druid.java.util.common.io.Closer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.QueryRunner;
+import org.apache.druid.query.QuerySegmentWalker;
+import org.apache.druid.query.SegmentDescriptor;
+import org.apache.druid.segment.realtime.appenderator.AppenderatorsManager;
+import org.apache.druid.server.DruidNode;
+import org.apache.druid.tasklogs.TaskLogPusher;
+import org.apache.druid.tasklogs.TaskLogStreamer;
+import org.joda.time.DateTime;
+import org.joda.time.Interval;
+
+import javax.annotation.Nullable;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * TaskRunner implemention for the Indexer task execution service, which runs 
all tasks in a single process.
+ *
+ * Two thread pools are used:
+ * - A task execution pool, sized to number of worker slots. This is used to 
execute the Task run() methods.
+ * - A control thread pool, sized to worker slots * 2. The control threads 
setup and submit work to the
+ *   task execution pool, and are also responsible for running graceful 
shutdown on the Task objects.
+ *   Only one shutdown per-task can be running at a given time, and there is 
one control thread per task,
+ *   thus the pool has 2 * worker slots.
+ *
+ * Note that separate task logs are not supported, all task log entries will 
be written to the Indexer process log
 
 Review comment:
   I think this is a pretty big departure from what we are used to, where the 
lifetime of task logs is managed entirely independently from the relatively 
useless middle manager logs, and will definitely need to be called out. It 
might also require revisiting what goes into a task log, since it is going to 
make them a lot noisier, especially when multiple tasks are all running at the 
same time.
   
   At first, besides giggling with glee when I fired this thing up and saw task 
logs in my service log, I was a bit worried about how we would troubleshoot 
failing tasks if we were going to live in a world where task logs are just 
interleaved with everything else. However, after thinking on it a bit, I 
realized the sort of things we currently look for in task logs won't really 
have the same relevance anymore since they aren't little silos that are 
isolated from everything, so we will probably _need_ the context of everything 
else going on to figure out what's up. This does tie into a bit what makes me 
nervous about this approach in general, the loss of isolation we have with the 
middle manager model, but I think the benefits like sharing query processing, 
lookup loading, etc, still probably make it worth it, or at minimum worth 
investigating.

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