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

Deprecate public class names with master terminology #3871

Merged
merged 15 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Restore method getMasterService() to return MasterService
Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed Jul 14, 2022
commit 694d876f35424c2b059710035cae6e7fb93d035c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

import java.util.Collections;
import java.util.Map;
import java.util.Objects;

/**
* Main Cluster Service
Expand All @@ -63,6 +64,8 @@
*/
public class ClusterService extends AbstractLifecycleComponent {
private final ClusterManagerService clusterManagerService;
@Deprecated
private MasterService masterService = null;

private final ClusterApplierService clusterApplierService;

Expand Down Expand Up @@ -114,6 +117,20 @@ public ClusterService(
this.clusterApplierService = clusterApplierService;
}

/**
* @deprecated As of 2.2, because supporting inclusive language.
*/
@Deprecated
public ClusterService(
Settings settings,
ClusterSettings clusterSettings,
MasterService masterService,
ClusterApplierService clusterApplierService
) {
this(settings, clusterSettings, (ClusterManagerService) masterService, clusterApplierService);
this.masterService = masterService;
}

public synchronized void setNodeConnectionsService(NodeConnectionsService nodeConnectionsService) {
clusterApplierService.setNodeConnectionsService(nodeConnectionsService);
}
Expand Down Expand Up @@ -218,10 +235,21 @@ public void addLocalNodeMasterListener(LocalNodeClusterManagerListener listener)
clusterApplierService.addLocalNodeMasterListener(listener);
}

public ClusterManagerService getMasterService() {
public ClusterManagerService getClusterManagerService() {
return clusterManagerService;
}

/**
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerService()}
*/
@Deprecated
public MasterService getMasterService() {
return Objects.requireNonNullElseGet(
masterService,
() -> new MasterService(settings, clusterSettings, clusterManagerService.threadPool)
);
}

/**
* Getter and Setter for IndexingPressureService, This method exposes IndexingPressureService stats to other plugins for usage.
* Although Indexing Pressure instances can be accessed via Node and NodeService class but none of them are
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.cluster.service;

import org.hamcrest.Matchers;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.OpenSearchTestCase;

public class ClusterServiceTests extends OpenSearchTestCase {
public void testDeprecatedGetMasterServiceWhenUsingMasterServiceToInitializeClusterService() {
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
MasterService masterService = new MasterService(Settings.EMPTY, clusterSettings, null);
ClusterService clusterServiceWithMasterService = new ClusterService(Settings.EMPTY, clusterSettings, masterService, null);
assertThat(clusterServiceWithMasterService.getMasterService(), Matchers.equalTo(masterService));
}

public void testDeprecatedGetMasterServiceWithoutAssigningMasterService() {
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
ClusterService clusterService = new ClusterService(Settings.EMPTY, clusterSettings, null);
assertThat(clusterService.getMasterService(), Matchers.instanceOf(MasterService.class));
}
}