Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.io.Closeable;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -653,10 +652,6 @@ public RemoteClusterClient getRemoteClusterClient(
});
}

Collection<RemoteClusterConnection> getConnections() {
return remoteClusters.values();
}

static void registerRemoteClusterHandshakeRequestHandler(TransportService transportService) {
transportService.registerRequestHandler(
REMOTE_CLUSTER_HANDSHAKE_ACTION_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,14 +838,18 @@ public void testCCSRemoteReduceWithDisconnectedRemoteClusters() throws Exception
}

CountDownLatch disconnectedLatch = new CountDownLatch(numDisconnectedClusters);
RemoteClusterServiceTests.addConnectionListener(remoteClusterService, new TransportConnectionListener() {
@Override
public void onNodeDisconnected(DiscoveryNode node, @Nullable Exception closeException) {
if (disconnectedNodes.remove(node)) {
disconnectedLatch.countDown();
RemoteClusterServiceTests.addConnectionListener(
remoteClusterService,
remoteIndicesByCluster.keySet(),
new TransportConnectionListener() {
@Override
public void onNodeDisconnected(DiscoveryNode node, @Nullable Exception closeException) {
if (disconnectedNodes.remove(node)) {
disconnectedLatch.countDown();
}
}
}
});
);
for (DiscoveryNode disconnectedNode : disconnectedNodes) {
service.addFailToSendNoConnectRule(disconnectedNode.getAddress());
}
Expand Down Expand Up @@ -1149,14 +1153,18 @@ public void testCollectSearchShards() throws Exception {
}

CountDownLatch disconnectedLatch = new CountDownLatch(numDisconnectedClusters);
RemoteClusterServiceTests.addConnectionListener(remoteClusterService, new TransportConnectionListener() {
@Override
public void onNodeDisconnected(DiscoveryNode node, @Nullable Exception closeException) {
if (disconnectedNodes.remove(node)) {
disconnectedLatch.countDown();
RemoteClusterServiceTests.addConnectionListener(
remoteClusterService,
remoteIndicesByCluster.keySet(),
new TransportConnectionListener() {
@Override
public void onNodeDisconnected(DiscoveryNode node, @Nullable Exception closeException) {
if (disconnectedNodes.remove(node)) {
disconnectedLatch.countDown();
}
}
}
});
);
for (DiscoveryNode disconnectedNode : disconnectedNodes) {
service.addFailToSendNoConnectRule(disconnectedNode.getAddress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,13 @@ public static void updateSkipUnavailable(RemoteClusterService service, String cl
connection.setSkipUnavailable(skipUnavailable);
}

public static void addConnectionListener(RemoteClusterService service, TransportConnectionListener listener) {
for (RemoteClusterConnection connection : service.getConnections()) {
public static void addConnectionListener(
RemoteClusterService service,
Set<String> clusterAliases,
TransportConnectionListener listener
) {
for (final var clusterAlias : clusterAliases) {
final var connection = service.getRemoteClusterConnection(clusterAlias);
ConnectionManager connectionManager = connection.getConnectionManager();
connectionManager.addListener(listener);
}
Expand Down