Search in sources :

Example 1 with CheckpointCompletedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent in project flink by apache.

the class OneInputTestStreamOperator method notifyCheckpointComplete.

@Override
public void notifyCheckpointComplete(long checkpointId) throws Exception {
    eventQueue.add(new CheckpointCompletedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), checkpointId));
    super.notifyCheckpointComplete(checkpointId);
}
Also used : CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent)

Example 2 with CheckpointCompletedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent in project flink by apache.

the class FinishingValidator method validateOperatorLifecycle.

@Override
public void validateOperatorLifecycle(TestJobWithDescription job, String operatorId, int subtaskIndex, List<TestEvent> operatorEvents) {
    boolean opFinished = false;
    Set<Long> finalCheckpointCandidates = new HashSet<>();
    for (TestEvent ev : operatorEvents) {
        if (ev instanceof OperatorFinishedEvent) {
            opFinished = true;
        } else if (ev instanceof CheckpointStartedEvent) {
            if (opFinished) {
                finalCheckpointCandidates.add(((CheckpointStartedEvent) ev).checkpointID);
            }
        } else if (ev instanceof CheckpointCompletedEvent) {
            if (finalCheckpointCandidates.contains(((CheckpointCompletedEvent) ev).checkpointID)) {
                return;
            }
        } else if (opFinished) {
            fail(format("Unexpected event after operator %s[%d] finished: %s", operatorId, subtaskIndex, ev));
        }
    }
    assertTrue(format("Operator %s[%d] wasn't finished (events: %s)", operatorId, subtaskIndex, operatorEvents), opFinished);
    fail(format("Operator %s[%d] was finished but didn't finish the checkpoint after that;" + "checkpoints started after finish: %s (events (excluding watermarks): %s)", operatorId, subtaskIndex, finalCheckpointCandidates, operatorEvents.stream().filter(ev -> !(ev instanceof WatermarkReceivedEvent)).collect(toList())));
}
Also used : CheckpointStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent) CheckpointStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent) TestJobWithDescription(org.apache.flink.runtime.operators.lifecycle.TestJobWithDescription) WatermarkReceivedEvent(org.apache.flink.runtime.operators.lifecycle.event.WatermarkReceivedEvent) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) String.format(java.lang.String.format) TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) HashSet(java.util.HashSet) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) OperatorFinishedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorFinishedEvent) CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent) Assert.fail(org.junit.Assert.fail) OperatorFinishedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorFinishedEvent) TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) WatermarkReceivedEvent(org.apache.flink.runtime.operators.lifecycle.event.WatermarkReceivedEvent) CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent) HashSet(java.util.HashSet)

Example 3 with CheckpointCompletedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent in project flink by apache.

the class MultiInputTestOperator method notifyCheckpointComplete.

@Override
public void notifyCheckpointComplete(long checkpointId) throws Exception {
    eventQueue.add(new CheckpointCompletedEvent(operatorId, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), checkpointId));
    super.notifyCheckpointComplete(checkpointId);
}
Also used : CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent)

Example 4 with CheckpointCompletedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent in project flink by apache.

the class SameCheckpointValidator method validateOperatorLifecycle.

@Override
public void validateOperatorLifecycle(TestJobWithDescription job, String operatorId, int subtaskIndex, List<TestEvent> operatorEvents) {
    boolean started = false;
    boolean finished = false;
    for (TestEvent ev : operatorEvents) {
        if (ev instanceof CheckpointStartedEvent) {
            if (lastCheckpointID == ((CheckpointStartedEvent) ev).checkpointID) {
                assertFalse(format("Operator %s[%d] started checkpoint %d twice", operatorId, subtaskIndex, lastCheckpointID), started);
                started = true;
            }
        } else if (ev instanceof CheckpointCompletedEvent) {
            if (lastCheckpointID == ((CheckpointCompletedEvent) ev).checkpointID) {
                assertTrue(format("Operator %s[%d] finished checkpoint %d before starting", operatorId, subtaskIndex, lastCheckpointID), started);
                assertFalse(format("Operator %s[%d] finished checkpoint %d twice", operatorId, subtaskIndex, lastCheckpointID), finished);
                finished = true;
            }
        }
    }
    assertTrue(format("Operator %s[%d] didn't finish checkpoint %d (events: %s)", operatorId, subtaskIndex, lastCheckpointID, operatorEvents), finished);
}
Also used : CheckpointStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent) TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent)

Example 5 with CheckpointCompletedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent in project flink by apache.

the class TwoInputTestStreamOperator method notifyCheckpointComplete.

@Override
public void notifyCheckpointComplete(long checkpointId) throws Exception {
    collectEvent(new CheckpointCompletedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), checkpointId));
    super.notifyCheckpointComplete(checkpointId);
}
Also used : CheckpointCompletedEvent(org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent)

Aggregations

CheckpointCompletedEvent (org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent)5 CheckpointStartedEvent (org.apache.flink.runtime.operators.lifecycle.event.CheckpointStartedEvent)2 TestEvent (org.apache.flink.runtime.operators.lifecycle.event.TestEvent)2 String.format (java.lang.String.format)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 TestJobWithDescription (org.apache.flink.runtime.operators.lifecycle.TestJobWithDescription)1 OperatorFinishedEvent (org.apache.flink.runtime.operators.lifecycle.event.OperatorFinishedEvent)1 WatermarkReceivedEvent (org.apache.flink.runtime.operators.lifecycle.event.WatermarkReceivedEvent)1 StreamOperator (org.apache.flink.streaming.api.operators.StreamOperator)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1