Example usage for io.netty.util.internal.logging InternalLogLevel WARN

List of usage examples for io.netty.util.internal.logging InternalLogLevel WARN

Introduction

In this page you can find the example usage for io.netty.util.internal.logging InternalLogLevel WARN.

Prototype

InternalLogLevel WARN

To view the source code for io.netty.util.internal.logging InternalLogLevel WARN.

Click Source Link

Document

'WARN' log level.

Usage

From source file:io.lettuce.core.protocol.CommandHandler.java

License:Apache License

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {

    InternalLogLevel logLevel = InternalLogLevel.WARN;

    if (!stack.isEmpty()) {
        RedisCommand<?, ?, ?> command = stack.poll();
        if (debugEnabled) {
            logger.debug("{} Storing exception in {}", logPrefix(), command);
        }//  www .jav  a2 s.  c o m
        logLevel = InternalLogLevel.DEBUG;

        try {
            command.completeExceptionally(cause);
        } catch (Exception ex) {
            logger.warn("{} Unexpected exception during command completion exceptionally: {}", logPrefix,
                    ex.toString(), ex);
        }
    }

    if (channel == null || !channel.isActive() || !isConnected()) {

        if (debugEnabled) {
            logger.debug("{} Storing exception in connectionError", logPrefix());
        }

        logLevel = InternalLogLevel.DEBUG;
        endpoint.notifyException(cause);
    }

    if (cause instanceof IOException && logLevel.ordinal() > InternalLogLevel.INFO.ordinal()) {
        logLevel = InternalLogLevel.INFO;
        if (SUPPRESS_IO_EXCEPTION_MESSAGES.contains(cause.getMessage())) {
            logLevel = InternalLogLevel.DEBUG;
        }
    }

    logger.log(logLevel, "{} Unexpected exception during request: {}", logPrefix, cause.toString(), cause);
}

From source file:io.lettuce.core.protocol.ConnectionWatchdog.java

License:Apache License

/**
 * Reconnect to the remote address that the closed channel was connected to. This creates a new {@link ChannelPipeline} with
 * the same handler instances contained in the old channel's pipeline.
 *
 * @param attempt attempt counter//  w  w w. ja va  2s . c  om
 *
 * @throws Exception when reconnection fails.
 */
public void run(int attempt) throws Exception {

    reconnectSchedulerSync.set(false);
    reconnectScheduleTimeout = null;

    if (!isEventLoopGroupActive()) {
        logger.debug("isEventLoopGroupActive() == false");
        return;
    }

    if (!isListenOnChannelInactive()) {
        logger.debug("Skip reconnect scheduling, listener disabled");
        return;
    }

    if (isReconnectSuspended()) {
        logger.debug("Skip reconnect scheduling, reconnect is suspended");
        return;
    }

    boolean shouldLog = shouldLog();

    InternalLogLevel infoLevel = InternalLogLevel.INFO;
    InternalLogLevel warnLevel = InternalLogLevel.WARN;

    if (shouldLog) {
        lastReconnectionLogging = System.currentTimeMillis();
    } else {
        warnLevel = InternalLogLevel.DEBUG;
        infoLevel = InternalLogLevel.DEBUG;
    }

    InternalLogLevel warnLevelToUse = warnLevel;

    try {
        reconnectionListener.onReconnectAttempt(new ConnectionEvents.Reconnect(attempt));
        logger.log(infoLevel, "Reconnecting, last destination was {}", remoteAddress);

        CompletableFuture<Channel> future = reconnectionHandler.reconnect();

        future.whenComplete((c, t) -> {

            if (c != null && t == null) {
                return;
            }

            if (ReconnectionHandler.isExecutionException(t)) {
                logger.log(warnLevelToUse, "Cannot reconnect: {}", t.toString());
            } else {
                logger.log(warnLevelToUse, "Cannot reconnect: {}", t.toString(), t);
            }

            if (!isReconnectSuspended()) {
                scheduleReconnect();
            }
        });
    } catch (Exception e) {
        logger.log(warnLevel, "Cannot reconnect: {}", e.toString());
    }
}