use of org.apache.druid.timeline.partition.NumberedOverwritePartialShardSpec in project druid by druid-io.
the class IndexerSQLMetadataStorageCoordinatorTest method testAllocatePendingSegmentsWithOvershadowingSegments.
@Test
public void testAllocatePendingSegmentsWithOvershadowingSegments() throws IOException {
final String dataSource = "ds";
final Interval interval = Intervals.of("2017-01-01/2017-02-01");
String prevSegmentId = null;
for (int i = 0; i < 10; i++) {
final SegmentIdWithShardSpec identifier = coordinator.allocatePendingSegment(dataSource, "seq", prevSegmentId, interval, new NumberedOverwritePartialShardSpec(0, 1, (short) (i + 1)), "version", false);
Assert.assertEquals(StringUtils.format("ds_2017-01-01T00:00:00.000Z_2017-02-01T00:00:00.000Z_version%s", "_" + (i + PartitionIds.NON_ROOT_GEN_START_PARTITION_ID)), identifier.toString());
prevSegmentId = identifier.toString();
final Set<DataSegment> toBeAnnounced = Collections.singleton(new DataSegment(identifier.getDataSource(), identifier.getInterval(), identifier.getVersion(), null, Collections.emptyList(), Collections.emptyList(), ((NumberedOverwriteShardSpec) identifier.getShardSpec()).withAtomicUpdateGroupSize(1), 0, 10L));
final Set<DataSegment> announced = coordinator.announceHistoricalSegments(toBeAnnounced);
Assert.assertEquals(toBeAnnounced, announced);
}
final Collection<DataSegment> visibleSegments = coordinator.retrieveUsedSegmentsForInterval(dataSource, interval, Segments.ONLY_VISIBLE);
Assert.assertEquals(1, visibleSegments.size());
Assert.assertEquals(new DataSegment(dataSource, interval, "version", null, Collections.emptyList(), Collections.emptyList(), new NumberedOverwriteShardSpec(9 + PartitionIds.NON_ROOT_GEN_START_PARTITION_ID, 0, 1, (short) 9, (short) 1), 0, 10L), Iterables.getOnlyElement(visibleSegments));
}
use of org.apache.druid.timeline.partition.NumberedOverwritePartialShardSpec in project druid by druid-io.
the class TaskLockboxTest method testRequestForNewSegmentWithSegmentLock.
@Test
public void testRequestForNewSegmentWithSegmentLock() {
final Task task = NoopTask.create();
lockbox.add(task);
allocateSegmentsAndAssert(task, "seq", 3, NumberedPartialShardSpec.instance());
allocateSegmentsAndAssert(task, "seq2", 2, new NumberedOverwritePartialShardSpec(0, 3, (short) 1));
final List<TaskLock> locks = lockbox.findLocksForTask(task);
Assert.assertEquals(5, locks.size());
int expectedPartitionId = 0;
for (TaskLock lock : locks) {
Assert.assertTrue(lock instanceof SegmentLock);
final SegmentLock segmentLock = (SegmentLock) lock;
Assert.assertEquals(expectedPartitionId++, segmentLock.getPartitionId());
if (expectedPartitionId == 3) {
expectedPartitionId = PartitionIds.NON_ROOT_GEN_START_PARTITION_ID;
}
}
}
Aggregations