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.elasticsearch.hadoop.integration.rest.ssl.BasicSSLServer.java

License:Apache License

public void start() throws Exception {
    File cert = Paths.get(getClass().getResource("/ssl/server.pem").toURI()).toFile();
    File keyStore = Paths.get(getClass().getResource("/ssl/server.key").toURI()).toFile();

    SslContext sslCtx = SslContext.newServerContext(cert, keyStore);

    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();

    server = new ServerBootstrap();
    server.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(new BasicSSLServerInitializer(sslCtx));

    server.bind(port).sync().channel().closeFuture();
}

From source file:org.fiware.kiara.netty.NettyTransportFactory.java

License:Open Source License

public void startServer(NettyServerTransport serverTransport, TransportConnectionListener listener)
        throws InterruptedException {
    if (serverTransport == null) {
        throw new NullPointerException("serverTransport");
    }/*from   w ww. ja  v a 2 s  .  c  o  m*/
    if (listener == null) {
        throw new NullPointerException("listener");
    }

    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(createServerChildHandler(serverTransport.getPath(), listener));

    final Channel channel = b.bind(serverTransport.getLocalSocketAddress()).sync().channel();
    serverTransport.setChannel(channel);
    serverTransport.setListener(listener);
}

From source file:org.ftccommunity.ftcxtensible.networking.http.HttpHelloWorldServer.java

License:Apache License

public void run() {
    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {//from w  w  w  . j a  v a2  s .c o m
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.option(ChannelOption.SO_BACKLOG, 1024);
            b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    //.childHandler(new HttpHelloWorldServerInitializer(sslCtx, main));
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        /**
                         * This method will be called once the {@link Channel} was registered. After the method returns this instance
                         * will be removed from the {@link ChannelPipeline} of the {@link Channel}.
                         *
                         * @param ch the {@link Channel} which was registered.
                         * @throws Exception is thrown if an error occurs. In that case the {@link Channel} will be closed.
                         */
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new HttpServerCodec(),
                                    new HttpHelloWorldServerHandler(context));
                        }
                    });

            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();
        }
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    }
    Log.i("NET_OP_MODE::", "Op Mode Server is shuting down.");
}

From source file:org.ftccommunity.ftcxtensible.networking.http.RobotHttpServer.java

License:Open Source License

/**
 * The server thread implementation. This loads the Netty server and runs as the Netty server.
 *//* ww  w.  ja va  2 s . com*/
public void run() {
    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.option(ChannelOption.SO_BACKLOG, 1024);
            b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    //.childHandler(new HttpHelloWorldServerInitializer(sslCtx, main));
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        /**
                         * This method will be called once the {@link Channel} was registered. After the method returns this instance
                         * will be removed from the {@link ChannelPipeline} of the {@link Channel}.
                         *
                         * @param ch the {@link Channel} which was registered.
                         * @throws Exception is thrown if an error occurs. In that case the {@link Channel} will be closed.
                         */
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new HttpServerCodec(),
                                    new org.ftccommunity.ftcxtensible.networking.http.RobotHttpServerHandler(
                                            context));
                        }
                    });

            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();
        }
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    }
    Log.i("NET_OP_MODE::", "OpMode Server is shutting down.");
}

From source file:org.ftccommunity.services.DevConsole.java

License:Apache License

/**
 * Start the service.//from ww  w .  j av  a  2s . com
 */
@Override
protected void startUp() throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }

    serverBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new TelnetServerInitializer(sslCtx));
    mainThread = Thread.currentThread();
}

From source file:org.glowroot.agent.plugin.netty.Http2Server.java

License:Apache License

Http2Server(int port, boolean supportHttp1) throws InterruptedException {
    group = new NioEventLoopGroup();
    ServerBootstrap b = new ServerBootstrap();
    b.option(ChannelOption.SO_BACKLOG, 1024);
    b.group(group).channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(//from w  w  w.  j av a  2s .co  m
                    supportHttp1 ? new Http2ServerWithHttp1SupportInitializer() : new Http2ServerInitializer());
    channel = b.bind(port).sync().channel();
}

From source file:org.glowroot.agent.plugin.netty.HttpServer.java

License:Apache License

HttpServer(int port) throws InterruptedException {
    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 HttpServerInitializer());
    channel = b.bind(port).sync().channel();
}

From source file:org.graylog2.inputs.transports.UdpTransportTest.java

License:Open Source License

private UdpTransport launchTransportForBootStrapTest(final ChannelInboundHandler channelHandler)
        throws MisfireException {
    final UdpTransport transport = new UdpTransport(CONFIGURATION, eventLoopGroupFactory,
            nettyTransportConfiguration, throughputCounter, new LocalMetricRegistry()) {
        @Override/*from  ww  w. ja v  a 2 s. co  m*/
        protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getChannelHandlers(
                MessageInput input) {
            final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
            handlers.put("logging", () -> new LoggingHandler(LogLevel.INFO));
            handlers.put("counter", () -> channelHandler);
            handlers.putAll(super.getChannelHandlers(input));
            return handlers;
        }
    };

    final MessageInput messageInput = mock(MessageInput.class);
    when(messageInput.getId()).thenReturn("TEST");
    when(messageInput.getName()).thenReturn("TEST");

    transport.launch(messageInput);

    return transport;
}

From source file:org.greencheek.caching.herdcache.memcached.elasticacheconfig.server.StringServer.java

License:Apache License

/**
 * Override to set up your specific external resource.
 *
 * @throws if setup fails (which will disable {@code after}
 *//*  w w  w  .j a  va  2  s  .com*/
public void before(final String[] message, final TimeUnit delayUnit, final long delay,
        boolean sendAllMessages) {
    final ServerSocket socket = findFreePort();

    final ChannelHandler sharedHandler = new StringBasedServerHandler(message, delayUnit, delay,
            sendAllMessages);
    // do nothing
    try {
        final ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_SNDBUF, 100)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ChannelPipeline p = ch.pipeline();

                        p.addLast(new ConfigGetClusterDecoder());
                        p.addLast(new LoggingHandler(LogLevel.INFO));
                        p.addLast(sharedHandler);
                    }
                });

        // Start the server.
        if (startDelay > 0) {
            port = getPortNoClose(socket);
            workerGroup.schedule(new Runnable() {
                @Override
                public void run() {
                    try {
                        port = getPort(socket);
                        b.bind(port).sync();
                        outputStartedMessage();
                    } catch (InterruptedException e) {

                    }
                }
            }, startDelay, startDelayUnit);
        } else {
            port = getPort(socket);
            try {
                b.bind(port).sync();
                outputStartedMessage();
            } catch (InterruptedException e) {
            }
        }

    } finally {

    }
}

From source file:org.greencheek.dns.server.HttpHelloWorldServer.java

License:Apache License

public HttpHelloWorldServer(InetAddress address, int port) {
    // Configure the server.
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    try {//from  www . ja  va 2 s  . co m
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new HttpHelloWorldServerInitializer(address));

        Channel ch = b.bind(address, port).sync().channel();

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

    } catch (Exception e) {

    }

}