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_r297913092
########## File path: indexing-service/src/main/java/org/apache/druid/indexing/overlord/LockRequestForNewSegment.java ########## @@ -0,0 +1,183 @@ +/* + * 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.google.common.annotations.VisibleForTesting; +import org.apache.druid.indexing.common.LockGranularity; +import org.apache.druid.indexing.common.TaskLock; +import org.apache.druid.indexing.common.TaskLockType; +import org.apache.druid.indexing.common.task.Task; +import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.timeline.partition.ShardSpecFactory; +import org.joda.time.Interval; + +import javax.annotation.Nullable; + +public class LockRequestForNewSegment implements LockRequest +{ + private final TaskLockType lockType; + private final String groupId; + private final String dataSource; + private final Interval interval; + private final ShardSpecFactory shardSpecFactory; + private final int priority; + private final String sequenceName; + @Nullable + private final String previsousSegmentId; + private final boolean skipSegmentLineageCheck; + + public LockRequestForNewSegment( + TaskLockType lockType, + String groupId, + String dataSource, + Interval interval, + ShardSpecFactory shardSpecFactory, + int priority, + String sequenceName, + @Nullable String previsousSegmentId, + boolean skipSegmentLineageCheck + ) + { + this.lockType = lockType; + this.groupId = groupId; + this.dataSource = dataSource; + this.interval = interval; + this.shardSpecFactory = shardSpecFactory; + this.priority = priority; + this.sequenceName = sequenceName; + this.previsousSegmentId = previsousSegmentId; + this.skipSegmentLineageCheck = skipSegmentLineageCheck; + } + + @VisibleForTesting + public LockRequestForNewSegment( + TaskLockType lockType, + Task task, + Interval interval, + ShardSpecFactory shardSpecFactory, + String sequenceName, + @Nullable String previsousSegmentId, + boolean skipSegmentLineageCheck + ) + { + this( + lockType, + task.getGroupId(), + task.getDataSource(), + interval, + shardSpecFactory, + task.getPriority(), + sequenceName, + previsousSegmentId, + skipSegmentLineageCheck + ); + } + + @Override + public LockGranularity getGranularity() + { + return LockGranularity.SEGMENT; + } + + @Override + public TaskLockType getType() + { + return lockType; + } + + @Override + public String getGroupId() + { + return groupId; + } + + @Override + public String getDataSource() + { + return dataSource; + } + + @Override + public Interval getInterval() + { + return interval; + } + + @Override + public int getPriority() + { + return priority; + } + + public ShardSpecFactory getShardSpecFactory() + { + return shardSpecFactory; + } + + @Override + public String getVersion() + { + return DateTimes.nowUtc().toString(); + } + + @Override + public boolean isRevoked() + { + return false; + } + + @Override + public TaskLock toLock() + { + throw new UnsupportedOperationException(); Review comment: Can you add a comment here about how `LockRequestForNewSegment` gets converted to `SpecificSegmentLockRequest` in `TaskLockbox`? ---------------------------------------------------------------- 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]
