Skip to content

Commit

Permalink
Revert renaming method onMaster() and offMaster() in interface LocalN…
Browse files Browse the repository at this point in the history
…odeMasterListener (#3686) (#3693)

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng authored Jun 24, 2022
1 parent 718ea66 commit 07ee249
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
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

0 comments on commit 07ee249

Please sign in to comment.