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:io.reactivex.netty.RxNetty.java

License:Apache License

public static <I, O> ServerBuilder<I, O> newTcpServerBuilder(int port,
        ConnectionHandler<I, O> connectionHandler) {
    ServerBuilder<I, O> builder = new ServerBuilder<I, O>(port, connectionHandler)
            .enableWireLogging(LogLevel.DEBUG);
    if (null != metricEventsListenerFactory) {
        builder.withMetricEventsListenerFactory(metricEventsListenerFactory);
    }//  w w  w  .j  a  v a 2s.c  om
    return builder;
}

From source file:io.reactivex.netty.RxNetty.java

License:Apache License

public static <I, O> ClientBuilder<I, O> newTcpClientBuilder(String host, int port) {
    ClientBuilder<I, O> builder = new ClientBuilder<I, O>(host, port).enableWireLogging(LogLevel.DEBUG);
    if (null != metricEventsListenerFactory) {
        builder.withMetricEventsListenerFactory(metricEventsListenerFactory);
    }//from   w  w w. j  a v a2s. co  m
    return builder;
}

From source file:io.reactivex.netty.RxNetty.java

License:Apache License

public static <I, O> HttpServerBuilder<I, O> newHttpServerBuilder(int port,
        RequestHandler<I, O> requestHandler) {
    HttpServerBuilder<I, O> builder = new HttpServerBuilder<I, O>(port, requestHandler)
            .enableWireLogging(LogLevel.DEBUG);
    if (null != metricEventsListenerFactory) {
        builder.withMetricEventsListenerFactory(metricEventsListenerFactory);
    }//from   www  .  j  a va 2 s .c  o m
    return builder;
}

From source file:io.reactivex.netty.RxNetty.java

License:Apache License

public static <I, O> HttpClientBuilder<I, O> newHttpClientBuilder(String host, int port) {
    HttpClientBuilder<I, O> builder = new HttpClientBuilder<I, O>(host, port)
            .withMaxConnections(DEFAULT_MAX_CONNECTIONS).enableWireLogging(LogLevel.DEBUG);
    if (null != metricEventsListenerFactory) {
        builder.withMetricEventsListenerFactory(metricEventsListenerFactory);
    }//from  w ww  .j  a  v  a  2s.c  om
    return builder;
}

From source file:io.vertx.core.http.impl.VertxHttp2ConnectionHandlerBuilder.java

License:Open Source License

@Override
protected VertxHttp2ConnectionHandler<C> build() {
    if (initialSettings != null) {
        HttpUtils.fromVertxInitialSettings(isServer(), initialSettings, initialSettings());
    }/*from  w w  w.ja  va2  s.com*/
    if (logEnabled) {
        frameLogger(new Http2FrameLogger(LogLevel.DEBUG));
    }
    return super.build();
}

From source file:malcolm.HttpProxyBackendInitializer.java

License:Open Source License

@Override
public void initChannel(final SocketChannel ch) {
    ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG)).addLast(new HttpClientCodec())
            .addLast(new HttpContentDecompressor()).addLast(new HttpProxyBackendHandler(frontendChannel));
}

From source file:malcolm.HttpProxyFrontendInitializer.java

License:Open Source License

@Override
public void initChannel(final SocketChannel ch) {
    ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG)).addLast("decoder", new HttpRequestDecoder())
            .addLast("encoder", new HttpResponseEncoder()).addLast("deflater", new HttpContentCompressor())
            .addLast("proxy", new HttpProxyFrontendHandler());
}

From source file:malcolm.HttpProxyServer.java

License:Open Source License

public void start() throws Exception {
    final EventLoopGroup bossGroup = new NioEventLoopGroup();
    final EventLoopGroup workerGroup = new NioEventLoopGroup();
    final ChannelFuture channelFuture = new ServerBootstrap().group(bossGroup, workerGroup)
            .channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.DEBUG))
            .childHandler(new HttpProxyFrontendInitializer()).bind(port);
    try {/*from   ww  w . j  av a 2 s  .c o  m*/
        channelFuture.sync().channel().closeFuture().sync();
    } finally {
        workerGroup.shutdownGracefully();
        bossGroup.shutdownGracefully();
    }
}

From source file:me.netty.http.HttpServer.java

License:Apache License

public void start() throws Exception {
    //?//from  w  w  w  .j  av  a  2 s.com
    serverContext.initContext();

    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).sslProvider(provider)
                /* NOTE: the cipher filter may not include all ciphers required by the HTTP/2 specification.
                 * Please refer to the HTTP/2 specification for cipher requirements. */
                .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                .applicationProtocolConfig(new ApplicationProtocolConfig(Protocol.ALPN,
                        // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                        SelectorFailureBehavior.NO_ADVERTISE,
                        // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                        SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2,
                        ApplicationProtocolNames.HTTP_1_1))
                .build();
    } else {
        sslCtx = null;
    }
    // Configure the http2Orhttp.

    //CPU??workwork?
    // ?????
    int threads = Runtime.getRuntime().availableProcessors() * 2;

    EventLoopGroup bossGroup = new NioEventLoopGroup(threads);
    EventLoopGroup workerGroup = new NioEventLoopGroup(threads);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .handler(new LoggingHandler(LogLevel.DEBUG)).childHandler(new Http2ServerInitializer(sslCtx));

        Channel ch = b.bind(PORT).sync().channel();

        logger.info("Open your HTTP/2-enabled web browser and navigate to " + (SSL ? "https" : "http")
                + "://127.0.0.1:" + PORT + '/');

        ch.closeFuture().sync().addListener(new GenericFutureListener<Future<? super Void>>() {
            public void operationComplete(Future<? super Void> future) throws Exception {
                logger.info("service has shutdown");
            }
        });
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }

}

From source file:net.anyflow.menton.http.HttpClient.java

License:Apache License

/**
 * request./*  www. j a  v  a  2  s  .com*/
 * 
 * @param receiver
 * @return if receiver is not null the request processed successfully,
 *         returns HttpResponse instance, otherwise null.
 */
private HttpResponse request(final MessageReceiver receiver) {
    httpRequest().normalize();
    setDefaultHeaders(httpRequest());

    if (logger.isDebugEnabled()) {
        logger.debug(httpRequest().toString());
    }

    final HttpClientHandler clientHandler = new HttpClientHandler(receiver, httpRequest);

    final EventLoopGroup group = new NioEventLoopGroup(1, new DefaultThreadFactory("client"));
    bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
        @Override
        protected void initChannel(SocketChannel ch) throws Exception {

            if ("true".equalsIgnoreCase(Settings.SELF.getProperty("menton.logging.writelogOfNettyLogger"))) {
                ch.pipeline().addLast("log", new LoggingHandler("menton/server", LogLevel.DEBUG));
            }

            if ("https".equalsIgnoreCase(httpRequest().uriObject().getScheme())) {
                SslContext sslCtx = SslContextBuilder.forClient().trustManager(trustManagerFactory).build();

                ch.pipeline().addLast(sslCtx.newHandler(ch.alloc(), httpRequest().uriObject().getHost(),
                        httpRequest().uriObject().getPort()));
            }

            ch.pipeline().addLast("codec", new HttpClientCodec());
            ch.pipeline().addLast("inflater", new HttpContentDecompressor());
            ch.pipeline().addLast("chunkAggregator", new HttpObjectAggregator(1048576));
            ch.pipeline().addLast("handler", clientHandler);
        }
    });

    try {
        Channel channel = bootstrap
                .connect(httpRequest().uriObject().getHost(), httpRequest().uriObject().getPort()).sync()
                .channel();
        channel.writeAndFlush(httpRequest);

        if (receiver == null) {
            channel.closeFuture().sync();
            group.shutdownGracefully();

            return clientHandler.httpResponse();
        } else {
            channel.closeFuture().addListener(new ChannelFutureListener() {

                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    group.shutdownGracefully();
                }
            });

            return null;
        }
    } catch (Exception e) {
        group.shutdownGracefully();
        logger.error(e.getMessage(), e);

        return null;
    }

}