use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskAsyncCallTest method createTask.
private Task createTask(Class<? extends AbstractInvokable> invokableClass) throws Exception {
final TestingClassLoaderLease classLoaderHandle = TestingClassLoaderLease.newBuilder().setGetOrResolveClassLoaderFunction((permanentBlobKeys, urls) -> TestingUserCodeClassLoader.newBuilder().setClassLoader(new TestUserCodeClassLoader()).build()).build();
ResultPartitionConsumableNotifier consumableNotifier = new NoOpResultPartitionConsumableNotifier();
PartitionProducerStateChecker partitionProducerStateChecker = mock(PartitionProducerStateChecker.class);
Executor executor = mock(Executor.class);
TaskMetricGroup taskMetricGroup = UnregisteredMetricGroups.createUnregisteredTaskMetricGroup();
JobInformation jobInformation = new JobInformation(new JobID(), "Job Name", new SerializedValue<>(new ExecutionConfig()), new Configuration(), Collections.emptyList(), Collections.emptyList());
TaskInformation taskInformation = new TaskInformation(new JobVertexID(), "Test Task", 1, 1, invokableClass.getName(), new Configuration());
return new Task(jobInformation, taskInformation, new ExecutionAttemptID(), new AllocationID(), 0, 0, Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), mock(MemoryManager.class), mock(IOManager.class), shuffleEnvironment, new KvStateService(new KvStateRegistry(), null, null), mock(BroadcastVariableManager.class), new TaskEventDispatcher(), ExternalResourceInfoProvider.NO_EXTERNAL_RESOURCES, new TestTaskStateManager(), mock(TaskManagerActions.class), mock(InputSplitProvider.class), mock(CheckpointResponder.class), new NoOpTaskOperatorEventGateway(), new TestGlobalAggregateManager(), classLoaderHandle, mock(FileCache.class), new TestingTaskManagerRuntimeInfo(), taskMetricGroup, consumableNotifier, partitionProducerStateChecker, executor);
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testInconsistentStaticSlotAllocation.
/**
* Tests that inconsistent static slot allocation with the same AllocationID to a different slot
* is rejected.
*/
@Test
public void testInconsistentStaticSlotAllocation() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
final JobID jobId = new JobID();
final AllocationID allocationId1 = new AllocationID();
final AllocationID allocationId2 = new AllocationID();
assertThat(taskSlotTable.allocateSlot(0, jobId, allocationId1, SLOT_TIMEOUT), is(true));
assertThat(taskSlotTable.allocateSlot(1, jobId, allocationId1, SLOT_TIMEOUT), is(false));
assertThat(taskSlotTable.allocateSlot(0, jobId, allocationId2, SLOT_TIMEOUT), is(false));
assertThat(taskSlotTable.isAllocated(0, jobId, allocationId1), is(true));
assertThat(taskSlotTable.isSlotFree(1), is(true));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
assertThat(allocatedSlots.next().getIndex(), is(0));
assertThat(allocatedSlots.hasNext(), is(false));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testRemoveTaskCallsFreeSlotAction.
@Test(timeout = 10000)
public void testRemoveTaskCallsFreeSlotAction() throws Exception {
final JobID jobId = new JobID();
final ExecutionAttemptID executionAttemptId = new ExecutionAttemptID();
final AllocationID allocationId = new AllocationID();
CompletableFuture<AllocationID> freeSlotFuture = new CompletableFuture<>();
SlotActions slotActions = new TestingSlotActions(freeSlotFuture::complete, (aid, uid) -> {
});
TaskSlotPayload task = new TestingTaskSlotPayload(jobId, executionAttemptId, allocationId).terminate();
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableWithStartedTask(task, slotActions)) {
// we have to initiate closing of the slot externally
// to enable that the last remaining finished task does the final slot freeing
taskSlotTable.freeSlot(allocationId);
taskSlotTable.removeTask(executionAttemptId);
assertThat(freeSlotFuture.get(), is(allocationId));
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method runDeactivateSlotTimeoutTest.
private void runDeactivateSlotTimeoutTest(TriFunctionWithException<TaskSlotTable<TaskSlotPayload>, JobID, AllocationID, Boolean, SlotNotFoundException> taskSlotTableAction) throws Exception {
final CompletableFuture<AllocationID> timeoutCancellationFuture = new CompletableFuture<>();
final TimerService<AllocationID> testingTimerService = new TestingTimerServiceBuilder<AllocationID>().setUnregisterTimeoutConsumer(timeoutCancellationFuture::complete).createTestingTimerService();
try (final TaskSlotTableImpl<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(1, testingTimerService)) {
final AllocationID allocationId = new AllocationID();
final long timeout = 50L;
final JobID jobId = new JobID();
assertThat(taskSlotTable.allocateSlot(0, jobId, allocationId, Time.milliseconds(timeout)), is(true));
assertThat(taskSlotTableAction.apply(taskSlotTable, jobId, allocationId), is(true));
timeoutCancellationFuture.get();
}
}
use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.
the class TaskSlotTableImplTest method testDuplicateStaticSlotAllocation.
@Test
public void testDuplicateStaticSlotAllocation() throws Exception {
try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
final JobID jobId = new JobID();
final AllocationID allocationId = new AllocationID();
assertThat(taskSlotTable.allocateSlot(0, jobId, allocationId, ResourceProfile.UNKNOWN, SLOT_TIMEOUT), is(true));
assertThat(taskSlotTable.allocateSlot(0, jobId, allocationId, ResourceProfile.UNKNOWN, SLOT_TIMEOUT), is(true));
assertThat(taskSlotTable.isAllocated(0, jobId, allocationId), is(true));
assertThat(taskSlotTable.isSlotFree(1), is(true));
Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
assertThat(allocatedSlots.next().getIndex(), is(0));
assertThat(allocatedSlots.hasNext(), is(false));
}
}
Aggregations