Search in sources :

Example 1 with FixedObjectPool

use of io.grpc.internal.FixedObjectPool in project grpc-java by grpc.

the class AltsProtocolNegotiatorTest method setup.

@Before
public void setup() throws Exception {
    ChannelHandler uncaughtExceptionHandler = new ChannelDuplexHandler() {

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
            caughtException = cause;
            super.exceptionCaught(ctx, cause);
            ctx.close();
        }
    };
    TsiHandshakerFactory handshakerFactory = new DelegatingTsiHandshakerFactory(FakeTsiHandshaker.clientHandshakerFactory()) {

        @Override
        public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) {
            return new DelegatingTsiHandshaker(super.newHandshaker(authority, logger)) {

                @Override
                public TsiPeer extractPeer() throws GeneralSecurityException {
                    return mockedTsiPeer;
                }

                @Override
                public Object extractPeerObject() throws GeneralSecurityException {
                    return mockedAltsContext;
                }
            };
        }
    };
    ManagedChannel fakeChannel = NettyChannelBuilder.forTarget("localhost:8080").build();
    ObjectPool<Channel> fakeChannelPool = new FixedObjectPool<Channel>(fakeChannel);
    LazyChannel lazyFakeChannel = new LazyChannel(fakeChannelPool);
    ChannelHandler altsServerHandler = new ServerAltsProtocolNegotiator(handshakerFactory, lazyFakeChannel).newHandler(grpcHandler);
    // On real server, WBAEH fires default ProtocolNegotiationEvent. KickNH provides this behavior.
    ChannelHandler handler = new KickNegotiationHandler(altsServerHandler);
    channel = new EmbeddedChannel(uncaughtExceptionHandler, handler);
}
Also used : ServerAltsProtocolNegotiator(io.grpc.alts.internal.AltsProtocolNegotiator.ServerAltsProtocolNegotiator) LazyChannel(io.grpc.alts.internal.AltsProtocolNegotiator.LazyChannel) ManagedChannel(io.grpc.ManagedChannel) Channel(io.grpc.Channel) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) LazyChannel(io.grpc.alts.internal.AltsProtocolNegotiator.LazyChannel) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ChannelHandler(io.netty.channel.ChannelHandler) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) ManagedChannel(io.grpc.ManagedChannel) ChannelLogger(io.grpc.ChannelLogger) NoopChannelLogger(io.grpc.internal.TestUtils.NoopChannelLogger) FixedObjectPool(io.grpc.internal.FixedObjectPool) Before(org.junit.Before)

Example 2 with FixedObjectPool

use of io.grpc.internal.FixedObjectPool in project grpc-java by grpc.

the class NettyClientTransportTest method startServer.

private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException {
    server = new NettyServer(TestUtils.testServerAddresses(new InetSocketAddress(0)), new ReflectiveChannelFactory<>(NioServerSocketChannel.class), new HashMap<ChannelOption<?>, Object>(), new HashMap<ChannelOption<?>, Object>(), new FixedObjectPool<>(group), new FixedObjectPool<>(group), false, negotiator, Collections.<ServerStreamTracer.Factory>emptyList(), TransportTracer.getDefaultFactory(), maxStreamsPerConnection, false, DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize, DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS, MAX_CONNECTION_IDLE_NANOS_DISABLED, MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0, Attributes.EMPTY, channelz);
    server.start(serverListener);
    address = TestUtils.testServerAddress((InetSocketAddress) server.getListenSocketAddress());
    authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
}
Also used : HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) ChannelFactory(io.netty.channel.ChannelFactory) ReflectiveChannelFactory(io.netty.channel.ReflectiveChannelFactory) FixedObjectPool(io.grpc.internal.FixedObjectPool) ReflectiveChannelFactory(io.netty.channel.ReflectiveChannelFactory)

Aggregations

FixedObjectPool (io.grpc.internal.FixedObjectPool)2 Channel (io.grpc.Channel)1 ChannelLogger (io.grpc.ChannelLogger)1 ManagedChannel (io.grpc.ManagedChannel)1 LazyChannel (io.grpc.alts.internal.AltsProtocolNegotiator.LazyChannel)1 ServerAltsProtocolNegotiator (io.grpc.alts.internal.AltsProtocolNegotiator.ServerAltsProtocolNegotiator)1 NoopChannelLogger (io.grpc.internal.TestUtils.NoopChannelLogger)1 ChannelDuplexHandler (io.netty.channel.ChannelDuplexHandler)1 ChannelFactory (io.netty.channel.ChannelFactory)1 ChannelHandler (io.netty.channel.ChannelHandler)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ReflectiveChannelFactory (io.netty.channel.ReflectiveChannelFactory)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1