Example usage for io.netty.handler.logging LogLevel DEBUG

List of usage examples for io.netty.handler.logging LogLevel DEBUG

Introduction

In this page you can find the example usage for io.netty.handler.logging LogLevel DEBUG.

Prototype

LogLevel DEBUG

To view the source code for io.netty.handler.logging LogLevel DEBUG.

Click Source Link

Usage

From source file:com.hxr.javatone.nettyguide.d12.server.NettyServer.java

License:Apache License

public void bind() throws Exception {
    // ??NIO/*from  w w w  .  j av a2 s.  c om*/
    EventLoopGroup bossGroup = new NioEventLoopGroup();
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100)
            .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws IOException {
                    ch.pipeline().addLast(new NettyMessageDecoder(1024 * 1024, 4, 4));
                    ch.pipeline().addLast(new NettyMessageEncoder());
                    ch.pipeline().addLast("readTimeoutHandler", new ReadTimeoutHandler(50));
                    ch.pipeline().addLast(new LoginAuthRespHandler());
                    ch.pipeline().addLast("HeartBeatHandler", new HeartBeatRespHandler());
                }
            });

    // ???
    b.bind(NettyConstant.REMOTEIP, NettyConstant.PORT).sync().channel().closeFuture().sync().channel();
    System.out.println("Netty server start ok : " + (NettyConstant.REMOTEIP + " : " + NettyConstant.PORT));
}

From source file:com.jt.flash.proxy.handler.ProxyInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {

    ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG), new HttpServerCodec(),
            //new HttpContentCompressor(),
            new ProxyFrontendHandler(sslCtx));
}

From source file:com.jt.flash.proxy.server.ProxyServer.java

License:Apache License

public void start() {
    try {//from  w  ww  . ja  v  a2 s .c  o m
        log.info("Proxying server start at port {}", upstreamPort);
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
        ConfigService.reload(configDao.loadLastest());
        ServerBootstrap b = new ServerBootstrap();
        channel = b.group(proxyServerBossGroup, proxyServerWorkerGroup).channel(NioServerSocketChannel.class)
                .childOption(ChannelOption.AUTO_READ, false).handler(new LoggingHandler(LogLevel.DEBUG))
                .childHandler(new ProxyInitializer(sslCtx)).bind(upstreamPort).channel();
    } catch (Exception e) {
        log.warn("start proxy server fail", e);
    }
}

From source file:com.nitesh.netty.snoop.client.HttpSnoopClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline p = ch.pipeline();/*from   w ww  .ja v a2 s.  com*/

    p.addLast("log", new LoggingHandler(LogLevel.DEBUG));

    p.addLast("codec", new HttpClientCodec());

    // Remove the following line if you don't want automatic content decompression.
    p.addLast("inflater", new HttpContentDecompressor());

    // Uncomment the following line if you don't want to handle HttpChunks.
    //p.addLast("aggregator", new HttpObjectAggregator(1048576));

    p.addLast("handler", new HttpSnoopClientHandler());
}

From source file:com.nitesh.netty.snoop.server.HttpSnoopServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline p = ch.pipeline();/*  w  w  w.  j a  va  2  s  . c  o m*/

    // Uncomment the following line if you want HTTPS
    //SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine();
    //engine.setUseClientMode(false);
    //p.addLast("ssl", new SslHandler(engine));

    p.addLast("log", new LoggingHandler(LogLevel.DEBUG));
    p.addLast("decoder", new HttpRequestDecoder());
    // Uncomment the following line if you don't want to handle HttpChunks.
    //p.addLast("aggregator", new HttpObjectAggregator(1048576));
    p.addLast("encoder", new HttpResponseEncoder());
    // Remove the following line if you don't want automatic content compression.
    //p.addLast("deflater", new HttpContentCompressor());
    p.addLast("handler", new HttpSnoopServerHandler());
}

From source file:com.qc.you.socket.server.Application.java

License:Apache License

@SuppressWarnings("unchecked")
@Bean(name = "serverBootstrap")
public ServerBootstrap bootstrap() {
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup(), workerGroup()).channel(NioServerSocketChannel.class)
            .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(new ChannelInitializer<SocketChannel>() {
                @Override/*ww  w.  j  a  v a 2  s.c  o  m*/
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();
                    // Add the text line codec combination first,
                    pipeline.addLast(new DelimiterBasedFrameDecoder(1024 * 1024, Delimiters.lineDelimiter()));
                    // the encoder and decoder are static as these are sharable
                    pipeline.addLast(DECODER);
                    pipeline.addLast(ENCODER);

                    pipeline.addLast(somethingServerHandler);
                    pipeline.addLast(broadCastChannelHandler);
                }
            });
    Map<ChannelOption<?>, Object> tcpChannelOptions = tcpChannelOptions();
    Set<ChannelOption<?>> keySet = tcpChannelOptions.keySet();
    for (@SuppressWarnings("rawtypes")
    ChannelOption option : keySet) {
        b.option(option, tcpChannelOptions.get(option));
    }
    return b;
}

From source file:com.srotya.sidewinder.core.ingress.binary.NettyBinaryIngestionServer.java

License:Apache License

public void start() throws InterruptedException {
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup(4);

    ServerBootstrap bs = new ServerBootstrap();
    channel = bs.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_RCVBUF, 10485760).option(ChannelOption.SO_SNDBUF, 10485760)
            .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(new ChannelInitializer<SocketChannel>() {

                @Override//from  www  . j a v  a 2s  .  c  om
                protected void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    p.addLast(new LengthFieldBasedFrameDecoder(3000, 0, 4, 0, 4));
                    p.addLast(new SeriesDataPointDecoder());
                    p.addLast(new SeriesDataPointWriter(storageEngine));
                }

            }).bind("localhost", 9927).sync().channel();
}

From source file:com.srotya.sidewinder.core.ingress.http.NettyHTTPIngestionServer.java

License:Apache License

public void start() throws InterruptedException {
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup(4);

    ServerBootstrap bs = new ServerBootstrap();
    channel = bs.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_RCVBUF, 10485760).option(ChannelOption.SO_SNDBUF, 10485760)
            .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(new ChannelInitializer<SocketChannel>() {

                @Override//from  w w w.  ja  v a  2  s  .c  o m
                protected void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    p.addLast(new HttpRequestDecoder());
                    p.addLast(new HttpResponseEncoder());
                    p.addLast(new HTTPDataPointDecoder(storageEngine));
                }

            }).bind("localhost", 9928).sync().channel();
}

From source file:com.study.hc.net.netty.EchoServer.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Configure the server.
    // EventLoopGroup   accept NioEventLoop
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    // EventLoopGroup   I/O
    EventLoopGroup workerGroup2 = new NioEventLoopGroup(1);
    try {//from  www .ja  v a2 s  . co m
        // ??
        ServerBootstrap b = new ServerBootstrap();
        // ???reactor???
        b.group(bossGroup, workerGroup2).channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.DEBUG))
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ChannelPipeline p = ch.pipeline();
                        p.addLast(new EchoServerHandler());
                    }
                });
        // bind??
        ChannelFuture f = b.bind(PORT).sync();
        // ??
        f.channel().closeFuture().sync();
    } finally {
        // 
        bossGroup.shutdownGracefully();
        workerGroup2.shutdownGracefully();
    }
}

From source file:com.twocater.diamond.core.netty.http.HttpHandlerFactory.java

@Override
public ChannelHandlerAdapter createServerHandler() {
    return new LoggingHandler(LogLevel.DEBUG);
}