Search in sources :

Example 26 with Execution

use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.

the class SimpleSlotTest method testReleaseCancelsVertex.

@Test
public void testReleaseCancelsVertex() {
    try {
        Execution ev = mock(Execution.class);
        SimpleSlot slot = getSlot();
        assertTrue(slot.setExecutedVertex(ev));
        assertEquals(ev, slot.getExecutedVertex());
        slot.releaseSlot();
        slot.releaseSlot();
        slot.releaseSlot();
        verify(ev, times(1)).fail(Matchers.any(Throwable.class));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Execution(org.apache.flink.runtime.executiongraph.Execution) Test(org.junit.Test)

Example 27 with Execution

use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.

the class JobMaster method requestNextInputSplit.

@RpcMethod
public SerializedInputSplit requestNextInputSplit(final UUID leaderSessionID, final JobVertexID vertexID, final ExecutionAttemptID executionAttempt) throws Exception {
    validateLeaderSessionId(leaderSessionID);
    final Execution execution = executionGraph.getRegisteredExecutions().get(executionAttempt);
    if (execution == null) {
        // but TaskManager get some delay to aware of that situation
        if (log.isDebugEnabled()) {
            log.debug("Can not find Execution for attempt {}.", executionAttempt);
        }
        // but we should TaskManager be aware of this
        throw new Exception("Can not find Execution for attempt " + executionAttempt);
    }
    final ExecutionJobVertex vertex = executionGraph.getJobVertex(vertexID);
    if (vertex == null) {
        log.error("Cannot find execution vertex for vertex ID {}.", vertexID);
        throw new Exception("Cannot find execution vertex for vertex ID " + vertexID);
    }
    final InputSplitAssigner splitAssigner = vertex.getSplitAssigner();
    if (splitAssigner == null) {
        log.error("No InputSplitAssigner for vertex ID {}.", vertexID);
        throw new Exception("No InputSplitAssigner for vertex ID " + vertexID);
    }
    final Slot slot = execution.getAssignedResource();
    final int taskId = execution.getVertex().getParallelSubtaskIndex();
    final String host = slot != null ? slot.getTaskManagerLocation().getHostname() : null;
    final InputSplit nextInputSplit = splitAssigner.getNextInputSplit(host, taskId);
    if (log.isDebugEnabled()) {
        log.debug("Send next input split {}.", nextInputSplit);
    }
    try {
        final byte[] serializedInputSplit = InstantiationUtil.serializeObject(nextInputSplit);
        return new SerializedInputSplit(serializedInputSplit);
    } catch (Exception ex) {
        log.error("Could not serialize the next input split of class {}.", nextInputSplit.getClass(), ex);
        IOException reason = new IOException("Could not serialize the next input split of class " + nextInputSplit.getClass() + ".", ex);
        vertex.fail(reason);
        throw reason;
    }
}
Also used : InputSplitAssigner(org.apache.flink.core.io.InputSplitAssigner) Execution(org.apache.flink.runtime.executiongraph.Execution) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) Slot(org.apache.flink.runtime.instance.Slot) AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) IOException(java.io.IOException) InputSplit(org.apache.flink.core.io.InputSplit) TimeoutException(java.util.concurrent.TimeoutException) CheckpointException(org.apache.flink.runtime.checkpoint.CheckpointException) LeaderIdMismatchException(org.apache.flink.runtime.highavailability.LeaderIdMismatchException) PartitionProducerDisposedException(org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) IOException(java.io.IOException) RpcEndpoint(org.apache.flink.runtime.rpc.RpcEndpoint) AcknowledgeCheckpoint(org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint) DeclineCheckpoint(org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 28 with Execution

use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.

the class JobMaster method requestPartitionState.

@RpcMethod
public ExecutionState requestPartitionState(final UUID leaderSessionID, final IntermediateDataSetID intermediateResultId, final ResultPartitionID resultPartitionId) throws Exception {
    validateLeaderSessionId(leaderSessionID);
    final Execution execution = executionGraph.getRegisteredExecutions().get(resultPartitionId.getProducerId());
    if (execution != null) {
        return execution.getState();
    } else {
        final IntermediateResult intermediateResult = executionGraph.getAllIntermediateResults().get(intermediateResultId);
        if (intermediateResult != null) {
            // Try to find the producing execution
            Execution producerExecution = intermediateResult.getPartitionById(resultPartitionId.getPartitionId()).getProducer().getCurrentExecutionAttempt();
            if (producerExecution.getAttemptId() == resultPartitionId.getProducerId()) {
                return producerExecution.getState();
            } else {
                throw new PartitionProducerDisposedException(resultPartitionId);
            }
        } else {
            throw new IllegalArgumentException("Intermediate data set with ID " + intermediateResultId + " not found.");
        }
    }
}
Also used : IntermediateResult(org.apache.flink.runtime.executiongraph.IntermediateResult) Execution(org.apache.flink.runtime.executiongraph.Execution) PartitionProducerDisposedException(org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 29 with Execution

use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.

the class SchedulerTestUtils method getTestVertex.

public static Execution getTestVertex(Iterable<TaskManagerLocation> preferredLocations) {
    ExecutionVertex vertex = mock(ExecutionVertex.class);
    when(vertex.getPreferredLocationsBasedOnInputs()).thenReturn(preferredLocations);
    when(vertex.getJobId()).thenReturn(new JobID());
    when(vertex.toString()).thenReturn("TEST-VERTEX");
    Execution execution = mock(Execution.class);
    when(execution.getVertex()).thenReturn(vertex);
    return execution;
}
Also used : Execution(org.apache.flink.runtime.executiongraph.Execution) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) JobID(org.apache.flink.api.common.JobID)

Example 30 with Execution

use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.

the class SchedulerTestUtils method getTestVertex.

public static Execution getTestVertex(JobVertexID jid, int taskIndex, int numTasks) {
    ExecutionVertex vertex = mock(ExecutionVertex.class);
    when(vertex.getPreferredLocationsBasedOnInputs()).thenReturn(null);
    when(vertex.getJobId()).thenReturn(new JobID());
    when(vertex.getJobvertexId()).thenReturn(jid);
    when(vertex.getParallelSubtaskIndex()).thenReturn(taskIndex);
    when(vertex.getTotalNumberOfParallelSubtasks()).thenReturn(numTasks);
    when(vertex.getMaxParallelism()).thenReturn(numTasks);
    when(vertex.toString()).thenReturn("TEST-VERTEX");
    when(vertex.getSimpleName()).thenReturn("TEST-VERTEX");
    Execution execution = mock(Execution.class);
    when(execution.getVertex()).thenReturn(vertex);
    return execution;
}
Also used : Execution(org.apache.flink.runtime.executiongraph.Execution) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) JobID(org.apache.flink.api.common.JobID)

Aggregations

Execution (org.apache.flink.runtime.executiongraph.Execution)45 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)26 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)11 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)8 JobID (org.apache.flink.api.common.JobID)7 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)7 Test (org.junit.Test)7 AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)6 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)4 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)4 HashMap (java.util.HashMap)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 TimeoutException (java.util.concurrent.TimeoutException)3 Time (org.apache.flink.api.common.time.Time)3 PartitionProducerDisposedException (org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException)3 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)3 StackTraceSampleResponse (org.apache.flink.runtime.messages.StackTraceSampleResponse)3 Collection (java.util.Collection)2