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.
This commit is contained in:
Tim Brooks 2018-12-05 08:11:47 -07:00 committed by GitHub
parent a3c1c6938a
commit 068c856e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 9 deletions

View File

@ -10,7 +10,6 @@ import org.apache.lucene.util.SetOnce;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
@ -151,7 +150,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
return emptyList(); return emptyList();
} }
this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, (NodeClient) client)); this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, client));
return Arrays.asList( return Arrays.asList(
ccrLicenseChecker, ccrLicenseChecker,

View File

@ -8,7 +8,7 @@ package org.elasticsearch.xpack.ccr;
import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.support.PlainActionFuture; 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.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.transport.RemoteClusterAware; import org.elasticsearch.transport.RemoteClusterAware;
@ -22,9 +22,9 @@ import java.util.List;
class CcrRepositoryManager extends RemoteClusterAware { 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); super(settings);
this.client = client; this.client = client;
listenForUpdates(clusterService.getClusterSettings()); listenForUpdates(clusterService.getClusterSettings());
@ -36,12 +36,12 @@ class CcrRepositoryManager extends RemoteClusterAware {
if (addresses.isEmpty()) { if (addresses.isEmpty()) {
DeleteInternalCcrRepositoryRequest request = new DeleteInternalCcrRepositoryRequest(repositoryName); DeleteInternalCcrRepositoryRequest request = new DeleteInternalCcrRepositoryRequest(repositoryName);
PlainActionFuture<DeleteInternalCcrRepositoryAction.DeleteInternalCcrRepositoryResponse> f = PlainActionFuture.newFuture(); PlainActionFuture<DeleteInternalCcrRepositoryAction.DeleteInternalCcrRepositoryResponse> 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"; assert f.isDone() : "Should be completed as it is executed synchronously";
} else { } else {
ActionRequest request = new PutInternalCcrRepositoryRequest(repositoryName, CcrRepository.TYPE); ActionRequest request = new PutInternalCcrRepositoryRequest(repositoryName, CcrRepository.TYPE);
PlainActionFuture<PutInternalCcrRepositoryAction.PutInternalCcrRepositoryResponse> f = PlainActionFuture.newFuture(); PlainActionFuture<PutInternalCcrRepositoryAction.PutInternalCcrRepositoryResponse> 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"; assert f.isDone() : "Should be completed as it is executed synchronously";
} }
} }

View File

@ -23,7 +23,7 @@ import java.io.IOException;
public class DeleteInternalCcrRepositoryAction extends Action<DeleteInternalCcrRepositoryAction.DeleteInternalCcrRepositoryResponse> { public class DeleteInternalCcrRepositoryAction extends Action<DeleteInternalCcrRepositoryAction.DeleteInternalCcrRepositoryResponse> {
public static final DeleteInternalCcrRepositoryAction INSTANCE = new DeleteInternalCcrRepositoryAction(); 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() { private DeleteInternalCcrRepositoryAction() {
super(NAME); super(NAME);

View File

@ -23,7 +23,7 @@ import java.io.IOException;
public class PutInternalCcrRepositoryAction extends Action<PutInternalCcrRepositoryAction.PutInternalCcrRepositoryResponse> { public class PutInternalCcrRepositoryAction extends Action<PutInternalCcrRepositoryAction.PutInternalCcrRepositoryResponse> {
public static final PutInternalCcrRepositoryAction INSTANCE = new PutInternalCcrRepositoryAction(); 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() { private PutInternalCcrRepositoryAction() {
super(NAME); super(NAME);