use of org.apache.druid.indexing.overlord.TaskLockbox.TaskLockPosse in project druid by druid-io.
the class TaskLockboxTest method testFindLockPosseAfterRevokeWithDifferentLockIntervals.
@Test
public void testFindLockPosseAfterRevokeWithDifferentLockIntervals() throws EntryExistsException {
final Task lowPriorityTask = NoopTask.create(0);
final Task highPriorityTask = NoopTask.create(10);
taskStorage.insert(lowPriorityTask, TaskStatus.running(lowPriorityTask.getId()));
taskStorage.insert(highPriorityTask, TaskStatus.running(highPriorityTask.getId()));
lockbox.add(lowPriorityTask);
lockbox.add(highPriorityTask);
Assert.assertTrue(tryTimeChunkLock(TaskLockType.EXCLUSIVE, lowPriorityTask, Intervals.of("2018-12-16T09:00:00/2018-12-16T10:00:00")).isOk());
Assert.assertTrue(tryTimeChunkLock(TaskLockType.EXCLUSIVE, highPriorityTask, Intervals.of("2018-12-16T09:00:00/2018-12-16T09:30:00")).isOk());
final List<TaskLockPosse> highLockPosses = lockbox.getOnlyTaskLockPosseContainingInterval(highPriorityTask, Intervals.of("2018-12-16T09:00:00/2018-12-16T09:30:00"));
Assert.assertEquals(1, highLockPosses.size());
Assert.assertTrue(highLockPosses.get(0).containsTask(highPriorityTask));
Assert.assertFalse(highLockPosses.get(0).getTaskLock().isRevoked());
final List<TaskLockPosse> lowLockPosses = lockbox.getOnlyTaskLockPosseContainingInterval(lowPriorityTask, Intervals.of("2018-12-16T09:00:00/2018-12-16T10:00:00"));
Assert.assertEquals(1, lowLockPosses.size());
Assert.assertTrue(lowLockPosses.get(0).containsTask(lowPriorityTask));
Assert.assertTrue(lowLockPosses.get(0).getTaskLock().isRevoked());
}
use of org.apache.druid.indexing.overlord.TaskLockbox.TaskLockPosse in project druid by druid-io.
the class TaskLockboxTest method testGetTimeChunkAndSegmentLockForSameGroup.
@Test
public void testGetTimeChunkAndSegmentLockForSameGroup() {
final Task task1 = NoopTask.withGroupId("groupId");
final Task task2 = NoopTask.withGroupId("groupId");
lockbox.add(task1);
lockbox.add(task2);
Assert.assertTrue(lockbox.tryLock(task1, new TimeChunkLockRequest(TaskLockType.EXCLUSIVE, task1, Intervals.of("2017/2018"), null)).isOk());
Assert.assertTrue(lockbox.tryLock(task2, new SpecificSegmentLockRequest(TaskLockType.EXCLUSIVE, task2, Intervals.of("2017/2018"), "version", 0)).isOk());
final List<TaskLockPosse> posses = lockbox.getAllLocks().get(task1.getDataSource()).get(DateTimes.of("2017")).get(Intervals.of("2017/2018"));
Assert.assertEquals(2, posses.size());
Assert.assertEquals(LockGranularity.TIME_CHUNK, posses.get(0).getTaskLock().getGranularity());
final TimeChunkLock timeChunkLock = (TimeChunkLock) posses.get(0).getTaskLock();
Assert.assertEquals("none", timeChunkLock.getDataSource());
Assert.assertEquals("groupId", timeChunkLock.getGroupId());
Assert.assertEquals(Intervals.of("2017/2018"), timeChunkLock.getInterval());
Assert.assertEquals(LockGranularity.SEGMENT, posses.get(1).getTaskLock().getGranularity());
final SegmentLock segmentLock = (SegmentLock) posses.get(1).getTaskLock();
Assert.assertEquals("none", segmentLock.getDataSource());
Assert.assertEquals("groupId", segmentLock.getGroupId());
Assert.assertEquals(Intervals.of("2017/2018"), segmentLock.getInterval());
Assert.assertEquals(0, segmentLock.getPartitionId());
}
use of org.apache.druid.indexing.overlord.TaskLockbox.TaskLockPosse in project druid by druid-io.
the class TaskLockboxTest method testLockPosseEquals.
@Test
public void testLockPosseEquals() {
final Task task1 = NoopTask.create();
final Task task2 = NoopTask.create();
TaskLock taskLock1 = new TimeChunkLock(TaskLockType.EXCLUSIVE, task1.getGroupId(), task1.getDataSource(), Intervals.of("2018/2019"), "v1", task1.getPriority());
TaskLock taskLock2 = new TimeChunkLock(TaskLockType.EXCLUSIVE, task2.getGroupId(), task2.getDataSource(), Intervals.of("2018/2019"), "v2", task2.getPriority());
TaskLockPosse taskLockPosse1 = new TaskLockPosse(taskLock1);
TaskLockPosse taskLockPosse2 = new TaskLockPosse(taskLock2);
TaskLockPosse taskLockPosse3 = new TaskLockPosse(taskLock1);
Assert.assertNotEquals(taskLockPosse1, null);
Assert.assertNotEquals(null, taskLockPosse1);
Assert.assertNotEquals(taskLockPosse1, taskLockPosse2);
Assert.assertEquals(taskLockPosse1, taskLockPosse3);
}
Aggregations