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

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

Introduction

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

Prototype

LogLevel TRACE

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

Click Source Link

Usage

From source file:de.unipassau.isl.evs.ssh.core.network.ClientHandshakeHandler.java

License:Open Source License

/**
 * Called once the TCP connection is established.
 * Configures the per-connection pipeline that is responsible for handling incoming and outgoing data.
 * After an incoming packet is decrypted, decoded and verified,
 * it will be sent to its target {@link de.unipassau.isl.evs.ssh.core.handler.MessageHandler}
 * by the {@link IncomingDispatcher}.//from   w w  w  . j  a  va 2 s. co m
 */
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
    Log.v(TAG, "channelRegistered " + ctx);
    ctx.attr(ATTR_HANDSHAKE_FINISHED).set(false);

    // Add (de-)serialization Handlers before this Handler
    ctx.pipeline().addBefore(ctx.name(), ObjectEncoder.class.getSimpleName(), new ObjectEncoder());
    ctx.pipeline().addBefore(ctx.name(), ObjectDecoder.class.getSimpleName(),
            new ObjectDecoder(ClassResolvers.weakCachingConcurrentResolver(getClass().getClassLoader())));
    ctx.pipeline().addBefore(ctx.name(), LoggingHandler.class.getSimpleName(),
            new LoggingHandler(LogLevel.TRACE));

    // Timeout Handler
    ctx.pipeline().addBefore(ctx.name(), IdleStateHandler.class.getSimpleName(),
            new IdleStateHandler(READER_IDLE_TIME, WRITER_IDLE_TIME, ALL_IDLE_TIME));
    ctx.pipeline().addBefore(ctx.name(), TimeoutHandler.class.getSimpleName(), new TimeoutHandler());

    // Add exception handler
    ctx.pipeline().addAfter(ctx.name(), PipelinePlug.class.getSimpleName(), new PipelinePlug());

    super.channelRegistered(ctx);
    Log.v(TAG, "Pipeline after register: " + ctx.pipeline());
}

From source file:de.unipassau.isl.evs.ssh.master.network.ServerHandshakeHandler.java

License:Open Source License

/**
 * Configures the per-connection pipeline that is responsible for handling incoming and outgoing data.
 * After an incoming packet is decrypted, decoded and verified,
 * it will be sent to its target {@link MessageHandler}
 * by the {@link IncomingDispatcher}./*  ww w.  j  a va  2  s.  co  m*/
 */
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
    Log.v(TAG, "channelRegistered " + ctx);
    if (container == null) {
        //Do not accept new connections after the Server has been shut down
        Log.v(TAG, "channelRegistered:closed");
        ctx.close();
        return;
    }

    // Add (de-)serialization Handlers before this Handler
    ctx.pipeline().addBefore(ctx.name(), ObjectEncoder.class.getSimpleName(), new ObjectEncoder());
    ctx.pipeline().addBefore(ctx.name(), ObjectDecoder.class.getSimpleName(),
            new ObjectDecoder(ClassResolvers.weakCachingConcurrentResolver(getClass().getClassLoader())));
    ctx.pipeline().addBefore(ctx.name(), LoggingHandler.class.getSimpleName(),
            new LoggingHandler(LogLevel.TRACE));

    // Timeout Handler
    ctx.pipeline().addBefore(ctx.name(), IdleStateHandler.class.getSimpleName(),
            new IdleStateHandler(READER_IDLE_TIME, WRITER_IDLE_TIME, ALL_IDLE_TIME));
    ctx.pipeline().addBefore(ctx.name(), TimeoutHandler.class.getSimpleName(), new TimeoutHandler());

    // Add exception handler
    ctx.pipeline().addLast(PipelinePlug.class.getSimpleName(), new PipelinePlug());

    super.channelRegistered(ctx);
    Log.v(TAG, "Pipeline after register: " + ctx.pipeline());
}

From source file:net.smert.frameworkgl.Network.java

License:Apache License

public void setLogLevelTrace() {
    this.logLevel = LogLevel.TRACE;
}

From source file:org.apache.hive.spark.client.rpc.Rpc.java

License:Apache License

private static Rpc createRpc(RpcConfiguration config, SaslHandler saslHandler, SocketChannel client,
        EventExecutorGroup egroup) throws IOException {
    LogLevel logLevel = LogLevel.TRACE;
    if (config.getRpcChannelLogLevel() != null) {
        try {//from  w w  w .j a  va  2 s . c  om
            logLevel = LogLevel.valueOf(config.getRpcChannelLogLevel());
        } catch (Exception e) {
            LOG.warn("Invalid log level {}, reverting to default.", config.getRpcChannelLogLevel());
        }
    }

    boolean logEnabled = false;
    switch (logLevel) {
    case DEBUG:
        logEnabled = LOG.isDebugEnabled();
        break;
    case ERROR:
        logEnabled = LOG.isErrorEnabled();
        break;
    case INFO:
        logEnabled = LOG.isInfoEnabled();
        break;
    case TRACE:
        logEnabled = LOG.isTraceEnabled();
        break;
    case WARN:
        logEnabled = LOG.isWarnEnabled();
        break;
    }

    if (logEnabled) {
        client.pipeline().addLast("logger", new LoggingHandler(Rpc.class, logLevel));
    }

    KryoMessageCodec kryo = new KryoMessageCodec(config.getMaxMessageSize(), MessageHeader.class,
            NullMessage.class, SaslMessage.class);
    saslHandler.setKryoMessageCodec(kryo);
    client.pipeline().addLast("codec", kryo).addLast("sasl", saslHandler);
    return new Rpc(config, client, egroup);
}

From source file:org.apache.spark.sql.hive.thriftserver.rsc.Rpc.java

License:Apache License

private static Rpc createRpc(RSCConf config, SaslHandler saslHandler, SocketChannel client,
        EventExecutorGroup egroup) throws IOException {
    LogLevel logLevel = LogLevel.TRACE;
    String logLevelStr = config.get(RSCConf.Entry.RPC_CHANNEL_LOG_LEVEL);
    if (logLevelStr != null) {
        try {/*from  w w  w. j a  v a2  s  .c  om*/
            logLevel = LogLevel.valueOf(logLevelStr);
        } catch (Exception e) {
            LOG.warn("Invalid log level {}, reverting to default.", logLevelStr);
        }
    }

    boolean logEnabled = false;
    switch (logLevel) {
    case DEBUG:
        logEnabled = LOG.isDebugEnabled();
        break;
    case ERROR:
        logEnabled = LOG.isErrorEnabled();
        break;
    case INFO:
        logEnabled = LOG.isInfoEnabled();
        break;
    case TRACE:
        logEnabled = LOG.isTraceEnabled();
        break;
    case WARN:
        logEnabled = LOG.isWarnEnabled();
        break;
    }

    if (logEnabled) {
        client.pipeline().addLast("logger", new LoggingHandler(Rpc.class, logLevel));
    }

    KryoMessageCodec kryo = new KryoMessageCodec(config.getInt(RSCConf.Entry.RPC_MAX_MESSAGE_SIZE),
            MessageHeader.class, NullMessage.class, SaslMessage.class);
    saslHandler.setKryoMessageCodec(kryo);
    client.pipeline().addLast("codec", kryo).addLast("sasl", saslHandler);
    return new Rpc(config, client, egroup);
}

From source file:org.asynchttpclient.netty.channel.ChannelManager.java

License:Open Source License

public void configureBootstraps(NettyRequestSender requestSender) {

    final AsyncHttpClientHandler httpHandler = new HttpHandler(config, this, requestSender);
    wsHandler = new WebSocketHandler(config, this, requestSender);

    final NoopHandler pinnedEntry = new NoopHandler();

    final LoggingHandler loggingHandler = new LoggingHandler(LogLevel.TRACE);

    httpBootstrap.handler(new ChannelInitializer<Channel>() {
        @Override//from   ww  w  . j a va 2  s.com
        protected void initChannel(Channel ch) throws Exception {
            ChannelPipeline pipeline = ch.pipeline()//
                    .addLast(PINNED_ENTRY, pinnedEntry)//
                    .addLast(HTTP_CLIENT_CODEC, newHttpClientCodec())//
                    .addLast(INFLATER_HANDLER, newHttpContentDecompressor())//
                    .addLast(CHUNKED_WRITER_HANDLER, new ChunkedWriteHandler())//
                    .addLast(AHC_HTTP_HANDLER, httpHandler);

            if (LOGGER.isTraceEnabled()) {
                pipeline.addAfter(PINNED_ENTRY, LOGGING_HANDLER, loggingHandler);
            }

            if (config.getHttpAdditionalChannelInitializer() != null)
                config.getHttpAdditionalChannelInitializer().initChannel(ch);
        }
    });

    wsBootstrap.handler(new ChannelInitializer<Channel>() {
        @Override
        protected void initChannel(Channel ch) throws Exception {
            ChannelPipeline pipeline = ch.pipeline()//
                    .addLast(PINNED_ENTRY, pinnedEntry)//
                    .addLast(HTTP_CLIENT_CODEC, newHttpClientCodec())//
                    .addLast(AHC_WS_HANDLER, wsHandler);

            if (LOGGER.isDebugEnabled()) {
                pipeline.addAfter(PINNED_ENTRY, LOGGING_HANDLER, loggingHandler);
            }

            if (config.getWsAdditionalChannelInitializer() != null)
                config.getWsAdditionalChannelInitializer().initChannel(ch);
        }
    });
}

From source file:org.eclipse.milo.opcua.stack.client.transport.http.OpcHttpTransport.java

License:Open Source License

private static ChannelPool createChannelPool(UaStackClientConfig config) {
    final String endpointUrl = config.getEndpoint().getEndpointUrl();

    String host = EndpointUtil.getHost(endpointUrl);
    if (host == null)
        host = "";

    int port = EndpointUtil.getPort(endpointUrl);

    LOGGER.debug("createChannelPool() host={} port={}", host, port);

    Bootstrap bootstrap = new Bootstrap().channelFactory(NioSocketChannel::new).group(config.getEventLoop())
            .remoteAddress(host, port);//w  w  w.  j a  va 2 s  . c  o m

    return new SimpleChannelPool(bootstrap, new AbstractChannelPoolHandler() {
        @Override
        public void channelCreated(Channel channel) throws Exception {
            String scheme = EndpointUtil.getScheme(endpointUrl);

            if ("https".equalsIgnoreCase(scheme) || "opc.https".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.TRACE));
            channel.pipeline().addLast(new HttpClientCodec());
            channel.pipeline().addLast(new HttpObjectAggregator(maxMessageSize));
            channel.pipeline().addLast(new OpcClientHttpCodec(config));

            LOGGER.debug("channelCreated(): " + channel);
        }

        @Override
        public void channelAcquired(Channel channel) {
            LOGGER.debug("channelAcquired(): " + channel);
        }

        @Override
        public void channelReleased(Channel channel) {
            LOGGER.debug("channelReleased(): " + channel);
        }
    });
}

From source file:org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer.java

License:Open Source License

@Override
protected void initChannel(SocketChannel channel) {
    stackServer.registerConnectedChannel(channel);

    channel.closeFuture().addListener(future -> stackServer.unregisterConnectedChannel(channel));

    channel.pipeline().addLast(RateLimitingHandler.getInstance());

    if (sslContext != null) {
        channel.pipeline().addLast(sslContext.newHandler(channel.alloc()));
    }/*  w  w w  .  j a v  a 2  s.  co m*/

    channel.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
    channel.pipeline().addLast(new HttpServerCodec());

    // TODO configure maxContentLength based on MaxRequestSize?
    channel.pipeline().addLast(new HttpObjectAggregator(Integer.MAX_VALUE));
    channel.pipeline().addLast(new OpcHttpTransportInterceptor(stackServer));
}

From source file:org.eclipse.neoscada.protocol.iec60870.client.Client.java

License:Open Source License

protected void handleInitChannel(final SocketChannel ch) {
    // add the APCI/APDU handler
    ch.pipeline().addLast(new APDUDecoder());
    ch.pipeline().addLast(new APDUEncoder());

    // add logging
    if (Boolean.getBoolean("org.eclipse.scada.protocol.iec60870.trace")) {
        ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
    }//from  w ww . j  a  v a 2 s .  co m

    final MessageChannel messageChannel = new MessageChannel(this.options, this.manager);

    // message channel
    ch.pipeline().addLast(messageChannel);

    // now add all server modules

    for (final Module module : this.modules) {
        module.initializeChannel(ch, messageChannel);
    }

    // finally add the default exception catcher

    ch.pipeline().addLast(new ChannelDuplexHandler() {
        @Override
        public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
            logger.warn("Close connection due to uncaught exception", cause);
            ctx.close();
        }

        @Override
        public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
            super.channelInactive(ctx);
            fireDisconnected(null);
        }
    });
}

From source file:org.eclipse.neoscada.protocol.iec60870.server.Server.java

License:Open Source License

protected void handleInitChannel(final SocketChannel ch) {
    // add the APCI/APDU handler

    ch.pipeline().addLast(new APDUDecoder());
    ch.pipeline().addLast(new APDUEncoder());

    // add logging

    if (Boolean.getBoolean("org.eclipse.scada.protocol.iec60870.trace")) {
        ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
    }//from w w  w.j  a v a 2s . c  o  m

    final MessageChannel messageChannel = new MessageChannel(this.options, this.manager);

    // message channel

    ch.pipeline().addLast(messageChannel);

    // now add all server modules

    for (final ServerModule module : this.modules) {
        module.initializeChannel(ch, messageChannel);
    }

    // finally add the default exception catcher

    ch.pipeline().addLast(new ChannelDuplexHandler() {
        @Override
        public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
            logger.warn("Close connection due to uncaught exception", cause);
            ctx.close();
        }
    });
}