Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Revert renaming method onMaster() and offMaster() in interface LocalNodeMasterListener #3693

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public interface LocalNodeMasterListener extends ClusterStateListener {
/**
* Called when local node is elected to be the cluster-manager
*/
void onClusterManager();
void onMaster();

/**
* Called when the local node used to be the cluster-manager, a new cluster-manager was elected and it's no longer the local node.
*/
void offClusterManager();
void offMaster();

@Override
default void clusterChanged(ClusterChangedEvent event) {
final boolean wasClusterManager = event.previousState().nodes().isLocalNodeElectedMaster();
final boolean isClusterManager = event.localNodeMaster();
if (wasClusterManager == false && isClusterManager) {
onClusterManager();
onMaster();
} else if (wasClusterManager && isClusterManager == false) {
offClusterManager();
offMaster();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static final class HashesPublisher implements LocalNodeMasterListener {
}

@Override
public void onClusterManager() {
public void onMaster() {
clusterService.submitStateUpdateTask("publish-secure-settings-hashes", new ClusterStateUpdateTask(Priority.URGENT) {
@Override
public ClusterState execute(ClusterState currentState) {
Expand All @@ -284,7 +284,7 @@ public void onFailure(String source, Exception e) {
}

@Override
public void offClusterManager() {
public void offMaster() {
logger.trace("I am no longer cluster-manager, nothing to do");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ public void testLocalNodeClusterManagerListenerCallbacks() {
AtomicBoolean isClusterManager = new AtomicBoolean();
timedClusterApplierService.addLocalNodeMasterListener(new LocalNodeMasterListener() {
@Override
public void onClusterManager() {
public void onMaster() {
isClusterManager.set(true);
}

@Override
public void offClusterManager() {
public void offMaster() {
isClusterManager.set(false);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public void testSingleStringSetting() throws Exception {
// hashes not yet published
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(false));
// publish
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onMaster();
ConsistentSettingsService consistentService = new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting));
assertThat(consistentService.areAllConsistent(), is(true));
// change value
secureSettings.setString(stringSetting.getKey(), "_TYPO_somethingsecure");
assertThat(consistentService.areAllConsistent(), is(false));
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(false));
// publish change
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onMaster();
assertThat(consistentService.areAllConsistent(), is(true));
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(true));
}
Expand All @@ -108,7 +108,7 @@ public void testSingleAffixSetting() throws Exception {
is(false)
);
// publish
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onMaster();
ConsistentSettingsService consistentService = new ConsistentSettingsService(
settings,
clusterService,
Expand All @@ -123,7 +123,7 @@ public void testSingleAffixSetting() throws Exception {
is(false)
);
// publish change
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onMaster();
assertThat(consistentService.areAllConsistent(), is(true));
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).areAllConsistent(), is(true));
// add value
Expand All @@ -136,7 +136,7 @@ public void testSingleAffixSetting() throws Exception {
is(false)
);
// publish
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onMaster();
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).areAllConsistent(), is(true));
// remove value
secureSettings = new MockSecureSettings();
Expand Down Expand Up @@ -173,7 +173,7 @@ public void testStringAndAffixSettings() throws Exception {
is(false)
);
// publish only the simple string setting
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).newHashPublisher().onMaster();
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(true));
assertThat(
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).areAllConsistent(),
Expand All @@ -184,7 +184,7 @@ public void testStringAndAffixSettings() throws Exception {
is(false)
);
// publish only the affix string setting
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onClusterManager();
new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).newHashPublisher().onMaster();
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(false));
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).areAllConsistent(), is(true));
assertThat(
Expand All @@ -193,7 +193,7 @@ public void testStringAndAffixSettings() throws Exception {
);
// publish both settings
new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting, affixStringSetting)).newHashPublisher()
.onClusterManager();
.onMaster();
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(stringSetting)).areAllConsistent(), is(true));
assertThat(new ConsistentSettingsService(settings, clusterService, Arrays.asList(affixStringSetting)).areAllConsistent(), is(true));
assertThat(
Expand Down