use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testSlotAllocationWithDynamicSlotId.
@Test
public void testSlotAllocationWithDynamicSlotId() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
final JobID jobId = new JobID();
final AllocationID allocationId = new AllocationID();
assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
assertThat(allocatedSlots.next().getIndex(), is(2));
assertThat(allocatedSlots.hasNext(), is(false));
assertThat(taskSlotTable.isAllocated(2, jobId, allocationId), is(true));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testDuplicateDynamicSlotAllocation.
@Test
public void testDuplicateDynamicSlotAllocation() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(1)) {
final JobID jobId = new JobID();
final AllocationID allocationId = new AllocationID();
assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
TaskSlot<TaskSlotPayload> taskSlot1 = allocatedSlots.next();
assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
TaskSlot<TaskSlotPayload> taskSlot2 = allocatedSlots.next();
assertThat(taskSlotTable.isAllocated(1, jobId, allocationId), is(true));
assertEquals(taskSlot1, taskSlot2);
assertThat(allocatedSlots.hasNext(), is(false));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testInconsistentDynamicSlotAllocation.
/**
* Tests that inconsistent dynamic slot allocation with the same AllocationID to a different
* slot is rejected.
*/
@Test
public void testInconsistentDynamicSlotAllocation() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(1)) {
final JobID jobId1 = new JobID();
final JobID jobId2 = new JobID();
final AllocationID allocationId = new AllocationID();
assertThat(taskSlotTable.allocateSlot(-1, jobId1, allocationId, SLOT_TIMEOUT), is(true));
assertThat(taskSlotTable.allocateSlot(-1, jobId2, allocationId, SLOT_TIMEOUT), is(false));
assertThat(taskSlotTable.isAllocated(1, jobId1, allocationId), is(true));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId1);
assertThat(allocatedSlots.next().getAllocationId(), is(allocationId));
assertThat(allocatedSlots.hasNext(), is(false));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testAllocateSlot.
@Test
public void testAllocateSlot() throws Exception {
final JobID jobId = new JobID();
final AllocationID allocationId = new AllocationID();
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableWithAllocatedSlot(jobId, allocationId, new TestingSlotActionsBuilder().build())) {
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
TaskSlot<TaskSlotPayload> nextSlot = allocatedSlots.next();
assertThat(nextSlot.getIndex(), is(0));
assertThat(nextSlot.getAllocationId(), is(allocationId));
assertThat(nextSlot.getJobId(), is(jobId));
assertThat(allocatedSlots.hasNext(), is(false));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testSlotAllocationWithResourceProfileFailure.
@Test
public void testSlotAllocationWithResourceProfileFailure() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
final JobID jobId = new JobID();
final AllocationID allocationId = new AllocationID();
ResourceProfile resourceProfile = TaskSlotUtils.DEFAULT_RESOURCE_PROFILE;
resourceProfile = resourceProfile.merge(resourceProfile).merge(resourceProfile);
assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, resourceProfile, SLOT_TIMEOUT), is(false));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
assertThat(allocatedSlots.hasNext(), is(false));
}
}
Aggregations