Search in sources :

Example 16 with TaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway in project flink by apache.

the class Execution method sendFailIntermediateResultPartitionsRpcCall.

private void sendFailIntermediateResultPartitionsRpcCall() {
    final SimpleSlot slot = assignedResource;
    if (slot != null) {
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        // TODO For some tests this could be a problem when querying too early if all resources were released
        taskManagerGateway.failPartition(attemptId);
    }
}
Also used : TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot)

Example 17 with TaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway in project flink by apache.

the class SlotPoolTest method createAllocatedSlot.

static AllocatedSlot createAllocatedSlot(final ResourceID resourceId, final AllocationID allocationId, final JobID jobId, final ResourceProfile resourceProfile) {
    TaskManagerLocation mockTaskManagerLocation = mock(TaskManagerLocation.class);
    when(mockTaskManagerLocation.getResourceID()).thenReturn(resourceId);
    TaskManagerGateway mockTaskManagerGateway = mock(TaskManagerGateway.class);
    return new AllocatedSlot(allocationId, jobId, mockTaskManagerLocation, 0, resourceProfile, mockTaskManagerGateway);
}
Also used : AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway)

Example 18 with TaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway in project flink by apache.

the class ExecutionGraphSchedulingTest method createTaskManager.

private static TaskManagerGateway createTaskManager() {
    TaskManagerGateway tm = mock(TaskManagerGateway.class);
    when(tm.submitTask(any(TaskDeploymentDescriptor.class), any(Time.class))).thenReturn(FlinkCompletableFuture.completed(Acknowledge.get()));
    return tm;
}
Also used : TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) Time(org.apache.flink.api.common.time.Time)

Example 19 with TaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway in project flink by apache.

the class ExecutionGraphSchedulingTest method testTimeoutForSlotAllocation.

/**
	 * This test verifies that the slot allocations times out after a certain time, and that
	 * all slots are released in that case.
	 */
@Test
public void testTimeoutForSlotAllocation() throws Exception {
    //  we construct a simple graph:    (task)
    final int parallelism = 3;
    final JobVertex vertex = new JobVertex("task");
    vertex.setParallelism(parallelism);
    vertex.setInvokableClass(NoOpInvokable.class);
    final JobID jobId = new JobID();
    final JobGraph jobGraph = new JobGraph(jobId, "test", vertex);
    final SlotOwner slotOwner = mock(SlotOwner.class);
    final TaskManagerGateway taskManager = mock(TaskManagerGateway.class);
    final SimpleSlot[] slots = new SimpleSlot[parallelism];
    @SuppressWarnings({ "unchecked", "rawtypes" }) final FlinkCompletableFuture<SimpleSlot>[] slotFutures = new FlinkCompletableFuture[parallelism];
    for (int i = 0; i < parallelism; i++) {
        slots[i] = createSlot(taskManager, jobId, slotOwner);
        slotFutures[i] = new FlinkCompletableFuture<>();
    }
    ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(parallelism);
    slotProvider.addSlots(vertex.getID(), slotFutures);
    final ExecutionGraph eg = createExecutionGraph(jobGraph, slotProvider, Time.milliseconds(20));
    final TerminalJobStatusListener statusListener = new TerminalJobStatusListener();
    eg.registerJobStatusListener(statusListener);
    //  we complete one future
    slotFutures[1].complete(slots[1]);
    //  kick off the scheduling
    eg.setScheduleMode(ScheduleMode.EAGER);
    eg.setQueuedSchedulingAllowed(true);
    eg.scheduleForExecution();
    //  we complete another future
    slotFutures[2].complete(slots[2]);
    // since future[0] is still missing the while operation must time out
    // we have no restarts allowed, so the job will go terminal
    statusListener.waitForTerminalState(2000);
    // wait until all slots are back
    verify(slotOwner, new Timeout(2000, times(2))).returnAllocatedSlot(any(Slot.class));
    //  verify that no deployments have happened
    verify(taskManager, times(0)).submitTask(any(TaskDeploymentDescriptor.class), any(Time.class));
    for (Future<SimpleSlot> future : slotFutures) {
        if (future.isDone()) {
            assertTrue(future.get().isCanceled());
        }
    }
}
Also used : Timeout(org.mockito.verification.Timeout) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) Time(org.apache.flink.api.common.time.Time) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) FlinkCompletableFuture(org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture) SlotOwner(org.apache.flink.runtime.jobmanager.slots.SlotOwner) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) Slot(org.apache.flink.runtime.instance.Slot) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

TaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway)19 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)13 FlinkCompletableFuture (org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture)10 Test (org.junit.Test)9 JobID (org.apache.flink.api.common.JobID)8 Time (org.apache.flink.api.common.time.Time)7 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)7 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)7 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)7 AllocatedSlot (org.apache.flink.runtime.jobmanager.slots.AllocatedSlot)7 Slot (org.apache.flink.runtime.instance.Slot)5 JobException (org.apache.flink.runtime.JobException)4 Future (org.apache.flink.runtime.concurrent.Future)4 SlotOwner (org.apache.flink.runtime.jobmanager.slots.SlotOwner)4 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)4 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)4 ArrayList (java.util.ArrayList)3 TimeoutException (java.util.concurrent.TimeoutException)3 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 Instance (org.apache.flink.runtime.instance.Instance)3