Java Code Examples for org.apache.flink.runtime.io.network.api.writer.RecordWriter#broadcastEvent()

The following examples show how to use org.apache.flink.runtime.io.network.api.writer.RecordWriter#broadcastEvent() . 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: IterationHeadTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void sendEndOfSuperstepToAllIterationOutputs() throws IOException, InterruptedException {
	if (log.isDebugEnabled()) {
		log.debug(formatLogString("Sending end-of-superstep to all iteration outputs."));
	}

	for (RecordWriter<?> eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}
 
Example 2
Source File: IterationHeadTask.java    From flink with Apache License 2.0 5 votes vote down vote up
private void sendEndOfSuperstepToAllIterationOutputs() throws IOException, InterruptedException {
	if (log.isDebugEnabled()) {
		log.debug(formatLogString("Sending end-of-superstep to all iteration outputs."));
	}

	for (RecordWriter<?> eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}
 
Example 3
Source File: IterationHeadTask.java    From flink with Apache License 2.0 5 votes vote down vote up
private void sendEndOfSuperstepToAllIterationOutputs() throws IOException, InterruptedException {
	if (log.isDebugEnabled()) {
		log.debug(formatLogString("Sending end-of-superstep to all iteration outputs."));
	}

	for (RecordWriter<?> eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}
 
Example 4
Source File: IterationIntermediateTask.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void sendEndOfSuperstep() throws IOException, InterruptedException {
	for (RecordWriter eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}
 
Example 5
Source File: StreamTask.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private boolean performCheckpoint(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		CheckpointMetrics checkpointMetrics) throws Exception {

	LOG.debug("Starting checkpoint ({}) {} on task {}",
		checkpointMetaData.getCheckpointId(), checkpointOptions.getCheckpointType(), getName());

	synchronized (lock) {
		if (isRunning) {
			// we can do a checkpoint

			// All of the following steps happen as an atomic step from the perspective of barriers and
			// records/watermarks/timers/callbacks.
			// We generally try to emit the checkpoint barrier as soon as possible to not affect downstream
			// checkpoint alignments

			// Step (1): Prepare the checkpoint, allow operators to do some pre-barrier work.
			//           The pre-barrier work should be nothing or minimal in the common case.
			operatorChain.prepareSnapshotPreBarrier(checkpointMetaData.getCheckpointId());

			// Step (2): Send the checkpoint barrier downstream
			operatorChain.broadcastCheckpointBarrier(
					checkpointMetaData.getCheckpointId(),
					checkpointMetaData.getTimestamp(),
					checkpointOptions);

			// Step (3): Take the state snapshot. This should be largely asynchronous, to not
			//           impact progress of the streaming topology
			checkpointState(checkpointMetaData, checkpointOptions, checkpointMetrics);
			return true;
		}
		else {
			// we cannot perform our checkpoint - let the downstream operators know that they
			// should not wait for any input from this operator

			// we cannot broadcast the cancellation markers on the 'operator chain', because it may not
			// yet be created
			final CancelCheckpointMarker message = new CancelCheckpointMarker(checkpointMetaData.getCheckpointId());
			Exception exception = null;

			for (RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter : recordWriters) {
				try {
					recordWriter.broadcastEvent(message);
				} catch (Exception e) {
					exception = ExceptionUtils.firstOrSuppressed(
						new Exception("Could not send cancel checkpoint marker to downstream tasks.", e),
						exception);
				}
			}

			if (exception != null) {
				throw exception;
			}

			return false;
		}
	}
}
 
Example 6
Source File: IterationIntermediateTask.java    From flink with Apache License 2.0 4 votes vote down vote up
private void sendEndOfSuperstep() throws IOException, InterruptedException {
	for (RecordWriter eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}
 
Example 7
Source File: StreamTask.java    From flink with Apache License 2.0 4 votes vote down vote up
private boolean performCheckpoint(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		CheckpointMetrics checkpointMetrics,
		boolean advanceToEndOfTime) throws Exception {

	LOG.debug("Starting checkpoint ({}) {} on task {}",
		checkpointMetaData.getCheckpointId(), checkpointOptions.getCheckpointType(), getName());

	final long checkpointId = checkpointMetaData.getCheckpointId();

	synchronized (lock) {
		if (isRunning) {

			if (checkpointOptions.getCheckpointType().isSynchronous()) {
				syncSavepointLatch.setCheckpointId(checkpointId);

				if (advanceToEndOfTime) {
					advanceToEndOfEventTime();
				}
			}

			// All of the following steps happen as an atomic step from the perspective of barriers and
			// records/watermarks/timers/callbacks.
			// We generally try to emit the checkpoint barrier as soon as possible to not affect downstream
			// checkpoint alignments

			// Step (1): Prepare the checkpoint, allow operators to do some pre-barrier work.
			//           The pre-barrier work should be nothing or minimal in the common case.
			operatorChain.prepareSnapshotPreBarrier(checkpointId);

			// Step (2): Send the checkpoint barrier downstream
			operatorChain.broadcastCheckpointBarrier(
					checkpointId,
					checkpointMetaData.getTimestamp(),
					checkpointOptions);

			// Step (3): Take the state snapshot. This should be largely asynchronous, to not
			//           impact progress of the streaming topology
			checkpointState(checkpointMetaData, checkpointOptions, checkpointMetrics);

			return true;
		}
		else {
			// we cannot perform our checkpoint - let the downstream operators know that they
			// should not wait for any input from this operator

			// we cannot broadcast the cancellation markers on the 'operator chain', because it may not
			// yet be created
			final CancelCheckpointMarker message = new CancelCheckpointMarker(checkpointMetaData.getCheckpointId());
			Exception exception = null;

			for (RecordWriter<SerializationDelegate<StreamRecord<OUT>>> recordWriter : recordWriters) {
				try {
					recordWriter.broadcastEvent(message);
				} catch (Exception e) {
					exception = ExceptionUtils.firstOrSuppressed(
						new Exception("Could not send cancel checkpoint marker to downstream tasks.", e),
						exception);
				}
			}

			if (exception != null) {
				throw exception;
			}

			return false;
		}
	}
}
 
Example 8
Source File: IterationIntermediateTask.java    From flink with Apache License 2.0 4 votes vote down vote up
private void sendEndOfSuperstep() throws IOException, InterruptedException {
	for (RecordWriter eventualOutput : this.eventualOutputs) {
		eventualOutput.broadcastEvent(EndOfSuperstepEvent.INSTANCE);
	}
}