aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-07-09 13:00:09 +0200
committerHarald Musum <musum@verizonmedia.com>2020-07-09 13:00:09 +0200
commit4ffd74ae2eabd17e49f95427addb7ed82bf11ee7 (patch)
treec8680f8bf47ef7e9827e474941da196ea9be1f3d /configserver
parent8edf60cd8d701509a23a90712f1f97a71771d4a5 (diff)
Minor changes after review feedback
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java13
2 files changed, 5 insertions, 10 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
index 46b1f26a62b..ec06336c80a 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
@@ -38,6 +38,6 @@ public class SessionsMaintainer extends ConfigServerMaintainer {
Duration lockExpiryTime = Duration.ofDays(1);
int deleted = applicationRepository.deleteExpiredLocks(lockExpiryTime);
- log.log(LogLevel.INFO, "Deleted " + deleted + " expired locks, expiry time " + lockExpiryTime);
+ log.log(LogLevel.INFO, "Deleted " + deleted + " locks older than " + lockExpiryTime);
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
index 312a574bb2e..b3eb0342a2f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
@@ -37,7 +37,6 @@ import com.yahoo.vespa.flags.Flags;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
-import org.apache.zookeeper.data.Stat;
import java.io.File;
import java.io.FilenameFilter;
@@ -286,7 +285,7 @@ public class SessionRepository {
int deleted = 0;
for (var lock : curator.getChildren(locksPath)) {
Path path = locksPath.append(lock);
- if (zooKeeperNodeCreated(path).isBefore(clock.instant().minus(expiryTime))) {
+ if (zooKeeperNodeCreated(path).orElse(clock.instant()).isBefore(clock.instant().minus(expiryTime))) {
log.log(Level.INFO, "Lock " + path + " has expired, deleting it");
curator.delete(path);
deleted++;
@@ -295,12 +294,8 @@ public class SessionRepository {
return deleted;
}
- private Instant zooKeeperNodeCreated(Path path) {
- Optional<Stat> stat = curator.getStat(path);
- if (stat.isPresent())
- return Instant.ofEpochMilli(stat.get().getCtime());
- else
- return componentRegistry.getClock().instant();
+ private Optional<Instant> zooKeeperNodeCreated(Path path) {
+ return curator.getStat(path).map(s -> Instant.ofEpochMilli(s.getCtime()));
}
private boolean sessionHasExpired(Instant created, Duration expiryTime, Clock clock) {
@@ -687,7 +682,7 @@ public class SessionRepository {
return curator.lock(lockPath(sessionId), Duration.ofMinutes(1)); // These locks shouldn't be held for very long.
}
- public Path lockPath(long sessionId) {
+ private Path lockPath(long sessionId) {
return locksPath.append(String.valueOf(sessionId));
}