Search in sources :

Example 11 with RpcMethod

use of org.apache.flink.runtime.rpc.RpcMethod 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 12 with RpcMethod

use of org.apache.flink.runtime.rpc.RpcMethod in project flink by apache.

the class JobMaster method declineCheckpoint.

// TODO: This method needs a leader session ID
@RpcMethod
public void declineCheckpoint(final JobID jobID, final ExecutionAttemptID executionAttemptID, final long checkpointID, final Throwable reason) {
    final DeclineCheckpoint decline = new DeclineCheckpoint(jobID, executionAttemptID, checkpointID, reason);
    final CheckpointCoordinator checkpointCoordinator = executionGraph.getCheckpointCoordinator();
    if (checkpointCoordinator != null) {
        getRpcService().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    checkpointCoordinator.receiveDeclineMessage(decline);
                } catch (Exception e) {
                    log.error("Error in CheckpointCoordinator while processing {}", decline, e);
                }
            }
        });
    } else {
        log.error("Received DeclineCheckpoint message for job {} with no CheckpointCoordinator", jobGraph.getJobID());
    }
}
Also used : DeclineCheckpoint(org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint) CheckpointCoordinator(org.apache.flink.runtime.checkpoint.CheckpointCoordinator) 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) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 13 with RpcMethod

use of org.apache.flink.runtime.rpc.RpcMethod in project flink by apache.

the class JobMaster method lookupKvStateLocation.

@RpcMethod
public KvStateLocation lookupKvStateLocation(final String registrationName) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Lookup key-value state for job {} with registration " + "name {}.", jobGraph.getJobID(), registrationName);
    }
    final KvStateLocationRegistry registry = executionGraph.getKvStateLocationRegistry();
    final KvStateLocation location = registry.getKvStateLocation(registrationName);
    if (location != null) {
        return location;
    } else {
        throw new UnknownKvStateLocation(registrationName);
    }
}
Also used : UnknownKvStateLocation(org.apache.flink.runtime.query.UnknownKvStateLocation) KvStateLocationRegistry(org.apache.flink.runtime.query.KvStateLocationRegistry) UnknownKvStateLocation(org.apache.flink.runtime.query.UnknownKvStateLocation) KvStateLocation(org.apache.flink.runtime.query.KvStateLocation) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 14 with RpcMethod

use of org.apache.flink.runtime.rpc.RpcMethod in project flink by apache.

the class JobMaster method acknowledgeCheckpoint.

// TODO: This method needs a leader session ID
@RpcMethod
public void acknowledgeCheckpoint(final JobID jobID, final ExecutionAttemptID executionAttemptID, final long checkpointId, final CheckpointMetrics checkpointMetrics, final SubtaskState checkpointState) throws CheckpointException {
    final CheckpointCoordinator checkpointCoordinator = executionGraph.getCheckpointCoordinator();
    final AcknowledgeCheckpoint ackMessage = new AcknowledgeCheckpoint(jobID, executionAttemptID, checkpointId, checkpointMetrics, checkpointState);
    if (checkpointCoordinator != null) {
        getRpcService().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    checkpointCoordinator.receiveAcknowledgeMessage(ackMessage);
                } catch (Throwable t) {
                    log.warn("Error while processing checkpoint acknowledgement message");
                }
            }
        });
    } else {
        log.error("Received AcknowledgeCheckpoint message for job {} with no CheckpointCoordinator", jobGraph.getJobID());
    }
}
Also used : AcknowledgeCheckpoint(org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint) CheckpointCoordinator(org.apache.flink.runtime.checkpoint.CheckpointCoordinator) SerializedThrowable(org.apache.flink.runtime.util.SerializedThrowable) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Example 15 with RpcMethod

use of org.apache.flink.runtime.rpc.RpcMethod 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)

Aggregations

RpcMethod (org.apache.flink.runtime.rpc.RpcMethod)18 Task (org.apache.flink.runtime.taskmanager.Task)6 IOException (java.io.IOException)5 TimeoutException (java.util.concurrent.TimeoutException)4 LeaderIdMismatchException (org.apache.flink.runtime.highavailability.LeaderIdMismatchException)4 PartitionProducerDisposedException (org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException)4 JobID (org.apache.flink.api.common.JobID)3 CheckpointException (org.apache.flink.runtime.checkpoint.CheckpointException)3 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)3 AllocatedSlot (org.apache.flink.runtime.jobmanager.slots.AllocatedSlot)3 CheckpointException (org.apache.flink.runtime.taskexecutor.exceptions.CheckpointException)3 TaskException (org.apache.flink.runtime.taskexecutor.exceptions.TaskException)3 CheckpointCoordinator (org.apache.flink.runtime.checkpoint.CheckpointCoordinator)2 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)2 Execution (org.apache.flink.runtime.executiongraph.Execution)2 AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)2 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)2 JobManagerRegistration (org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration)2 PartitionException (org.apache.flink.runtime.taskexecutor.exceptions.PartitionException)2 TaskSubmissionException (org.apache.flink.runtime.taskexecutor.exceptions.TaskSubmissionException)2