Search in sources :

Example 1 with TestCommandAckEvent

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

the class OneInputTestStreamOperator method ack.

private void ack(TestCommand cmd) {
    LOG.info("Executed command: {}", cmd);
    eventQueue.add(new TestCommandAckEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber(), cmd));
}
Also used : TestCommandAckEvent(org.apache.flink.runtime.operators.lifecycle.event.TestCommandAckEvent)

Example 2 with TestCommandAckEvent

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

the class TestJobExecutor method waitForFailover.

private void waitForFailover(BlockingQueue<TestEvent> queue) throws Exception {
    int timeoutMs = 10_000;
    Deadline deadline = Deadline.fromNow(Duration.ofMillis(timeoutMs));
    String operatorId = null;
    int subtaskId = -1;
    int attemptNumber = -1;
    while (deadline.hasTimeLeft()) {
        TestEvent e = queue.poll(deadline.timeLeft().toMillis(), MILLISECONDS);
        if (e instanceof TestCommandAckEvent) {
            TestCommandAckEvent ack = (TestCommandAckEvent) e;
            if (ack.getCommand() == FAIL) {
                operatorId = ack.operatorId;
                subtaskId = ack.subtaskIndex;
                attemptNumber = ack.getAttemptNumber();
            }
        } else if (e instanceof OperatorStartedEvent && operatorId != null) {
            OperatorStartedEvent started = (OperatorStartedEvent) e;
            if (started.operatorId.equals(operatorId) && started.subtaskIndex == subtaskId && started.getAttemptNumber() >= attemptNumber) {
                return;
            }
        }
    }
    throw new TimeoutException("No subtask restarted in " + timeoutMs + "ms");
}
Also used : TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) Deadline(org.apache.flink.api.common.time.Deadline) TestCommandAckEvent(org.apache.flink.runtime.operators.lifecycle.event.TestCommandAckEvent) OperatorStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TestCommandAckEvent (org.apache.flink.runtime.operators.lifecycle.event.TestCommandAckEvent)2 TimeoutException (java.util.concurrent.TimeoutException)1 Deadline (org.apache.flink.api.common.time.Deadline)1 OperatorStartedEvent (org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent)1 TestEvent (org.apache.flink.runtime.operators.lifecycle.event.TestEvent)1