Skip to content

Commit

Permalink
Rename classes with name 'MasterService' to 'ClusterManagerService' i…
Browse files Browse the repository at this point in the history
…n directory 'test/framework' (#4051)

To support inclusive language, the master terminology is going to be replaced by cluster manager in the code base.

After the class MasterService has been deprecated and class ClusterManagerService has been created in #4022 / commit 740f75d, the classes in `test/framework` directory with name 'MasterService' can be deprecated and renamed.

- Rename the following classes in `test/framework` directory:

FakeThreadPoolMasterService -> FakeThreadPoolClusterManagerService
BlockMasterServiceOnMaster -> BlockClusterManagerServiceOnClusterManager
BusyMasterServiceDisruption -> BusyClusterManagerServiceDisruption

In the following commit, I will add back the above 3 classes with the old name and deprecate them, to keep the backwards compatibility.

Signed-off-by: Tianli Feng <[email protected]>
(cherry picked from commit bea5d1a)
  • Loading branch information
Tianli Feng authored and github-actions[bot] committed Aug 1, 2022
1 parent 3f47160 commit 83f5ca9
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.disruption.BlockMasterServiceOnMaster;
import org.opensearch.test.disruption.BlockClusterManagerServiceOnClusterManager;
import org.opensearch.test.disruption.IntermittentLongGCDisruption;
import org.opensearch.test.disruption.NetworkDisruption;
import org.opensearch.test.disruption.NetworkDisruption.TwoPartitions;
Expand Down Expand Up @@ -316,7 +316,7 @@ public void testMappingTimeout() throws Exception {
.setTransientSettings(Settings.builder().put("indices.mapping.dynamic_timeout", "1ms"))
);

ServiceDisruptionScheme disruption = new BlockMasterServiceOnMaster(random());
ServiceDisruptionScheme disruption = new BlockClusterManagerServiceOnClusterManager(random());
setDisruptionScheme(disruption);

disruption.startDisrupting();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.TestCustomMetadata;
import org.opensearch.test.disruption.BusyMasterServiceDisruption;
import org.opensearch.test.disruption.BusyClusterManagerServiceDisruption;
import org.opensearch.test.disruption.ServiceDisruptionScheme;
import org.opensearch.test.rest.FakeRestRequest;
import org.opensearch.test.transport.MockTransportService;
Expand Down Expand Up @@ -1157,7 +1157,7 @@ public void testDataNodeRestartWithBusyClusterManagerDuringSnapshot() throws Exc

final String dataNode = blockNodeWithIndex("test-repo", "test-idx");
logger.info("--> snapshot");
ServiceDisruptionScheme disruption = new BusyMasterServiceDisruption(random(), Priority.HIGH);
ServiceDisruptionScheme disruption = new BusyClusterManagerServiceDisruption(random(), Priority.HIGH);
setDisruptionScheme(disruption);
client(internalCluster().getClusterManagerName()).admin()
.cluster()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.opensearch.cluster.service.ClusterApplier;
import org.opensearch.cluster.service.ClusterApplierService;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.cluster.service.FakeThreadPoolMasterService;
import org.opensearch.cluster.service.FakeThreadPoolClusterManagerService;
import org.opensearch.cluster.service.ClusterManagerService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -89,7 +89,7 @@ protected PrioritizedOpenSearchThreadPoolExecutor createThreadPoolExecutor() {
}
};

final ClusterManagerService clusterManagerService = new FakeThreadPoolMasterService(
final ClusterManagerService clusterManagerService = new FakeThreadPoolClusterManagerService(
"test",
"clusterManagerService",
threadPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.service.FakeThreadPoolMasterService;
import org.opensearch.cluster.service.FakeThreadPoolClusterManagerService;
import org.opensearch.cluster.service.ClusterManagerService;
import org.opensearch.cluster.service.MasterServiceTests;
import org.opensearch.common.Randomness;
Expand Down Expand Up @@ -144,7 +144,7 @@ private void setupFakeClusterManagerServiceAndCoordinator(long term, ClusterStat
random()
);
final ThreadPool fakeThreadPool = deterministicTaskQueue.getThreadPool();
FakeThreadPoolMasterService fakeClusterManagerService = new FakeThreadPoolMasterService(
FakeThreadPoolClusterManagerService fakeClusterManagerService = new FakeThreadPoolClusterManagerService(
"test_node",
"test",
fakeThreadPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
import org.opensearch.cluster.service.ClusterApplierService;
import org.opensearch.cluster.service.ClusterManagerService;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.cluster.service.FakeThreadPoolMasterService;
import org.opensearch.cluster.service.FakeThreadPoolClusterManagerService;
import org.opensearch.common.CheckedConsumer;
import org.opensearch.common.Nullable;
import org.opensearch.common.io.stream.NamedWriteableRegistry;
Expand Down Expand Up @@ -1661,7 +1661,7 @@ private final class TestClusterNode {
this.node = node;
final Environment environment = createEnvironment(node.getName());
threadPool = deterministicTaskQueue.getThreadPool(runnable -> CoordinatorTests.onNodeLog(node, runnable));
clusterManagerService = new FakeThreadPoolMasterService(
clusterManagerService = new FakeThreadPoolClusterManagerService(
node.getName(),
"test",
threadPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.opensearch.cluster.routing.allocation.AllocationService;
import org.opensearch.cluster.service.ClusterApplierService;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.cluster.service.FakeThreadPoolMasterService;
import org.opensearch.cluster.service.FakeThreadPoolClusterManagerService;
import org.opensearch.common.Nullable;
import org.opensearch.common.Randomness;
import org.opensearch.common.UUIDs;
Expand Down Expand Up @@ -1026,7 +1026,7 @@ class ClusterNode {
private final DiscoveryNode localNode;
final MockPersistedState persistedState;
final Settings nodeSettings;
private AckedFakeThreadPoolMasterService clusterManagerService;
private AckedFakeThreadPoolClusterManagerService clusterManagerService;
private DisruptableClusterApplierService clusterApplierService;
private ClusterService clusterService;
TransportService transportService;
Expand Down Expand Up @@ -1106,7 +1106,7 @@ protected Optional<DisruptableMockTransport> getDisruptableMockTransport(Transpo
null,
emptySet()
);
clusterManagerService = new AckedFakeThreadPoolMasterService(
clusterManagerService = new AckedFakeThreadPoolClusterManagerService(
localNode.getId(),
"test",
threadPool,
Expand Down Expand Up @@ -1513,11 +1513,11 @@ int getSuccessfulAckIndex(ClusterNode clusterNode) {
}
}

static class AckedFakeThreadPoolMasterService extends FakeThreadPoolMasterService {
static class AckedFakeThreadPoolClusterManagerService extends FakeThreadPoolClusterManagerService {

AckCollector nextAckCollector = new AckCollector();

AckedFakeThreadPoolMasterService(
AckedFakeThreadPoolClusterManagerService(
String nodeName,
String serviceName,
ThreadPool threadPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
import static org.apache.lucene.tests.util.LuceneTestCase.random;
import static org.opensearch.test.OpenSearchTestCase.randomInt;

public class FakeThreadPoolMasterService extends ClusterManagerService {
private static final Logger logger = LogManager.getLogger(FakeThreadPoolMasterService.class);
public class FakeThreadPoolClusterManagerService extends ClusterManagerService {
private static final Logger logger = LogManager.getLogger(FakeThreadPoolClusterManagerService.class);

private final String name;
private final List<Runnable> pendingTasks = new ArrayList<>();
Expand All @@ -65,7 +65,7 @@ public class FakeThreadPoolMasterService extends ClusterManagerService {
private boolean taskInProgress = false;
private boolean waitForPublish = false;

public FakeThreadPoolMasterService(
public FakeThreadPoolClusterManagerService(
String nodeName,
String serviceName,
ThreadPool threadPool,
Expand Down Expand Up @@ -137,7 +137,7 @@ public void run() {
if (waitForPublish == false) {
taskInProgress = false;
}
FakeThreadPoolMasterService.this.scheduleNextTaskIfNecessary();
FakeThreadPoolClusterManagerService.this.scheduleNextTaskIfNecessary();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;

public class BlockMasterServiceOnMaster extends SingleNodeDisruption {
public class BlockClusterManagerServiceOnClusterManager extends SingleNodeDisruption {

AtomicReference<CountDownLatch> disruptionLatch = new AtomicReference<>();

public BlockMasterServiceOnMaster(Random random) {
public BlockClusterManagerServiceOnClusterManager(Random random) {
super(random);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

public class BusyMasterServiceDisruption extends SingleNodeDisruption {
public class BusyClusterManagerServiceDisruption extends SingleNodeDisruption {
private final AtomicBoolean active = new AtomicBoolean();
private final Priority priority;

public BusyMasterServiceDisruption(Random random, Priority priority) {
public BusyClusterManagerServiceDisruption(Random random, Priority priority) {
super(random);
this.priority = priority;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class FakeThreadPoolMasterServiceTests extends OpenSearchTestCase {
public class FakeThreadPoolClusterManagerServiceTests extends OpenSearchTestCase {

public void testFakeClusterManagerService() {
List<Runnable> runnableTasks = new ArrayList<>();
Expand All @@ -84,7 +84,7 @@ public void testFakeClusterManagerService() {
doAnswer(invocationOnMock -> runnableTasks.add((Runnable) invocationOnMock.getArguments()[0])).when(executorService).execute(any());
when(mockThreadPool.generic()).thenReturn(executorService);

FakeThreadPoolMasterService clusterManagerService = new FakeThreadPoolMasterService(
FakeThreadPoolClusterManagerService clusterManagerService = new FakeThreadPoolClusterManagerService(
"test_node",
"test",
mockThreadPool,
Expand Down

0 comments on commit 83f5ca9

Please sign in to comment.