Java Code Examples for org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel#unsynchronizedGetNumberOfQueuedBuffers()

The following examples show how to use org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel#unsynchronizedGetNumberOfQueuedBuffers() . 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: InputGateMetrics.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Iterates over all input channels and collects the minimum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return minimum number of queued buffers per channel (<tt>0</tt> if no channels exist)
 */
int refreshAndGetMin() {
	int min = Integer.MAX_VALUE;

	Collection<InputChannel> channels = inputGate.getInputChannels().values();

	for (InputChannel channel : channels) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			min = Math.min(min, size);
		}
	}

	if (min == Integer.MAX_VALUE) { // in case all channels are local, or the channel collection was empty
		return 0;
	}
	return min;
}
 
Example 2
Source File: InputGateMetrics.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Iterates over all input channels and collects the average number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return average number of queued buffers per channel
 */
float refreshAndGetAvg() {
	long total = 0;
	int count = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			total += size;
			++count;
		}
	}

	return count == 0 ? 0 : total / (float) count;
}
 
Example 3
Source File: InputGateMetrics.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Iterates over all input channels and collects the minimum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return minimum number of queued buffers per channel (<tt>0</tt> if no channels exist)
 */
int refreshAndGetMin() {
	int min = Integer.MAX_VALUE;

	Collection<InputChannel> channels = inputGate.getInputChannels().values();

	for (InputChannel channel : channels) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			min = Math.min(min, size);
		}
	}

	if (min == Integer.MAX_VALUE) { // in case all channels are local, or the channel collection was empty
		return 0;
	}
	return min;
}
 
Example 4
Source File: InputGateMetrics.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Iterates over all input channels and collects the average number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return average number of queued buffers per channel
 */
float refreshAndGetAvg() {
	long total = 0;
	int count = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			total += size;
			++count;
		}
	}

	return count == 0 ? 0 : total / (float) count;
}
 
Example 5
Source File: InputGateMetrics.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over all input channels and collects the total number of queued buffers in a
 * best-effort way.
 *
 * @return total number of queued buffers
 */
long refreshAndGetTotal() {
	long total = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			total += rc.unsynchronizedGetNumberOfQueuedBuffers();
		}
	}

	return total;
}
 
Example 6
Source File: InputGateMetrics.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over all input channels and collects the maximum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return maximum number of queued buffers per channel
 */
int refreshAndGetMax() {
	int max = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			max = Math.max(max, size);
		}
	}

	return max;
}
 
Example 7
Source File: InputGateMetrics.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over all input channels and collects the total number of queued buffers in a
 * best-effort way.
 *
 * @return total number of queued buffers
 */
long refreshAndGetTotal() {
	long total = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			total += rc.unsynchronizedGetNumberOfQueuedBuffers();
		}
	}

	return total;
}
 
Example 8
Source File: InputGateMetrics.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over all input channels and collects the maximum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return maximum number of queued buffers per channel
 */
int refreshAndGetMax() {
	int max = 0;

	for (InputChannel channel : inputGate.getInputChannels().values()) {
		if (channel instanceof RemoteInputChannel) {
			RemoteInputChannel rc = (RemoteInputChannel) channel;

			int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
			max = Math.max(max, size);
		}
	}

	return max;
}