@Override public ChannelHandler call() { return new LoggingHandler(name, wireLoggingLevel); } });
protected void initChannel(ChannelPipeline pipeline) { if (logEnabled) { pipeline.addLast("logging", new LoggingHandler()); } if (sslHelper.isSSL()) { // only add ChunkedWriteHandler when SSL is enabled otherwise it is not needed as FileRegion is used. pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); // For large file / sendfile support } if (idleTimeout > 0) { pipeline.addLast("idle", new IdleStateHandler(0, 0, idleTimeout, idleTimeoutUnit)); } }
private void groupsNio(final ServerBootstrap bootstrap) { workerGroup = new NioEventLoopGroup(); bootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 128) .option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024)) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.TCP_NODELAY, true) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ServerHandlerInitializer()); } }
private void groupsNio(final ServerBootstrap bootstrap) { workerGroup = new NioEventLoopGroup(); bootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 128) .option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024)) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.TCP_NODELAY, true) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ServerHandlerInitializer()); } }
private void groupsEpoll(final ServerBootstrap bootstrap) { workerGroup = new EpollEventLoopGroup(); bootstrap.group(bossGroup, workerGroup) .channel(EpollServerSocketChannel.class) .option(EpollChannelOption.SO_BACKLOG, 128) .option(EpollChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024)) .option(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(EpollChannelOption.TCP_NODELAY, true) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ServerHandlerInitializer()); }
private void groupsEpoll(final ServerBootstrap bootstrap) { workerGroup = new EpollEventLoopGroup(); bootstrap.group(bossGroup, workerGroup) .channel(EpollServerSocketChannel.class) .option(EpollChannelOption.SO_BACKLOG, 128) .option(EpollChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024)) .option(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(EpollChannelOption.TCP_NODELAY, true) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ServerHandlerInitializer()); }
@Override public DuplexChannel getChannel() { DuplexChannel channel = connect(); channel.pipeline().addLast(new LoggingHandler(getClass())); return channel; } };
private void groupsEpoll(final ServerBootstrap bootstrap, final int workThreads) { workerGroup = new EpollEventLoopGroup(workThreads); bootstrap.group(bossGroup, workerGroup) .channel(EpollServerSocketChannel.class) .option(EpollChannelOption.TCP_CORK, true) .option(EpollChannelOption.SO_KEEPALIVE, true) .option(EpollChannelOption.SO_BACKLOG, 100) .option(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(nettyServerHandlerInitializer); }
protected void initChannel(ChannelPipeline pipeline) { if (logEnabled) { pipeline.addLast("logging", new LoggingHandler()); } if (sslHelper.isSSL()) { // only add ChunkedWriteHandler when SSL is enabled otherwise it is not needed as FileRegion is used. pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); // For large file / sendfile support } if (options.getIdleTimeout() > 0) { pipeline.addLast("idle", new IdleStateHandler(0, 0, options.getIdleTimeout(), options.getIdleTimeoutUnit())); } }
@Override public void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (log.isDebugEnabled()) { pipeline.addLast(new LoggingHandler()); } if (sslContext != null) { pipeline.addLast("ssl", sslContext.newHandler(channel.alloc())); } pipeline.addLast("http-codec", new HttpClientCodec()); for (ChannelHandler handler : handlers) { pipeline.addLast(handler); } pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); } }
@VisibleForTesting static Rpc createEmbedded(RpcDispatcher dispatcher) { EmbeddedChannel c = new EmbeddedChannel( new LoggingHandler(Rpc.class), new KryoMessageCodec(0, MessageHeader.class, NullMessage.class), dispatcher); Rpc rpc = new Rpc(new RpcConfiguration(Collections.<String, String>emptyMap()), c, ImmediateEventExecutor.INSTANCE); rpc.dispatcher = dispatcher; return rpc; }
@Override protected void initChannel(final KQueueDomainSocketChannel channel) throws Exception { channel.pipeline().addLast(new LoggingHandler(getClass())); channel.pipeline().addLast(new HttpClientCodec()); channel.pipeline().addLast(new HttpContentDecompressor()); } });
public static void start(int port) throws Exception { bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new HttpStaticFileServerInitializer()); b.bind(port).sync().channel(); LOGGER.info("Open your web browser and navigate to " + ("http") + "://localhost:" + port + '/'); }
public DefaultOriginChannelInitializer(ConnectionPoolConfig connPoolConfig, Registry spectatorRegistry) { this.connectionPoolConfig = connPoolConfig; final String originName = connectionPoolConfig.getOriginName(); this.connectionPoolHandler = new ConnectionPoolHandler(originName); this.httpMetricsHandler = new HttpMetricsChannelHandler(spectatorRegistry, "client", originName); this.nettyLogger = new LoggingHandler("zuul.origin.nettylog." + originName, LogLevel.INFO); this.sslContext = getClientSslContext(spectatorRegistry); }
private void applyHttp1xConnectionOptions(ChannelPipeline pipeline) { if (options.getIdleTimeout() > 0) { pipeline.addLast("idle", new IdleStateHandler(0, 0, options.getIdleTimeout(), options.getIdleTimeoutUnit())); } if (options.getLogActivity()) { pipeline.addLast("logging", new LoggingHandler()); } pipeline.addLast("codec", new HttpClientCodec( options.getMaxInitialLineLength(), options.getMaxHeaderSize(), options.getMaxChunkSize(), false, false, options.getDecoderInitialBufferSize())); if (options.isTryUseCompression()) { pipeline.addLast("inflater", new HttpContentDecompressor(true)); } }
@Override public void evaluate() throws Throwable { final EmbeddedChannel channel = new EmbeddedChannel(new LoggingHandler()); @SuppressWarnings("unchecked") ChannelOperations<ByteBuf> channelOperations = Mockito.mock(ChannelOperations.class); ConnRule.this.channelOperations = channelOperations; connection = ConnectionImpl.create(channel, ConnRule.this.channelOperations); base.evaluate(); } };
@Override public void evaluate() throws Throwable { channel = new EmbeddedChannel(new LoggingHandler()); subscriber = Subscribers.empty(); producer = new ReadProducer<>(subscriber, channel); base.evaluate(); } };
public DefaultOriginChannelInitializer(ConnectionPoolConfig connPoolConfig, Registry spectatorRegistry) { this.connectionPoolConfig = connPoolConfig; final String originName = connectionPoolConfig.getOriginName(); this.connectionPoolHandler = new ConnectionPoolHandler(originName); this.httpMetricsHandler = new HttpMetricsChannelHandler(spectatorRegistry, "client", originName); this.nettyLogger = new LoggingHandler("zuul.origin.nettylog." + originName, LogLevel.INFO); this.sslContext = getClientSslContext(spectatorRegistry); }
protected void init(int defaultRequestN) { this.defaultRequestN = defaultRequestN; channel = new EmbeddedChannel(new LoggingHandler()); channelPromise = channel.newPromise(); ChannelHandlerContext ctx = channel.pipeline().firstContext(); subscriber = new WriteStreamSubscriber(ctx, channelPromise, defaultRequestN().intValue()); mockProducer = new MockProducer(); }
private DatagramSocketImpl(VertxInternal vertx, DatagramSocketOptions options) { Transport transport = vertx.transport(); DatagramChannel channel = transport.datagramChannel(options.isIpV6() ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4); transport.configure(channel, new DatagramSocketOptions(options)); ContextInternal context = vertx.getOrCreateContext(); channel.config().setOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); MaxMessagesRecvByteBufAllocator bufAllocator = channel.config().getRecvByteBufAllocator(); bufAllocator.maxMessagesPerRead(1); context.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createDatagramSocketMetrics(options) : null; this.channel = channel; this.context = context; this.demand = Long.MAX_VALUE; }