Search in sources :

Example 26 with InputChannelInfo

use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.

the class UnalignedCheckpointsCancellationTest method test.

@Test
public void test() throws Exception {
    TestInvokable invokable = new TestInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    SingleCheckpointBarrierHandler unaligner = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    for (RuntimeEvent e : events) {
        if (e instanceof CancelCheckpointMarker) {
            unaligner.processCancellationBarrier((CancelCheckpointMarker) e, new InputChannelInfo(0, channel));
        } else if (e instanceof CheckpointBarrier) {
            unaligner.processBarrier((CheckpointBarrier) e, new InputChannelInfo(0, channel), false);
        } else {
            throw new IllegalArgumentException("unexpected event type: " + e);
        }
    }
    assertEquals("expectAbortCheckpoint", expectAbortCheckpoint, invokable.checkpointAborted);
    assertEquals("expectTriggerCheckpoint", expectTriggerCheckpoint, invokable.checkpointTriggered);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RuntimeEvent(org.apache.flink.runtime.event.RuntimeEvent) Test(org.junit.Test)

Example 27 with InputChannelInfo

use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.

the class UnalignedCheckpointsTest method testProcessCancellationBarrierBeforeProcessAndReceiveBarrier.

@Test
public void testProcessCancellationBarrierBeforeProcessAndReceiveBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    handler.processCancellationBarrier(new CancelCheckpointMarker(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0));
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
    // it would not trigger checkpoint since the respective cancellation barrier already
    // happened before
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 28 with InputChannelInfo

use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.

the class UnalignedCheckpointsTest method testProcessCancellationBarrierAfterProcessBarrier.

/**
 * Tests {@link
 * SingleCheckpointBarrierHandler#processCancellationBarrier(CancelCheckpointMarker,
 * InputChannelInfo)} abort the current pending checkpoint triggered by {@link
 * CheckpointBarrierHandler#processBarrier(CheckpointBarrier, InputChannelInfo)}.
 */
@Test
public void testProcessCancellationBarrierAfterProcessBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    // should trigger respective checkpoint
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    assertTrue(handler.isCheckpointPending());
    assertEquals(DEFAULT_CHECKPOINT_ID, handler.getLatestCheckpointId());
    testProcessCancellationBarrier(handler, invokable);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 29 with InputChannelInfo

use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo in project flink by apache.

the class RecordWriterTest method parseBuffer.

// ---------------------------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------------------------
static BufferOrEvent parseBuffer(Buffer buffer, int targetChannel) throws IOException {
    if (buffer.isBuffer()) {
        return new BufferOrEvent(buffer, new InputChannelInfo(0, targetChannel));
    } else {
        // is event:
        AbstractEvent event = EventSerializer.fromBuffer(buffer, RecordWriterTest.class.getClassLoader());
        // the buffer is not needed anymore
        buffer.recycleBuffer();
        return new BufferOrEvent(event, new InputChannelInfo(0, targetChannel));
    }
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) AbstractEvent(org.apache.flink.runtime.event.AbstractEvent) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)

Example 30 with InputChannelInfo

use of org.apache.flink.runtime.checkpoint.channel.InputChannelInfo 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 {
    JobVertexID jobVertexId = new JobVertexID();
    final ManuallyTriggeredScheduledExecutor manuallyTriggeredScheduledExecutor = new ManuallyTriggeredScheduledExecutor();
    ExecutionGraph testGraph = new CheckpointCoordinatorTestingUtils.CheckpointExecutionGraphBuilder().addJobVertex(jobVertexId).build();
    ExecutionVertex vertex = testGraph.getJobVertex(jobVertexId).getTaskVertices()[0];
    // set up the coordinator and validate the initial state
    CheckpointCoordinator coord = new CheckpointCoordinatorBuilder().setExecutionGraph(testGraph).setCompletedCheckpointStore(new FailingCompletedCheckpointStore(new Exception("The failing completed checkpoint store failed again... :-("))).setTimer(manuallyTriggeredScheduledExecutor).build();
    coord.triggerCheckpoint(false);
    manuallyTriggeredScheduledExecutor.triggerAll();
    assertEquals(1, coord.getNumberOfPendingCheckpoints());
    PendingCheckpoint pendingCheckpoint = coord.getPendingCheckpoints().values().iterator().next();
    assertFalse(pendingCheckpoint.isDisposed());
    final long checkpointId = coord.getPendingCheckpoints().keySet().iterator().next();
    KeyedStateHandle managedKeyedHandle = mock(KeyedStateHandle.class);
    KeyedStateHandle rawKeyedHandle = mock(KeyedStateHandle.class);
    OperatorStateHandle managedOpHandle = mock(OperatorStreamStateHandle.class);
    OperatorStateHandle rawOpHandle = mock(OperatorStreamStateHandle.class);
    InputChannelStateHandle inputChannelStateHandle = new InputChannelStateHandle(new InputChannelInfo(0, 1), mock(StreamStateHandle.class), Collections.singletonList(1L));
    ResultSubpartitionStateHandle resultSubpartitionStateHandle = new ResultSubpartitionStateHandle(new ResultSubpartitionInfo(0, 1), mock(StreamStateHandle.class), Collections.singletonList(1L));
    final OperatorSubtaskState operatorSubtaskState = spy(OperatorSubtaskState.builder().setManagedOperatorState(managedOpHandle).setRawOperatorState(rawOpHandle).setManagedKeyedState(managedKeyedHandle).setRawKeyedState(rawKeyedHandle).setInputChannelState(StateObjectCollection.singleton(inputChannelStateHandle)).setResultSubpartitionState(StateObjectCollection.singleton(resultSubpartitionStateHandle)).build());
    TaskStateSnapshot subtaskState = spy(new TaskStateSnapshot());
    subtaskState.putSubtaskStateByOperatorID(new OperatorID(), operatorSubtaskState);
    when(subtaskState.getSubtaskStateByOperatorID(OperatorID.fromJobVertexID(vertex.getJobvertexId()))).thenReturn(operatorSubtaskState);
    AcknowledgeCheckpoint acknowledgeMessage = new AcknowledgeCheckpoint(testGraph.getJobID(), vertex.getCurrentExecutionAttempt().getAttemptId(), checkpointId, new CheckpointMetrics(), subtaskState);
    try {
        coord.receiveAcknowledgeMessage(acknowledgeMessage, "Unknown location");
        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.isDisposed());
    // make sure that the subtask state has been discarded after we could not complete it.
    verify(operatorSubtaskState).discardState();
    verify(operatorSubtaskState.getManagedOperatorState().iterator().next()).discardState();
    verify(operatorSubtaskState.getRawOperatorState().iterator().next()).discardState();
    verify(operatorSubtaskState.getManagedKeyedState().iterator().next()).discardState();
    verify(operatorSubtaskState.getRawKeyedState().iterator().next()).discardState();
    verify(operatorSubtaskState.getInputChannelState().iterator().next().getDelegate()).discardState();
    verify(operatorSubtaskState.getResultSubpartitionState().iterator().next().getDelegate()).discardState();
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) CheckpointCoordinatorBuilder(org.apache.flink.runtime.checkpoint.CheckpointCoordinatorTestingUtils.CheckpointCoordinatorBuilder) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) PossibleInconsistentStateException(org.apache.flink.runtime.persistence.PossibleInconsistentStateException) ManuallyTriggeredScheduledExecutor(org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor) AcknowledgeCheckpoint(org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint) OperatorStreamStateHandle(org.apache.flink.runtime.state.OperatorStreamStateHandle) StreamStateHandle(org.apache.flink.runtime.state.StreamStateHandle) ResultSubpartitionInfo(org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) ResultSubpartitionStateHandle(org.apache.flink.runtime.state.ResultSubpartitionStateHandle) OperatorStateHandle(org.apache.flink.runtime.state.OperatorStateHandle) InputChannelStateHandle(org.apache.flink.runtime.state.InputChannelStateHandle) Test(org.junit.Test)

Aggregations

InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)30 Test (org.junit.Test)21 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)9 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)8 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)8 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)5 BufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilder)4 MemorySegment (org.apache.flink.core.memory.MemorySegment)3 ResultSubpartitionInfo (org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo)3 CancelCheckpointMarker (org.apache.flink.runtime.io.network.api.CancelCheckpointMarker)3 SubtaskConnectionDescriptor (org.apache.flink.runtime.io.network.api.SubtaskConnectionDescriptor)3 BufferBuilderTestUtils.createBufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createBufferBuilder)3 BufferOrEvent (org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)3 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LongSerializer (org.apache.flink.api.common.typeutils.base.LongSerializer)2 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 NetworkBuffer (org.apache.flink.runtime.io.network.buffer.NetworkBuffer)2