Java Code Examples for org.apache.flink.runtime.iterative.concurrent.SolutionSetUpdateBarrierBroker

The following examples show how to use org.apache.flink.runtime.iterative.concurrent.SolutionSetUpdateBarrierBroker. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}
 
Example 2
Source Project: flink   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}
 
Example 3
Source Project: flink   Source File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}