Java Code Examples for org.apache.flink.runtime.io.network.api.writer.ChannelSelector#setup()
The following examples show how to use
org.apache.flink.runtime.io.network.api.writer.ChannelSelector#setup() .
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: OutputEmitterTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private ChannelSelector createChannelSelector( ShipStrategyType shipStrategyType, TypeComparator comparator, int numberOfChannels) { final ChannelSelector selector = new OutputEmitter<>(shipStrategyType, comparator); selector.setup(numberOfChannels); assertEquals(shipStrategyType == ShipStrategyType.BROADCAST, selector.isBroadcast()); return selector; }
Example 2
Source File: OutputEmitterTest.java From flink with Apache License 2.0 | 5 votes |
private ChannelSelector createChannelSelector( ShipStrategyType shipStrategyType, TypeComparator comparator, int numberOfChannels) { final ChannelSelector selector = new OutputEmitter<>(shipStrategyType, comparator); selector.setup(numberOfChannels); assertEquals(shipStrategyType == ShipStrategyType.BROADCAST, selector.isBroadcast()); return selector; }
Example 3
Source File: OutputEmitterTest.java From flink with Apache License 2.0 | 5 votes |
private ChannelSelector createChannelSelector( ShipStrategyType shipStrategyType, TypeComparator comparator, int numberOfChannels) { final ChannelSelector selector = new OutputEmitter<>(shipStrategyType, comparator); selector.setup(numberOfChannels); assertEquals(shipStrategyType == ShipStrategyType.BROADCAST, selector.isBroadcast()); return selector; }
Example 4
Source File: OutputEmitterTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testForcedRebalance() { final int numberOfChannels = 100; int toTaskIndex = numberOfChannels * 6 / 7; int fromTaskIndex = toTaskIndex + numberOfChannels; int extraRecords = numberOfChannels / 3; int numRecords = 50000 + extraRecords; final SerializationDelegate<Record> delegate = new SerializationDelegate<>( new RecordSerializerFactory().getSerializer()); final ChannelSelector<SerializationDelegate<Record>> selector = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector.setup(numberOfChannels); // Test for IntValue int[] hits = getSelectedChannelsHitCount(selector, delegate, RecordType.INTEGER, numRecords, numberOfChannels); int totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i || i < toTaskIndex+extraRecords - numberOfChannels) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); toTaskIndex = numberOfChannels / 5; fromTaskIndex = toTaskIndex + 2 * numberOfChannels; extraRecords = numberOfChannels * 2 / 9; numRecords = 10000 + extraRecords; // Test for StringValue final ChannelSelector<SerializationDelegate<Record>> selector2 = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector2.setup(numberOfChannels); hits = getSelectedChannelsHitCount(selector2, delegate, RecordType.STRING, numRecords, numberOfChannels); totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i && i < toTaskIndex + extraRecords) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); }
Example 5
Source File: OutputEmitterTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testForcedRebalance() { final int numberOfChannels = 100; int toTaskIndex = numberOfChannels * 6 / 7; int fromTaskIndex = toTaskIndex + numberOfChannels; int extraRecords = numberOfChannels / 3; int numRecords = 50000 + extraRecords; final SerializationDelegate<Record> delegate = new SerializationDelegate<>( new RecordSerializerFactory().getSerializer()); final ChannelSelector<SerializationDelegate<Record>> selector = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector.setup(numberOfChannels); // Test for IntValue int[] hits = getSelectedChannelsHitCount(selector, delegate, RecordType.INTEGER, numRecords, numberOfChannels); int totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i || i < toTaskIndex+extraRecords - numberOfChannels) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); toTaskIndex = numberOfChannels / 5; fromTaskIndex = toTaskIndex + 2 * numberOfChannels; extraRecords = numberOfChannels * 2 / 9; numRecords = 10000 + extraRecords; // Test for StringValue final ChannelSelector<SerializationDelegate<Record>> selector2 = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector2.setup(numberOfChannels); hits = getSelectedChannelsHitCount(selector2, delegate, RecordType.STRING, numRecords, numberOfChannels); totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i && i < toTaskIndex + extraRecords) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); }
Example 6
Source File: OutputEmitterTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testForcedRebalance() { final int numberOfChannels = 100; int toTaskIndex = numberOfChannels * 6 / 7; int fromTaskIndex = toTaskIndex + numberOfChannels; int extraRecords = numberOfChannels / 3; int numRecords = 50000 + extraRecords; final SerializationDelegate<Record> delegate = new SerializationDelegate<>( new RecordSerializerFactory().getSerializer()); final ChannelSelector<SerializationDelegate<Record>> selector = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector.setup(numberOfChannels); // Test for IntValue int[] hits = getSelectedChannelsHitCount(selector, delegate, RecordType.INTEGER, numRecords, numberOfChannels); int totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i || i < toTaskIndex+extraRecords - numberOfChannels) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); toTaskIndex = numberOfChannels / 5; fromTaskIndex = toTaskIndex + 2 * numberOfChannels; extraRecords = numberOfChannels * 2 / 9; numRecords = 10000 + extraRecords; // Test for StringValue final ChannelSelector<SerializationDelegate<Record>> selector2 = new OutputEmitter<>( ShipStrategyType.PARTITION_FORCED_REBALANCE, fromTaskIndex); selector2.setup(numberOfChannels); hits = getSelectedChannelsHitCount(selector2, delegate, RecordType.STRING, numRecords, numberOfChannels); totalHitCount = 0; for (int i = 0; i < hits.length; i++) { if (toTaskIndex <= i && i < toTaskIndex + extraRecords) { assertTrue(hits[i] == (numRecords / numberOfChannels) + 1); } else { assertTrue(hits[i] == numRecords / numberOfChannels); } totalHitCount += hits[i]; } assertTrue(totalHitCount == numRecords); }