use of org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate in project flink by apache.
the class StreamTaskTest method testBufferDebloatingMultiGates.
@Test
public void testBufferDebloatingMultiGates() throws Exception {
// debloat period doesn't matter, we will schedule debloating manually
Configuration config = new Configuration().set(BUFFER_DEBLOAT_PERIOD, Duration.ofHours(10)).set(BUFFER_DEBLOAT_TARGET, Duration.ofSeconds(1)).set(BUFFER_DEBLOAT_ENABLED, true).set(BUFFER_DEBLOAT_THRESHOLD_PERCENTAGES, // disable the threshold to achieve exact buffer sizes
0);
final long throughputGate1 = 1024L;
final long throughputGate2 = 60 * 1024L;
final int inputChannelsGate1 = 1;
final int inputChannelsGate2 = 4;
final ThroughputCalculator throughputCalculator = new ThroughputCalculator(SystemClock.getInstance()) {
/* parameters are ignored */
private int callCount = 0;
@Override
public long calculateThroughput() {
if (callCount++ % 2 == 0) {
return throughputGate1;
} else {
return throughputGate2;
}
}
};
try (StreamTaskMailboxTestHarness<String> harness = new StreamTaskMailboxTestHarnessBuilder<>(OneInputStreamTask::new, STRING_TYPE_INFO).setTaskManagerRuntimeInfo(new TestingTaskManagerRuntimeInfo(config)).addInput(STRING_TYPE_INFO, inputChannelsGate1).addInput(STRING_TYPE_INFO, inputChannelsGate2).modifyGateBuilder(gateBuilder -> gateBuilder.setThroughputCalculator(bufferDebloatConfiguration -> throughputCalculator)).setupOutputForSingletonOperatorChain(new TestBoundedOneInputStreamOperator()).build()) {
final IndexedInputGate[] inputGates = harness.streamTask.getEnvironment().getAllInputGates();
harness.processAll();
// call debloating until the EMA reaches the target buffer size
while (getCurrentBufferSize(inputGates[0]) == 0 || getCurrentBufferSize(inputGates[0]) > throughputGate1) {
harness.streamTask.debloat();
}
assertThat(getCurrentBufferSize(inputGates[0]), equalTo((int) throughputGate1));
assertThat(getCurrentBufferSize(inputGates[1]), equalTo((int) throughputGate2 / inputChannelsGate2));
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate in project flink by apache.
the class StreamNetworkBenchmarkEnvironment method createInputGate.
private InputGate createInputGate(TaskManagerLocation senderLocation) throws Exception {
IndexedInputGate[] gates = new IndexedInputGate[partitionIds.length];
for (int gateIndex = 0; gateIndex < gates.length; ++gateIndex) {
final InputGateDeploymentDescriptor gateDescriptor = createInputGateDeploymentDescriptor(senderLocation, gateIndex, location);
final IndexedInputGate gate = createInputGateWithMetrics(gateFactory, gateDescriptor, gateIndex);
gate.setup();
gates[gateIndex] = gate;
}
if (gates.length > 1) {
return new UnionInputGate(gates);
} else {
return gates[0];
}
}
Aggregations