@Override public NioSocketChannel newChannel() { return new NioSocketChannel(); } }
@Override public NioSocketChannel newChannel() { return configure(new NioSocketChannel()); } };
@Override public EventLoopGroup init(Bootstrap bootstrap, final DockerClientConfig dockerClientConfig) { EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0, createThreadFactory()); // TODO do we really need BouncyCastle? Security.addProvider(new BouncyCastleProvider()); ChannelFactory<NioSocketChannel> factory = () -> configure(new NioSocketChannel()); bootstrap.group(nioEventLoopGroup).channelFactory(factory) .handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(final SocketChannel channel) throws Exception { channel.pipeline().addLast(new HttpClientCodec()); channel.pipeline().addLast(new HttpContentDecompressor()); } }); return nioEventLoopGroup; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
switch (socketType) { case JAVA_NIO: return (T) new NioSocketChannel(); case NATIVE_EPOLL: return (T) new EpollSocketChannel();
switch (socketType) { case JAVA_NIO: return (T) new NioSocketChannel(); case NATIVE_EPOLL: return (T) new EpollSocketChannel();
@Override public NioSocketChannel newChannel() { return configure(new NioSocketChannel()); } };
@Override public NioSocketChannel newChannel() { return configure(new NioSocketChannel()); } };
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
public static Promise<RedisClientBase> connect(String host, int port) { final Queue<Promise<Reply>> queue = new LinkedList<>(); SocketChannel socketChannel = new NioSocketChannel(); final RedisClientBase client = new RedisClientBase(socketChannel, queue); socketChannel.pipeline().addLast(new RedisCommandEncoder(), new RedisReplyDecoder(), new SimpleChannelInboundHandler<Reply<?>>() { @Override protected void channelRead0(ChannelHandlerContext channelHandlerContext, Reply<?> reply) throws Exception { Promise<Reply> poll; synchronized (client) { poll = queue.poll(); if (poll == null) { throw new IllegalStateException("Promise queue is empty, received reply"); } } poll.set(reply); } }); final Promise<RedisClientBase> promise = new Promise<>(); socketChannel.connect(new InetSocketAddress(host, port)).addListener(new ChannelFutureListenerPromiseAdapter<>(promise, client)); return promise; }
switch (socketType) { case JAVA_NIO: return (T) new NioSocketChannel(); case NATIVE_EPOLL: return (T) new EpollSocketChannel();
switch (socketType) { case JAVA_NIO: return (T) new NioSocketChannel(); case NATIVE_EPOLL: return (T) new EpollSocketChannel();