diff options
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java index eda4f713732..bc0170ee695 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java @@ -188,6 +188,10 @@ public class CuratorDb { return curator.lock(lockRoot.append("nameServiceQueue"), defaultLockTimeout); } + public Lock lockMeteringRefreshTime() throws TimeoutException { + return tryLock(lockRoot.append("meteringRefreshTime")); + } + // -------------- Helpers ------------------------------------------ /** Try locking with a low timeout, meaning it is OK to fail lock acquisition. @@ -519,6 +523,18 @@ public class CuratorDb { return allEndpointCertificateMetadata; } + // -------------- Metering view refresh times ---------------------------- + + public void writeMeteringRefreshTime(long timestamp) { + curator.set(meteringRefreshPath(), Long.toString(timestamp).getBytes()); + } + + public long readMeteringRefreshTime() { + return curator.getData(meteringRefreshPath()) + .map(String::new).map(Long::parseLong) + .orElse(0l); + } + // -------------- Paths --------------------------------------------------- private Path lockPath(TenantName tenant) { @@ -640,4 +656,8 @@ public class CuratorDb { return endpointCertificateRoot.append(id.serializedForm()); } + private static Path meteringRefreshPath() { + return root.append("meteringRefreshTime"); + } + } |