Search in sources :

Example 11 with ConnectionID

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);
}
Also used : ConnectionID(org.apache.flink.runtime.io.network.ConnectionID) HashSet(java.util.HashSet)

Example 12 with ConnectionID

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);
    }
}
Also used : ConnectionID(org.apache.flink.runtime.io.network.ConnectionID) NetUtils(org.apache.flink.util.NetUtils) Configuration(org.apache.flink.configuration.Configuration) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

ConnectionID (org.apache.flink.runtime.io.network.ConnectionID)12 Test (org.junit.Test)6 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)5 IOException (java.io.IOException)4 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)4 InetSocketAddress (java.net.InetSocketAddress)3 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)3 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 TimeoutException (java.util.concurrent.TimeoutException)2 Configuration (org.apache.flink.configuration.Configuration)2 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)2 ActorRef (akka.actor.ActorRef)1 JavaTestKit (akka.testkit.JavaTestKit)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 List (java.util.List)1