Skip to content

Commit 07a69a5

Browse files
authored
[CCR] Rename leaderClient variables and parameters to remoteClient (#35368)
1 parent 54b445d commit 07a69a5

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrLicenseChecker.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ public void checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs(
128128
return;
129129
}
130130

131-
final Client leaderClient = client.getRemoteClusterClient(clusterAlias);
132-
hasPrivilegesToFollowIndices(leaderClient, new String[] {leaderIndex}, e -> {
131+
final Client remoteClient = client.getRemoteClusterClient(clusterAlias);
132+
hasPrivilegesToFollowIndices(remoteClient, new String[] {leaderIndex}, e -> {
133133
if (e == null) {
134-
fetchLeaderHistoryUUIDs(leaderClient, leaderIndexMetaData, onFailure, historyUUIDs ->
134+
fetchLeaderHistoryUUIDs(remoteClient, leaderIndexMetaData, onFailure, historyUUIDs ->
135135
consumer.accept(historyUUIDs, leaderIndexMetaData));
136136
} else {
137137
onFailure.accept(e);
@@ -179,7 +179,7 @@ public void checkRemoteClusterLicenseAndFetchClusterState(
179179
*
180180
* @param client the client
181181
* @param clusterAlias the remote cluster alias
182-
* @param leaderClient the leader client to use to execute cluster state API
182+
* @param remoteClient the remote client to use to execute cluster state API
183183
* @param request the cluster state request
184184
* @param onFailure the failure consumer
185185
* @param leaderClusterStateConsumer the leader cluster state consumer
@@ -189,7 +189,7 @@ public void checkRemoteClusterLicenseAndFetchClusterState(
189189
private void checkRemoteClusterLicenseAndFetchClusterState(
190190
final Client client,
191191
final String clusterAlias,
192-
final Client leaderClient,
192+
final Client remoteClient,
193193
final ClusterStateRequest request,
194194
final Consumer<Exception> onFailure,
195195
final Consumer<ClusterState> leaderClusterStateConsumer,
@@ -206,7 +206,7 @@ public void onResponse(final RemoteClusterLicenseChecker.LicenseCheck licenseChe
206206
final ActionListener<ClusterStateResponse> clusterStateListener =
207207
ActionListener.wrap(s -> leaderClusterStateConsumer.accept(s.getState()), onFailure);
208208
// following an index in remote cluster, so use remote client to fetch leader index metadata
209-
leaderClient.admin().cluster().state(request, clusterStateListener);
209+
remoteClient.admin().cluster().state(request, clusterStateListener);
210210
} else {
211211
onFailure.accept(nonCompliantLicense.apply(licenseCheck));
212212
}
@@ -221,17 +221,17 @@ public void onFailure(final Exception e) {
221221
}
222222

223223
/**
224-
* Fetches the history UUIDs for leader index on per shard basis using the specified leaderClient.
224+
* Fetches the history UUIDs for leader index on per shard basis using the specified remoteClient.
225225
*
226-
* @param leaderClient the leader client
226+
* @param remoteClient the remote client
227227
* @param leaderIndexMetaData the leader index metadata
228228
* @param onFailure the failure consumer
229229
* @param historyUUIDConsumer the leader index history uuid and consumer
230230
*/
231231
// NOTE: Placed this method here; in order to avoid duplication of logic for fetching history UUIDs
232232
// in case of following a local or a remote cluster.
233233
public void fetchLeaderHistoryUUIDs(
234-
final Client leaderClient,
234+
final Client remoteClient,
235235
final IndexMetaData leaderIndexMetaData,
236236
final Consumer<Exception> onFailure,
237237
final Consumer<String[]> historyUUIDConsumer) {
@@ -274,20 +274,20 @@ public void fetchLeaderHistoryUUIDs(
274274
IndicesStatsRequest request = new IndicesStatsRequest();
275275
request.clear();
276276
request.indices(leaderIndex);
277-
leaderClient.admin().indices().stats(request, ActionListener.wrap(indicesStatsHandler, onFailure));
277+
remoteClient.admin().indices().stats(request, ActionListener.wrap(indicesStatsHandler, onFailure));
278278
}
279279

280280
/**
281281
* Check if the user executing the current action has privileges to follow the specified indices on the cluster specified by the leader
282282
* client. The specified callback will be invoked with null if the user has the necessary privileges to follow the specified indices,
283283
* otherwise the callback will be invoked with an exception outlining the authorization error.
284284
*
285-
* @param leaderClient the leader client
285+
* @param remoteClient the remote client
286286
* @param indices the indices
287287
* @param handler the callback
288288
*/
289-
public void hasPrivilegesToFollowIndices(final Client leaderClient, final String[] indices, final Consumer<Exception> handler) {
290-
Objects.requireNonNull(leaderClient, "leaderClient");
289+
public void hasPrivilegesToFollowIndices(final Client remoteClient, final String[] indices, final Consumer<Exception> handler) {
290+
Objects.requireNonNull(remoteClient, "remoteClient");
291291
Objects.requireNonNull(indices, "indices");
292292
if (indices.length == 0) {
293293
throw new IllegalArgumentException("indices must not be empty");
@@ -298,7 +298,7 @@ public void hasPrivilegesToFollowIndices(final Client leaderClient, final String
298298
return;
299299
}
300300

301-
ThreadContext threadContext = leaderClient.threadPool().getThreadContext();
301+
ThreadContext threadContext = remoteClient.threadPool().getThreadContext();
302302
SecurityContext securityContext = new SecurityContext(Settings.EMPTY, threadContext);
303303
String username = securityContext.getUser().principal();
304304

@@ -332,7 +332,7 @@ public void hasPrivilegesToFollowIndices(final Client leaderClient, final String
332332
handler.accept(Exceptions.authorizationError(message.toString()));
333333
}
334334
};
335-
leaderClient.execute(HasPrivilegesAction.INSTANCE, request, ActionListener.wrap(responseHandler, handler));
335+
remoteClient.execute(HasPrivilegesAction.INSTANCE, request, ActionListener.wrap(responseHandler, handler));
336336
}
337337

338338
public static Client wrapClient(Client client, Map<String, String> headers) {

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ protected AllocatedPersistentTask createTask(long id, String type, String action
9191
PersistentTasksCustomMetaData.PersistentTask<ShardFollowTask> taskInProgress,
9292
Map<String, String> headers) {
9393
ShardFollowTask params = taskInProgress.getParams();
94-
final Client leaderClient;
94+
final Client remoteClient;
9595
if (params.getRemoteCluster() != null) {
96-
leaderClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
96+
remoteClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
9797
} else {
98-
leaderClient = wrapClient(client, params.getHeaders());
98+
remoteClient = wrapClient(client, params.getHeaders());
9999
}
100100
Client followerClient = wrapClient(client, params.getHeaders());
101101
BiConsumer<TimeValue, Runnable> scheduler = (delay, command) -> {
@@ -124,7 +124,7 @@ protected void innerUpdateMapping(LongConsumer handler, Consumer<Exception> erro
124124
clusterStateRequest.metaData(true);
125125
clusterStateRequest.indices(leaderIndex.getName());
126126

127-
leaderClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> {
127+
remoteClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> {
128128
IndexMetaData indexMetaData = clusterStateResponse.getState().metaData().getIndexSafe(leaderIndex);
129129
if (indexMetaData.getMappings().isEmpty()) {
130130
assert indexMetaData.getMappingVersion() == 1;
@@ -186,7 +186,7 @@ protected void innerUpdateSettings(final LongConsumer finalHandler, final Consum
186186
}
187187
}
188188
};
189-
leaderClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(onResponse, errorHandler));
189+
remoteClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(onResponse, errorHandler));
190190
}
191191

192192
private void closeIndexUpdateSettingsAndOpenIndex(String followIndex,
@@ -240,7 +240,7 @@ protected void innerSendShardChangesRequest(long from, int maxOperationCount, Co
240240
request.setMaxOperationCount(maxOperationCount);
241241
request.setMaxBatchSize(params.getMaxReadRequestSize());
242242
request.setPollTimeout(params.getReadPollTimeout());
243-
leaderClient.execute(ShardChangesAction.INSTANCE, request, ActionListener.wrap(handler::accept, errorHandler));
243+
remoteClient.execute(ShardChangesAction.INSTANCE, request, ActionListener.wrap(handler::accept, errorHandler));
244244
}
245245
};
246246
}

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
7474
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
7575
return;
7676
}
77-
final Client leaderClient = client.getRemoteClusterClient(request.getRemoteCluster());
77+
final Client remoteClient = client.getRemoteClusterClient(request.getRemoteCluster());
7878
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
7979
clusterStateRequest.clear();
8080
clusterStateRequest.metaData(true);
@@ -84,9 +84,9 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
8484
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
8585

8686
String[] indices = request.getLeaderIndexPatterns().toArray(new String[0]);
87-
ccrLicenseChecker.hasPrivilegesToFollowIndices(leaderClient, indices, e -> {
87+
ccrLicenseChecker.hasPrivilegesToFollowIndices(remoteClient, indices, e -> {
8888
if (e == null) {
89-
leaderClient.admin().cluster().state(
89+
remoteClient.admin().cluster().state(
9090
clusterStateRequest,
9191
ActionListener.wrap(
9292
clusterStateResponse -> {

0 commit comments

Comments
 (0)