summaryrefslogtreecommitdiffstats
path: root/routing-generator
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-10-28 11:33:03 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-10-28 11:33:03 +0200
commit252b907096b052621763d4e3ed176a407b324c28 (patch)
treeeed5960ac927fbfaa482f744b902fb81d72b8a31 /routing-generator
parent78e9af018af94eb0d6210cc8d528891231d9e829 (diff)
Avoid stalling akamai requests during routing table reload.
Diffstat (limited to 'routing-generator')
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
index ba14bc83137..6a6b6e0287b 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
@@ -29,6 +29,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -57,7 +58,7 @@ public class RoutingGenerator extends AbstractComponent {
private final ScheduledExecutorService scheduledExecutor = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("routing-generator-maintenance"));
private final Object monitor = new Object();
- private volatile RoutingTable routingTable = null;
+ private final AtomicReference<RoutingTable> routingTable = new AtomicReference<>();
@Inject
public RoutingGenerator(ZoneConfig zoneConfig, RoutingStatus routingStatus, Metric metric) {
@@ -81,23 +82,19 @@ public class RoutingGenerator extends AbstractComponent {
/** Get the currently active routing table, if any */
public Optional<RoutingTable> routingTable() {
- synchronized (monitor) {
- return Optional.ofNullable(routingTable);
- }
+ return Optional.ofNullable(routingTable.get());
}
/** Reload the current routing table, if any */
private void reload() {
- synchronized (monitor) {
- routingTable().ifPresent(this::load);
- }
+ routingTable().ifPresent(this::load);
}
/** Load the given routing table */
private void load(RoutingTable newTable) {
synchronized (monitor) {
router.load(newTable);
- routingTable = newTable;
+ routingTable.set(newTable);
}
}