Skip to content

Commit

Permalink
Remove MasterService class
Browse files Browse the repository at this point in the history
This has been deprecated and is replaced by ClusterManagerService.

Signed-off-by: Andrew Ross <[email protected]>
  • Loading branch information
andrross committed Jan 27, 2025
1 parent e6fc600 commit 7e63c2b
Show file tree
Hide file tree
Showing 8 changed files with 1,105 additions and 1,161 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public ClusterManagerService getClusterManagerService() {

/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerService()} */
@Deprecated
public MasterService getMasterService() {
public ClusterManagerService getMasterService() {
return clusterManagerService;
}

Expand Down
1,050 changes: 0 additions & 1,050 deletions server/src/main/java/org/opensearch/cluster/service/MasterService.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.service.ClusterManagerService;
import org.opensearch.cluster.service.ClusterManagerServiceTests;
import org.opensearch.cluster.service.FakeThreadPoolClusterManagerService;
import org.opensearch.cluster.service.MasterServiceTests;
import org.opensearch.common.Randomness;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -549,9 +549,11 @@ public void testJoinUpdateVotingConfigExclusion() throws Exception {
)
);

assertTrue(MasterServiceTests.discoveryState(clusterManagerService).getVotingConfigExclusions().stream().anyMatch(exclusion -> {
return "knownNodeName".equals(exclusion.getNodeName()) && "newNodeId".equals(exclusion.getNodeId());
}));
assertTrue(
ClusterManagerServiceTests.discoveryState(clusterManagerService).getVotingConfigExclusions().stream().anyMatch(exclusion -> {
return "knownNodeName".equals(exclusion.getNodeName()) && "newNodeId".equals(exclusion.getNodeId());
})
);
}

private ClusterState buildStateWithVotingConfigExclusion(
Expand Down Expand Up @@ -777,7 +779,7 @@ public void testConcurrentJoining() {
throw new RuntimeException(e);
}

assertTrue(MasterServiceTests.discoveryState(clusterManagerService).nodes().isLocalNodeElectedMaster());
assertTrue(ClusterManagerServiceTests.discoveryState(clusterManagerService).nodes().isLocalNodeElectedMaster());
for (DiscoveryNode successfulNode : successfulNodes) {
assertTrue(successfulNode + " joined cluster", clusterStateHasNode(successfulNode));
assertFalse(successfulNode + " voted for cluster-manager", coordinator.missingJoinVoteFrom(successfulNode));
Expand Down Expand Up @@ -861,11 +863,11 @@ public void testJoinFailsWhenDecommissioned() {
}

private boolean isLocalNodeElectedMaster() {
return MasterServiceTests.discoveryState(clusterManagerService).nodes().isLocalNodeElectedMaster();
return ClusterManagerServiceTests.discoveryState(clusterManagerService).nodes().isLocalNodeElectedMaster();
}

private boolean clusterStateHasNode(DiscoveryNode node) {
return node.equals(MasterServiceTests.discoveryState(clusterManagerService).nodes().get(node.getId()));
return node.equals(ClusterManagerServiceTests.discoveryState(clusterManagerService).nodes().get(node.getId()));
}

private static ClusterState initialStateWithDecommissionedAttribute(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testDeprecatedGetMasterServiceBWC() {
threadPool
)
) {
MasterService masterService = clusterService.getMasterService();
ClusterManagerService masterService = clusterService.getMasterService();
ClusterManagerService clusterManagerService = clusterService.getClusterManagerService();
assertThat(masterService, equalTo(clusterManagerService));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void testClusterManagerServiceSettingsExist() {
"Both 'cluster.service.slow_cluster_manager_task_logging_threshold' and its predecessor should be supported built-in settings",
settings.containsAll(
Arrays.asList(
MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
)
)
);
Expand All @@ -45,8 +45,8 @@ public void testClusterManagerServiceSettingsExist() {
*/
public void testSettingFallback() {
assertEquals(
MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY),
MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY)
ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY),
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY)
);
}

Expand All @@ -57,11 +57,11 @@ public void testSettingGetValue() {
Settings settings = Settings.builder().put("cluster.service.slow_cluster_manager_task_logging_threshold", "9s").build();
assertEquals(
TimeValue.timeValueSeconds(9),
MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)
);
assertEquals(
MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.getDefault(Settings.EMPTY),
MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)
ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.getDefault(Settings.EMPTY),
ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)

);
}
Expand All @@ -73,10 +73,10 @@ public void testSettingGetValueWithFallback() {
Settings settings = Settings.builder().put("cluster.service.slow_master_task_logging_threshold", "8s").build();
assertEquals(
TimeValue.timeValueSeconds(8),
MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)

);
assertSettingDeprecationsAndWarnings(new Setting<?>[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING });
assertSettingDeprecationsAndWarnings(new Setting<?>[] { ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING });
}

/**
Expand All @@ -89,11 +89,11 @@ public void testSettingGetValueWhenBothAreConfigured() {
.build();
assertEquals(
TimeValue.timeValueSeconds(9),
MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)

);
assertEquals(TimeValue.timeValueSeconds(8), MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings));
assertSettingDeprecationsAndWarnings(new Setting<?>[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING });
assertEquals(TimeValue.timeValueSeconds(8), ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings));
assertSettingDeprecationsAndWarnings(new Setting<?>[] { ClusterManagerService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.opensearch.cluster.service.ClusterApplierService;
import org.opensearch.cluster.service.ClusterManagerService;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.cluster.service.MasterService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.node.Node;
Expand Down Expand Up @@ -92,13 +91,13 @@ public static ClusterManagerService createClusterManagerService(ThreadPool threa

/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #createClusterManagerService(ThreadPool, ClusterState)} */
@Deprecated
public static MasterService createMasterService(ThreadPool threadPool, ClusterState initialClusterState) {
public static ClusterManagerService createMasterService(ThreadPool threadPool, ClusterState initialClusterState) {
return createClusterManagerService(threadPool, initialClusterState);
}

/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #createClusterManagerService(ThreadPool, DiscoveryNode)} */
@Deprecated
public static MasterService createMasterService(ThreadPool threadPool, DiscoveryNode localNode) {
public static ClusterManagerService createMasterService(ThreadPool threadPool, DiscoveryNode localNode) {
return createClusterManagerService(threadPool, localNode);
}

Expand Down

0 comments on commit 7e63c2b

Please sign in to comment.