Skip to content

Commit 6f88c16

Browse files
Relocate RemoteClusterService methods only used in tests. (elastic#132037)
This change eliminates or moves the following methods from RemoteClusterService: isCrossClusterSearchEnabled() isRemoteNodeConnected() isRemoteClusterRegistered() This is part of an effort to reduce the API surface area of RemoteClusterService. Relates: elastic#131894, elastic#131948
1 parent 31b0d6e commit 6f88c16

File tree

3 files changed

+72
-78
lines changed

3 files changed

+72
-78
lines changed

server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,6 @@ public DiscoveryNode getLocalNode() {
172172
return transportService.getLocalNode();
173173
}
174174

175-
/**
176-
* Returns <code>true</code> if at least one remote cluster is configured
177-
*/
178-
public boolean isCrossClusterSearchEnabled() {
179-
return remoteClusters.isEmpty() == false;
180-
}
181-
182-
boolean isRemoteNodeConnected(final String remoteCluster, final DiscoveryNode node) {
183-
return remoteClusters.get(remoteCluster).isNodeConnected(node);
184-
}
185-
186175
/**
187176
* Group indices by cluster alias mapped to OriginalIndices for that cluster.
188177
* @param remoteClusterNames Set of configured remote cluster names.
@@ -258,13 +247,6 @@ public Set<String> getConfiguredClusters() {
258247
return getRegisteredRemoteClusterNames();
259248
}
260249

261-
/**
262-
* Returns <code>true</code> iff the given cluster is configured as a remote cluster. Otherwise <code>false</code>
263-
*/
264-
boolean isRemoteClusterRegistered(String clusterName) {
265-
return remoteClusters.containsKey(clusterName);
266-
}
267-
268250
/**
269251
* Returns the registered remote cluster names.
270252
*/

server/src/test/java/org/elasticsearch/transport/RemoteClusterClientTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import static org.elasticsearch.test.NodeRoles.removeRoles;
4141
import static org.elasticsearch.transport.AbstractSimpleTransportTestCase.IGNORE_DESERIALIZATION_ERRORS_SETTING;
4242
import static org.elasticsearch.transport.RemoteClusterConnectionTests.startTransport;
43+
import static org.elasticsearch.transport.RemoteClusterServiceTests.isRemoteNodeConnected;
4344
import static org.hamcrest.Matchers.equalTo;
4445
import static org.hamcrest.Matchers.instanceOf;
4546

@@ -95,7 +96,7 @@ public void testConnectAndExecuteRequest() throws Exception {
9596
service.acceptIncomingRequests();
9697
logger.info("now accepting incoming requests on local transport");
9798
RemoteClusterService remoteClusterService = service.getRemoteClusterService();
98-
assertTrue(remoteClusterService.isRemoteNodeConnected("test", remoteNode));
99+
assertTrue(isRemoteNodeConnected(remoteClusterService, "test", remoteNode));
99100
var client = remoteClusterService.getRemoteClusterClient(
100101
"test",
101102
threadPool.executor(TEST_THREAD_POOL_NAME),
@@ -172,7 +173,7 @@ public void testEnsureWeReconnect() throws Exception {
172173
// the right calls in place in the RemoteAwareClient
173174
service.acceptIncomingRequests();
174175
RemoteClusterService remoteClusterService = service.getRemoteClusterService();
175-
assertBusy(() -> assertTrue(remoteClusterService.isRemoteNodeConnected("test", remoteNode)));
176+
assertBusy(() -> assertTrue(isRemoteNodeConnected(remoteClusterService, "test", remoteNode)));
176177
for (int i = 0; i < 10; i++) {
177178
RemoteClusterConnection remoteClusterConnection = remoteClusterService.getRemoteClusterConnection("test");
178179
assertBusy(remoteClusterConnection::assertNoRunningConnections);
@@ -286,7 +287,7 @@ public void testQuicklySkipUnavailableClusters() throws Exception {
286287
);
287288

288289
try {
289-
assertFalse(remoteClusterService.isRemoteNodeConnected("test", remoteNode));
290+
assertFalse(isRemoteNodeConnected(remoteClusterService, "test", remoteNode));
290291

291292
// check that we quickly fail
292293
if (randomBoolean()) {
@@ -325,7 +326,7 @@ public void testQuicklySkipUnavailableClusters() throws Exception {
325326
() -> safeAwait(listener -> client.getConnection(null, listener.map(v -> v)))
326327
)
327328
);
328-
assertTrue(remoteClusterService.isRemoteNodeConnected("test", remoteNode));
329+
assertTrue(isRemoteNodeConnected(remoteClusterService, "test", remoteNode));
329330
}
330331
}
331332
}

0 commit comments

Comments
 (0)