Java Code Examples for org.apache.flink.runtime.jobgraph.OperatorID#fromJobVertexID()
The following examples show how to use
org.apache.flink.runtime.jobgraph.OperatorID#fromJobVertexID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoordinatorEventsExactlyOnceITCase.java From flink with Apache License 2.0 | 6 votes |
private static JobVertex buildJobVertex(String name, int numEvents, int delay, String accName) throws IOException { final JobVertex vertex = new JobVertex(name); final OperatorID opId = OperatorID.fromJobVertexID(vertex.getID()); vertex.setParallelism(1); vertex.setInvokableClass(EventCollectingTask.class); vertex.getConfiguration().setString(ACC_NAME, accName); final OperatorCoordinator.Provider provider = new OperatorCoordinator.Provider() { @Override public OperatorID getOperatorId() { return opId; } @Override public OperatorCoordinator create(OperatorCoordinator.Context context) { return new EventSendingCoordinator(context, numEvents, delay); } }; vertex.addOperatorCoordinator(new SerializedValue<>(provider)); return vertex; }
Example 2
Source File: CheckpointCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testCheckpointTimeoutIsolated() { try { final JobID jid = new JobID(); final long timestamp = System.currentTimeMillis(); // create some mock execution vertices final ExecutionAttemptID triggerAttemptID = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID1 = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID2 = new ExecutionAttemptID(); final ExecutionAttemptID commitAttemptID = new ExecutionAttemptID(); ExecutionVertex triggerVertex = mockExecutionVertex(triggerAttemptID); ExecutionVertex ackVertex1 = mockExecutionVertex(ackAttemptID1); ExecutionVertex ackVertex2 = mockExecutionVertex(ackAttemptID2); ExecutionVertex commitVertex = mockExecutionVertex(commitAttemptID); // set up the coordinator // the timeout for the checkpoint is a 200 milliseconds CheckpointCoordinator coord = new CheckpointCoordinator( jid, 600000, 200, 0, Integer.MAX_VALUE, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, new ExecutionVertex[] { triggerVertex }, new ExecutionVertex[] { ackVertex1, ackVertex2 }, new ExecutionVertex[] { commitVertex }, new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(2), new MemoryStateBackend(), Executors.directExecutor(), SharedStateRegistry.DEFAULT_FACTORY); // trigger a checkpoint, partially acknowledged assertTrue(coord.triggerCheckpoint(timestamp, false)); assertEquals(1, coord.getNumberOfPendingCheckpoints()); PendingCheckpoint checkpoint = coord.getPendingCheckpoints().values().iterator().next(); assertFalse(checkpoint.isDiscarded()); OperatorID opID1 = OperatorID.fromJobVertexID(ackVertex1.getJobvertexId()); TaskStateSnapshot taskOperatorSubtaskStates1 = spy(new TaskStateSnapshot()); OperatorSubtaskState subtaskState1 = mock(OperatorSubtaskState.class); taskOperatorSubtaskStates1.putSubtaskStateByOperatorID(opID1, subtaskState1); coord.receiveAcknowledgeMessage(new AcknowledgeCheckpoint(jid, ackAttemptID1, checkpoint.getCheckpointId(), new CheckpointMetrics(), taskOperatorSubtaskStates1)); // wait until the checkpoint must have expired. // we check every 250 msecs conservatively for 5 seconds // to give even slow build servers a very good chance of completing this long deadline = System.currentTimeMillis() + 5000; do { Thread.sleep(250); } while (!checkpoint.isDiscarded() && coord.getNumberOfPendingCheckpoints() > 0 && System.currentTimeMillis() < deadline); assertTrue("Checkpoint was not canceled by the timeout", checkpoint.isDiscarded()); assertEquals(0, coord.getNumberOfPendingCheckpoints()); assertEquals(0, coord.getNumberOfRetainedSuccessfulCheckpoints()); // validate that the received states have been discarded verify(subtaskState1, times(1)).discardState(); // no confirm message must have been sent verify(commitVertex.getCurrentExecutionAttempt(), times(0)).notifyCheckpointComplete(anyLong(), anyLong()); coord.shutdown(JobStatus.FINISHED); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 3
Source File: CheckpointCoordinatorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private static Tuple2<JobVertexID, OperatorID> generateIDPair() { JobVertexID jobVertexID = new JobVertexID(); OperatorID operatorID = OperatorID.fromJobVertexID(jobVertexID); return new Tuple2<>(jobVertexID, operatorID); }
Example 4
Source File: CheckpointCoordinatorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testCheckpointTimeoutIsolated() { try { final JobID jid = new JobID(); final long timestamp = System.currentTimeMillis(); // create some mock execution vertices final ExecutionAttemptID triggerAttemptID = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID1 = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID2 = new ExecutionAttemptID(); final ExecutionAttemptID commitAttemptID = new ExecutionAttemptID(); ExecutionVertex triggerVertex = mockExecutionVertex(triggerAttemptID); ExecutionVertex ackVertex1 = mockExecutionVertex(ackAttemptID1); ExecutionVertex ackVertex2 = mockExecutionVertex(ackAttemptID2); ExecutionVertex commitVertex = mockExecutionVertex(commitAttemptID); // set up the coordinator // the timeout for the checkpoint is a 200 milliseconds CheckpointCoordinatorConfiguration chkConfig = new CheckpointCoordinatorConfiguration( 600000, 200, 0, Integer.MAX_VALUE, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0); CheckpointCoordinator coord = new CheckpointCoordinator( jid, chkConfig, new ExecutionVertex[] { triggerVertex }, new ExecutionVertex[] { ackVertex1, ackVertex2 }, new ExecutionVertex[] { commitVertex }, new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(2), new MemoryStateBackend(), Executors.directExecutor(), SharedStateRegistry.DEFAULT_FACTORY, failureManager); // trigger a checkpoint, partially acknowledged assertTrue(coord.triggerCheckpoint(timestamp, false)); assertEquals(1, coord.getNumberOfPendingCheckpoints()); PendingCheckpoint checkpoint = coord.getPendingCheckpoints().values().iterator().next(); assertFalse(checkpoint.isDiscarded()); OperatorID opID1 = OperatorID.fromJobVertexID(ackVertex1.getJobvertexId()); TaskStateSnapshot taskOperatorSubtaskStates1 = spy(new TaskStateSnapshot()); OperatorSubtaskState subtaskState1 = mock(OperatorSubtaskState.class); taskOperatorSubtaskStates1.putSubtaskStateByOperatorID(opID1, subtaskState1); coord.receiveAcknowledgeMessage(new AcknowledgeCheckpoint(jid, ackAttemptID1, checkpoint.getCheckpointId(), new CheckpointMetrics(), taskOperatorSubtaskStates1), TASK_MANAGER_LOCATION_INFO); // wait until the checkpoint must have expired. // we check every 250 msecs conservatively for 5 seconds // to give even slow build servers a very good chance of completing this long deadline = System.currentTimeMillis() + 5000; do { Thread.sleep(250); } while (!checkpoint.isDiscarded() && coord.getNumberOfPendingCheckpoints() > 0 && System.currentTimeMillis() < deadline); assertTrue("Checkpoint was not canceled by the timeout", checkpoint.isDiscarded()); assertEquals(0, coord.getNumberOfPendingCheckpoints()); assertEquals(0, coord.getNumberOfRetainedSuccessfulCheckpoints()); // validate that the received states have been discarded verify(subtaskState1, times(1)).discardState(); // no confirm message must have been sent verify(commitVertex.getCurrentExecutionAttempt(), times(0)).notifyCheckpointComplete(anyLong(), anyLong()); coord.shutdown(JobStatus.FINISHED); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 5
Source File: CheckpointCoordinatorTest.java From flink with Apache License 2.0 | 4 votes |
private static Tuple2<JobVertexID, OperatorID> generateIDPair() { JobVertexID jobVertexID = new JobVertexID(); OperatorID operatorID = OperatorID.fromJobVertexID(jobVertexID); return new Tuple2<>(jobVertexID, operatorID); }
Example 6
Source File: CheckpointCoordinatorRestoringTest.java From flink with Apache License 2.0 | 4 votes |
private static Tuple2<JobVertexID, OperatorID> generateIDPair() { JobVertexID jobVertexID = new JobVertexID(); OperatorID operatorID = OperatorID.fromJobVertexID(jobVertexID); return new Tuple2<>(jobVertexID, operatorID); }
Example 7
Source File: CheckpointCoordinatorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testCheckpointTimeoutIsolated() { try { final JobID jid = new JobID(); // create some mock execution vertices final ExecutionAttemptID triggerAttemptID = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID1 = new ExecutionAttemptID(); final ExecutionAttemptID ackAttemptID2 = new ExecutionAttemptID(); final ExecutionAttemptID commitAttemptID = new ExecutionAttemptID(); ExecutionVertex triggerVertex = mockExecutionVertex(triggerAttemptID); ExecutionVertex ackVertex1 = mockExecutionVertex(ackAttemptID1); ExecutionVertex ackVertex2 = mockExecutionVertex(ackAttemptID2); ExecutionVertex commitVertex = mockExecutionVertex(commitAttemptID); // set up the coordinator CheckpointCoordinator coord = new CheckpointCoordinatorBuilder() .setJobId(jid) .setTasksToTrigger(new ExecutionVertex[] { triggerVertex }) .setTasksToWaitFor(new ExecutionVertex[] { ackVertex1, ackVertex2 }) .setTasksToCommitTo(new ExecutionVertex[] { commitVertex }) .setCompletedCheckpointStore(new StandaloneCompletedCheckpointStore(2)) .setTimer(manuallyTriggeredScheduledExecutor) .build(); // trigger a checkpoint, partially acknowledged final CompletableFuture<CompletedCheckpoint> checkpointFuture = coord.triggerCheckpoint(false); manuallyTriggeredScheduledExecutor.triggerAll(); assertFalse(checkpointFuture.isCompletedExceptionally()); assertEquals(1, coord.getNumberOfPendingCheckpoints()); PendingCheckpoint checkpoint = coord.getPendingCheckpoints().values().iterator().next(); assertFalse(checkpoint.isDiscarded()); OperatorID opID1 = OperatorID.fromJobVertexID(ackVertex1.getJobvertexId()); TaskStateSnapshot taskOperatorSubtaskStates1 = spy(new TaskStateSnapshot()); OperatorSubtaskState subtaskState1 = mock(OperatorSubtaskState.class); taskOperatorSubtaskStates1.putSubtaskStateByOperatorID(opID1, subtaskState1); coord.receiveAcknowledgeMessage(new AcknowledgeCheckpoint(jid, ackAttemptID1, checkpoint.getCheckpointId(), new CheckpointMetrics(), taskOperatorSubtaskStates1), TASK_MANAGER_LOCATION_INFO); // triggers cancelling manuallyTriggeredScheduledExecutor.triggerScheduledTasks(); assertTrue("Checkpoint was not canceled by the timeout", checkpoint.isDiscarded()); assertEquals(0, coord.getNumberOfPendingCheckpoints()); assertEquals(0, coord.getNumberOfRetainedSuccessfulCheckpoints()); // validate that the received states have been discarded verify(subtaskState1, times(1)).discardState(); // no confirm message must have been sent verify(commitVertex.getCurrentExecutionAttempt(), times(0)).notifyCheckpointComplete(anyLong(), anyLong()); coord.shutdown(JobStatus.FINISHED); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 8
Source File: CoordinatorEventsExactlyOnceITCase.java From flink with Apache License 2.0 | 4 votes |
public EventCollectingTask(Environment environment) { super(environment); this.operatorID = OperatorID.fromJobVertexID(environment.getJobVertexId()); this.accumulatorName = environment.getTaskConfiguration().get(ACC_NAME); this.actions = new LinkedBlockingQueue<>(); }