Search in sources :

Example 1 with LogLevel

use of io.netty.handler.logging.LogLevel in project hive by apache.

the class Rpc method createRpc.

private static Rpc createRpc(RpcConfiguration config, SaslHandler saslHandler, SocketChannel client, EventExecutorGroup egroup) throws IOException {
    LogLevel logLevel = LogLevel.TRACE;
    if (config.getRpcChannelLogLevel() != null) {
        try {
            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);
}
Also used : LoggingHandler(io.netty.handler.logging.LoggingHandler) LogLevel(io.netty.handler.logging.LogLevel) TimeoutException(java.util.concurrent.TimeoutException) SaslException(javax.security.sasl.SaslException) IOException(java.io.IOException)

Aggregations

LogLevel (io.netty.handler.logging.LogLevel)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 SaslException (javax.security.sasl.SaslException)1