diff --git a/src/main/java/org/opensearch/ad/cluster/ClusterManagerEventListener.java b/src/main/java/org/opensearch/ad/cluster/ClusterManagerEventListener.java index 353a7ad14..505cbf888 100644 --- a/src/main/java/org/opensearch/ad/cluster/ClusterManagerEventListener.java +++ b/src/main/java/org/opensearch/ad/cluster/ClusterManagerEventListener.java @@ -57,7 +57,7 @@ public ClusterManagerEventListener( } @Override - public void onClusterManager() { + public void onMaster() { if (hourlyCron == null) { hourlyCron = threadPool.scheduleWithFixedDelay(new HourlyCron(client, nodeFilter), TimeValue.timeValueHours(1), executorName()); clusterService.addLifecycleListener(new LifecycleListener() { @@ -88,7 +88,7 @@ public void beforeStop() { } @Override - public void offClusterManager() { + public void offMaster() { cancel(hourlyCron); cancel(checkpointIndexRetentionCron); hourlyCron = null; diff --git a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java index 2320e1c2c..266a5ece4 100644 --- a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java @@ -677,7 +677,7 @@ public void initCheckpointIndex(ActionListener actionListen } @Override - public void onClusterManager() { + public void onMaster() { try { // try to rollover immediately as we might be restarting the cluster rolloverAndDeleteHistoryIndex(); @@ -692,7 +692,7 @@ public void onClusterManager() { } @Override - public void offClusterManager() { + public void offMaster() { if (scheduledRollover != null) { scheduledRollover.cancel(); } diff --git a/src/test/java/org/opensearch/ad/cluster/ClusterManagerEventListenerTests.java b/src/test/java/org/opensearch/ad/cluster/ClusterManagerEventListenerTests.java index eccf67de8..39146c90b 100644 --- a/src/test/java/org/opensearch/ad/cluster/ClusterManagerEventListenerTests.java +++ b/src/test/java/org/opensearch/ad/cluster/ClusterManagerEventListenerTests.java @@ -71,12 +71,12 @@ public void setUp() throws Exception { } public void testOnOffMaster() { - clusterManagerService.onClusterManager(); + clusterManagerService.onMaster(); assertThat(hourlyCancellable, is(notNullValue())); assertThat(checkpointIndexRetentionCancellable, is(notNullValue())); assertTrue(!clusterManagerService.getHourlyCron().isCancelled()); assertTrue(!clusterManagerService.getCheckpointIndexRetentionCron().isCancelled()); - clusterManagerService.offClusterManager(); + clusterManagerService.offMaster(); assertThat(clusterManagerService.getCheckpointIndexRetentionCron(), is(nullValue())); assertThat(clusterManagerService.getHourlyCron(), is(nullValue())); } @@ -100,10 +100,10 @@ public void testBeforeStop() { return null; }).when(clusterService).addLifecycleListener(any()); - clusterManagerService.onClusterManager(); + clusterManagerService.onMaster(); assertThat(clusterManagerService.getCheckpointIndexRetentionCron(), is(nullValue())); assertThat(clusterManagerService.getHourlyCron(), is(nullValue())); - clusterManagerService.offClusterManager(); + clusterManagerService.offMaster(); assertThat(clusterManagerService.getCheckpointIndexRetentionCron(), is(nullValue())); assertThat(clusterManagerService.getHourlyCron(), is(nullValue())); }