use of org.apache.druid.indexing.common.task.TaskLockHelper in project druid by druid-io.
the class SegmentTransactionalInsertAction method checkWithSegmentLock.
private void checkWithSegmentLock() {
final Map<Interval, List<DataSegment>> oldSegmentsMap = groupSegmentsByIntervalAndSort(segmentsToBeOverwritten);
final Map<Interval, List<DataSegment>> newSegmentsMap = groupSegmentsByIntervalAndSort(segments);
oldSegmentsMap.values().forEach(TaskLockHelper::verifyRootPartitionIsAdjacentAndAtomicUpdateGroupIsFull);
newSegmentsMap.values().forEach(TaskLockHelper::verifyRootPartitionIsAdjacentAndAtomicUpdateGroupIsFull);
oldSegmentsMap.forEach((interval, oldSegmentsPerInterval) -> {
final List<DataSegment> newSegmentsPerInterval = Preconditions.checkNotNull(newSegmentsMap.get(interval), "segments of interval[%s]", interval);
// These lists are already sorted in groupSegmentsByIntervalAndSort().
final int oldStartRootPartitionId = oldSegmentsPerInterval.get(0).getStartRootPartitionId();
final int oldEndRootPartitionId = oldSegmentsPerInterval.get(oldSegmentsPerInterval.size() - 1).getEndRootPartitionId();
final int newStartRootPartitionId = newSegmentsPerInterval.get(0).getStartRootPartitionId();
final int newEndRootPartitionId = newSegmentsPerInterval.get(newSegmentsPerInterval.size() - 1).getEndRootPartitionId();
if (oldStartRootPartitionId != newStartRootPartitionId || oldEndRootPartitionId != newEndRootPartitionId) {
throw new ISE("Root partition range[%d, %d] of new segments doesn't match to root partition range[%d, %d] of old segments", newStartRootPartitionId, newEndRootPartitionId, oldStartRootPartitionId, oldEndRootPartitionId);
}
newSegmentsPerInterval.forEach(eachNewSegment -> oldSegmentsPerInterval.forEach(eachOldSegment -> {
if (eachNewSegment.getMinorVersion() <= eachOldSegment.getMinorVersion()) {
throw new ISE("New segment[%s] have a smaller minor version than old segment[%s]", eachNewSegment, eachOldSegment);
}
}));
});
}
Aggregations