diff options
author | Harald Musum <musum@yahooinc.com> | 2021-11-24 13:42:04 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2021-11-24 13:42:04 +0100 |
commit | a5997c310543f092daad5cf03f74e502b2d83e47 (patch) | |
tree | b13db21dacea27e2020e943986162591f1e5e413 /config | |
parent | 223532e4a1ecc531047f6eefee3bb563a48ecbe8 (diff) |
Adust when we log warnings a bit to avoid noise
Diffstat (limited to 'config')
-rw-r--r-- | config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java index 4c1d7b39755..8383bc33b1d 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java @@ -53,8 +53,9 @@ public class JRTConfigRequester implements RequestWaiter { private final ConnectionPool connectionPool; private final ConfigSourceSet configSourceSet; - private Instant noApplicationWarningLogged = Instant.MIN; + private Instant timeForLastLogWarning; private int failures = 0; + private boolean closed = false; /** * Returns a new requester @@ -68,6 +69,8 @@ public class JRTConfigRequester implements RequestWaiter { this.scheduler = scheduler; this.connectionPool = connectionPool; this.timingValues = timingValues; + // Adjust so that we wait 1 second with logging warning in case there are some errors just when starting up + timeForLastLogWarning = Instant.now().minus(delayBetweenWarnings.plus(Duration.ofSeconds(1))); } /** @@ -145,12 +148,7 @@ public class JRTConfigRequester implements RequestWaiter { break; case ErrorCode.APPLICATION_NOT_LOADED: case ErrorCode.UNKNOWN_VESPA_VERSION: - if (noApplicationWarningLogged.isBefore(Instant.now().minus(delayBetweenWarnings))) { - log.log(WARNING, "Request callback failed: " + ErrorCode.getName(jrtReq.errorCode()) + - ". Connection spec: " + connection.getAddress() + - ", error message: " + jrtReq.errorMessage()); - noApplicationWarningLogged = Instant.now(); - } + logWarning(jrtReq, connection); break; default: log.log(WARNING, "Request callback failed. Req: " + jrtReq + "\nSpec: " + connection.getAddress() + @@ -159,6 +157,15 @@ public class JRTConfigRequester implements RequestWaiter { } } + private void logWarning(JRTClientConfigRequest jrtReq, Connection connection) { + if ( ! closed && timeForLastLogWarning.isBefore(Instant.now().minus(delayBetweenWarnings))) { + log.log(WARNING, "Request callback failed: " + ErrorCode.getName(jrtReq.errorCode()) + + ". Connection spec: " + connection.getAddress() + + ", error message: " + jrtReq.errorMessage()); + timeForLastLogWarning = Instant.now(); + } + } + private void handleFailedRequest(JRTClientConfigRequest jrtReq, JRTConfigSubscription<ConfigInstance> sub, Connection connection) { logError(jrtReq, connection); @@ -190,7 +197,6 @@ public class JRTConfigRequester implements RequestWaiter { private void handleOKRequest(JRTClientConfigRequest jrtReq, JRTConfigSubscription<ConfigInstance> sub) { failures = 0; - noApplicationWarningLogged = Instant.MIN; sub.setLastCallBackOKTS(Instant.now()); log.log(FINE, () -> "OK response received in handleOkRequest: " + jrtReq); if (jrtReq.hasUpdatedGeneration()) { @@ -237,8 +243,7 @@ public class JRTConfigRequester implements RequestWaiter { } public void close() { - // Fake that we have logged to avoid printing warnings after this - noApplicationWarningLogged = Instant.now(); + closed = true; if (configSourceSet != null) { managedPool.release(configSourceSet); } |