Skip to content

Commit

Permalink
fixup! Use Filesystem locking to avoid concurrent updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Jan 7, 2025
1 parent c0bb63d commit 765da61
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<RoutingRule> getRoutingRules()
throws IOException
{
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
String rulesConfigPath = routingRulesConfiguration.getRulesConfigPath();
ImmutableList.Builder<RoutingRule> routingRulesBuilder = ImmutableList.builder();
try {
String content = Files.readString(Paths.get(rulesConfigPath), UTF_8);
Expand All @@ -67,7 +65,6 @@ public synchronized List<RoutingRule> updateRoutingRule(RoutingRule routingRule)
throws IOException
{
ImmutableList.Builder<RoutingRule> updatedRoutingRulesBuilder = ImmutableList.builder();
String rulesConfigPath = routingRulesConfiguration.getRulesConfigPath();
List<RoutingRule> currentRoutingRulesList = new ArrayList<>();
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
try {
Expand Down

0 comments on commit 765da61

Please sign in to comment.