From ca3c20a889ce847af0027aafbe4c66b5390d7a14 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 5 Dec 2018 08:11:47 -0700 Subject: [PATCH 1/2] Rename internal repository actions to be internal (#36244) This is a follow-up to #36086. It renames the internal repository actions to be prefixed by "internal". This allows the system user to execute the actions. Additionally, this PR stops casting Client to NodeClient. The client we have is a NodeClient so executing the actions will be local. --- .../src/main/java/org/elasticsearch/xpack/ccr/Ccr.java | 3 +-- .../elasticsearch/xpack/ccr/CcrRepositoryManager.java | 10 +++++----- .../DeleteInternalCcrRepositoryAction.java | 2 +- .../repositories/PutInternalCcrRepositoryAction.java | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java index 1d6bf82fe54e5..ed6413429932c 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.Client; -import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; @@ -157,7 +156,7 @@ public Collection createComponents( return emptyList(); } - this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, (NodeClient) client)); + this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, client)); return Arrays.asList( ccrLicenseChecker, diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java index 842cbef7a4684..6cdee878b1f53 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.ccr; import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.RemoteClusterAware; @@ -21,9 +21,9 @@ class CcrRepositoryManager extends RemoteClusterAware { - private final NodeClient client; + private final Client client; - CcrRepositoryManager(Settings settings, ClusterService clusterService, NodeClient client) { + CcrRepositoryManager(Settings settings, ClusterService clusterService, Client client) { super(settings); this.client = client; listenForUpdates(clusterService.getClusterSettings()); @@ -35,12 +35,12 @@ protected void updateRemoteCluster(String clusterAlias, List addresses, if (addresses.isEmpty()) { DeleteInternalCcrRepositoryRequest request = new DeleteInternalCcrRepositoryRequest(repositoryName); PlainActionFuture f = PlainActionFuture.newFuture(); - client.executeLocally(DeleteInternalCcrRepositoryAction.INSTANCE, request, f); + client.execute(DeleteInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } else { PutInternalCcrRepositoryRequest request = new PutInternalCcrRepositoryRequest(repositoryName, CcrRepository.TYPE); PlainActionFuture f = PlainActionFuture.newFuture(); - client.executeLocally(PutInternalCcrRepositoryAction.INSTANCE, request, f); + client.execute(PutInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java index bdb1bc895411e..c7b60e5b17d73 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java @@ -26,7 +26,7 @@ public class DeleteInternalCcrRepositoryAction extends GenericAction { public static final DeleteInternalCcrRepositoryAction INSTANCE = new DeleteInternalCcrRepositoryAction(); - public static final String NAME = "cluster:admin/ccr/internal_repository/delete"; + public static final String NAME = "internal:admin/ccr/internal_repository/delete"; private DeleteInternalCcrRepositoryAction() { super(NAME); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java index 41b75b2c2ad51..7c0054e949fd9 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java @@ -26,7 +26,7 @@ public class PutInternalCcrRepositoryAction extends GenericAction { public static final PutInternalCcrRepositoryAction INSTANCE = new PutInternalCcrRepositoryAction(); - public static final String NAME = "cluster:admin/ccr/internal_repository/put"; + public static final String NAME = "internal:admin/ccr/internal_repository/put"; private PutInternalCcrRepositoryAction() { super(NAME); From 473ef8c9c0ddf5a904b19ed631c7a646d3f9ac83 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Fri, 7 Dec 2018 09:37:25 -0700 Subject: [PATCH 2/2] WIP --- .../src/main/java/org/elasticsearch/xpack/ccr/Ccr.java | 3 ++- .../elasticsearch/xpack/ccr/CcrRepositoryManager.java | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java index ed6413429932c..1d6bf82fe54e5 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; @@ -156,7 +157,7 @@ public Collection createComponents( return emptyList(); } - this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, client)); + this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, (NodeClient) client)); return Arrays.asList( ccrLicenseChecker, diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java index 6cdee878b1f53..842cbef7a4684 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.ccr; import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.RemoteClusterAware; @@ -21,9 +21,9 @@ class CcrRepositoryManager extends RemoteClusterAware { - private final Client client; + private final NodeClient client; - CcrRepositoryManager(Settings settings, ClusterService clusterService, Client client) { + CcrRepositoryManager(Settings settings, ClusterService clusterService, NodeClient client) { super(settings); this.client = client; listenForUpdates(clusterService.getClusterSettings()); @@ -35,12 +35,12 @@ protected void updateRemoteCluster(String clusterAlias, List addresses, if (addresses.isEmpty()) { DeleteInternalCcrRepositoryRequest request = new DeleteInternalCcrRepositoryRequest(repositoryName); PlainActionFuture f = PlainActionFuture.newFuture(); - client.execute(DeleteInternalCcrRepositoryAction.INSTANCE, request, f); + client.executeLocally(DeleteInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } else { PutInternalCcrRepositoryRequest request = new PutInternalCcrRepositoryRequest(repositoryName, CcrRepository.TYPE); PlainActionFuture f = PlainActionFuture.newFuture(); - client.execute(PutInternalCcrRepositoryAction.INSTANCE, request, f); + client.executeLocally(PutInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } }