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

The following examples show how to use org.apache.flink.runtime.iterative.concurrent.BlockingBackChannelBroker. 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: IterationHeadTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and
 * hands it to the iteration tail via a {@link Broker} singleton.
 **/
private BlockingBackChannel initBackChannel() throws Exception {

	/* get the size of the memory available to the backchannel */
	int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory());

	/* allocate the memory available to the backchannel */
	List<MemorySegment> segments = new ArrayList<MemorySegment>();
	int segmentSize = getMemoryManager().getPageSize();
	getMemoryManager().allocatePages(this, segments, backChannelMemoryPages);

	/* instantiate the backchannel */
	BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize,
		getIOManager()));

	/* hand the backchannel over to the iteration tail */
	Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance();
	broker.handIn(brokerKey(), backChannel);

	return backChannel;
}
 
Example 2
Source Project: flink   Source File: IterationHeadTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and
 * hands it to the iteration tail via a {@link Broker} singleton.
 **/
private BlockingBackChannel initBackChannel() throws Exception {

	/* get the size of the memory available to the backchannel */
	int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory());

	/* allocate the memory available to the backchannel */
	List<MemorySegment> segments = new ArrayList<MemorySegment>();
	int segmentSize = getMemoryManager().getPageSize();
	getMemoryManager().allocatePages(this, segments, backChannelMemoryPages);

	/* instantiate the backchannel */
	BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize,
		getIOManager()));

	/* hand the backchannel over to the iteration tail */
	Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance();
	broker.handIn(brokerKey(), backChannel);

	return backChannel;
}
 
Example 3
Source Project: flink   Source File: IterationHeadTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The iteration head prepares the backchannel: it allocates memory, instantiates a {@link BlockingBackChannel} and
 * hands it to the iteration tail via a {@link Broker} singleton.
 **/
private BlockingBackChannel initBackChannel() throws Exception {

	/* get the size of the memory available to the backchannel */
	int backChannelMemoryPages = getMemoryManager().computeNumberOfPages(this.config.getRelativeBackChannelMemory());

	/* allocate the memory available to the backchannel */
	List<MemorySegment> segments = new ArrayList<MemorySegment>();
	int segmentSize = getMemoryManager().getPageSize();
	getMemoryManager().allocatePages(this, segments, backChannelMemoryPages);

	/* instantiate the backchannel */
	BlockingBackChannel backChannel = new BlockingBackChannel(new SerializedUpdateBuffer(segments, segmentSize,
		getIOManager()));

	/* hand the backchannel over to the iteration tail */
	Broker<BlockingBackChannel> broker = BlockingBackChannelBroker.instance();
	broker.handIn(brokerKey(), backChannel);

	return backChannel;
}
 
Example 4
Source Project: Flink-CEPplus   Source File: AbstractIterativeTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}
 
Example 5
Source Project: flink   Source File: AbstractIterativeTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}
 
Example 6
Source Project: flink   Source File: AbstractIterativeTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}