summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-06-19 12:07:18 +0200
committerJon Bratseth <bratseth@oath.com>2018-06-19 12:07:18 +0200
commitaebc3edabe3e06a90600b5204f2a9d5b2506ce2e (patch)
treec48f4ca5846519e85d4c02653944ea2d091fceff /vespajlib
parent0f4b4c99881aed25e9c9b946c74c4be80ee242ab (diff)
Reuse allocation decisions
During deployment we first prepare the application on one config server then notifies the other config servers (by setting state=PREPARED) that they should load it. That will cause allocation requests against the node repo to be done once over on the those config servers. These simultaneous requests against the node repo may cause ut to time out waiting for the node repo's application lock if these requests take a somewhat long time. This change reads existing allocations instead of redoing allocation requests against the node repo. The existing allocation is saved (on the first config server) before state=PREPARED is set.
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/lang/SettableOptional.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/lang/SettableOptional.java b/vespajlib/src/main/java/com/yahoo/lang/SettableOptional.java
index db5dd76c124..e83a6c3f308 100644
--- a/vespajlib/src/main/java/com/yahoo/lang/SettableOptional.java
+++ b/vespajlib/src/main/java/com/yahoo/lang/SettableOptional.java
@@ -19,6 +19,11 @@ public final class SettableOptional<T> {
/** Creates a new settable optional with the given value */
public SettableOptional(T value) { this.value = value; }
+ /** Creates a new settable optional with the given value, or an empty */
+ public SettableOptional(Optional<T> value) {
+ this.value = value.isPresent() ? value.get() : null;
+ }
+
public boolean isPresent() {
return value != null;
}