Search in sources :

Example 21 with AcknowledgeCheckpoint

use of org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint in project flink by apache.

the class CheckpointCoordinatorFailureTest method testFailingCompletedCheckpointStoreAdd.

/**
	 * Tests that a failure while storing a completed checkpoint in the completed checkpoint store
	 * will properly fail the originating pending checkpoint and clean upt the completed checkpoint.
	 */
@Test
public void testFailingCompletedCheckpointStoreAdd() throws Exception {
    JobID jid = new JobID();
    final ExecutionAttemptID executionAttemptId = new ExecutionAttemptID();
    final ExecutionVertex vertex = CheckpointCoordinatorTest.mockExecutionVertex(executionAttemptId);
    final long triggerTimestamp = 1L;
    // set up the coordinator and validate the initial state
    CheckpointCoordinator coord = new CheckpointCoordinator(jid, 600000, 600000, 0, Integer.MAX_VALUE, ExternalizedCheckpointSettings.none(), new ExecutionVertex[] { vertex }, new ExecutionVertex[] { vertex }, new ExecutionVertex[] { vertex }, new StandaloneCheckpointIDCounter(), new FailingCompletedCheckpointStore(), null, Executors.directExecutor());
    coord.triggerCheckpoint(triggerTimestamp, false);
    assertEquals(1, coord.getNumberOfPendingCheckpoints());
    PendingCheckpoint pendingCheckpoint = coord.getPendingCheckpoints().values().iterator().next();
    assertFalse(pendingCheckpoint.isDiscarded());
    final long checkpointId = coord.getPendingCheckpoints().keySet().iterator().next();
    AcknowledgeCheckpoint acknowledgeMessage = new AcknowledgeCheckpoint(jid, executionAttemptId, checkpointId);
    CompletedCheckpoint completedCheckpoint = mock(CompletedCheckpoint.class);
    PowerMockito.whenNew(CompletedCheckpoint.class).withAnyArguments().thenReturn(completedCheckpoint);
    try {
        coord.receiveAcknowledgeMessage(acknowledgeMessage);
        fail("Expected a checkpoint exception because the completed checkpoint store could not " + "store the completed checkpoint.");
    } catch (CheckpointException e) {
    // ignore because we expected this exception
    }
    // make sure that the pending checkpoint has been discarded after we could not complete it
    assertTrue(pendingCheckpoint.isDiscarded());
    verify(completedCheckpoint).discard();
}
Also used : AcknowledgeCheckpoint(org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) JobID(org.apache.flink.api.common.JobID) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with AcknowledgeCheckpoint

use of org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint 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 23 with AcknowledgeCheckpoint

use of org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint in project flink by apache.

the class ActorGatewayCheckpointResponder method acknowledgeCheckpoint.

@Override
public void acknowledgeCheckpoint(JobID jobID, ExecutionAttemptID executionAttemptID, long checkpointId, CheckpointMetrics checkpointMetrics, SubtaskState checkpointStateHandles) {
    AcknowledgeCheckpoint message = new AcknowledgeCheckpoint(jobID, executionAttemptID, checkpointId, checkpointMetrics, checkpointStateHandles);
    actorGateway.tell(message);
}
Also used : AcknowledgeCheckpoint(org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)

Aggregations

AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)23 JobID (org.apache.flink.api.common.JobID)21 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)20 Test (org.junit.Test)19 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)16 IOException (java.io.IOException)9 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)8 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)7 HashMap (java.util.HashMap)6 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)6 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)6 ArrayList (java.util.ArrayList)5 KeyGroupsStateHandle (org.apache.flink.runtime.state.KeyGroupsStateHandle)5 StreamStateHandle (org.apache.flink.runtime.state.StreamStateHandle)5 ByteStreamStateHandle (org.apache.flink.runtime.state.memory.ByteStreamStateHandle)4 Execution (org.apache.flink.runtime.executiongraph.Execution)3 OperatorStateHandle (org.apache.flink.runtime.state.OperatorStateHandle)3 Iterator (java.util.Iterator)2 TaskStateHandles (org.apache.flink.runtime.state.TaskStateHandles)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2