From 765da61fe3281344e3cb131b3fff30b9ff37bf63 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 7 Jan 2025 16:24:12 +0900 Subject: [PATCH] fixup! Use Filesystem locking to avoid concurrent updates --- .../io/trino/gateway/ha/router/RoutingRulesManager.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingRulesManager.java b/gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingRulesManager.java index ffc7b7f32..0f83d0ed6 100644 --- a/gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingRulesManager.java +++ b/gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingRulesManager.java @@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import io.trino.gateway.ha.config.HaGatewayConfiguration; -import io.trino.gateway.ha.config.RoutingRulesConfiguration; import io.trino.gateway.ha.domain.RoutingRule; import java.io.IOException; @@ -35,19 +34,18 @@ public class RoutingRulesManager { - private final RoutingRulesConfiguration routingRulesConfiguration; + private final String rulesConfigPath; @Inject public RoutingRulesManager(HaGatewayConfiguration configuration) { - this.routingRulesConfiguration = configuration.getRoutingRules(); + this.rulesConfigPath = configuration.getRoutingRules().getRulesConfigPath(); } public List getRoutingRules() throws IOException { ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); - String rulesConfigPath = routingRulesConfiguration.getRulesConfigPath(); ImmutableList.Builder routingRulesBuilder = ImmutableList.builder(); try { String content = Files.readString(Paths.get(rulesConfigPath), UTF_8); @@ -67,7 +65,6 @@ public synchronized List updateRoutingRule(RoutingRule routingRule) throws IOException { ImmutableList.Builder updatedRoutingRulesBuilder = ImmutableList.builder(); - String rulesConfigPath = routingRulesConfiguration.getRulesConfigPath(); List currentRoutingRulesList = new ArrayList<>(); ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); try {