Search in sources :

Example 1 with PoolManager

use of com.datastax.oss.driver.internal.core.session.PoolManager in project java-driver by datastax.

the class InsightsClientTest method mockConnectionPools.

private void mockConnectionPools(DefaultDriverContext driverContext) {
    Node node1 = mock(Node.class);
    EndPoint endPoint1 = mock(EndPoint.class);
    when(endPoint1.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 10));
    when(node1.getEndPoint()).thenReturn(endPoint1);
    when(node1.getOpenConnections()).thenReturn(1);
    ChannelPool channelPool1 = mock(ChannelPool.class);
    when(channelPool1.getInFlight()).thenReturn(10);
    Node node2 = mock(Node.class);
    EndPoint endPoint2 = mock(EndPoint.class);
    when(endPoint2.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 20));
    when(node2.getEndPoint()).thenReturn(endPoint2);
    when(node2.getOpenConnections()).thenReturn(2);
    ChannelPool channelPool2 = mock(ChannelPool.class);
    when(channelPool2.getInFlight()).thenReturn(20);
    Map<Node, ChannelPool> channelPools = ImmutableMap.of(node1, channelPool1, node2, channelPool2);
    PoolManager poolManager = mock(PoolManager.class);
    when(poolManager.getPools()).thenReturn(channelPools);
    when(driverContext.getPoolManager()).thenReturn(poolManager);
}
Also used : ChannelPool(com.datastax.oss.driver.internal.core.pool.ChannelPool) InetSocketAddress(java.net.InetSocketAddress) DefaultNode(com.datastax.oss.driver.internal.core.metadata.DefaultNode) SessionStateForNode(com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode) Node(com.datastax.oss.driver.api.core.metadata.Node) EndPoint(com.datastax.oss.driver.api.core.metadata.EndPoint) PoolManager(com.datastax.oss.driver.internal.core.session.PoolManager)

Aggregations

SessionStateForNode (com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode)1 EndPoint (com.datastax.oss.driver.api.core.metadata.EndPoint)1 Node (com.datastax.oss.driver.api.core.metadata.Node)1 DefaultNode (com.datastax.oss.driver.internal.core.metadata.DefaultNode)1 ChannelPool (com.datastax.oss.driver.internal.core.pool.ChannelPool)1 PoolManager (com.datastax.oss.driver.internal.core.session.PoolManager)1 InetSocketAddress (java.net.InetSocketAddress)1