Search in sources :

Example 1 with LogLevel

use of com.yahoo.log.LogLevel in project vespa by vespa-engine.

the class JRTConfigRequester method handleFatallyFailed.

/**
 * This handles a fatal error both in the case that the subscriber is configured and not.
 * The difference is in the delay (passed from outside) and the log level used for
 * error message.
 *
 * @param jrtReq a JRT config request
 * @param sub    a config subscription
 * @param delay  delay before sending a new request
 */
private void handleFatallyFailed(JRTClientConfigRequest jrtReq, JRTConfigSubscription<ConfigInstance> sub, long delay) {
    if (sub.getState() != ConfigSubscription.State.OPEN)
        return;
    fatalFailures++;
    // The logging depends on whether we are configured or not.
    Level logLevel = sub.getConfigState().getConfig() == null ? LogLevel.DEBUG : LogLevel.INFO;
    String logMessage = "Request for config " + jrtReq.getShortDescription() + "' failed with error code " + jrtReq.errorCode() + " (" + jrtReq.errorMessage() + "), scheduling new connect " + " in " + delay + " ms";
    log.log(logLevel, logMessage);
    scheduleNextRequest(jrtReq, sub, delay, calculateErrorTimeout());
}
Also used : Level(java.util.logging.Level) LogLevel(com.yahoo.log.LogLevel)

Example 2 with LogLevel

use of com.yahoo.log.LogLevel in project vespa by vespa-engine.

the class VdsStreamingSearcher method verifyDocId.

static boolean verifyDocId(String id, Query query, boolean skippedEarlierResult) {
    String expUserId = query.properties().getString(streamingUserid);
    String expGroupName = query.properties().getString(streamingGroupname);
    LogLevel logLevel = LogLevel.ERROR;
    if (skippedEarlierResult) {
        logLevel = LogLevel.DEBUG;
    }
    DocumentId docId;
    try {
        docId = new DocumentId(id);
    } catch (IllegalArgumentException iae) {
        log.log(logLevel, "Bad result for " + query + ": " + iae.getMessage());
        return false;
    }
    if (expUserId != null) {
        long userId;
        if (docId.getScheme().hasNumber()) {
            userId = docId.getScheme().getNumber();
        } else {
            log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.userdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
            return false;
        }
        if (new BigInteger(expUserId).longValue() != userId) {
            log.log(logLevel, "Got result with wrong user ID (expected " + expUserId + ") in document ID (" + id + ") for " + query);
            return false;
        }
    } else if (expGroupName != null) {
        String groupName;
        if (docId.getScheme().hasGroup()) {
            groupName = docId.getScheme().getGroup();
        } else {
            log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.groupdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
            return false;
        }
        if (!expGroupName.equals(groupName)) {
            log.log(logLevel, "Got result with wrong group name (expected " + expGroupName + ") in document ID (" + id + ") for " + query);
            return false;
        }
    }
    return true;
}
Also used : DocumentId(com.yahoo.document.DocumentId) BigInteger(java.math.BigInteger) IdString(com.yahoo.document.idstring.IdString) LogLevel(com.yahoo.log.LogLevel)

Example 3 with LogLevel

use of com.yahoo.log.LogLevel in project vespa by vespa-engine.

the class StateChangeHandler method handleNewReportedNodeState.

// TODO nodeListener is only used via updateNodeInfoFromReportedState -> handlePrematureCrash
// TODO this will recursively invoke proposeNewNodeState, which will presumably (i.e. hopefully) be a no-op...
public void handleNewReportedNodeState(final ClusterState currentClusterState, final NodeInfo node, final NodeState reportedState, final NodeStateOrHostInfoChangeHandler nodeListener) {
    final NodeState currentState = currentClusterState.getNodeState(node.getNode());
    final LogLevel level = (currentState.equals(reportedState) && node.getVersion() == 0) ? LogLevel.SPAM : LogLevel.DEBUG;
    if (log.isLoggable(level)) {
        log.log(level, String.format("Got nodestate reply from %s: %s (Current state is %s)", node, node.getReportedState().getTextualDifference(reportedState), currentState.toString(true)));
    }
    final long currentTime = timer.getCurrentTimeInMillis();
    if (reportedState.getState().equals(State.DOWN)) {
        node.setTimeOfFirstFailingConnectionAttempt(currentTime);
    }
    // *** LOGGING ONLY
    if (!reportedState.similarTo(node.getReportedState())) {
        if (reportedState.getState().equals(State.DOWN)) {
            eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(node, "Failed to get node state: " + reportedState.toString(true), NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
        } else {
            eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(node, "Now reporting state " + reportedState.toString(true), NodeEvent.Type.REPORTED, currentTime), LogLevel.DEBUG);
        }
    }
    if (reportedState.equals(node.getReportedState()) && !reportedState.getState().equals(State.INITIALIZING)) {
        return;
    }
    updateNodeInfoFromReportedState(node, currentState, reportedState, nodeListener);
    if (reportedState.getMinUsedBits() != currentState.getMinUsedBits()) {
        final int oldCount = currentState.getMinUsedBits();
        final int newCount = reportedState.getMinUsedBits();
        log.log(LogLevel.DEBUG, String.format("Altering node state to reflect that min distribution bit count has changed from %d to %d", oldCount, newCount));
        eventLog.add(NodeEvent.forBaseline(node, String.format("Altered min distribution bit count from %d to %d", oldCount, newCount), NodeEvent.Type.CURRENT, currentTime), isMaster);
    } else if (log.isLoggable(LogLevel.DEBUG)) {
        log.log(LogLevel.DEBUG, String.format("Not altering state of %s in cluster state because new state is too similar: %s", node, currentState.getTextualDifference(reportedState)));
    }
    stateMayHaveChanged = true;
}
Also used : LogLevel(com.yahoo.log.LogLevel)

Example 4 with LogLevel

use of com.yahoo.log.LogLevel in project vespa by vespa-engine.

the class GetConfigProcessor method respond.

private void respond(JRTServerConfigRequest request) {
    final Request req = request.getRequest();
    if (req.isError()) {
        Level logLevel = (req.errorCode() == ErrorCode.APPLICATION_NOT_LOADED) ? LogLevel.DEBUG : LogLevel.INFO;
        log.log(logLevel, logPre + req.errorMessage());
    }
    rpcServer.respond(request);
}
Also used : Request(com.yahoo.jrt.Request) Level(java.util.logging.Level) LogLevel(com.yahoo.log.LogLevel)

Example 5 with LogLevel

use of com.yahoo.log.LogLevel in project vespa by vespa-engine.

the class LogMetricsHandler method doHandle.

public boolean doHandle(LogMessage message) {
    String host = message.getHost();
    Level logLevel = message.getLevel();
    boolean found = false;
    if (logMetrics.size() > 0) {
        LevelCount count;
        // exists an element with the same host and level.
        for (int i = 0; i < logMetrics.size(); i++) {
            count = logMetrics.get(i);
            if (count.getHost().equals(host) && count.getLevel().getName().equals(logLevel.getName())) {
                count.addCount(1);
                found = true;
                break;
            }
        }
    }
    // to the list.
    if (!found) {
        for (Level level : Arrays.asList(levels)) {
            LevelCount levelCount;
            if (level.getName().equals(logLevel.getName())) {
                levelCount = new LevelCount(host, level, 1);
            } else {
                levelCount = new LevelCount(host, level, 0);
            }
            logMetrics.add(levelCount);
        }
    }
    return true;
}
Also used : LogLevel(com.yahoo.log.LogLevel) Level(java.util.logging.Level)

Aggregations

LogLevel (com.yahoo.log.LogLevel)5 Level (java.util.logging.Level)3 DocumentId (com.yahoo.document.DocumentId)1 IdString (com.yahoo.document.idstring.IdString)1 Request (com.yahoo.jrt.Request)1 BigInteger (java.math.BigInteger)1