Skip to content

Commit bd2d733

Browse files
Address review comment: use new naming conventions
1 parent 1a9866d commit bd2d733

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/RemoteFieldCapsForceConnectTimeoutIT.java renamed to server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/FieldCapsForceConnectTimeoutIT.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.indices.cluster;
1111

1212
import org.elasticsearch.ElasticsearchTimeoutException;
13+
import org.elasticsearch.ExceptionsHelper;
1314
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
1415
import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction;
1516
import org.elasticsearch.common.settings.Setting;
@@ -29,9 +30,9 @@
2930

3031
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3132

32-
public class RemoteFieldCapsForceConnectTimeoutIT extends AbstractMultiClustersTestCase {
33-
private static final String REMOTE_CLUSTER_1 = "cluster-a";
34-
private static final String REMOTE_CLUSTER_2 = "cluster-b";
33+
public class FieldCapsForceConnectTimeoutIT extends AbstractMultiClustersTestCase {
34+
private static final String LINKED_CLUSTER_1 = "cluster-a";
35+
private static final String LINKED_CLUSTER_2 = "cluster-b";
3536

3637
public static class ForceConnectTimeoutPlugin extends Plugin implements ClusterPlugin {
3738
@Override
@@ -47,7 +48,7 @@ public List<Setting<?>> getSettings() {
4748

4849
@Override
4950
protected List<String> remoteClusterAlias() {
50-
return List.of(REMOTE_CLUSTER_1, REMOTE_CLUSTER_2);
51+
return List.of(LINKED_CLUSTER_1, LINKED_CLUSTER_2);
5152
}
5253

5354
@Override
@@ -67,7 +68,7 @@ protected Settings nodeSettings() {
6768

6869
@Override
6970
protected Map<String, Boolean> skipUnavailableForRemoteClusters() {
70-
return Map.of(REMOTE_CLUSTER_1, true, REMOTE_CLUSTER_2, true);
71+
return Map.of(LINKED_CLUSTER_1, true, LINKED_CLUSTER_2, true);
7172
}
7273

7374
public void testTimeoutSetting() {
@@ -76,7 +77,7 @@ public void testTimeoutSetting() {
7677
MockTransportService mts = (MockTransportService) cluster(LOCAL_CLUSTER).getInstance(TransportService.class, nodeName);
7778

7879
mts.addConnectBehavior(
79-
cluster(REMOTE_CLUSTER_1).getInstance(TransportService.class, (String) null),
80+
cluster(LINKED_CLUSTER_1).getInstance(TransportService.class, (String) null),
8081
((transport, discoveryNode, profile, listener) -> {
8182
try {
8283
latch.await();
@@ -90,27 +91,27 @@ public void testTimeoutSetting() {
9091
}
9192

9293
// Add some dummy data to prove we are communicating fine with the remote.
93-
assertAcked(client(REMOTE_CLUSTER_1).admin().indices().prepareCreate("test-index"));
94-
client(REMOTE_CLUSTER_1).prepareIndex("test-index").setSource("sample-field", "sample-value").get();
95-
client(REMOTE_CLUSTER_1).admin().indices().prepareRefresh("test-index").get();
94+
assertAcked(client(LINKED_CLUSTER_1).admin().indices().prepareCreate("test-index"));
95+
client(LINKED_CLUSTER_1).prepareIndex("test-index").setSource("sample-field", "sample-value").get();
96+
client(LINKED_CLUSTER_1).admin().indices().prepareRefresh("test-index").get();
9697

9798
/*
9899
* Do a full restart so that our custom connect behaviour takes effect since it does not apply to
99100
* pre-existing connections -- they're already established by the time this test runs.
100101
*/
101102
try {
102-
cluster(REMOTE_CLUSTER_1).fullRestart();
103+
cluster(LINKED_CLUSTER_1).fullRestart();
103104
} catch (Exception e) {
104105
throw new AssertionError(e);
105106
} finally {
106107
var fieldCapsRequest = new FieldCapabilitiesRequest();
107108
/*
108-
* We have a local and 2 remote clusters but will target only the remote that we stalled.
109-
* This is because when the timeout kicks in, and we move on from the stalled remote, we do not want
109+
* We have an origin and 2 linked clusters but will target only the one that we stalled.
110+
* This is because when the timeout kicks in, and we move on from the stalled cluster, we do not want
110111
* the error to be a top-level error. Rather, it must be present in the response object under "failures".
111112
* All other errors are free to be top-level errors though.
112113
*/
113-
fieldCapsRequest.indices(REMOTE_CLUSTER_1 + ":*");
114+
fieldCapsRequest.indices(LINKED_CLUSTER_1 + ":*");
114115
fieldCapsRequest.fields("foo", "bar", "baz");
115116
var result = safeGet(client().execute(TransportFieldCapabilitiesAction.TYPE, fieldCapsRequest));
116117

@@ -126,8 +127,9 @@ public void testTimeoutSetting() {
126127
Matchers.containsString("java.lang.IllegalStateException: Unable to open any connections")
127128
);
128129

129-
// The actual error that is thrown by the subscribable listener when a remote could not be talked to.
130+
// The actual error that is thrown by the subscribable listener when a linked cluster could not be talked to.
130131
assertThat(failure.getException().getCause(), Matchers.instanceOf(ElasticsearchTimeoutException.class));
132+
assertThat(ExceptionsHelper.isRemoteUnavailableException(failure.getException()), Matchers.is(true));
131133

132134
latch.countDown();
133135
result.decRef();

server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ protected void doExecute(Task task, FieldCapabilitiesRequest request, final Acti
146146
public void executeRequest(
147147
Task task,
148148
FieldCapabilitiesRequest request,
149-
RemoteRequestExecutor remoteRequestExecutor,
149+
LinkedRequestExecutor linkedRequestExecutor,
150150
ActionListener<FieldCapabilitiesResponse> listener
151151
) {
152152
// workaround for https://github.com/elastic/elasticsearch/issues/97916 - TODO remove this when we can
153-
searchCoordinationExecutor.execute(ActionRunnable.wrap(listener, l -> doExecuteForked(task, request, remoteRequestExecutor, l)));
153+
searchCoordinationExecutor.execute(ActionRunnable.wrap(listener, l -> doExecuteForked(task, request, linkedRequestExecutor, l)));
154154
}
155155

156156
private void doExecuteForked(
157157
Task task,
158158
FieldCapabilitiesRequest request,
159-
RemoteRequestExecutor remoteRequestExecutor,
159+
LinkedRequestExecutor linkedRequestExecutor,
160160
ActionListener<FieldCapabilitiesResponse> listener
161161
) {
162162
if (ccsCheckCompatibility) {
@@ -322,7 +322,7 @@ private void doExecuteForked(
322322
true,
323323
ActionListener.releaseAfter(remoteListener, refs.acquire())
324324
).delegateFailure(
325-
(responseListener, conn) -> remoteRequestExecutor.executeRemoteRequest(
325+
(responseListener, conn) -> linkedRequestExecutor.executeRemoteRequest(
326326
transportService,
327327
conn,
328328
remoteRequest,
@@ -362,7 +362,7 @@ public void onFailure(Exception e) {
362362
});
363363
}
364364

365-
public interface RemoteRequestExecutor {
365+
public interface LinkedRequestExecutor {
366366
void executeRemoteRequest(
367367
TransportService transportService,
368368
Transport.Connection conn,
@@ -623,8 +623,8 @@ List<FieldCapabilitiesFailure> build(Set<String> successfulIndices) {
623623
String index = failure.getKey();
624624
Exception e = failure.getValue();
625625
/*
626-
* The listener we use to briefly try, and connect to a remote can throw an ElasticsearchTimeoutException
627-
* error if a remote cannot be reached. To make sure we correctly recognise this scenario via
626+
* The listener we use to briefly try, and connect to a linked cluster can throw an ElasticsearchTimeoutException
627+
* error if it cannot be reached. To make sure we correctly recognise this scenario via
628628
* ExceptionsHelper.isRemoteUnavailableException(), we wrap this error appropriately.
629629
*/
630630
if (e instanceof ElasticsearchTimeoutException ete) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlResolveFieldsAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ public EsqlResolveFieldsAction(
5151

5252
@Override
5353
protected void doExecute(Task task, FieldCapabilitiesRequest request, final ActionListener<FieldCapabilitiesResponse> listener) {
54-
fieldCapsAction.executeRequest(task, request, this::executeRemoteRequest, listener);
54+
fieldCapsAction.executeRequest(task, request, this::executeLinkedRequest, listener);
5555
}
5656

57-
void executeRemoteRequest(
57+
void executeLinkedRequest(
5858
TransportService transportService,
5959
Transport.Connection conn,
60-
FieldCapabilitiesRequest remoteRequest,
60+
FieldCapabilitiesRequest request,
6161
ActionListenerResponseHandler<FieldCapabilitiesResponse> responseHandler
6262
) {
6363
var remoteAction = conn.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)
6464
? RESOLVE_REMOTE_TYPE
6565
: TransportFieldCapabilitiesAction.REMOTE_TYPE;
66-
transportService.sendRequest(conn, remoteAction.name(), remoteRequest, TransportRequestOptions.EMPTY, responseHandler);
66+
transportService.sendRequest(conn, remoteAction.name(), request, TransportRequestOptions.EMPTY, responseHandler);
6767
}
6868
}

0 commit comments

Comments
 (0)