From 07a69a528ba09642e3ea8b7b0c17c954157698b8 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 8 Nov 2018 16:26:14 +0100 Subject: [PATCH] [CCR] Rename leaderClient variables and parameters to remoteClient (#35368) --- .../xpack/ccr/CcrLicenseChecker.java | 30 +++++++++---------- .../ccr/action/ShardFollowTasksExecutor.java | 12 ++++---- .../TransportPutAutoFollowPatternAction.java | 6 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrLicenseChecker.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrLicenseChecker.java index e056e312819..3985b90a71b 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrLicenseChecker.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrLicenseChecker.java @@ -128,10 +128,10 @@ public final class CcrLicenseChecker { return; } - final Client leaderClient = client.getRemoteClusterClient(clusterAlias); - hasPrivilegesToFollowIndices(leaderClient, new String[] {leaderIndex}, e -> { + final Client remoteClient = client.getRemoteClusterClient(clusterAlias); + hasPrivilegesToFollowIndices(remoteClient, new String[] {leaderIndex}, e -> { if (e == null) { - fetchLeaderHistoryUUIDs(leaderClient, leaderIndexMetaData, onFailure, historyUUIDs -> + fetchLeaderHistoryUUIDs(remoteClient, leaderIndexMetaData, onFailure, historyUUIDs -> consumer.accept(historyUUIDs, leaderIndexMetaData)); } else { onFailure.accept(e); @@ -179,7 +179,7 @@ public final class CcrLicenseChecker { * * @param client the client * @param clusterAlias the remote cluster alias - * @param leaderClient the leader client to use to execute cluster state API + * @param remoteClient the remote client to use to execute cluster state API * @param request the cluster state request * @param onFailure the failure consumer * @param leaderClusterStateConsumer the leader cluster state consumer @@ -189,7 +189,7 @@ public final class CcrLicenseChecker { private void checkRemoteClusterLicenseAndFetchClusterState( final Client client, final String clusterAlias, - final Client leaderClient, + final Client remoteClient, final ClusterStateRequest request, final Consumer onFailure, final Consumer leaderClusterStateConsumer, @@ -206,7 +206,7 @@ public final class CcrLicenseChecker { final ActionListener clusterStateListener = ActionListener.wrap(s -> leaderClusterStateConsumer.accept(s.getState()), onFailure); // following an index in remote cluster, so use remote client to fetch leader index metadata - leaderClient.admin().cluster().state(request, clusterStateListener); + remoteClient.admin().cluster().state(request, clusterStateListener); } else { onFailure.accept(nonCompliantLicense.apply(licenseCheck)); } @@ -221,9 +221,9 @@ public final class CcrLicenseChecker { } /** - * Fetches the history UUIDs for leader index on per shard basis using the specified leaderClient. + * Fetches the history UUIDs for leader index on per shard basis using the specified remoteClient. * - * @param leaderClient the leader client + * @param remoteClient the remote client * @param leaderIndexMetaData the leader index metadata * @param onFailure the failure consumer * @param historyUUIDConsumer the leader index history uuid and consumer @@ -231,7 +231,7 @@ public final class CcrLicenseChecker { // NOTE: Placed this method here; in order to avoid duplication of logic for fetching history UUIDs // in case of following a local or a remote cluster. public void fetchLeaderHistoryUUIDs( - final Client leaderClient, + final Client remoteClient, final IndexMetaData leaderIndexMetaData, final Consumer onFailure, final Consumer historyUUIDConsumer) { @@ -274,7 +274,7 @@ public final class CcrLicenseChecker { IndicesStatsRequest request = new IndicesStatsRequest(); request.clear(); request.indices(leaderIndex); - leaderClient.admin().indices().stats(request, ActionListener.wrap(indicesStatsHandler, onFailure)); + remoteClient.admin().indices().stats(request, ActionListener.wrap(indicesStatsHandler, onFailure)); } /** @@ -282,12 +282,12 @@ public final class CcrLicenseChecker { * client. The specified callback will be invoked with null if the user has the necessary privileges to follow the specified indices, * otherwise the callback will be invoked with an exception outlining the authorization error. * - * @param leaderClient the leader client + * @param remoteClient the remote client * @param indices the indices * @param handler the callback */ - public void hasPrivilegesToFollowIndices(final Client leaderClient, final String[] indices, final Consumer handler) { - Objects.requireNonNull(leaderClient, "leaderClient"); + public void hasPrivilegesToFollowIndices(final Client remoteClient, final String[] indices, final Consumer handler) { + Objects.requireNonNull(remoteClient, "remoteClient"); Objects.requireNonNull(indices, "indices"); if (indices.length == 0) { throw new IllegalArgumentException("indices must not be empty"); @@ -298,7 +298,7 @@ public final class CcrLicenseChecker { return; } - ThreadContext threadContext = leaderClient.threadPool().getThreadContext(); + ThreadContext threadContext = remoteClient.threadPool().getThreadContext(); SecurityContext securityContext = new SecurityContext(Settings.EMPTY, threadContext); String username = securityContext.getUser().principal(); @@ -332,7 +332,7 @@ public final class CcrLicenseChecker { handler.accept(Exceptions.authorizationError(message.toString())); } }; - leaderClient.execute(HasPrivilegesAction.INSTANCE, request, ActionListener.wrap(responseHandler, handler)); + remoteClient.execute(HasPrivilegesAction.INSTANCE, request, ActionListener.wrap(responseHandler, handler)); } public static Client wrapClient(Client client, Map headers) { diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java index 79de49c7a28..797c08cc973 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java @@ -91,11 +91,11 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor taskInProgress, Map headers) { ShardFollowTask params = taskInProgress.getParams(); - final Client leaderClient; + final Client remoteClient; if (params.getRemoteCluster() != null) { - leaderClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders()); + remoteClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders()); } else { - leaderClient = wrapClient(client, params.getHeaders()); + remoteClient = wrapClient(client, params.getHeaders()); } Client followerClient = wrapClient(client, params.getHeaders()); BiConsumer scheduler = (delay, command) -> { @@ -124,7 +124,7 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor { + remoteClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> { IndexMetaData indexMetaData = clusterStateResponse.getState().metaData().getIndexSafe(leaderIndex); if (indexMetaData.getMappings().isEmpty()) { assert indexMetaData.getMappingVersion() == 1; @@ -186,7 +186,7 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor { + ccrLicenseChecker.hasPrivilegesToFollowIndices(remoteClient, indices, e -> { if (e == null) { - leaderClient.admin().cluster().state( + remoteClient.admin().cluster().state( clusterStateRequest, ActionListener.wrap( clusterStateResponse -> {