use of org.apache.flink.runtime.io.network.ConnectionID in project flink by apache.
the class PartitionRequestClientFactoryTest method checkReuseNettyPartitionRequestClient.
private void checkReuseNettyPartitionRequestClient(NettyTestUtil.NettyServerAndClient nettyServerAndClient, int maxNumberOfConnections) throws Exception {
final Set<NettyPartitionRequestClient> set = new HashSet<>();
final PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyServerAndClient.client(), 0, maxNumberOfConnections, connectionReuseEnabled);
for (int i = 0; i < Math.max(100, maxNumberOfConnections); i++) {
final ConnectionID connectionID = nettyServerAndClient.getConnectionID((int) (Math.random() * Integer.MAX_VALUE));
set.add(factory.createPartitionRequestClient(connectionID));
}
assertTrue(set.size() <= maxNumberOfConnections);
}
use of org.apache.flink.runtime.io.network.ConnectionID in project flink by apache.
the class NettyPartitionRequestClientTest method createPartitionRequestClient.
private NettyPartitionRequestClient createPartitionRequestClient(Channel tcpChannel, NetworkClientHandler clientHandler, boolean connectionReuseEnabled) throws Exception {
try (NetUtils.Port availablePort = NetUtils.getAvailablePort()) {
int port = availablePort.getPort();
ConnectionID connectionID = new ConnectionID(new InetSocketAddress("localhost", port), 0);
NettyConfig config = new NettyConfig(InetAddress.getLocalHost(), port, 1024, 1, new Configuration());
NettyClient nettyClient = new NettyClient(config);
PartitionRequestClientFactory partitionRequestClientFactory = new PartitionRequestClientFactory(nettyClient, connectionReuseEnabled);
return new NettyPartitionRequestClient(tcpChannel, clientHandler, connectionID, partitionRequestClientFactory);
}
}
Aggregations