Skip to content

Commit ef68276

Browse files
committed
[CCR] Rename leaderClient variables and parameters to remoteClient (#35368)
1 parent 29bf3e6 commit ef68276

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
@@ -129,10 +129,10 @@ public void checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs(
129129
return;
130130
}
131131

132-
final Client leaderClient = client.getRemoteClusterClient(clusterAlias);
133-
hasPrivilegesToFollowIndices(leaderClient, new String[] {leaderIndex}, e -> {
132+
final Client remoteClient = client.getRemoteClusterClient(clusterAlias);
133+
hasPrivilegesToFollowIndices(remoteClient, new String[] {leaderIndex}, e -> {
134134
if (e == null) {
135-
fetchLeaderHistoryUUIDs(leaderClient, leaderIndexMetaData, onFailure, historyUUIDs ->
135+
fetchLeaderHistoryUUIDs(remoteClient, leaderIndexMetaData, onFailure, historyUUIDs ->
136136
consumer.accept(historyUUIDs, leaderIndexMetaData));
137137
} else {
138138
onFailure.accept(e);
@@ -180,7 +180,7 @@ public void checkRemoteClusterLicenseAndFetchClusterState(
180180
*
181181
* @param client the client
182182
* @param clusterAlias the remote cluster alias
183-
* @param leaderClient the leader client to use to execute cluster state API
183+
* @param remoteClient the remote client to use to execute cluster state API
184184
* @param request the cluster state request
185185
* @param onFailure the failure consumer
186186
* @param leaderClusterStateConsumer the leader cluster state consumer
@@ -190,7 +190,7 @@ public void checkRemoteClusterLicenseAndFetchClusterState(
190190
private void checkRemoteClusterLicenseAndFetchClusterState(
191191
final Client client,
192192
final String clusterAlias,
193-
final Client leaderClient,
193+
final Client remoteClient,
194194
final ClusterStateRequest request,
195195
final Consumer<Exception> onFailure,
196196
final Consumer<ClusterState> leaderClusterStateConsumer,
@@ -207,7 +207,7 @@ public void onResponse(final RemoteClusterLicenseChecker.LicenseCheck licenseChe
207207
final ActionListener<ClusterStateResponse> clusterStateListener =
208208
ActionListener.wrap(s -> leaderClusterStateConsumer.accept(s.getState()), onFailure);
209209
// following an index in remote cluster, so use remote client to fetch leader index metadata
210-
leaderClient.admin().cluster().state(request, clusterStateListener);
210+
remoteClient.admin().cluster().state(request, clusterStateListener);
211211
} else {
212212
onFailure.accept(nonCompliantLicense.apply(licenseCheck));
213213
}
@@ -222,17 +222,17 @@ public void onFailure(final Exception e) {
222222
}
223223

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

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

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

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

339339
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
@@ -92,11 +92,11 @@ protected AllocatedPersistentTask createTask(long id, String type, String action
9292
PersistentTasksCustomMetaData.PersistentTask<ShardFollowTask> taskInProgress,
9393
Map<String, String> headers) {
9494
ShardFollowTask params = taskInProgress.getParams();
95-
final Client leaderClient;
95+
final Client remoteClient;
9696
if (params.getRemoteCluster() != null) {
97-
leaderClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
97+
remoteClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
9898
} else {
99-
leaderClient = wrapClient(client, params.getHeaders());
99+
remoteClient = wrapClient(client, params.getHeaders());
100100
}
101101
Client followerClient = wrapClient(client, params.getHeaders());
102102
BiConsumer<TimeValue, Runnable> scheduler = (delay, command) -> {
@@ -125,7 +125,7 @@ protected void innerUpdateMapping(LongConsumer handler, Consumer<Exception> erro
125125
clusterStateRequest.metaData(true);
126126
clusterStateRequest.indices(leaderIndex.getName());
127127

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

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

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
@@ -76,7 +76,7 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
7676
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
7777
return;
7878
}
79-
final Client leaderClient = client.getRemoteClusterClient(request.getRemoteCluster());
79+
final Client remoteClient = client.getRemoteClusterClient(request.getRemoteCluster());
8080
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
8181
clusterStateRequest.clear();
8282
clusterStateRequest.metaData(true);
@@ -86,9 +86,9 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
8686
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
8787

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

0 commit comments

Comments
 (0)