aboutsummaryrefslogtreecommitdiffstats
path: root/routing-generator
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-11-01 18:33:11 +0100
committerGitHub <noreply@github.com>2022-11-01 18:33:11 +0100
commit6ed54786305e9f61bd877bc8dd66aa12f9fcbef3 (patch)
tree29f8bca349d314b557a6421e20397898611179f0 /routing-generator
parent319f5f0ca686ba1302a11c4154a2ac9960273e63 (diff)
parent2d48ab6e76737b735ce86c1704f2bcc8ff00289d (diff)
Merge pull request #24695 from vespa-engine/balder/hold-monitor-on-reload-too
Hold monitor on reload too.
Diffstat (limited to 'routing-generator')
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java10
1 files changed, 6 insertions, 4 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 6a6b6e0287b..cad69d35b55 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
@@ -58,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 final AtomicReference<RoutingTable> routingTable = new AtomicReference<>();
+ private volatile RoutingTable routingTable = null;
@Inject
public RoutingGenerator(ZoneConfig zoneConfig, RoutingStatus routingStatus, Metric metric) {
@@ -82,19 +82,21 @@ public class RoutingGenerator extends AbstractComponent {
/** Get the currently active routing table, if any */
public Optional<RoutingTable> routingTable() {
- return Optional.ofNullable(routingTable.get());
+ return Optional.ofNullable(routingTable);
}
/** Reload the current routing table, if any */
private void reload() {
- routingTable().ifPresent(this::load);
+ synchronized (monitor) {
+ routingTable().ifPresent(this::load);
+ }
}
/** Load the given routing table */
private void load(RoutingTable newTable) {
synchronized (monitor) {
router.load(newTable);
- routingTable.set(newTable);
+ routingTable = newTable;
}
}