jon-wei commented on a change in pull request #7547: Add support minor 
compaction with segment locking
URL: https://github.com/apache/incubator-druid/pull/7547#discussion_r297446907
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/common/task/AbstractBatchIndexTask.java
 ##########
 @@ -0,0 +1,377 @@
+/*
+ * 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.common.task;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import org.apache.druid.indexing.common.SegmentLock;
+import org.apache.druid.indexing.common.TaskLock;
+import org.apache.druid.indexing.common.TaskLockType;
+import org.apache.druid.indexing.common.actions.SegmentLockReleaseAction;
+import org.apache.druid.indexing.common.actions.SegmentLockTryAcquireAction;
+import org.apache.druid.indexing.common.actions.TaskActionClient;
+import org.apache.druid.indexing.common.actions.TimeChunkLockTryAcquireAction;
+import org.apache.druid.indexing.overlord.LockResult;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.common.JodaUtils;
+import org.apache.druid.java.util.common.granularity.Granularity;
+import org.apache.druid.java.util.common.io.Closer;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.TimelineObjectHolder;
+import org.apache.druid.timeline.VersionedIntervalTimeline;
+import org.apache.druid.timeline.partition.PartitionChunk;
+import org.joda.time.Interval;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+/**
+ * Abstract class for batch tasks like {@link IndexTask}.
+ * Provides some methods ({@link #tryLockWithIntervals} and {@link 
#tryLockWithSegments}) for easily acquiring task
+ * locks.
+ */
+public abstract class AbstractBatchIndexTask extends AbstractTask
+{
+  @Nullable
+  private Map<Interval, OverwritingRootGenerationPartitions> 
overwritingRootGenPartitions;
+  @Nullable
+  private Set<DataSegment> allInputSegments;
+
+  @Nullable
+  private Boolean changeSegmentGranularity;
+
+  public static class OverwritingRootGenerationPartitions
+  {
+    private final int startRootPartitionId;
+    private final int endRootPartitionId;
+    private final short maxMinorVersion;
+
+    private OverwritingRootGenerationPartitions(int startRootPartitionId, int 
endRootPartitionId, short maxMinorVersion)
+    {
+      this.startRootPartitionId = startRootPartitionId;
+      this.endRootPartitionId = endRootPartitionId;
+      this.maxMinorVersion = maxMinorVersion;
+    }
+
+    public int getStartRootPartitionId()
+    {
+      return startRootPartitionId;
+    }
+
+    public int getEndRootPartitionId()
+    {
+      return endRootPartitionId;
+    }
+
+    public short getMinorVersionForNewSegments()
+    {
+      return (short) (maxMinorVersion + 1);
+    }
+  }
+
+  protected AbstractBatchIndexTask(String id, String dataSource, Map<String, 
Object> context)
+  {
+    super(id, dataSource, context);
+  }
+
+  protected AbstractBatchIndexTask(
+      String id,
+      @Nullable String groupId,
+      @Nullable TaskResource taskResource,
+      String dataSource,
+      @Nullable Map<String, Object> context
+  )
+  {
+    super(id, groupId, taskResource, dataSource, context);
+  }
+
+  public abstract boolean requireLockInputSegments();
 
 Review comment:
   `requireLockInputSegments` -> The method name seems to assume that all batch 
index tasks have input segments (what if it's just reading from a CSV file?)

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