Java Code Examples for org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext#fireUserEventTriggered()

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext#fireUserEventTriggered() . 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: PartitionRequestQueue.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	// The user event triggered event loop callback is used for thread-safe
	// hand over of reader queues and cancelled producers.

	if (msg instanceof NetworkSequenceViewReader) {
		enqueueAvailableReader((NetworkSequenceViewReader) msg);
	} else if (msg.getClass() == InputChannelID.class) {
		// Release partition view that get a cancel request.
		InputChannelID toCancel = (InputChannelID) msg;

		// remove reader from queue of available readers
		availableReaders.removeIf(reader -> reader.getReceiverId().equals(toCancel));

		// remove reader from queue of all readers and release its resource
		final NetworkSequenceViewReader toRelease = allReaders.remove(toCancel);
		if (toRelease != null) {
			releaseViewReader(toRelease);
		}
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}
 
Example 2
Source File: PartitionRequestQueue.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	// The user event triggered event loop callback is used for thread-safe
	// hand over of reader queues and cancelled producers.

	if (msg instanceof NetworkSequenceViewReader) {
		enqueueAvailableReader((NetworkSequenceViewReader) msg);
	} else if (msg.getClass() == InputChannelID.class) {
		// Release partition view that get a cancel request.
		InputChannelID toCancel = (InputChannelID) msg;

		// remove reader from queue of available readers
		availableReaders.removeIf(reader -> reader.getReceiverId().equals(toCancel));

		// remove reader from queue of all readers and release its resource
		final NetworkSequenceViewReader toRelease = allReaders.remove(toCancel);
		if (toRelease != null) {
			releaseViewReader(toRelease);
		}
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}
 
Example 3
Source File: CreditBasedPartitionRequestClientHandler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Triggered by notifying credit available in the client handler pipeline.
 *
 * <p>Enqueues the input channel and will trigger write&flush unannounced credits
 * for this input channel if it is the first one in the queue.
 */
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	if (msg instanceof RemoteInputChannel) {
		boolean triggerWrite = inputChannelsWithCredit.isEmpty();

		inputChannelsWithCredit.add((RemoteInputChannel) msg);

		if (triggerWrite) {
			writeAndFlushNextMessageIfPossible(ctx.channel());
		}
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}
 
Example 4
Source File: PartitionRequestQueue.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	// The user event triggered event loop callback is used for thread-safe
	// hand over of reader queues and cancelled producers.

	if (msg instanceof NetworkSequenceViewReader) {
		enqueueAvailableReader((NetworkSequenceViewReader) msg);
	} else if (msg.getClass() == InputChannelID.class) {
		// Release partition view that get a cancel request.
		InputChannelID toCancel = (InputChannelID) msg;
		if (released.contains(toCancel)) {
			return;
		}

		// Cancel the request for the input channel
		int size = availableReaders.size();
		for (int i = 0; i < size; i++) {
			NetworkSequenceViewReader reader = pollAvailableReader();
			if (reader.getReceiverId().equals(toCancel)) {
				reader.releaseAllResources();
				markAsReleased(reader.getReceiverId());
			} else {
				registerAvailableReader(reader);
			}
		}

		allReaders.remove(toCancel);
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}
 
Example 5
Source File: CreditBasedPartitionRequestClientHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Triggered by notifying credit available in the client handler pipeline.
 *
 * <p>Enqueues the input channel and will trigger write&flush unannounced credits
 * for this input channel if it is the first one in the queue.
 */
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	if (msg instanceof RemoteInputChannel) {
		boolean triggerWrite = inputChannelsWithCredit.isEmpty();

		inputChannelsWithCredit.add((RemoteInputChannel) msg);

		if (triggerWrite) {
			writeAndFlushNextMessageIfPossible(ctx.channel());
		}
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}
 
Example 6
Source File: CreditBasedPartitionRequestClientHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Triggered by notifying credit available in the client handler pipeline.
 *
 * <p>Enqueues the input channel and will trigger write&flush unannounced credits
 * for this input channel if it is the first one in the queue.
 */
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object msg) throws Exception {
	if (msg instanceof ClientOutboundMessage) {
		boolean triggerWrite = clientOutboundMessages.isEmpty();

		clientOutboundMessages.add((ClientOutboundMessage) msg);

		if (triggerWrite) {
			writeAndFlushNextMessageIfPossible(ctx.channel());
		}
	} else {
		ctx.fireUserEventTriggered(msg);
	}
}