Search in sources :

Example 1 with OperatorStartedEvent

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

the class MultiInputTestOperator method open.

@Override
public void open() throws Exception {
    super.open();
    registerTimer();
    this.eventQueue.add(new OperatorStartedEvent(operatorId, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber()));
}
Also used : OperatorStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent)

Example 2 with OperatorStartedEvent

use of org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent 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)

Example 3 with OperatorStartedEvent

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

the class TestEventSource method open.

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);
    this.isRunning = true;
    this.scheduledCommands = new LinkedBlockingQueue<>();
    this.commandQueue.subscribe(cmd -> scheduledCommands.add(cmd), operatorID);
    this.eventQueue.add(new OperatorStartedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber()));
}
Also used : OperatorStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent)

Example 4 with OperatorStartedEvent

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

the class OneInputTestStreamOperator method open.

@Override
public void open() throws Exception {
    super.open();
    this.eventQueue.add(new OperatorStartedEvent(operatorID, getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getAttemptNumber()));
    this.dispatcher.subscribe(receivedCommands::add, operatorID);
    this.state = getKeyedStateBackend() != null ? getRuntimeContext().getListState(new ListStateDescriptor<>("test", String.class)) : getOperatorStateBackend().getListState(new ListStateDescriptor<>("test", String.class));
}
Also used : OperatorStartedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorStartedEvent)

Example 5 with OperatorStartedEvent

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

the class TwoInputTestStreamOperator method open.

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

Aggregations

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