use of org.apache.druid.indexing.common.TaskLock in project druid by druid-io.
the class TaskLocksTest method testCheckSegmentLockCoversSegments.
@Test
public void testCheckSegmentLockCoversSegments() {
final Set<DataSegment> segments = createNumberedPartitionedSegments();
final Interval interval = Intervals.of("2017-01-01/2017-01-02");
final String version = DateTimes.nowUtc().toString();
final List<TaskLock> locks = IntStream.range(0, 5).mapToObj(partitionId -> {
final TaskLock lock = trySegmentLock(task, interval, version, partitionId).getTaskLock();
Assert.assertNotNull(lock);
return lock;
}).collect(Collectors.toList());
Assert.assertEquals(5, locks.size());
Assert.assertTrue(TaskLocks.isLockCoversSegments(task, lockbox, segments));
}
use of org.apache.druid.indexing.common.TaskLock in project druid by druid-io.
the class TimeChunkLockTryAcquireActionTest method testWithLockType.
@Test(timeout = 60_000L)
public void testWithLockType() {
final Task task = NoopTask.create();
final TimeChunkLockTryAcquireAction action = new TimeChunkLockTryAcquireAction(TaskLockType.EXCLUSIVE, Intervals.of("2017-01-01/2017-01-02"));
actionTestKit.getTaskLockbox().add(task);
final TaskLock lock = action.perform(task, actionTestKit.getTaskActionToolbox());
Assert.assertNotNull(lock);
}
use of org.apache.druid.indexing.common.TaskLock in project druid by druid-io.
the class TimeChunkLockAcquireActionTest method testWithLockType.
@Test(timeout = 60_000L)
public void testWithLockType() {
final Task task = NoopTask.create();
final TimeChunkLockAcquireAction action = new TimeChunkLockAcquireAction(TaskLockType.EXCLUSIVE, Intervals.of("2017-01-01/2017-01-02"), 1000);
actionTestKit.getTaskLockbox().add(task);
final TaskLock lock = action.perform(task, actionTestKit.getTaskActionToolbox());
Assert.assertNotNull(lock);
}
use of org.apache.druid.indexing.common.TaskLock in project druid by druid-io.
the class TimeChunkLockAcquireActionTest method testWithoutLockType.
@Test(timeout = 60_000L)
public void testWithoutLockType() {
final Task task = NoopTask.create();
final TimeChunkLockAcquireAction action = new TimeChunkLockAcquireAction(null, Intervals.of("2017-01-01/2017-01-02"), 1000);
actionTestKit.getTaskLockbox().add(task);
final TaskLock lock = action.perform(task, actionTestKit.getTaskActionToolbox());
Assert.assertNotNull(lock);
}
use of org.apache.druid.indexing.common.TaskLock in project druid by druid-io.
the class HashPartitionCachingLocalSegmentAllocatorTest method createTaskActionClient.
private static TaskActionClient createTaskActionClient() {
List<TaskLock> taskLocks = Collections.singletonList(createTaskLock());
try {
TaskActionClient taskActionClient = EasyMock.mock(TaskActionClient.class);
EasyMock.expect(taskActionClient.submit(EasyMock.anyObject(LockListAction.class))).andStubReturn(taskLocks);
EasyMock.replay(taskActionClient);
return taskActionClient;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations