use of org.apache.flink.runtime.io.network.partition.consumer.LocalInputChannel in project flink by apache.
the class InputGateConcurrentTest method testConsumptionWithLocalChannels.
@Test
public void testConsumptionWithLocalChannels() throws Exception {
final int numChannels = 11;
final int buffersPerChannel = 1000;
final ResultPartition resultPartition = mock(ResultPartition.class);
final PipelinedSubpartition[] partitions = new PipelinedSubpartition[numChannels];
final Source[] sources = new Source[numChannels];
final ResultPartitionManager resultPartitionManager = createResultPartitionManager(partitions);
final SingleInputGate gate = new SingleInputGate("Test Task Name", new JobID(), new IntermediateDataSetID(), ResultPartitionType.PIPELINED, 0, numChannels, mock(TaskActions.class), new UnregisteredTaskMetricsGroup.DummyTaskIOMetricGroup());
for (int i = 0; i < numChannels; i++) {
LocalInputChannel channel = new LocalInputChannel(gate, i, new ResultPartitionID(), resultPartitionManager, mock(TaskEventDispatcher.class), new UnregisteredTaskMetricsGroup.DummyTaskIOMetricGroup());
gate.setInputChannel(new IntermediateResultPartitionID(), channel);
partitions[i] = new PipelinedSubpartition(0, resultPartition);
sources[i] = new PipelinedSubpartitionSource(partitions[i]);
}
ProducerThread producer = new ProducerThread(sources, numChannels * buffersPerChannel, 4, 10);
ConsumerThread consumer = new ConsumerThread(gate, numChannels * buffersPerChannel);
producer.start();
consumer.start();
// the 'sync()' call checks for exceptions and failed assertions
producer.sync();
consumer.sync();
}
use of org.apache.flink.runtime.io.network.partition.consumer.LocalInputChannel in project flink by apache.
the class InputGateConcurrentTest method testConsumptionWithMixedChannels.
@Test
public void testConsumptionWithMixedChannels() throws Exception {
final int numChannels = 61;
final int numLocalChannels = 20;
final int buffersPerChannel = 1000;
// fill the local/remote decision
List<Boolean> localOrRemote = new ArrayList<>(numChannels);
for (int i = 0; i < numChannels; i++) {
localOrRemote.add(i < numLocalChannels);
}
Collections.shuffle(localOrRemote);
final ConnectionManager connManager = createDummyConnectionManager();
final ResultPartition resultPartition = mock(ResultPartition.class);
final PipelinedSubpartition[] localPartitions = new PipelinedSubpartition[numLocalChannels];
final ResultPartitionManager resultPartitionManager = createResultPartitionManager(localPartitions);
final Source[] sources = new Source[numChannels];
final SingleInputGate gate = new SingleInputGate("Test Task Name", new JobID(), new IntermediateDataSetID(), ResultPartitionType.PIPELINED, 0, numChannels, mock(TaskActions.class), new UnregisteredTaskMetricsGroup.DummyTaskIOMetricGroup());
for (int i = 0, local = 0; i < numChannels; i++) {
if (localOrRemote.get(i)) {
// local channel
PipelinedSubpartition psp = new PipelinedSubpartition(0, resultPartition);
localPartitions[local++] = psp;
sources[i] = new PipelinedSubpartitionSource(psp);
LocalInputChannel channel = new LocalInputChannel(gate, i, new ResultPartitionID(), resultPartitionManager, mock(TaskEventDispatcher.class), new UnregisteredTaskMetricsGroup.DummyTaskIOMetricGroup());
gate.setInputChannel(new IntermediateResultPartitionID(), channel);
} else {
//remote channel
RemoteInputChannel channel = new RemoteInputChannel(gate, i, new ResultPartitionID(), mock(ConnectionID.class), connManager, 0, 0, new UnregisteredTaskMetricsGroup.DummyTaskIOMetricGroup());
gate.setInputChannel(new IntermediateResultPartitionID(), channel);
sources[i] = new RemoteChannelSource(channel);
}
}
ProducerThread producer = new ProducerThread(sources, numChannels * buffersPerChannel, 4, 10);
ConsumerThread consumer = new ConsumerThread(gate, numChannels * buffersPerChannel);
producer.start();
consumer.start();
// the 'sync()' call checks for exceptions and failed assertions
producer.sync();
consumer.sync();
}
Aggregations