summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-02-08 10:02:46 +0100
committerJon Marius Venstad <venstad@gmail.com>2019-02-08 10:02:46 +0100
commitd8c6190f7d4a71fac6a2cf08f3d6c956491fd8f5 (patch)
treea3a68ab5f022f4073a26cf63876ee9ca2ddffa4d
parent4d6da807c84c8fbd6209068d0b6efeec8c9332ee (diff)
Invalidate cache only on changes or exceptions
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
index 4636457f522..fd6bcb9093c 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
@@ -124,40 +124,49 @@ public class ZookeeperStatusService implements StatusService {
HostStatus status) {
String path = hostAllowedDownPath(applicationInstanceReference, hostName);
+ boolean invalidate = false;
try {
switch (status) {
case NO_REMARKS:
- deleteNode_ignoreNoNodeException(path,"Host already has state NO_REMARKS, path = " + path);
+ invalidate = deleteNode_ignoreNoNodeException(path, "Host already has state NO_REMARKS, path = " + path);
break;
case ALLOWED_TO_BE_DOWN:
- createNode_ignoreNodeExistsException(path,
- "Host already has state ALLOWED_TO_BE_DOWN, path = " + path);
+ invalidate = createNode_ignoreNodeExistsException(path, "Host already has state ALLOWED_TO_BE_DOWN, path = " + path);
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected status '" + status + "'.");
}
} catch (Exception e) {
- //TODO: IOException with explanation
+ invalidate = true;
throw new RuntimeException(e);
}
finally {
- counter.next();
- hostsDown.remove(applicationInstanceReference);
+ if (invalidate) {
+ counter.next();
+ hostsDown.remove(applicationInstanceReference);
+ }
}
}
- private void deleteNode_ignoreNoNodeException(String path, String debugLogMessageIfNotExists) throws Exception {
+ private boolean deleteNode_ignoreNoNodeException(String path, String debugLogMessageIfNotExists) throws Exception {
try {
curator.framework().delete().forPath(path);
+ return true;
} catch (NoNodeException e) {
log.log(LogLevel.DEBUG, debugLogMessageIfNotExists, e);
+ return false;
}
}
- private void createNode_ignoreNodeExistsException(String path, String debugLogMessageIfExists) throws Exception {
+ private boolean createNode_ignoreNodeExistsException(String path, String debugLogMessageIfExists) throws Exception {
try {
curator.framework().create()
.creatingParentsIfNeeded()
.forPath(path);
+ return true;
} catch (NodeExistsException e) {
log.log(LogLevel.DEBUG, debugLogMessageIfExists, e);
+ return false;
}
}