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

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

Introduction

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

Prototype

LogLevel INFO

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

Click Source Link

Usage

From source file:org.apache.hadoop.mpich.appmaster.netty.ServerChannelInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    PMIClientCommandHandler handler = new PMIClientCommandHandler(manager, ch);
    pipeline.addLast(new LineBasedFrameDecoder(256));
    pipeline.addLast(new StringEncoder());
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new LoggingHandler(LogLevel.INFO));
    pipeline.addLast(new ClientChannelHandler(handler));
}

From source file:org.apache.kerby.kerberos.kdc.impl.NettyKdcNetwork.java

License:Apache License

private void doStart() throws Exception {
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100)
            .handler(new LoggingHandler(LogLevel.INFO)).childHandler(createChannelInitializer());

    // Start the server.
    b.bind(tcpAddress.getPort());/*from   www  . j a va  2s.c  om*/
    if (udpAddress != null) {
        startUDPServer();
    }
}

From source file:org.apache.qpid.jms.transports.netty.NettyServer.java

License:Apache License

public void start() throws Exception {

    if (started.compareAndSet(false, true)) {

        // Configure the server.
        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();

        ServerBootstrap server = new ServerBootstrap();
        server.group(bossGroup, workerGroup);
        server.channel(NioServerSocketChannel.class);
        server.option(ChannelOption.SO_BACKLOG, 100);
        server.handler(new LoggingHandler(LogLevel.INFO));
        server.childHandler(new ChannelInitializer<Channel>() {

            @Override/*from  w w  w . java  2  s  .c om*/
            public void initChannel(Channel ch) throws Exception {
                if (options instanceof TransportSslOptions) {
                    TransportSslOptions sslOptions = (TransportSslOptions) options;
                    SSLContext context = TransportSupport.createSslContext(sslOptions);
                    SSLEngine engine = TransportSupport.createSslEngine(context, sslOptions);
                    engine.setUseClientMode(false);
                    engine.setNeedClientAuth(needClientAuth);
                    sslHandler = new SslHandler(engine);
                    ch.pipeline().addLast(sslHandler);
                }

                if (webSocketServer) {
                    ch.pipeline().addLast(new HttpServerCodec());
                    ch.pipeline().addLast(new HttpObjectAggregator(65536));
                    ch.pipeline().addLast(new WebSocketServerProtocolHandler(getWebSocketPath(), "amqp", true));
                }

                ch.pipeline().addLast(new NettyServerOutboundHandler());
                ch.pipeline().addLast(new NettyServerInboundHandler());
                ch.pipeline().addLast(getServerHandler());
            }
        });

        // Start the server.
        serverChannel = server.bind(getServerPort()).sync().channel();
    }
}

From source file:org.artJava.chat.SecureChatServer.java

License:Apache License

public static void main(String[] args) throws Exception {
    //SelfSignedCertificate
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    ///*from  www  . j a  v  a  2s .  co  m*/
    SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();//
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new SecureChatServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
        //bindchannnel
        //syncfuture futurefuture
        //channel futureiochannel
        //closefuture future
        //

    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:org.artJava.upload.file.server.FileServer.java

License:Apache License

public void bind(int port) throws Exception {
    // ??NIO//  ww w . j a v a 2s .com
    EventLoopGroup bossGroup = new NioEventLoopGroup();
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) {
                        ch.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingDecoder());
                        ch.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingEncoder());
                        ch.pipeline().addLast(new FileServerHandler());
                    }
                });

        // ???
        ChannelFuture f = b.bind(port).sync();

        // ???
        f.channel().closeFuture().sync();
    } finally {
        // ?
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:org.asynchttpclient.reactivestreams.HttpStaticFileServer.java

License:Apache License

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();/*from   w  ww .ja v a2 s.c o m*/
    LOGGER.info("Open your web browser and navigate to " + ("http") + "://localhost:" + port + '/');
}

From source file:org.ballerinalang.test.util.websocket.server.WebSocketRemoteServer.java

License:Open Source License

public void run() throws InterruptedException {
    final SslContext sslCtx = null;
    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 WebSocketRemoteServerInitializer(sslCtx));

    b.bind(port).sync().channel();/*from w  w  w  .  j  av  a2 s  . c o  m*/
}

From source file:org.columbia.parikshan.proxy.NettyProxy.java

License:Apache License

public static void execute(int LOCAL_PORT, String REMOTE_HOST, int REMOTE_PORT) throws Exception {
    System.err.println("Proxying *:" + LOCAL_PORT + " to " + REMOTE_HOST + ':' + REMOTE_PORT + " ...");

    LoggingHandler l;/*from   www . j ava2s  .c  o m*/
    if (Main.debug)
        l = new LoggingHandler(LogLevel.INFO);
    else
        l = new LoggingHandler(LogLevel.DEBUG);

    // Configure the bootstrap.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).handler(l)
                .childHandler(new NettyProxyInitializer(REMOTE_HOST, REMOTE_PORT))
                .childOption(ChannelOption.AUTO_READ, false).bind(LOCAL_PORT).sync().channel().closeFuture()
                .sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:org.ebayopensource.scc.debug.DebugNettyClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline p = ch.pipeline();// w ww.j  a v a 2 s.  co  m
    p.addLast("log", new LoggingHandler(LogLevel.INFO));
    p.addLast("codec", new HttpClientCodec());
    p.addLast("aggregator", new HttpObjectAggregator(1048576));
    p.addLast("handler", new DebugClientHandler());
}

From source file:org.eclipse.milo.opcua.stack.client.transport.websocket.OpcClientWebSocketChannelInitializer.java

License:Open Source License

@Override
protected void initChannel(SocketChannel channel) throws Exception {
    String endpointUrl = config.getEndpoint().getEndpointUrl();
    String scheme = EndpointUtil.getScheme(endpointUrl);

    TransportProfile transportProfile = TransportProfile.fromUri(config.getEndpoint().getTransportProfileUri());

    String subprotocol;/*  w  ww  .  j ava2s  .c o  m*/
    if (transportProfile == TransportProfile.WSS_UASC_UABINARY) {
        subprotocol = "opcua+cp";
    } else if (transportProfile == TransportProfile.WSS_UAJSON) {
        subprotocol = "opcua+uajson";
    } else {
        throw new UaException(StatusCodes.Bad_InternalError,
                "unexpected TransportProfile: " + transportProfile);
    }

    if ("opc.wss".equalsIgnoreCase(scheme)) {
        SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE)
                .build();

        channel.pipeline().addLast(sslContext.newHandler(channel.alloc()));
    }

    int maxMessageSize = config.getMessageLimits().getMaxMessageSize();

    channel.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
    channel.pipeline().addLast(new HttpClientCodec());
    channel.pipeline().addLast(new HttpObjectAggregator(maxMessageSize));

    channel.pipeline()
            .addLast(new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(
                    new URI(endpointUrl), WebSocketVersion.V13, subprotocol, true, new DefaultHttpHeaders(),
                    config.getMessageLimits().getMaxChunkSize())));

    channel.pipeline().addLast(new WebSocketFrameAggregator(config.getMessageLimits().getMaxMessageSize()));

    // OpcClientWebSocketFrameCodec adds UascClientAcknowledgeHandler when the WS upgrade is done.
    channel.pipeline().addLast(new OpcClientWebSocketBinaryFrameCodec(config, handshake));
}