aboutsummaryrefslogtreecommitdiffstats
path: root/service-monitor/src
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2018-06-13 14:23:19 +0200
committerHåkon Hallingstad <hakon@oath.com>2018-06-13 14:23:19 +0200
commit1835b47e2962b238920328aeca546e79b12da3d1 (patch)
tree9fbe3e19b7ca84ddfde73e103e63a37c4401d539 /service-monitor/src
parent8bb08512378671a93a0c2fbee74e4ee8aeb48549 (diff)
Fixes after review round
Diffstat (limited to 'service-monitor/src')
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java6
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java10
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java2
5 files changed, 11 insertions, 11 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java
index 128ca1b5d18..c8b2d5d25f7 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java
@@ -150,9 +150,7 @@ public class HealthClient implements AutoCloseable, ServiceIdentityProvider.List
throw new IllegalStateException("HTTP client never started or has closed");
}
- CloseableHttpResponse httpResponse = httpClient.execute(httpget);
-
- try {
+ try (CloseableHttpResponse httpResponse = httpClient.execute(httpget)) {
int httpStatusCode = httpResponse.getStatusLine().getStatusCode();
if (httpStatusCode < 200 || httpStatusCode >= 300) {
return HealthInfo.fromBadHttpStatusCode(httpStatusCode);
@@ -171,8 +169,6 @@ public class HealthClient implements AutoCloseable, ServiceIdentityProvider.List
} else {
return HealthInfo.fromHealthStatusCode(healthResponse.status.code);
}
- } finally {
- httpResponse.close();
}
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java
index bc667a60bc7..38139d28d7f 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java
@@ -36,5 +36,5 @@ public interface HealthEndpoint {
ConnectionSocketFactory getConnectionSocketFactory();
void registerListener(ServiceIdentityProvider.Listener listener);
void removeListener(ServiceIdentityProvider.Listener listener);
- String toString();
+ String description();
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java
index 5518f9ddeba..2574f782afb 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java
@@ -71,8 +71,12 @@ public class HealthMonitor implements AutoCloseable {
healthClient.close();
}
- private long initialDelayInMillis(long maxInitialDelayInSeconds) {
- return random.nextLong() % maxInitialDelayInSeconds;
+ private long initialDelayInMillis(long maxInitialDelayInMillis) {
+ if (maxInitialDelayInMillis >= Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Max initial delay is out of bounds: " + maxInitialDelayInMillis);
+ }
+
+ return (long) random.nextInt((int) maxInitialDelayInMillis);
}
private void updateSynchronously() {
@@ -81,7 +85,7 @@ public class HealthMonitor implements AutoCloseable {
} catch (Throwable t) {
// An uncaught exception will kill the executor.scheduleWithFixedDelay thread!
logger.log(LogLevel.WARNING, "Failed to get health info for " +
- healthClient.getEndpoint(), t);
+ healthClient.getEndpoint().description(), t);
}
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java
index 5f4a1d1024b..254cb9785e1 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java
@@ -38,7 +38,7 @@ class HttpHealthEndpoint implements HealthEndpoint {
}
@Override
- public String toString() {
+ public String description() {
return url.toString();
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java
index d1198cda78d..f1ebb80f500 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java
@@ -47,7 +47,7 @@ public class HttpsHealthEndpoint implements HealthEndpoint {
}
@Override
- public String toString() {
+ public String description() {
return url.toString();
}
}