Skip to content

Commit

Permalink
s/election type/election strategy/
Browse files Browse the repository at this point in the history
  • Loading branch information
ywelsch committed Jun 21, 2019
1 parent e7c325e commit 1caa1b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void apply(Settings value, Settings current, Settings previous) {
Node.INITIAL_STATE_TIMEOUT_SETTING,
DiscoveryModule.DISCOVERY_TYPE_SETTING,
DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING,
DiscoveryModule.ELECTION_TYPE_SETTING,
DiscoveryModule.ELECTION_STRATEGY_SETTING,
SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING,
SeedHostsResolver.DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING,
SeedHostsResolver.DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public class DiscoveryModule {
Setting.listSetting("discovery.seed_providers", Collections.emptyList(), Function.identity(),
Property.NodeScope);

public static final String DEFAULT_ELECTION_TYPE = "default";
public static final String DEFAULT_ELECTION_STRATEGY = "default";

public static final Setting<String> ELECTION_TYPE_SETTING =
new Setting<>("cluster.election.type", DEFAULT_ELECTION_TYPE, Function.identity(), Property.NodeScope);
public static final Setting<String> ELECTION_STRATEGY_SETTING =
new Setting<>("cluster.election.strategy", DEFAULT_ELECTION_STRATEGY, Function.identity(), Property.NodeScope);

private final Discovery discovery;

Expand All @@ -93,7 +93,7 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic
hostProviders.put("settings", () -> new SettingsBasedSeedHostsProvider(settings, transportService));
hostProviders.put("file", () -> new FileBasedSeedHostsProvider(configFile));
final Map<String, ElectionStrategy> electionStrategies = new HashMap<>();
electionStrategies.put(DEFAULT_ELECTION_TYPE, ElectionStrategy.DefaultElectionStrategy.INSTANCE);
electionStrategies.put(DEFAULT_ELECTION_STRATEGY, ElectionStrategy.DefaultElectionStrategy.INSTANCE);
for (DiscoveryPlugin plugin : plugins) {
plugin.getSeedHostProviders(transportService, networkService).forEach((key, value) -> {
if (hostProviders.put(key, value) != null) {
Expand Down Expand Up @@ -139,9 +139,9 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic
return Collections.unmodifiableList(addresses);
};

final ElectionStrategy electionStrategy = electionStrategies.get(ELECTION_TYPE_SETTING.get(settings));
final ElectionStrategy electionStrategy = electionStrategies.get(ELECTION_STRATEGY_SETTING.get(settings));
if (electionStrategy == null) {
throw new IllegalArgumentException("Unknown election type " + ELECTION_TYPE_SETTING.get(settings));
throw new IllegalArgumentException("Unknown election strategy " + ELECTION_STRATEGY_SETTING.get(settings));
}

if (ZEN2_DISCOVERY_TYPE.equals(discoveryType) || SINGLE_NODE_DISCOVERY_TYPE.equals(discoveryType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class VotingOnlyNodePlugin extends Plugin implements DiscoveryPlugin, Net
public static final Setting<Boolean> VOTING_ONLY_NODE_SETTING
= Setting.boolSetting("node.voting_only", false, Setting.Property.NodeScope);

private static final String VOTING_ONLY_ELECTION_TYPE = "supports_voting_only";
private static final String VOTING_ONLY_ELECTION_STRATEGY = "supports_voting_only";

static DiscoveryNodeRole VOTING_ONLY_NODE_ROLE = new DiscoveryNodeRole("voting_only", "v") {
@Override
Expand Down Expand Up @@ -132,7 +132,7 @@ public Map<String, ElectionStrategy> getElectionStrategies() {
if (XPackSettings.VOTING_ONLY_ENABLED.get(settings) == false) {
return Collections.emptyMap();
}
return Collections.singletonMap(VOTING_ONLY_ELECTION_TYPE, new VotingOnlyNodeElectionStrategy());
return Collections.singletonMap(VOTING_ONLY_ELECTION_STRATEGY, new VotingOnlyNodeElectionStrategy());
}

@Override
Expand All @@ -154,7 +154,7 @@ public Settings additionalSettings() {
if (XPackSettings.VOTING_ONLY_ENABLED.get(settings) == false) {
return Settings.EMPTY;
}
return Settings.builder().put(DiscoveryModule.ELECTION_TYPE_SETTING.getKey(), VOTING_ONLY_ELECTION_TYPE).build();
return Settings.builder().put(DiscoveryModule.ELECTION_STRATEGY_SETTING.getKey(), VOTING_ONLY_ELECTION_STRATEGY).build();
}

static class VotingOnlyNodeElectionStrategy extends ElectionStrategy.DefaultElectionStrategy {
Expand Down

0 comments on commit 1caa1b6

Please sign in to comment.