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:com.lxd.server.AdamServer.java

License:Open Source License

private boolean netStart(int prot) {
    ///< ?/* w  ww. j  av  a2s. c  o m*/
    EventLoopGroup listenGroup = new NioEventLoopGroup(1);
    ///< 
    EventLoopGroup workerGroup = new NioEventLoopGroup();

    try {
        ServerBootstrap bootstrap = new ServerBootstrap();
        ///< ??
        bootstrap.group(listenGroup, workerGroup).channel(NioServerSocketChannel.class)
                ///< , ?? INFO
                .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ServerInitalizer());

        ///< ?
        try {
            bootstrap.bind(prot).sync().channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
            return false;
        }
    } finally {
        ///< 
        try {
            listenGroup.shutdownGracefully().sync();
            workerGroup.shutdownGracefully().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
            return false;
        }
    }

    return true;
}

From source file:com.lxz.talk.websocketx.server.WebSocketServer.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {/*  www.  j  a v a  2 s . com*/
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    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 WebSocketServerInitializer(sslCtx));

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

        System.err.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:"
                + PORT + '/');

        ch.closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:com.mapple.http.HttpHelloWorldServer.java

License:Apache License

public static void main(String[] args) throws Exception {

    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {//from ww  w. j a  v a 2s  . com
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 32);
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new HttpHelloWorldServerInitializer());

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

        System.err.println("Open your web browser and navigate to " + "http://127.0.0.1:" + PORT + '/');

        ch.closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}

From source file:com.mapr.franz.netty.FranzClient.java

License:Apache License

public void run() throws Exception {
    // Configure the client.
    Bootstrap b = new Bootstrap();
    try {//  w  w  w.j  a v  a2  s .  co  m
        b.group(new NioEventLoopGroup()).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true)
                .remoteAddress(new InetSocketAddress(host, port))
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO),
                                new FranzClientHandler(firstMessageSize));
                    }
                });

        // Start the client.
        ChannelFuture f = b.connect().sync();

        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        b.shutdown();
    }
}

From source file:com.mapr.franz.netty.FranzServer.java

License:Apache License

public void run() throws Exception {
    // Configure the server.
    ServerBootstrap b = new ServerBootstrap();
    try {/*from   w ww . ja va  2  s . c  om*/
        b.group(new NioEventLoopGroup(), new NioEventLoopGroup()).channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100).localAddress(new InetSocketAddress(port))
                .childOption(ChannelOption.TCP_NODELAY, true).handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new FranzServerHandler());
                    }
                });

        // Start the server.
        ChannelFuture f = b.bind().sync();

        // Wait until the server socket is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down all event loops to terminate all threads.
        b.shutdown();
    }
}

From source file:com.mastfrog.scamper.ChannelConfigurer.java

License:Open Source License

/**
 * Initialize a server sctp channel/*  ww w  .  ja va  2 s . c  o  m*/
 *
 * @param b The bootstrap
 * @return The bootstrap
 */
protected ServerBootstrap init(ServerBootstrap b) {
    b = b.group(group, worker).channel(NioSctpServerChannel.class).option(ChannelOption.SO_BACKLOG, 1000)
            .option(ChannelOption.ALLOCATOR, alloc).handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(init);
    return b;
}

From source file:com.mastfrog.scamper.ChannelConfigurer.java

License:Open Source License

/**
 * Initialize a client sctp channel// w  ww .jav a 2 s .co m
 *
 * @param b The bootstrap
 * @return The bootstrap
 */
protected Bootstrap init(Bootstrap b) {
    b = b.group(group).channel(NioSctpChannel.class).option(SctpChannelOption.SCTP_NODELAY, true)
            .option(ChannelOption.ALLOCATOR, alloc).handler(new LoggingHandler(LogLevel.INFO)).handler(init);
    return b;
}

From source file:com.mastfrog.scamper.SctpClient.java

License:Open Source License

/**
 * Start the client, returning a ChannelFuture which can be waited on to
 * keep the client running (the returned future is the client SCTP socket's
 * channel's <code>closeFuture()</code> - call its <code>sync()</code>
 * method to block the current thread until the connection is closed.
 *
 * @return The close future for this client's connection
 * @throws InterruptedException if the connect process is interrupted
 *//*  w  w  w.java  2s. com*/
public ChannelFuture start() throws InterruptedException {
    // Configure the client.
    Bootstrap b = new Bootstrap();

    configurer.init(b).handler(new LoggingHandler(LogLevel.INFO));

    logger.log(Level.INFO, "Start for {0} on {1}", new Object[] { host, port });
    // Start the client.
    ChannelFuture f = b.connect(host, port);
    if (logger.isLoggable(Level.FINE)) {
        f.addListener(new ChannelFutureListener() {

            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                logger.log(Level.FINE, "Connect to {0}:{1}", new Object[] { host, port });
            }

        });
    }
    f.sync();
    // Caller can until the connection is closed.
    return f.channel().closeFuture();
}

From source file:com.mastfrog.scamper.SctpServer.java

License:Open Source License

public ChannelFuture start(AtomicReference<ChannelFuture> connectFutureReceiver) throws InterruptedException {
    // Configure the server.
    ServerBootstrap b = new ServerBootstrap();
    config.init(b);//  w w w.  j  a  va  2  s. c o m
    b.handler(new LoggingHandler(LogLevel.INFO));

    logger.log(Level.FINE, "Start server on {0}", port);
    // Start the server.
    ChannelFuture f = b.bind(port);
    if (logger.isLoggable(Level.FINE)) {
        f.addListener(new ChannelFutureListener() {

            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                logger.log(Level.FINE, "Listening for connections on {0}", port);
            }

        });
    }
    f.sync();
    logger.log(Level.FINER, "Thread proceeding", Thread.currentThread());
    // For tests and things that need to delay execution until a connection
    // has been opened
    if (connectFutureReceiver != null) {
        connectFutureReceiver.set(f);
    }
    synchronized (this) {
        return future = f.channel().closeFuture();
    }
}

From source file:com.mattrjacobs.hystrix.client.rxnetty.ExampleClient.java

License:Apache License

public ExampleClient(String host, int port) {
    System.out.println("Creating HTTP Client on : " + host + " : " + port);
    httpClient = RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port).enableWireLogging(LogLevel.INFO)
            .build();//from   w  ww.j  ava2s. c o  m
}