Skip to content

Commit

Permalink
Deprecate and rename abstract methods in interfaces that contain 'mas…
Browse files Browse the repository at this point in the history
…ter' in name (#4121) (#4123)

Deprecate and rename abstract methods in interface
```
- in interface LocalNodeMasterListener:
void onMaster()
void offMaster()
- in interface AckedRequest:
TimeValue masterNodeTimeout()
```

Signed-off-by: Xue Zhou <xuezhou@amazon.com>
(cherry picked from commit ba9cdcd)
  • Loading branch information
opensearch-trigger-bot[bot] authored Aug 4, 2022
1 parent c793fe7 commit d771817
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public interface LocalNodeClusterManagerListener extends ClusterStateListener {
/**
* Called when local node is elected to be the cluster-manager
*/
void onMaster();
void onClusterManager();

/**
* 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 offMaster();
void offClusterManager();

@Override
default void clusterChanged(ClusterChangedEvent event) {
final boolean wasClusterManager = event.previousState().nodes().isLocalNodeElectedClusterManager();
final boolean isClusterManager = event.localNodeClusterManager();
if (wasClusterManager == false && isClusterManager) {
onMaster();
onClusterManager();
} else if (wasClusterManager && isClusterManager == false) {
offMaster();
offClusterManager();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,33 @@
@Deprecated
public interface LocalNodeMasterListener extends LocalNodeClusterManagerListener {

/**
* Called when local node is elected to be the cluster-manager.
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #onClusterManager()}
*/
@Deprecated
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.
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #offClusterManager()}
*/
@Deprecated
void offMaster();

/**
* Called when local node is elected to be the cluster-manager.
*/
@Override
default void onClusterManager() {
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.
*/
@Override
default void offClusterManager() {
offMaster();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public interface AckedRequest {

/**
* Returns the timeout for the request to be completed on the cluster-manager node
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeTimeout()}
*/
TimeValue masterNodeTimeout();
@Deprecated
default TimeValue masterNodeTimeout() {
throw new UnsupportedOperationException("Must be overridden");
}

/**
* Returns the timeout for the request to be completed on the cluster-manager node
*/
// TODO: Remove default implementation after removing the deprecated masterNodeTimeout()
default TimeValue clusterManagerNodeTimeout() {
return masterNodeTimeout();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ public void testLocalNodeClusterManagerListenerCallbacks() {
AtomicBoolean isClusterManager = new AtomicBoolean();
timedClusterApplierService.addLocalNodeClusterManagerListener(new LocalNodeClusterManagerListener() {
@Override
public void onMaster() {
public void onClusterManager() {
isClusterManager.set(true);
}

@Override
public void offMaster() {
public void offClusterManager() {
isClusterManager.set(false);
}
});
Expand Down

0 comments on commit d771817

Please sign in to comment.