Search in sources :

Example 1 with ChannelPoolManagerImpl

use of com.linkedin.r2.transport.http.client.common.ChannelPoolManagerImpl in project rest.li by linkedin.

the class TestChannelPoolManager method test.

@Test
public void test() {
    ChannelPoolFactory factory = new ChannelPoolFactory() {

        @Override
        public AsyncPool<Channel> getPool(SocketAddress address) {
            return new FakePool<>();
        }
    };
    ChannelPoolManager m = new ChannelPoolManagerImpl(factory, null, null);
    final int NUM = 100;
    List<SocketAddress> addresses = new ArrayList<>(NUM);
    for (int i = 0; i < NUM; i++) {
        addresses.add(new InetSocketAddress(i));
    }
    List<AsyncPool<Channel>> pools = new ArrayList<>(NUM);
    for (int i = 0; i < NUM; i++) {
        pools.add(m.getPoolForAddress(addresses.get(i)));
    }
    for (int i = 0; i < NUM; i++) {
        Assert.assertEquals(m.getPoolForAddress(addresses.get(i)), pools.get(i));
    }
}
Also used : ChannelPoolFactory(com.linkedin.r2.transport.http.client.common.ChannelPoolFactory) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) ChannelPoolManager(com.linkedin.r2.transport.http.client.common.ChannelPoolManager) ArrayList(java.util.ArrayList) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) ChannelPoolManagerImpl(com.linkedin.r2.transport.http.client.common.ChannelPoolManagerImpl) Test(org.testng.annotations.Test)

Example 2 with ChannelPoolManagerImpl

use of com.linkedin.r2.transport.http.client.common.ChannelPoolManagerImpl in project rest.li by linkedin.

the class ChannelPoolManagerFactoryImpl method buildHttp2Stream.

@Override
public ChannelPoolManager buildHttp2Stream(ChannelPoolManagerKey channelPoolManagerKey) {
    DefaultChannelGroup channelGroup = new DefaultChannelGroup("R2 client channels", _eventLoopGroup.next());
    ChannelPoolFactory channelPoolFactory;
    if (_usePipelineV2) {
        channelPoolFactory = new Http2ChannelPoolFactory(_scheduler, _eventLoopGroup, channelGroup, channelPoolManagerKey.getStrategy(), channelPoolManagerKey.getSslContext(), channelPoolManagerKey.getSslParameters(), channelPoolManagerKey.getMaxPoolSize(), channelPoolManagerKey.getMinPoolSize(), channelPoolManagerKey.getPoolWaiterSize(), MAX_INITIAL_LINE_LENGTH, channelPoolManagerKey.getMaxHeaderSize(), channelPoolManagerKey.getMaxChunkSize(), channelPoolManagerKey.getIdleTimeout(), channelPoolManagerKey.getMaxResponseSize(), channelPoolManagerKey.isTcpNoDelay(), _enableSSLSessionResumption, _connectTimeout, _sslHandShakeTimeout);
    } else {
        channelPoolFactory = new Http2NettyStreamChannelPoolFactory(channelPoolManagerKey.getIdleTimeout(), channelPoolManagerKey.getPoolWaiterSize(), channelPoolManagerKey.getMinPoolSize(), channelPoolManagerKey.isTcpNoDelay(), _scheduler, channelPoolManagerKey.getSslContext(), channelPoolManagerKey.getSslParameters(), channelPoolManagerKey.getGracefulShutdownTimeout(), channelPoolManagerKey.getMaxHeaderSize(), channelPoolManagerKey.getMaxChunkSize(), channelPoolManagerKey.getMaxResponseSize(), _enableSSLSessionResumption, _eventLoopGroup, channelGroup, _connectTimeout, _sslHandShakeTimeout);
    }
    return new ChannelPoolManagerImpl(channelPoolFactory, channelPoolManagerKey.getName() + "-HTTP/2-Stream", channelGroup, _scheduler);
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) HttpNettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamChannelPoolFactory) HttpChannelPoolFactory(com.linkedin.r2.netty.client.http.HttpChannelPoolFactory) Http2NettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http2.Http2NettyStreamChannelPoolFactory) Http2ChannelPoolFactory(com.linkedin.r2.netty.client.http2.Http2ChannelPoolFactory) HttpNettyChannelPoolFactory(com.linkedin.r2.transport.http.client.rest.HttpNettyChannelPoolFactory) Http2NettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http2.Http2NettyStreamChannelPoolFactory) Http2ChannelPoolFactory(com.linkedin.r2.netty.client.http2.Http2ChannelPoolFactory)

Example 3 with ChannelPoolManagerImpl

use of com.linkedin.r2.transport.http.client.common.ChannelPoolManagerImpl in project rest.li by linkedin.

the class ChannelPoolManagerFactoryImpl method buildStream.

@Override
public ChannelPoolManager buildStream(ChannelPoolManagerKey channelPoolManagerKey) {
    DefaultChannelGroup channelGroup = new DefaultChannelGroup("R2 client channels", _eventLoopGroup.next());
    ChannelPoolFactory channelPoolFactory;
    if (_usePipelineV2) {
        channelPoolFactory = new HttpChannelPoolFactory(_scheduler, _eventLoopGroup, channelGroup, channelPoolManagerKey.getStrategy(), channelPoolManagerKey.getSslContext(), channelPoolManagerKey.getSslParameters(), channelPoolManagerKey.getMaxPoolSize(), channelPoolManagerKey.getMinPoolSize(), channelPoolManagerKey.getPoolWaiterSize(), MAX_INITIAL_LINE_LENGTH, channelPoolManagerKey.getMaxHeaderSize(), channelPoolManagerKey.getMaxChunkSize(), channelPoolManagerKey.getMaxConcurrentConnectionInitializations(), channelPoolManagerKey.getIdleTimeout(), channelPoolManagerKey.getMaxResponseSize(), channelPoolManagerKey.isTcpNoDelay(), _enableSSLSessionResumption, _channelPoolWaiterTimeout, _connectTimeout, _sslHandShakeTimeout);
    } else {
        channelPoolFactory = new HttpNettyStreamChannelPoolFactory(channelPoolManagerKey.getMaxPoolSize(), channelPoolManagerKey.getIdleTimeout(), channelPoolManagerKey.getPoolWaiterSize(), channelPoolManagerKey.getStrategy(), channelPoolManagerKey.getMinPoolSize(), channelPoolManagerKey.isTcpNoDelay(), _scheduler, channelPoolManagerKey.getMaxConcurrentConnectionInitializations(), channelPoolManagerKey.getSslContext(), channelPoolManagerKey.getSslParameters(), channelPoolManagerKey.getMaxHeaderSize(), channelPoolManagerKey.getMaxChunkSize(), channelPoolManagerKey.getMaxResponseSize(), _enableSSLSessionResumption, _eventLoopGroup, channelGroup, _channelPoolWaiterTimeout, _connectTimeout, _sslHandShakeTimeout);
    }
    return new ChannelPoolManagerImpl(channelPoolFactory, channelPoolManagerKey.getName() + "-Stream", channelGroup, _scheduler);
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) HttpNettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamChannelPoolFactory) HttpChannelPoolFactory(com.linkedin.r2.netty.client.http.HttpChannelPoolFactory) Http2NettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http2.Http2NettyStreamChannelPoolFactory) Http2ChannelPoolFactory(com.linkedin.r2.netty.client.http2.Http2ChannelPoolFactory) HttpNettyChannelPoolFactory(com.linkedin.r2.transport.http.client.rest.HttpNettyChannelPoolFactory) HttpChannelPoolFactory(com.linkedin.r2.netty.client.http.HttpChannelPoolFactory) HttpNettyStreamChannelPoolFactory(com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamChannelPoolFactory)

Aggregations

HttpChannelPoolFactory (com.linkedin.r2.netty.client.http.HttpChannelPoolFactory)2 Http2ChannelPoolFactory (com.linkedin.r2.netty.client.http2.Http2ChannelPoolFactory)2 HttpNettyChannelPoolFactory (com.linkedin.r2.transport.http.client.rest.HttpNettyChannelPoolFactory)2 HttpNettyStreamChannelPoolFactory (com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamChannelPoolFactory)2 Http2NettyStreamChannelPoolFactory (com.linkedin.r2.transport.http.client.stream.http2.Http2NettyStreamChannelPoolFactory)2 DefaultChannelGroup (io.netty.channel.group.DefaultChannelGroup)2 ChannelPoolFactory (com.linkedin.r2.transport.http.client.common.ChannelPoolFactory)1 ChannelPoolManager (com.linkedin.r2.transport.http.client.common.ChannelPoolManager)1 ChannelPoolManagerImpl (com.linkedin.r2.transport.http.client.common.ChannelPoolManagerImpl)1 Channel (io.netty.channel.Channel)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 Test (org.testng.annotations.Test)1