From 1df171e26ac82803566d176532b6d0e3df177a28 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 07:56:06 +0200 Subject: [PATCH 1/6] Renamed CCR APIs Renamed: * `/{index}/_ccr/create_and_follow` to `/{index}/_ccr/follow` * `/{index}/_ccr/unfollow` to `/{index}/_ccr/pause_follow` * `/{index}/_ccr/follow` to `/{index}/_ccr/resume_follow` Relates to #33931 --- .../test/ccr/follow_and_unfollow.yml | 6 +- .../rest-api-spec/test/ccr/stats.yml | 4 +- .../java/org/elasticsearch/xpack/ccr/Ccr.java | 30 +++--- .../ccr/action/AutoFollowCoordinator.java | 14 +-- .../xpack/ccr/action/ShardChangesAction.java | 4 +- ...Action.java => TransportFollowAction.java} | 48 ++++----- ...n.java => TransportPauseFollowAction.java} | 12 +-- ....java => TransportResumeFollowAction.java} | 20 ++-- ...IndexAction.java => RestFollowAction.java} | 14 +-- ...Action.java => RestPauseFollowAction.java} | 12 +-- ...ction.java => RestResumeFollowAction.java} | 12 +-- .../elasticsearch/xpack/ccr/CcrLicenseIT.java | 22 ++-- .../xpack/ccr/ShardChangesIT.java | 100 +++++++++--------- .../action/AutoFollowCoordinatorTests.java | 10 +- .../CreateAndFollowIndexRequestTests.java | 12 +-- .../CreateAndFollowIndexResponseTests.java | 12 +-- .../ccr/action/FollowIndexRequestTests.java | 20 ++-- .../ShardFollowNodeTaskRandomTests.java | 2 +- ... => TransportResumeFollowActionTests.java} | 8 +- ...llowIndexAction.java => FollowAction.java} | 16 +-- ...ndexAction.java => PauseFollowAction.java} | 8 +- .../action/PutAutoFollowPatternAction.java | 4 +- ...dexAction.java => ResumeFollowAction.java} | 10 +- .../xpack/core/ccr/client/CcrClient.java | 36 +++---- ...{ccr.follow_index.json => ccr.follow.json} | 6 +- ...ollow_index.json => ccr.pause_follow.json} | 8 +- ...llow_index.json => ccr.resume_follow.json} | 8 +- 27 files changed, 229 insertions(+), 229 deletions(-) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/{TransportCreateAndFollowIndexAction.java => TransportFollowAction.java} (84%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/{TransportUnfollowIndexAction.java => TransportPauseFollowAction.java} (91%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/{TransportFollowIndexAction.java => TransportResumeFollowAction.java} (97%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/{RestCreateAndFollowIndexAction.java => RestFollowAction.java} (61%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/{RestUnfollowIndexAction.java => RestPauseFollowAction.java} (73%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/{RestFollowIndexAction.java => RestResumeFollowAction.java} (77%) rename x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/{TransportFollowIndexActionTests.java => TransportResumeFollowActionTests.java} (97%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/{CreateAndFollowIndexAction.java => FollowAction.java} (89%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/{UnfollowIndexAction.java => PauseFollowAction.java} (85%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/{FollowIndexAction.java => ResumeFollowAction.java} (97%) rename x-pack/plugin/src/test/resources/rest-api-spec/api/{ccr.follow_index.json => ccr.follow.json} (80%) rename x-pack/plugin/src/test/resources/rest-api-spec/api/{ccr.unfollow_index.json => ccr.pause_follow.json} (66%) rename x-pack/plugin/src/test/resources/rest-api-spec/api/{ccr.create_and_follow_index.json => ccr.resume_follow.json} (66%) diff --git a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml index 6c95f307c256e..c24b301032f68 100644 --- a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml +++ b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml @@ -16,7 +16,7 @@ - is_true: acknowledged - do: - ccr.create_and_follow_index: + ccr.follow: index: bar body: leader_index: foo @@ -30,13 +30,13 @@ - is_true: acknowledged - do: - ccr.follow_index: + ccr.resume_follow: index: bar body: leader_index: foo - is_true: acknowledged - do: - ccr.unfollow_index: + ccr.pause_follow: index: bar - is_true: acknowledged diff --git a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml index 431629b1d23b8..1c1170acf23a5 100644 --- a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml +++ b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml @@ -15,7 +15,7 @@ type: keyword - do: - ccr.create_and_follow_index: + ccr.follow: index: bar body: leader_index: foo @@ -51,7 +51,7 @@ - gte: { bar.0.time_since_last_fetch_millis: -1 } - do: - ccr.unfollow_index: + ccr.pause_follow: index: bar - is_true: acknowledged 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 1ef66d569851f..64e8b4b5d2033 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 @@ -52,26 +52,26 @@ import org.elasticsearch.xpack.ccr.action.ShardFollowTask; import org.elasticsearch.xpack.ccr.action.ShardFollowTasksExecutor; import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction; -import org.elasticsearch.xpack.ccr.action.TransportCreateAndFollowIndexAction; +import org.elasticsearch.xpack.ccr.action.TransportFollowAction; import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction; -import org.elasticsearch.xpack.ccr.action.TransportFollowIndexAction; +import org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction; import org.elasticsearch.xpack.ccr.action.TransportPutAutoFollowPatternAction; -import org.elasticsearch.xpack.ccr.action.TransportUnfollowIndexAction; +import org.elasticsearch.xpack.ccr.action.TransportPauseFollowAction; import org.elasticsearch.xpack.ccr.action.bulk.BulkShardOperationsAction; import org.elasticsearch.xpack.ccr.action.bulk.TransportBulkShardOperationsAction; import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory; import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction; -import org.elasticsearch.xpack.ccr.rest.RestCreateAndFollowIndexAction; +import org.elasticsearch.xpack.ccr.rest.RestFollowAction; import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction; -import org.elasticsearch.xpack.ccr.rest.RestFollowIndexAction; +import org.elasticsearch.xpack.ccr.rest.RestResumeFollowAction; import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction; -import org.elasticsearch.xpack.ccr.rest.RestUnfollowIndexAction; +import org.elasticsearch.xpack.ccr.rest.RestPauseFollowAction; import org.elasticsearch.xpack.core.XPackPlugin; import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; +import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import java.util.Arrays; import java.util.Collection; @@ -161,9 +161,9 @@ public List> getPersistentTasksExecutor(ClusterServic new ActionHandler<>(CcrStatsAction.INSTANCE, TransportCcrStatsAction.class), new ActionHandler<>(AutoFollowStatsAction.INSTANCE, TransportAutoFollowStatsAction.class), // follow actions - new ActionHandler<>(CreateAndFollowIndexAction.INSTANCE, TransportCreateAndFollowIndexAction.class), - new ActionHandler<>(FollowIndexAction.INSTANCE, TransportFollowIndexAction.class), - new ActionHandler<>(UnfollowIndexAction.INSTANCE, TransportUnfollowIndexAction.class), + new ActionHandler<>(FollowAction.INSTANCE, TransportFollowAction.class), + new ActionHandler<>(ResumeFollowAction.INSTANCE, TransportResumeFollowAction.class), + new ActionHandler<>(PauseFollowAction.INSTANCE, TransportPauseFollowAction.class), // auto-follow actions new ActionHandler<>(DeleteAutoFollowPatternAction.INSTANCE, TransportDeleteAutoFollowPatternAction.class), new ActionHandler<>(PutAutoFollowPatternAction.INSTANCE, TransportPutAutoFollowPatternAction.class), @@ -183,9 +183,9 @@ public List getRestHandlers(Settings settings, RestController restC new RestCcrStatsAction(settings, restController), new RestAutoFollowStatsAction(settings, restController), // follow APIs - new RestCreateAndFollowIndexAction(settings, restController), - new RestFollowIndexAction(settings, restController), - new RestUnfollowIndexAction(settings, restController), + new RestFollowAction(settings, restController), + new RestResumeFollowAction(settings, restController), + new RestPauseFollowAction(settings, restController), // auto-follow APIs new RestDeleteAutoFollowPatternAction(settings, restController), new RestPutAutoFollowPatternAction(settings, restController), diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java index b429227207903..3557339323e3e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java @@ -33,8 +33,8 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.util.ArrayList; import java.util.Collections; @@ -183,13 +183,13 @@ void getLeaderClusterState(final Map headers, @Override void createAndFollow(Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler) { Client followerClient = CcrLicenseChecker.wrapClient(client, headers); - CreateAndFollowIndexAction.Request request = new CreateAndFollowIndexAction.Request(followRequest); + FollowAction.Request request = new FollowAction.Request(followRequest); followerClient.execute( - CreateAndFollowIndexAction.INSTANCE, + FollowAction.INSTANCE, request, ActionListener.wrap(r -> successHandler.run(), failureHandler) ); @@ -305,7 +305,7 @@ private void followLeaderIndex(String clusterAlias, String leaderIndexNameWithClusterAliasPrefix = clusterAlias.equals("_local_") ? leaderIndexName : clusterAlias + ":" + leaderIndexName; - FollowIndexAction.Request request = new FollowIndexAction.Request(); + ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setLeaderIndex(leaderIndexNameWithClusterAliasPrefix); request.setFollowerIndex(followIndexName); request.setMaxBatchOperationCount(pattern.getMaxBatchOperationCount()); @@ -399,7 +399,7 @@ abstract void getLeaderClusterState( abstract void createAndFollow( Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler ); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardChangesAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardChangesAction.java index 937ca0a009613..be6d18864f959 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardChangesAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardChangesAction.java @@ -63,8 +63,8 @@ public static class Request extends SingleShardRequest { private int maxOperationCount; private ShardId shardId; private String expectedHistoryUUID; - private TimeValue pollTimeout = TransportFollowIndexAction.DEFAULT_POLL_TIMEOUT; - private long maxOperationSizeInBytes = TransportFollowIndexAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES; + private TimeValue pollTimeout = TransportResumeFollowAction.DEFAULT_POLL_TIMEOUT; + private long maxOperationSizeInBytes = TransportResumeFollowAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES; public Request(ShardId shardId, String expectedHistoryUUID) { super(shardId.getIndexName()); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportCreateAndFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java similarity index 84% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportCreateAndFollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java index fd421a9380b36..13d17a6412114 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportCreateAndFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java @@ -37,8 +37,8 @@ import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; import org.elasticsearch.xpack.ccr.CcrSettings; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.util.HashMap; import java.util.List; @@ -46,8 +46,8 @@ import java.util.Objects; import java.util.function.Consumer; -public final class TransportCreateAndFollowIndexAction - extends TransportMasterNodeAction { +public final class TransportFollowAction + extends TransportMasterNodeAction { private final Client client; private final AllocationService allocationService; @@ -56,7 +56,7 @@ public final class TransportCreateAndFollowIndexAction private final CcrLicenseChecker ccrLicenseChecker; @Inject - public TransportCreateAndFollowIndexAction( + public TransportFollowAction( final Settings settings, final ThreadPool threadPool, final TransportService transportService, @@ -68,13 +68,13 @@ public TransportCreateAndFollowIndexAction( final CcrLicenseChecker ccrLicenseChecker) { super( settings, - CreateAndFollowIndexAction.NAME, + FollowAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, - CreateAndFollowIndexAction.Request::new); + FollowAction.Request::new); this.client = client; this.allocationService = allocationService; this.remoteClusterService = transportService.getRemoteClusterService(); @@ -88,15 +88,15 @@ protected String executor() { } @Override - protected CreateAndFollowIndexAction.Response newResponse() { - return new CreateAndFollowIndexAction.Response(); + protected FollowAction.Response newResponse() { + return new FollowAction.Response(); } @Override protected void masterOperation( - final CreateAndFollowIndexAction.Request request, + final FollowAction.Request request, final ClusterState state, - final ActionListener listener) throws Exception { + final ActionListener listener) throws Exception { if (ccrLicenseChecker.isCcrAllowed() == false) { listener.onFailure(LicenseUtils.newComplianceException("ccr")); return; @@ -116,9 +116,9 @@ protected void masterOperation( } private void createFollowerIndexAndFollowLocalIndex( - final CreateAndFollowIndexAction.Request request, + final FollowAction.Request request, final ClusterState state, - final ActionListener listener) { + final ActionListener listener) { // following an index in local cluster, so use local cluster state to fetch leader index metadata final String leaderIndex = request.getFollowRequest().getLeaderIndex(); final IndexMetaData leaderIndexMetadata = state.getMetaData().index(leaderIndex); @@ -134,10 +134,10 @@ private void createFollowerIndexAndFollowLocalIndex( } private void createFollowerIndexAndFollowRemoteIndex( - final CreateAndFollowIndexAction.Request request, + final FollowAction.Request request, final String clusterAlias, final String leaderIndex, - final ActionListener listener) { + final ActionListener listener) { ccrLicenseChecker.checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs( client, clusterAlias, @@ -149,8 +149,8 @@ private void createFollowerIndexAndFollowRemoteIndex( private void createFollowerIndex( final IndexMetaData leaderIndexMetaData, final String[] historyUUIDs, - final CreateAndFollowIndexAction.Request request, - final ActionListener listener) { + final FollowAction.Request request, + final ActionListener listener) { if (leaderIndexMetaData == null) { listener.onFailure(new IllegalArgumentException("leader index [" + request.getFollowRequest().getLeaderIndex() + "] does not exist")); @@ -162,7 +162,7 @@ private void createFollowerIndex( if (result) { initiateFollowing(request, listener); } else { - listener.onResponse(new CreateAndFollowIndexAction.Response(true, false, false)); + listener.onResponse(new FollowAction.Response(true, false, false)); } }, listener::onFailure); @@ -228,23 +228,23 @@ public ClusterState execute(final ClusterState currentState) throws Exception { } private void initiateFollowing( - final CreateAndFollowIndexAction.Request request, - final ActionListener listener) { + final FollowAction.Request request, + final ActionListener listener) { activeShardsObserver.waitForActiveShards(new String[]{request.getFollowRequest().getFollowerIndex()}, ActiveShardCount.DEFAULT, request.timeout(), result -> { if (result) { - client.execute(FollowIndexAction.INSTANCE, request.getFollowRequest(), ActionListener.wrap( - r -> listener.onResponse(new CreateAndFollowIndexAction.Response(true, true, r.isAcknowledged())), + client.execute(ResumeFollowAction.INSTANCE, request.getFollowRequest(), ActionListener.wrap( + r -> listener.onResponse(new FollowAction.Response(true, true, r.isAcknowledged())), listener::onFailure )); } else { - listener.onResponse(new CreateAndFollowIndexAction.Response(true, false, false)); + listener.onResponse(new FollowAction.Response(true, false, false)); } }, listener::onFailure); } @Override - protected ClusterBlockException checkBlock(final CreateAndFollowIndexAction.Request request, final ClusterState state) { + protected ClusterBlockException checkBlock(final FollowAction.Request request, final ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, request.getFollowRequest().getFollowerIndex()); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java similarity index 91% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java index 05cde0eab8523..041d5e3f429e7 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java @@ -19,24 +19,24 @@ import org.elasticsearch.persistent.PersistentTasksService; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; -public class TransportUnfollowIndexAction extends HandledTransportAction { +public class TransportPauseFollowAction extends HandledTransportAction { private final Client client; private final PersistentTasksService persistentTasksService; @Inject - public TransportUnfollowIndexAction( + public TransportPauseFollowAction( final Settings settings, final TransportService transportService, final ActionFilters actionFilters, final Client client, final PersistentTasksService persistentTasksService) { - super(settings, UnfollowIndexAction.NAME, transportService, actionFilters, UnfollowIndexAction.Request::new); + super(settings, PauseFollowAction.NAME, transportService, actionFilters, PauseFollowAction.Request::new); this.client = client; this.persistentTasksService = persistentTasksService; } @@ -44,7 +44,7 @@ public TransportUnfollowIndexAction( @Override protected void doExecute( final Task task, - final UnfollowIndexAction.Request request, + final PauseFollowAction.Request request, final ActionListener listener) { client.admin().cluster().state(new ClusterStateRequest(), ActionListener.wrap(r -> { @@ -102,4 +102,4 @@ void finalizeResponse() { }, listener::onFailure)); } -} \ No newline at end of file +} diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java similarity index 97% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java index e9ee38fd1f9e2..902875a3ff7f5 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java @@ -40,7 +40,7 @@ import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; import org.elasticsearch.xpack.ccr.CcrSettings; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.io.IOException; import java.util.Collections; @@ -54,7 +54,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.stream.Collectors; -public class TransportFollowIndexAction extends HandledTransportAction { +public class TransportResumeFollowAction extends HandledTransportAction { static final long DEFAULT_MAX_BATCH_SIZE_IN_BYTES = Long.MAX_VALUE; private static final TimeValue DEFAULT_MAX_RETRY_DELAY = new TimeValue(500); @@ -73,7 +73,7 @@ public class TransportFollowIndexAction extends HandledTransportAction listener) { if (ccrLicenseChecker.isCcrAllowed() == false) { listener.onFailure(LicenseUtils.newComplianceException("ccr")); @@ -115,7 +115,7 @@ protected void doExecute(final Task task, } } - private void followLocalIndex(final FollowIndexAction.Request request, + private void followLocalIndex(final ResumeFollowAction.Request request, final ActionListener listener) { final ClusterState state = clusterService.state(); final IndexMetaData followerIndexMetadata = state.getMetaData().index(request.getFollowerIndex()); @@ -134,7 +134,7 @@ private void followLocalIndex(final FollowIndexAction.Request request, } private void followRemoteIndex( - final FollowIndexAction.Request request, + final ResumeFollowAction.Request request, final String clusterAlias, final String leaderIndex, final ActionListener listener) { @@ -165,7 +165,7 @@ private void followRemoteIndex( * */ void start( - FollowIndexAction.Request request, + ResumeFollowAction.Request request, String clusterNameAlias, IndexMetaData leaderIndexMetadata, IndexMetaData followIndexMetadata, @@ -233,7 +233,7 @@ void finalizeResponse() { } static void validate( - final FollowIndexAction.Request request, + final ResumeFollowAction.Request request, final IndexMetaData leaderIndex, final IndexMetaData followIndex, final String[] leaderIndexHistoryUUID, @@ -300,7 +300,7 @@ static void validate( private static ShardFollowTask createShardFollowTask( int shardId, String clusterAliasName, - FollowIndexAction.Request request, + ResumeFollowAction.Request request, IndexMetaData leaderIndexMetadata, IndexMetaData followIndexMetadata, String recordedLeaderShardHistoryUUID, diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCreateAndFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java similarity index 61% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCreateAndFollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java index 8816760f52617..5a737afab019a 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCreateAndFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java @@ -14,24 +14,24 @@ import java.io.IOException; -import static org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction.INSTANCE; -import static org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction.Request; +import static org.elasticsearch.xpack.core.ccr.action.FollowAction.INSTANCE; +import static org.elasticsearch.xpack.core.ccr.action.FollowAction.Request; -public class RestCreateAndFollowIndexAction extends BaseRestHandler { +public class RestFollowAction extends BaseRestHandler { - public RestCreateAndFollowIndexAction(Settings settings, RestController controller) { + public RestFollowAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(RestRequest.Method.POST, "/{index}/_ccr/create_and_follow", this); + controller.registerHandler(RestRequest.Method.PUT, "/{index}/_ccr/follow", this); } @Override public String getName() { - return "ccr_create_and_follow_index_action"; + return "ccr_follow_action"; } @Override protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { - Request request = new Request(RestFollowIndexAction.createRequest(restRequest)); + Request request = new Request(RestResumeFollowAction.createRequest(restRequest)); return channel -> client.execute(INSTANCE, request, new RestToXContentListener<>(channel)); } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java similarity index 73% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java index 9a82717b621bd..9d4df8d856716 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestUnfollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPauseFollowAction.java @@ -14,19 +14,19 @@ import java.io.IOException; -import static org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction.INSTANCE; -import static org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction.Request; +import static org.elasticsearch.xpack.core.ccr.action.PauseFollowAction.INSTANCE; +import static org.elasticsearch.xpack.core.ccr.action.PauseFollowAction.Request; -public class RestUnfollowIndexAction extends BaseRestHandler { +public class RestPauseFollowAction extends BaseRestHandler { - public RestUnfollowIndexAction(Settings settings, RestController controller) { + public RestPauseFollowAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(RestRequest.Method.POST, "/{index}/_ccr/unfollow", this); + controller.registerHandler(RestRequest.Method.POST, "/{index}/_ccr/pause_follow", this); } @Override public String getName() { - return "ccr_unfollow_index_action"; + return "ccr_pause_follow_action"; } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java similarity index 77% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowIndexAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java index 8a1d7d778bd86..62b3f6323ab88 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestResumeFollowAction.java @@ -15,19 +15,19 @@ import java.io.IOException; -import static org.elasticsearch.xpack.core.ccr.action.FollowIndexAction.INSTANCE; -import static org.elasticsearch.xpack.core.ccr.action.FollowIndexAction.Request; +import static org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction.INSTANCE; +import static org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction.Request; -public class RestFollowIndexAction extends BaseRestHandler { +public class RestResumeFollowAction extends BaseRestHandler { - public RestFollowIndexAction(Settings settings, RestController controller) { + public RestResumeFollowAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(RestRequest.Method.POST, "/{index}/_ccr/follow", this); + controller.registerHandler(RestRequest.Method.POST, "/{index}/_ccr/resume_follow", this); } @Override public String getName() { - return "ccr_follow_index_action"; + return "ccr_resume_follow_action"; } @Override diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java index 434f524b25535..d68dcc5d5a1bf 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java @@ -23,8 +23,8 @@ import org.elasticsearch.test.MockLogAppender; import org.elasticsearch.xpack.ccr.action.AutoFollowCoordinator; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction; @@ -44,10 +44,10 @@ protected Collection> getPlugins() { } public void testThatFollowingIndexIsUnavailableWithNonCompliantLicense() throws InterruptedException { - final FollowIndexAction.Request followRequest = getFollowRequest(); + final ResumeFollowAction.Request followRequest = getFollowRequest(); final CountDownLatch latch = new CountDownLatch(1); client().execute( - FollowIndexAction.INSTANCE, + ResumeFollowAction.INSTANCE, followRequest, new ActionListener() { @Override @@ -66,15 +66,15 @@ public void onFailure(final Exception e) { } public void testThatCreateAndFollowingIndexIsUnavailableWithNonCompliantLicense() throws InterruptedException { - final FollowIndexAction.Request followRequest = getFollowRequest(); - final CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); + final ResumeFollowAction.Request followRequest = getFollowRequest(); + final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); final CountDownLatch latch = new CountDownLatch(1); client().execute( - CreateAndFollowIndexAction.INSTANCE, + FollowAction.INSTANCE, createAndFollowRequest, - new ActionListener() { + new ActionListener() { @Override - public void onResponse(final CreateAndFollowIndexAction.Response response) { + public void onResponse(final FollowAction.Response response) { latch.countDown(); fail(); } @@ -191,8 +191,8 @@ private void assertNonCompliantLicense(final Exception e) { assertThat(e.getMessage(), equalTo("current license is non-compliant for [ccr]")); } - private FollowIndexAction.Request getFollowRequest() { - FollowIndexAction.Request request = new FollowIndexAction.Request(); + private ResumeFollowAction.Request getFollowRequest() { + ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setLeaderIndex("leader"); request.setFollowerIndex("follower"); request.setMaxRetryDelay(TimeValue.timeValueMillis(10)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java index 78715654a05e3..6e91cbbb29007 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java @@ -46,9 +46,9 @@ import org.elasticsearch.xpack.ccr.action.ShardFollowTask; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; -import org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; +import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import java.io.IOException; import java.util.Arrays; @@ -171,9 +171,9 @@ public void testFollowIndex() throws Exception { assertAcked(client().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureYellow("index1"); - final FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - final CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); final int firstBatchNumDocs = randomIntBetween(2, 64); logger.info("Indexing [{}] docs as first batch", firstBatchNumDocs); @@ -198,7 +198,7 @@ public void testFollowIndex() throws Exception { } unfollowIndex("index2"); - client().execute(FollowIndexAction.INSTANCE, followRequest).get(); + client().execute(ResumeFollowAction.INSTANCE, followRequest).get(); final int secondBatchNumDocs = randomIntBetween(2, 64); logger.info("Indexing [{}] docs as second batch", secondBatchNumDocs); for (int i = firstBatchNumDocs; i < firstBatchNumDocs + secondBatchNumDocs; i++) { @@ -229,9 +229,9 @@ public void testSyncMappings() throws Exception { assertAcked(client().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON)); ensureYellow("index1"); - final FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - final CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); final long firstBatchNumDocs = randomIntBetween(2, 64); for (long i = 0; i < firstBatchNumDocs; i++) { @@ -269,9 +269,9 @@ public void testNoMappingDefined() throws Exception { .build())); ensureGreen("index1"); - final FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - final CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); client().prepareIndex("index1", "doc", "1").setSource("{\"f\":1}", XContentType.JSON).get(); assertBusy(() -> assertThat(client().prepareSearch("index2").get().getHits().totalHits, equalTo(1L))); @@ -319,13 +319,13 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) long numDocsIndexed = Math.min(3000 * 2, randomLongBetween(maxReadSize, maxReadSize * 10)); atLeastDocsIndexed("index1", numDocsIndexed / 3); - FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); + ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); followRequest.setMaxBatchOperationCount(maxReadSize); followRequest.setMaxConcurrentReadBatches(randomIntBetween(2, 10)); followRequest.setMaxConcurrentWriteBatches(randomIntBetween(2, 10)); followRequest.setMaxWriteBufferSize(randomIntBetween(1024, 10240)); - CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); atLeastDocsIndexed("index1", numDocsIndexed); run.set(false); @@ -360,11 +360,11 @@ public void testFollowIndexAndCloseNode() throws Exception { }); thread.start(); - FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); + ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); followRequest.setMaxBatchOperationCount(randomIntBetween(32, 2048)); followRequest.setMaxConcurrentReadBatches(randomIntBetween(2, 10)); followRequest.setMaxConcurrentWriteBatches(randomIntBetween(2, 10)); - client().execute(CreateAndFollowIndexAction.INSTANCE, new CreateAndFollowIndexAction.Request(followRequest)).get(); + client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest)).get(); long maxNumDocsReplicated = Math.min(1000, randomLongBetween(followRequest.getMaxBatchOperationCount(), followRequest.getMaxBatchOperationCount() * 10)); @@ -388,8 +388,8 @@ public void testFollowIndexWithNestedField() throws Exception { internalCluster().ensureAtLeastNumDataNodes(2); ensureGreen("index1"); - final FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - client().execute(CreateAndFollowIndexAction.INSTANCE, new CreateAndFollowIndexAction.Request(followRequest)).get(); + final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest)).get(); final int numDocs = randomIntBetween(2, 64); for (int i = 0; i < numDocs; i++) { @@ -422,31 +422,31 @@ public void testFollowIndexWithNestedField() throws Exception { } public void testUnfollowNonExistingIndex() { - UnfollowIndexAction.Request unfollowRequest = new UnfollowIndexAction.Request(); + PauseFollowAction.Request unfollowRequest = new PauseFollowAction.Request(); unfollowRequest.setFollowIndex("non-existing-index"); - expectThrows(IllegalArgumentException.class, () -> client().execute(UnfollowIndexAction.INSTANCE, unfollowRequest).actionGet()); + expectThrows(IllegalArgumentException.class, () -> client().execute(PauseFollowAction.INSTANCE, unfollowRequest).actionGet()); } public void testFollowNonExistentIndex() throws Exception { assertAcked(client().admin().indices().prepareCreate("test-leader").get()); assertAcked(client().admin().indices().prepareCreate("test-follower").get()); // Leader index does not exist. - FollowIndexAction.Request followRequest1 = createFollowRequest("non-existent-leader", "test-follower"); - expectThrows(IndexNotFoundException.class, () -> client().execute(FollowIndexAction.INSTANCE, followRequest1).actionGet()); + ResumeFollowAction.Request followRequest1 = createFollowRequest("non-existent-leader", "test-follower"); + expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest1).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(CreateAndFollowIndexAction.INSTANCE, new CreateAndFollowIndexAction.Request(followRequest1)) + () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest1)) .actionGet()); // Follower index does not exist. - FollowIndexAction.Request followRequest2 = createFollowRequest("non-test-leader", "non-existent-follower"); - expectThrows(IndexNotFoundException.class, () -> client().execute(FollowIndexAction.INSTANCE, followRequest2).actionGet()); + ResumeFollowAction.Request followRequest2 = createFollowRequest("non-test-leader", "non-existent-follower"); + expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest2).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(CreateAndFollowIndexAction.INSTANCE, new CreateAndFollowIndexAction.Request(followRequest2)) + () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest2)) .actionGet()); // Both indices do not exist. - FollowIndexAction.Request followRequest3 = createFollowRequest("non-existent-leader", "non-existent-follower"); - expectThrows(IndexNotFoundException.class, () -> client().execute(FollowIndexAction.INSTANCE, followRequest3).actionGet()); + ResumeFollowAction.Request followRequest3 = createFollowRequest("non-existent-leader", "non-existent-follower"); + expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest3).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(CreateAndFollowIndexAction.INSTANCE, new CreateAndFollowIndexAction.Request(followRequest3)) + () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest3)) .actionGet()); } @@ -463,10 +463,10 @@ public void testFollowIndexMaxOperationSizeInBytes() throws Exception { client().prepareIndex("index1", "doc", Integer.toString(i)).setSource(source, XContentType.JSON).get(); } - FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); + ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); followRequest.setMaxOperationSizeInBytes(1L); - final CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); final Map firstBatchNumDocsPerShard = new HashMap<>(); final ShardStats[] firstBatchShardStats = client().admin().indices().prepareStats("index1").get().getIndex("index1").getShards(); @@ -492,22 +492,22 @@ public void testDontFollowTheWrongIndex() throws Exception { assertAcked(client().admin().indices().prepareCreate("index3").setSource(leaderIndexSettings, XContentType.JSON)); ensureGreen("index3"); - FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); followRequest = createFollowRequest("index3", "index4"); - createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); unfollowIndex("index2", "index4"); - FollowIndexAction.Request wrongRequest1 = createFollowRequest("index1", "index4"); + ResumeFollowAction.Request wrongRequest1 = createFollowRequest("index1", "index4"); Exception e = expectThrows(IllegalArgumentException.class, - () -> client().execute(FollowIndexAction.INSTANCE, wrongRequest1).actionGet()); + () -> client().execute(ResumeFollowAction.INSTANCE, wrongRequest1).actionGet()); assertThat(e.getMessage(), containsString("follow index [index4] should reference")); - FollowIndexAction.Request wrongRequest2 = createFollowRequest("index3", "index2"); - e = expectThrows(IllegalArgumentException.class, () -> client().execute(FollowIndexAction.INSTANCE, wrongRequest2).actionGet()); + ResumeFollowAction.Request wrongRequest2 = createFollowRequest("index3", "index2"); + e = expectThrows(IllegalArgumentException.class, () -> client().execute(ResumeFollowAction.INSTANCE, wrongRequest2).actionGet()); assertThat(e.getMessage(), containsString("follow index [index2] should reference")); } @@ -515,9 +515,9 @@ public void testAttemptToChangeCcrFollowingIndexSetting() throws Exception { String leaderIndexSettings = getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true")); assertAcked(client().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON).get()); ensureYellow("index1"); - FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2"); - CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest); - client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get(); + ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); + FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); unfollowIndex("index2"); client().admin().indices().close(new CloseIndexRequest("index2")).actionGet(); @@ -567,9 +567,9 @@ private CheckedRunnable assertTask(final int numberOfPrimaryShards, f private void unfollowIndex(String... indices) throws Exception { for (String index : indices) { - final UnfollowIndexAction.Request unfollowRequest = new UnfollowIndexAction.Request(); + final PauseFollowAction.Request unfollowRequest = new PauseFollowAction.Request(); unfollowRequest.setFollowIndex(index); - client().execute(UnfollowIndexAction.INSTANCE, unfollowRequest).get(); + client().execute(PauseFollowAction.INSTANCE, unfollowRequest).get(); } assertBusy(() -> { final ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); @@ -715,8 +715,8 @@ private void assertSameDocCount(String index1, String index2) throws Exception { }, 60, TimeUnit.SECONDS); } - public static FollowIndexAction.Request createFollowRequest(String leaderIndex, String followerIndex) { - FollowIndexAction.Request request = new FollowIndexAction.Request(); + public static ResumeFollowAction.Request createFollowRequest(String leaderIndex, String followerIndex) { + ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setLeaderIndex(leaderIndex); request.setFollowerIndex(followerIndex); request.setMaxRetryDelay(TimeValue.timeValueMillis(10)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java index 82f3153603946..8539c59a22cbe 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java @@ -21,7 +21,7 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.util.ArrayList; import java.util.Arrays; @@ -91,7 +91,7 @@ void getLeaderClusterState(Map headers, @Override void createAndFollow(Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler) { assertThat(headers, equalTo(autoFollowHeaders.get("remote"))); @@ -149,7 +149,7 @@ void getLeaderClusterState(Map headers, @Override void createAndFollow(Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler) { fail("should not get here"); @@ -210,7 +210,7 @@ void getLeaderClusterState(Map headers, @Override void createAndFollow(Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler) { assertThat(followRequest.getLeaderIndex(), equalTo("remote:logs-20190101")); @@ -272,7 +272,7 @@ void getLeaderClusterState(Map headers, @Override void createAndFollow(Map headers, - FollowIndexAction.Request followRequest, + ResumeFollowAction.Request followRequest, Runnable successHandler, Consumer failureHandler) { assertThat(followRequest.getLeaderIndex(), equalTo("remote:logs-20190101")); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java index c751ca5f00082..9e9111d019a3f 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java @@ -6,17 +6,17 @@ package org.elasticsearch.xpack.ccr.action; import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; -public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase { +public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase { @Override - protected CreateAndFollowIndexAction.Request createBlankInstance() { - return new CreateAndFollowIndexAction.Request(); + protected FollowAction.Request createBlankInstance() { + return new FollowAction.Request(); } @Override - protected CreateAndFollowIndexAction.Request createTestInstance() { - return new CreateAndFollowIndexAction.Request(FollowIndexRequestTests.createTestRequest()); + protected FollowAction.Request createTestInstance() { + return new FollowAction.Request(FollowIndexRequestTests.createTestRequest()); } } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java index 44ac21055a778..b7794f101726b 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java @@ -6,17 +6,17 @@ package org.elasticsearch.xpack.ccr.action; import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; -public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { +public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { @Override - protected CreateAndFollowIndexAction.Response createBlankInstance() { - return new CreateAndFollowIndexAction.Response(); + protected FollowAction.Response createBlankInstance() { + return new FollowAction.Response(); } @Override - protected CreateAndFollowIndexAction.Response createTestInstance() { - return new CreateAndFollowIndexAction.Response(randomBoolean(), randomBoolean(), randomBoolean()); + protected FollowAction.Response createTestInstance() { + return new FollowAction.Response(randomBoolean(), randomBoolean(), randomBoolean()); } } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java index 2bff73d223b57..2c4cd30d8e0db 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractStreamableXContentTestCase; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.io.IOException; @@ -17,21 +17,21 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -public class FollowIndexRequestTests extends AbstractStreamableXContentTestCase { +public class FollowIndexRequestTests extends AbstractStreamableXContentTestCase { @Override - protected FollowIndexAction.Request createBlankInstance() { - return new FollowIndexAction.Request(); + protected ResumeFollowAction.Request createBlankInstance() { + return new ResumeFollowAction.Request(); } @Override - protected FollowIndexAction.Request createTestInstance() { + protected ResumeFollowAction.Request createTestInstance() { return createTestRequest(); } @Override - protected FollowIndexAction.Request doParseInstance(XContentParser parser) throws IOException { - return FollowIndexAction.Request.fromXContent(parser, null); + protected ResumeFollowAction.Request doParseInstance(XContentParser parser) throws IOException { + return ResumeFollowAction.Request.fromXContent(parser, null); } @Override @@ -39,8 +39,8 @@ protected boolean supportsUnknownFields() { return false; } - static FollowIndexAction.Request createTestRequest() { - FollowIndexAction.Request request = new FollowIndexAction.Request(); + static ResumeFollowAction.Request createTestRequest() { + ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setLeaderIndex(randomAlphaOfLength(4)); request.setFollowerIndex(randomAlphaOfLength(4)); if (randomBoolean()) { @@ -68,7 +68,7 @@ static FollowIndexAction.Request createTestRequest() { } public void testValidate() { - FollowIndexAction.Request request = new FollowIndexAction.Request(); + ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setLeaderIndex("index1"); request.setFollowerIndex("index2"); request.setMaxRetryDelay(TimeValue.ZERO); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskRandomTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskRandomTests.java index e7d0987223bb9..c33fce335e6b1 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskRandomTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskRandomTests.java @@ -80,7 +80,7 @@ private ShardFollowNodeTask createShardFollowTask(int concurrency, TestRun testR new ShardId("leader_index", "", 0), testRun.maxOperationCount, concurrency, - TransportFollowIndexAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES, + TransportResumeFollowAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES, concurrency, 10240, TimeValue.timeValueMillis(10), diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java similarity index 97% rename from x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexActionTests.java rename to x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java index 8d4704566fd4d..b8e623c8d1b3d 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowIndexActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java @@ -17,7 +17,7 @@ import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrSettings; import org.elasticsearch.xpack.ccr.ShardChangesIT; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.io.IOException; import java.util.HashMap; @@ -25,17 +25,17 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; -import static org.elasticsearch.xpack.ccr.action.TransportFollowIndexAction.validate; +import static org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction.validate; import static org.hamcrest.Matchers.equalTo; -public class TransportFollowIndexActionTests extends ESTestCase { +public class TransportResumeFollowActionTests extends ESTestCase { public void testValidation() throws IOException { final Map customMetaData = new HashMap<>(); customMetaData.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, "uuid"); customMetaData.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, "_na_"); - FollowIndexAction.Request request = ShardChangesIT.createFollowRequest("index1", "index2"); + ResumeFollowAction.Request request = ShardChangesIT.createFollowRequest("index1", "index2"); String[] UUIDs = new String[]{"uuid"}; { // should fail, because leader index does not exist diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CreateAndFollowIndexAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java similarity index 89% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CreateAndFollowIndexAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java index ea63815c2b933..4ca6b6933c8b3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CreateAndFollowIndexAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java @@ -20,12 +20,12 @@ import java.io.IOException; import java.util.Objects; -public final class CreateAndFollowIndexAction extends Action { +public final class FollowAction extends Action { - public static final CreateAndFollowIndexAction INSTANCE = new CreateAndFollowIndexAction(); - public static final String NAME = "indices:admin/xpack/ccr/create_and_follow_index"; + public static final FollowAction INSTANCE = new FollowAction(); + public static final String NAME = "indices:admin/xpack/ccr/follow"; - private CreateAndFollowIndexAction() { + private FollowAction() { super(NAME); } @@ -36,9 +36,9 @@ public Response newResponse() { public static class Request extends AcknowledgedRequest implements IndicesRequest { - private FollowIndexAction.Request followRequest; + private ResumeFollowAction.Request followRequest; - public Request(FollowIndexAction.Request followRequest) { + public Request(ResumeFollowAction.Request followRequest) { this.followRequest = Objects.requireNonNull(followRequest); } @@ -46,7 +46,7 @@ public Request() { } - public FollowIndexAction.Request getFollowRequest() { + public ResumeFollowAction.Request getFollowRequest() { return followRequest; } @@ -68,7 +68,7 @@ public IndicesOptions indicesOptions() { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - followRequest = new FollowIndexAction.Request(); + followRequest = new ResumeFollowAction.Request(); followRequest.readFrom(in); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowIndexAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java similarity index 85% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowIndexAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java index 65ecd3dad2f8f..a5a45fea3f6b8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowIndexAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java @@ -15,12 +15,12 @@ import java.io.IOException; -public class UnfollowIndexAction extends Action { +public class PauseFollowAction extends Action { - public static final UnfollowIndexAction INSTANCE = new UnfollowIndexAction(); - public static final String NAME = "cluster:admin/xpack/ccr/unfollow_index"; + public static final PauseFollowAction INSTANCE = new PauseFollowAction(); + public static final String NAME = "cluster:admin/xpack/ccr/pause_follow"; - private UnfollowIndexAction() { + private PauseFollowAction() { super(NAME); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java index 03fcf2c153ed4..f13a29c59559b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java @@ -105,9 +105,9 @@ public ActionRequestValidationException validate() { maxRetryDelay.getStringRep() + "]"; validationException = addValidationError(message, validationException); } - if (maxRetryDelay.millis() > FollowIndexAction.MAX_RETRY_DELAY.millis()) { + if (maxRetryDelay.millis() > ResumeFollowAction.MAX_RETRY_DELAY.millis()) { String message = "[" + AutoFollowPattern.MAX_RETRY_DELAY.getPreferredName() + "] must be less than [" + - FollowIndexAction.MAX_RETRY_DELAY + + ResumeFollowAction.MAX_RETRY_DELAY + "] but was [" + maxRetryDelay.getStringRep() + "]"; validationException = addValidationError(message, validationException); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowIndexAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java similarity index 97% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowIndexAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java index c90ef63862b9a..f06dac2f0fe47 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowIndexAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java @@ -24,14 +24,14 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; -public final class FollowIndexAction extends Action { +public final class ResumeFollowAction extends Action { - public static final FollowIndexAction INSTANCE = new FollowIndexAction(); - public static final String NAME = "cluster:admin/xpack/ccr/follow_index"; + public static final ResumeFollowAction INSTANCE = new ResumeFollowAction(); + public static final String NAME = "cluster:admin/xpack/ccr/resume_follow"; public static final TimeValue MAX_RETRY_DELAY = TimeValue.timeValueMinutes(5); - private FollowIndexAction() { + private ResumeFollowAction() { super(NAME); } @@ -210,7 +210,7 @@ public ActionRequestValidationException validate() { maxRetryDelay.getStringRep() + "]"; e = addValidationError(message, e); } - if (maxRetryDelay != null && maxRetryDelay.millis() > FollowIndexAction.MAX_RETRY_DELAY.millis()) { + if (maxRetryDelay != null && maxRetryDelay.millis() > ResumeFollowAction.MAX_RETRY_DELAY.millis()) { String message = "[" + MAX_RETRY_DELAY_FIELD.getPreferredName() + "] must be less than [" + MAX_RETRY_DELAY + "] but was [" + maxRetryDelay.getStringRep() + "]"; e = addValidationError(message, e); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java index f2f76bcb846df..2e842504e5a56 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java @@ -13,12 +13,12 @@ import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.xpack.core.ccr.action.AutoFollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.FollowAction; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; -import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction; -import org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction; +import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import java.util.Objects; @@ -30,25 +30,25 @@ public CcrClient(final ElasticsearchClient client) { this.client = Objects.requireNonNull(client, "client"); } - public void createAndFollow( - final CreateAndFollowIndexAction.Request request, - final ActionListener listener) { - client.execute(CreateAndFollowIndexAction.INSTANCE, request, listener); + public void follow( + final FollowAction.Request request, + final ActionListener listener) { + client.execute(FollowAction.INSTANCE, request, listener); } - public ActionFuture createAndFollow(final CreateAndFollowIndexAction.Request request) { - final PlainActionFuture listener = PlainActionFuture.newFuture(); - client.execute(CreateAndFollowIndexAction.INSTANCE, request, listener); + public ActionFuture follow(final FollowAction.Request request) { + final PlainActionFuture listener = PlainActionFuture.newFuture(); + client.execute(FollowAction.INSTANCE, request, listener); return listener; } - public void follow(final FollowIndexAction.Request request, final ActionListener listener) { - client.execute(FollowIndexAction.INSTANCE, request, listener); + public void resumeFollow(final ResumeFollowAction.Request request, final ActionListener listener) { + client.execute(ResumeFollowAction.INSTANCE, request, listener); } - public ActionFuture follow(final FollowIndexAction.Request request) { + public ActionFuture resumeFollow(final ResumeFollowAction.Request request) { final PlainActionFuture listener = PlainActionFuture.newFuture(); - client.execute(FollowIndexAction.INSTANCE, request, listener); + client.execute(ResumeFollowAction.INSTANCE, request, listener); return listener; } @@ -75,13 +75,13 @@ public ActionFuture autoFollowStats(final AutoFo return listener; } - public void unfollow(final UnfollowIndexAction.Request request, final ActionListener listener) { - client.execute(UnfollowIndexAction.INSTANCE, request, listener); + public void pauseFollow(final PauseFollowAction.Request request, final ActionListener listener) { + client.execute(PauseFollowAction.INSTANCE, request, listener); } - public ActionFuture unfollow(final UnfollowIndexAction.Request request) { + public ActionFuture pauseFollow(final PauseFollowAction.Request request) { final PlainActionFuture listener = PlainActionFuture.newFuture(); - client.execute(UnfollowIndexAction.INSTANCE, request, listener); + client.execute(PauseFollowAction.INSTANCE, request, listener); return listener; } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json similarity index 80% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json rename to x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json index 749aae48d912f..ea6c2256794a4 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_index.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json @@ -1,7 +1,7 @@ { - "ccr.follow_index": { + "ccr.follow": { "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", - "methods": [ "POST" ], + "methods": [ "PUT" ], "url": { "path": "/{index}/_ccr/follow", "paths": [ "/{index}/_ccr/follow" ], @@ -9,7 +9,7 @@ "index": { "type": "string", "required": true, - "description": "The name of the follower index." + "description": "The name of the follower index" } } }, diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json similarity index 66% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json rename to x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json index 5e9a111496aa6..b6cfbe9fd0c69 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.unfollow_index.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json @@ -1,15 +1,15 @@ { - "ccr.unfollow_index": { + "ccr.pause_follow": { "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", "methods": [ "POST" ], "url": { - "path": "/{index}/_ccr/unfollow", - "paths": [ "/{index}/_ccr/unfollow" ], + "path": "/{index}/_ccr/pause_follow", + "paths": [ "/{index}/_ccr/pause_follow" ], "parts": { "index": { "type": "string", "required": true, - "description": "The name of the follower index that should stop following its leader index." + "description": "The name of the follower index that should pause following its leader index." } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json similarity index 66% rename from x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json rename to x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json index 46ff872a1a44c..b4f806e8b7fec 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.create_and_follow_index.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json @@ -1,15 +1,15 @@ { - "ccr.create_and_follow_index": { + "ccr.resume_follow": { "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", "methods": [ "POST" ], "url": { - "path": "/{index}/_ccr/create_and_follow", - "paths": [ "/{index}/_ccr/create_and_follow" ], + "path": "/{index}/_ccr/resume_follow", + "paths": [ "/{index}/_ccr/resume_follow" ], "parts": { "index": { "type": "string", "required": true, - "description": "The name of the follower index" + "description": "The name of the follow index to resume following." } } }, From 9cfe98e31c39f407c94c2c127288d6d119e204b2 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 08:51:37 +0200 Subject: [PATCH 2/6] fixed qa tests --- .../xpack/ccr/CcrMultiClusterLicenseIT.java | 8 ++--- .../xpack/ccr/FollowIndexSecurityIT.java | 30 +++++++++---------- .../xpack/ccr/FollowIndexIT.java | 22 +++++++------- .../authz/privilege/IndexPrivilege.java | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/x-pack/plugin/ccr/qa/multi-cluster-with-non-compliant-license/src/test/java/org/elasticsearch/xpack/ccr/CcrMultiClusterLicenseIT.java b/x-pack/plugin/ccr/qa/multi-cluster-with-non-compliant-license/src/test/java/org/elasticsearch/xpack/ccr/CcrMultiClusterLicenseIT.java index 505683b892ca8..07de603f28a6e 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster-with-non-compliant-license/src/test/java/org/elasticsearch/xpack/ccr/CcrMultiClusterLicenseIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster-with-non-compliant-license/src/test/java/org/elasticsearch/xpack/ccr/CcrMultiClusterLicenseIT.java @@ -31,17 +31,17 @@ protected boolean preserveClusterUponCompletion() { return true; } - public void testFollowIndex() { + public void testResumeFollow() { if (runningAgainstLeaderCluster == false) { - final Request request = new Request("POST", "/follower/_ccr/follow"); + final Request request = new Request("POST", "/follower/_ccr/resume_follow"); request.setJsonEntity("{\"leader_index\": \"leader_cluster:leader\"}"); assertNonCompliantLicense(request); } } - public void testCreateAndFollowIndex() { + public void testFollow() { if (runningAgainstLeaderCluster == false) { - final Request request = new Request("POST", "/follower/_ccr/create_and_follow"); + final Request request = new Request("PUT", "/follower/_ccr/follow"); request.setJsonEntity("{\"leader_index\": \"leader_cluster:leader\"}"); assertNonCompliantLicense(request); } diff --git a/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java b/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java index 723d4cddc3a52..8f6a3c279af24 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java @@ -80,11 +80,11 @@ public void testFollowIndex() throws Exception { refresh(allowedIndex); verifyDocuments(adminClient(), allowedIndex, numDocs); } else { - createAndFollowIndex("leader_cluster:" + allowedIndex, allowedIndex); + follow("leader_cluster:" + allowedIndex, allowedIndex); assertBusy(() -> verifyDocuments(client(), allowedIndex, numDocs)); assertThat(countCcrNodeTasks(), equalTo(1)); assertBusy(() -> verifyCcrMonitoring(allowedIndex, allowedIndex)); - assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/unfollow"))); + assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/pause_follow"))); // Make sure that there are no other ccr relates operations running: assertBusy(() -> { Map clusterState = toMap(adminClient().performRequest(new Request("GET", "/_cluster/state"))); @@ -93,9 +93,9 @@ public void testFollowIndex() throws Exception { assertThat(countCcrNodeTasks(), equalTo(0)); }); - followIndex("leader_cluster:" + allowedIndex, allowedIndex); + resumeFollow("leader_cluster:" + allowedIndex, allowedIndex); assertThat(countCcrNodeTasks(), equalTo(1)); - assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/unfollow"))); + assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/pause_follow"))); // Make sure that there are no other ccr relates operations running: assertBusy(() -> { Map clusterState = toMap(adminClient().performRequest(new Request("GET", "/_cluster/state"))); @@ -105,15 +105,15 @@ public void testFollowIndex() throws Exception { }); Exception e = expectThrows(ResponseException.class, - () -> createAndFollowIndex("leader_cluster:" + unallowedIndex, unallowedIndex)); + () -> follow("leader_cluster:" + unallowedIndex, unallowedIndex)); assertThat(e.getMessage(), - containsString("action [indices:admin/xpack/ccr/create_and_follow_index] is unauthorized for user [test_ccr]")); + containsString("action [indices:admin/xpack/ccr/follow] is unauthorized for user [test_ccr]")); // Verify that the follow index has not been created and no node tasks are running assertThat(indexExists(adminClient(), unallowedIndex), is(false)); assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); e = expectThrows(ResponseException.class, - () -> followIndex("leader_cluster:" + unallowedIndex, unallowedIndex)); + () -> resumeFollow("leader_cluster:" + unallowedIndex, unallowedIndex)); assertThat(e.getMessage(), containsString("action [indices:monitor/stats] is unauthorized for user [test_ccr]")); assertThat(indexExists(adminClient(), unallowedIndex), is(false)); assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); @@ -157,10 +157,10 @@ public void testAutoFollowPatterns() throws Exception { verifyAutoFollowMonitoring(); }); - // Cleanup by deleting auto follow pattern and unfollowing: + // Cleanup by deleting auto follow pattern and pause following: request = new Request("DELETE", "/_ccr/auto_follow/leader_cluster"); assertOK(client().performRequest(request)); - unfollowIndex(allowedIndex); + pauseFollow(allowedIndex); } private int countCcrNodeTasks() throws IOException { @@ -201,14 +201,14 @@ private static void refresh(String index) throws IOException { assertOK(adminClient().performRequest(new Request("POST", "/" + index + "/_refresh"))); } - private static void followIndex(String leaderIndex, String followIndex) throws IOException { - final Request request = new Request("POST", "/" + followIndex + "/_ccr/follow"); + private static void resumeFollow(String leaderIndex, String followIndex) throws IOException { + final Request request = new Request("POST", "/" + followIndex + "/_ccr/resume_follow"); request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}"); assertOK(client().performRequest(request)); } - private static void createAndFollowIndex(String leaderIndex, String followIndex) throws IOException { - final Request request = new Request("POST", "/" + followIndex + "/_ccr/create_and_follow"); + private static void follow(String leaderIndex, String followIndex) throws IOException { + final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow"); request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}"); assertOK(client().performRequest(request)); } @@ -273,8 +273,8 @@ private static boolean indexExists(RestClient client, String index) throws IOExc return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode(); } - private static void unfollowIndex(String followIndex) throws IOException { - assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/unfollow"))); + private static void pauseFollow(String followIndex) throws IOException { + assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/pause_follow"))); } private static void verifyCcrMonitoring(String expectedLeaderIndex, String expectedFollowerIndex) throws IOException { diff --git a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java index eaacd8c5ae788..bfb6408c16046 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java @@ -67,11 +67,11 @@ public void testFollowIndex() throws Exception { } else { logger.info("Running against follow cluster"); final String followIndexName = "test_index2"; - createAndFollowIndex("leader_cluster:" + leaderIndexName, followIndexName); + followIndex("leader_cluster:" + leaderIndexName, followIndexName); assertBusy(() -> verifyDocuments(followIndexName, numDocs)); // unfollow and then follow and then index a few docs in leader index: - unfollowIndex(followIndexName); - followIndex("leader_cluster:" + leaderIndexName, followIndexName); + pauseFollow(followIndexName); + resumeFollow("leader_cluster:" + leaderIndexName, followIndexName); try (RestClient leaderClient = buildLeaderClient()) { int id = numDocs; index(leaderClient, leaderIndexName, Integer.toString(id), "field", id, "filtered_field", "true"); @@ -86,11 +86,11 @@ public void testFollowIndex() throws Exception { public void testFollowNonExistingLeaderIndex() throws Exception { assumeFalse("Test should only run when both clusters are running", runningAgainstLeaderCluster); ResponseException e = expectThrows(ResponseException.class, - () -> followIndex("leader_cluster:non-existing-index", "non-existing-index")); + () -> resumeFollow("leader_cluster:non-existing-index", "non-existing-index")); assertThat(e.getMessage(), containsString("no such index")); assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404)); - e = expectThrows(ResponseException.class, () -> createAndFollowIndex("leader_cluster:non-existing-index", "non-existing-index")); + e = expectThrows(ResponseException.class, () -> followIndex("leader_cluster:non-existing-index", "non-existing-index")); assertThat(e.getMessage(), containsString("no such index")); assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404)); } @@ -146,20 +146,20 @@ private static void refresh(String index) throws IOException { assertOK(client().performRequest(new Request("POST", "/" + index + "/_refresh"))); } - private static void followIndex(String leaderIndex, String followIndex) throws IOException { - final Request request = new Request("POST", "/" + followIndex + "/_ccr/follow"); + private static void resumeFollow(String leaderIndex, String followIndex) throws IOException { + final Request request = new Request("POST", "/" + followIndex + "/_ccr/resume_follow"); request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}"); assertOK(client().performRequest(request)); } - private static void createAndFollowIndex(String leaderIndex, String followIndex) throws IOException { - final Request request = new Request("POST", "/" + followIndex + "/_ccr/create_and_follow"); + private static void followIndex(String leaderIndex, String followIndex) throws IOException { + final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow"); request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}"); assertOK(client().performRequest(request)); } - private static void unfollowIndex(String followIndex) throws IOException { - assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/unfollow"))); + private static void pauseFollow(String followIndex) throws IOException { + assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/pause_follow"))); } private static void verifyDocuments(String index, int expectedNumDocs) throws IOException { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java index 779f2765f4803..11795ff98c28d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java @@ -55,7 +55,7 @@ public final class IndexPrivilege extends Privilege { private static final Automaton VIEW_METADATA_AUTOMATON = patterns(GetAliasesAction.NAME, AliasesExistAction.NAME, GetIndexAction.NAME, IndicesExistsAction.NAME, GetFieldMappingsAction.NAME + "*", GetMappingsAction.NAME, ClusterSearchShardsAction.NAME, TypesExistsAction.NAME, ValidateQueryAction.NAME + "*", GetSettingsAction.NAME); - private static final Automaton CREATE_FOLLOW_INDEX_AUTOMATON = patterns("indices:admin/xpack/ccr/create_and_follow_index"); + private static final Automaton CREATE_FOLLOW_INDEX_AUTOMATON = patterns("indices:admin/xpack/ccr/follow"); public static final IndexPrivilege NONE = new IndexPrivilege("none", Automatons.EMPTY); public static final IndexPrivilege ALL = new IndexPrivilege("all", ALL_AUTOMATON); From 8f351268cab044e8f7d532d65eae48985b65e8ad Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 15:08:06 +0200 Subject: [PATCH 3/6] fixed rest test --- .../resources/rest-api-spec/test/ccr/follow_and_unfollow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml index c24b301032f68..9aa072a09bcf8 100644 --- a/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml +++ b/x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml @@ -25,7 +25,7 @@ - is_true: index_following_started - do: - ccr.unfollow_index: + ccr.pause_follow: index: bar - is_true: acknowledged From 2f24ad8dcaac360416b77807cf38df808fbc581f Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 15:34:45 +0200 Subject: [PATCH 4/6] rename --- .../java/org/elasticsearch/xpack/ccr/Ccr.java | 10 ++--- .../ccr/action/AutoFollowCoordinator.java | 6 +-- ...ion.java => TransportPutFollowAction.java} | 44 +++++++++---------- ...owAction.java => RestPutFollowAction.java} | 10 ++--- .../elasticsearch/xpack/ccr/CcrLicenseIT.java | 10 ++--- .../xpack/ccr/ShardChangesIT.java | 44 +++++++++---------- .../CreateAndFollowIndexRequestTests.java | 12 ++--- .../CreateAndFollowIndexResponseTests.java | 12 ++--- ...FollowAction.java => PutFollowAction.java} | 8 ++-- .../xpack/core/ccr/client/CcrClient.java | 16 +++---- 10 files changed, 86 insertions(+), 86 deletions(-) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/{TransportFollowAction.java => TransportPutFollowAction.java} (88%) rename x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/{RestFollowAction.java => RestPutFollowAction.java} (76%) rename x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/{FollowAction.java => PutFollowAction.java} (95%) 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 64e8b4b5d2033..d2d769d4269b8 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 @@ -52,7 +52,7 @@ import org.elasticsearch.xpack.ccr.action.ShardFollowTask; import org.elasticsearch.xpack.ccr.action.ShardFollowTasksExecutor; import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction; -import org.elasticsearch.xpack.ccr.action.TransportFollowAction; +import org.elasticsearch.xpack.ccr.action.TransportPutFollowAction; import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction; import org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction; import org.elasticsearch.xpack.ccr.action.TransportPutAutoFollowPatternAction; @@ -61,7 +61,7 @@ import org.elasticsearch.xpack.ccr.action.bulk.TransportBulkShardOperationsAction; import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory; import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction; -import org.elasticsearch.xpack.ccr.rest.RestFollowAction; +import org.elasticsearch.xpack.ccr.rest.RestPutFollowAction; import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction; import org.elasticsearch.xpack.ccr.rest.RestResumeFollowAction; import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction; @@ -69,7 +69,7 @@ import org.elasticsearch.xpack.core.XPackPlugin; import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; @@ -161,7 +161,7 @@ public List> getPersistentTasksExecutor(ClusterServic new ActionHandler<>(CcrStatsAction.INSTANCE, TransportCcrStatsAction.class), new ActionHandler<>(AutoFollowStatsAction.INSTANCE, TransportAutoFollowStatsAction.class), // follow actions - new ActionHandler<>(FollowAction.INSTANCE, TransportFollowAction.class), + new ActionHandler<>(PutFollowAction.INSTANCE, TransportPutFollowAction.class), new ActionHandler<>(ResumeFollowAction.INSTANCE, TransportResumeFollowAction.class), new ActionHandler<>(PauseFollowAction.INSTANCE, TransportPauseFollowAction.class), // auto-follow actions @@ -183,7 +183,7 @@ public List getRestHandlers(Settings settings, RestController restC new RestCcrStatsAction(settings, restController), new RestAutoFollowStatsAction(settings, restController), // follow APIs - new RestFollowAction(settings, restController), + new RestPutFollowAction(settings, restController), new RestResumeFollowAction(settings, restController), new RestPauseFollowAction(settings, restController), // auto-follow APIs diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java index 3557339323e3e..7c9947f52801e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java @@ -33,7 +33,7 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.util.ArrayList; @@ -187,9 +187,9 @@ void createAndFollow(Map headers, Runnable successHandler, Consumer failureHandler) { Client followerClient = CcrLicenseChecker.wrapClient(client, headers); - FollowAction.Request request = new FollowAction.Request(followRequest); + PutFollowAction.Request request = new PutFollowAction.Request(followRequest); followerClient.execute( - FollowAction.INSTANCE, + PutFollowAction.INSTANCE, request, ActionListener.wrap(r -> successHandler.run(), failureHandler) ); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java similarity index 88% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java index 13d17a6412114..6c01faa8ff25a 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java @@ -37,7 +37,7 @@ import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; import org.elasticsearch.xpack.ccr.CcrSettings; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import java.util.HashMap; @@ -46,8 +46,8 @@ import java.util.Objects; import java.util.function.Consumer; -public final class TransportFollowAction - extends TransportMasterNodeAction { +public final class TransportPutFollowAction + extends TransportMasterNodeAction { private final Client client; private final AllocationService allocationService; @@ -56,7 +56,7 @@ public final class TransportFollowAction private final CcrLicenseChecker ccrLicenseChecker; @Inject - public TransportFollowAction( + public TransportPutFollowAction( final Settings settings, final ThreadPool threadPool, final TransportService transportService, @@ -68,13 +68,13 @@ public TransportFollowAction( final CcrLicenseChecker ccrLicenseChecker) { super( settings, - FollowAction.NAME, + PutFollowAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, - FollowAction.Request::new); + PutFollowAction.Request::new); this.client = client; this.allocationService = allocationService; this.remoteClusterService = transportService.getRemoteClusterService(); @@ -88,15 +88,15 @@ protected String executor() { } @Override - protected FollowAction.Response newResponse() { - return new FollowAction.Response(); + protected PutFollowAction.Response newResponse() { + return new PutFollowAction.Response(); } @Override protected void masterOperation( - final FollowAction.Request request, + final PutFollowAction.Request request, final ClusterState state, - final ActionListener listener) throws Exception { + final ActionListener listener) throws Exception { if (ccrLicenseChecker.isCcrAllowed() == false) { listener.onFailure(LicenseUtils.newComplianceException("ccr")); return; @@ -116,9 +116,9 @@ protected void masterOperation( } private void createFollowerIndexAndFollowLocalIndex( - final FollowAction.Request request, + final PutFollowAction.Request request, final ClusterState state, - final ActionListener listener) { + final ActionListener listener) { // following an index in local cluster, so use local cluster state to fetch leader index metadata final String leaderIndex = request.getFollowRequest().getLeaderIndex(); final IndexMetaData leaderIndexMetadata = state.getMetaData().index(leaderIndex); @@ -134,10 +134,10 @@ private void createFollowerIndexAndFollowLocalIndex( } private void createFollowerIndexAndFollowRemoteIndex( - final FollowAction.Request request, + final PutFollowAction.Request request, final String clusterAlias, final String leaderIndex, - final ActionListener listener) { + final ActionListener listener) { ccrLicenseChecker.checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs( client, clusterAlias, @@ -149,8 +149,8 @@ private void createFollowerIndexAndFollowRemoteIndex( private void createFollowerIndex( final IndexMetaData leaderIndexMetaData, final String[] historyUUIDs, - final FollowAction.Request request, - final ActionListener listener) { + final PutFollowAction.Request request, + final ActionListener listener) { if (leaderIndexMetaData == null) { listener.onFailure(new IllegalArgumentException("leader index [" + request.getFollowRequest().getLeaderIndex() + "] does not exist")); @@ -162,7 +162,7 @@ private void createFollowerIndex( if (result) { initiateFollowing(request, listener); } else { - listener.onResponse(new FollowAction.Response(true, false, false)); + listener.onResponse(new PutFollowAction.Response(true, false, false)); } }, listener::onFailure); @@ -228,23 +228,23 @@ public ClusterState execute(final ClusterState currentState) throws Exception { } private void initiateFollowing( - final FollowAction.Request request, - final ActionListener listener) { + final PutFollowAction.Request request, + final ActionListener listener) { activeShardsObserver.waitForActiveShards(new String[]{request.getFollowRequest().getFollowerIndex()}, ActiveShardCount.DEFAULT, request.timeout(), result -> { if (result) { client.execute(ResumeFollowAction.INSTANCE, request.getFollowRequest(), ActionListener.wrap( - r -> listener.onResponse(new FollowAction.Response(true, true, r.isAcknowledged())), + r -> listener.onResponse(new PutFollowAction.Response(true, true, r.isAcknowledged())), listener::onFailure )); } else { - listener.onResponse(new FollowAction.Response(true, false, false)); + listener.onResponse(new PutFollowAction.Response(true, false, false)); } }, listener::onFailure); } @Override - protected ClusterBlockException checkBlock(final FollowAction.Request request, final ClusterState state) { + protected ClusterBlockException checkBlock(final PutFollowAction.Request request, final ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, request.getFollowRequest().getFollowerIndex()); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java similarity index 76% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java index 5a737afab019a..d6116ff274b58 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestPutFollowAction.java @@ -14,19 +14,19 @@ import java.io.IOException; -import static org.elasticsearch.xpack.core.ccr.action.FollowAction.INSTANCE; -import static org.elasticsearch.xpack.core.ccr.action.FollowAction.Request; +import static org.elasticsearch.xpack.core.ccr.action.PutFollowAction.INSTANCE; +import static org.elasticsearch.xpack.core.ccr.action.PutFollowAction.Request; -public class RestFollowAction extends BaseRestHandler { +public class RestPutFollowAction extends BaseRestHandler { - public RestFollowAction(Settings settings, RestController controller) { + public RestPutFollowAction(Settings settings, RestController controller) { super(settings); controller.registerHandler(RestRequest.Method.PUT, "/{index}/_ccr/follow", this); } @Override public String getName() { - return "ccr_follow_action"; + return "ccr_put_follow_action"; } @Override diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java index d68dcc5d5a1bf..7e5ae0924080e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java @@ -23,7 +23,7 @@ import org.elasticsearch.test.MockLogAppender; import org.elasticsearch.xpack.ccr.action.AutoFollowCoordinator; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; @@ -67,14 +67,14 @@ public void onFailure(final Exception e) { public void testThatCreateAndFollowingIndexIsUnavailableWithNonCompliantLicense() throws InterruptedException { final ResumeFollowAction.Request followRequest = getFollowRequest(); - final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); + final PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); final CountDownLatch latch = new CountDownLatch(1); client().execute( - FollowAction.INSTANCE, + PutFollowAction.INSTANCE, createAndFollowRequest, - new ActionListener() { + new ActionListener() { @Override - public void onResponse(final FollowAction.Response response) { + public void onResponse(final PutFollowAction.Response response) { latch.countDown(); fail(); } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java index 6e91cbbb29007..032bfad002f0a 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java @@ -46,7 +46,7 @@ import org.elasticsearch.xpack.ccr.action.ShardFollowTask; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; @@ -172,8 +172,8 @@ public void testFollowIndex() throws Exception { ensureYellow("index1"); final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + final PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); final int firstBatchNumDocs = randomIntBetween(2, 64); logger.info("Indexing [{}] docs as first batch", firstBatchNumDocs); @@ -230,8 +230,8 @@ public void testSyncMappings() throws Exception { ensureYellow("index1"); final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + final PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); final long firstBatchNumDocs = randomIntBetween(2, 64); for (long i = 0; i < firstBatchNumDocs; i++) { @@ -270,8 +270,8 @@ public void testNoMappingDefined() throws Exception { ensureGreen("index1"); final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + final PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); client().prepareIndex("index1", "doc", "1").setSource("{\"f\":1}", XContentType.JSON).get(); assertBusy(() -> assertThat(client().prepareSearch("index2").get().getHits().totalHits, equalTo(1L))); @@ -324,8 +324,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) followRequest.setMaxConcurrentReadBatches(randomIntBetween(2, 10)); followRequest.setMaxConcurrentWriteBatches(randomIntBetween(2, 10)); followRequest.setMaxWriteBufferSize(randomIntBetween(1024, 10240)); - FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); atLeastDocsIndexed("index1", numDocsIndexed); run.set(false); @@ -364,7 +364,7 @@ public void testFollowIndexAndCloseNode() throws Exception { followRequest.setMaxBatchOperationCount(randomIntBetween(32, 2048)); followRequest.setMaxConcurrentReadBatches(randomIntBetween(2, 10)); followRequest.setMaxConcurrentWriteBatches(randomIntBetween(2, 10)); - client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest)).get(); + client().execute(PutFollowAction.INSTANCE, new PutFollowAction.Request(followRequest)).get(); long maxNumDocsReplicated = Math.min(1000, randomLongBetween(followRequest.getMaxBatchOperationCount(), followRequest.getMaxBatchOperationCount() * 10)); @@ -389,7 +389,7 @@ public void testFollowIndexWithNestedField() throws Exception { ensureGreen("index1"); final ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest)).get(); + client().execute(PutFollowAction.INSTANCE, new PutFollowAction.Request(followRequest)).get(); final int numDocs = randomIntBetween(2, 64); for (int i = 0; i < numDocs; i++) { @@ -434,19 +434,19 @@ public void testFollowNonExistentIndex() throws Exception { ResumeFollowAction.Request followRequest1 = createFollowRequest("non-existent-leader", "test-follower"); expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest1).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest1)) + () -> client().execute(PutFollowAction.INSTANCE, new PutFollowAction.Request(followRequest1)) .actionGet()); // Follower index does not exist. ResumeFollowAction.Request followRequest2 = createFollowRequest("non-test-leader", "non-existent-follower"); expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest2).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest2)) + () -> client().execute(PutFollowAction.INSTANCE, new PutFollowAction.Request(followRequest2)) .actionGet()); // Both indices do not exist. ResumeFollowAction.Request followRequest3 = createFollowRequest("non-existent-leader", "non-existent-follower"); expectThrows(IndexNotFoundException.class, () -> client().execute(ResumeFollowAction.INSTANCE, followRequest3).actionGet()); expectThrows(IndexNotFoundException.class, - () -> client().execute(FollowAction.INSTANCE, new FollowAction.Request(followRequest3)) + () -> client().execute(PutFollowAction.INSTANCE, new PutFollowAction.Request(followRequest3)) .actionGet()); } @@ -465,8 +465,8 @@ public void testFollowIndexMaxOperationSizeInBytes() throws Exception { ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); followRequest.setMaxOperationSizeInBytes(1L); - final FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + final PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); final Map firstBatchNumDocsPerShard = new HashMap<>(); final ShardStats[] firstBatchShardStats = client().admin().indices().prepareStats("index1").get().getIndex("index1").getShards(); @@ -493,12 +493,12 @@ public void testDontFollowTheWrongIndex() throws Exception { ensureGreen("index3"); ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); followRequest = createFollowRequest("index3", "index4"); - createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); unfollowIndex("index2", "index4"); ResumeFollowAction.Request wrongRequest1 = createFollowRequest("index1", "index4"); @@ -516,8 +516,8 @@ public void testAttemptToChangeCcrFollowingIndexSetting() throws Exception { assertAcked(client().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON).get()); ensureYellow("index1"); ResumeFollowAction.Request followRequest = createFollowRequest("index1", "index2"); - FollowAction.Request createAndFollowRequest = new FollowAction.Request(followRequest); - client().execute(FollowAction.INSTANCE, createAndFollowRequest).get(); + PutFollowAction.Request createAndFollowRequest = new PutFollowAction.Request(followRequest); + client().execute(PutFollowAction.INSTANCE, createAndFollowRequest).get(); unfollowIndex("index2"); client().admin().indices().close(new CloseIndexRequest("index2")).actionGet(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java index 9e9111d019a3f..8d9bb781582b5 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java @@ -6,17 +6,17 @@ package org.elasticsearch.xpack.ccr.action; import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; -public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase { +public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase { @Override - protected FollowAction.Request createBlankInstance() { - return new FollowAction.Request(); + protected PutFollowAction.Request createBlankInstance() { + return new PutFollowAction.Request(); } @Override - protected FollowAction.Request createTestInstance() { - return new FollowAction.Request(FollowIndexRequestTests.createTestRequest()); + protected PutFollowAction.Request createTestInstance() { + return new PutFollowAction.Request(FollowIndexRequestTests.createTestRequest()); } } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java index b7794f101726b..86118e2d0b8a7 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java @@ -6,17 +6,17 @@ package org.elasticsearch.xpack.ccr.action; import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; -public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { +public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { @Override - protected FollowAction.Response createBlankInstance() { - return new FollowAction.Response(); + protected PutFollowAction.Response createBlankInstance() { + return new PutFollowAction.Response(); } @Override - protected FollowAction.Response createTestInstance() { - return new FollowAction.Response(randomBoolean(), randomBoolean(), randomBoolean()); + protected PutFollowAction.Response createTestInstance() { + return new PutFollowAction.Response(randomBoolean(), randomBoolean(), randomBoolean()); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutFollowAction.java similarity index 95% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutFollowAction.java index 4ca6b6933c8b3..5fdb13871b56c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutFollowAction.java @@ -20,12 +20,12 @@ import java.io.IOException; import java.util.Objects; -public final class FollowAction extends Action { +public final class PutFollowAction extends Action { - public static final FollowAction INSTANCE = new FollowAction(); - public static final String NAME = "indices:admin/xpack/ccr/follow"; + public static final PutFollowAction INSTANCE = new PutFollowAction(); + public static final String NAME = "indices:admin/xpack/ccr/put_follow"; - private FollowAction() { + private PutFollowAction() { super(NAME); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java index 2e842504e5a56..dd4af08978bfa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/client/CcrClient.java @@ -13,7 +13,7 @@ import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.xpack.core.ccr.action.AutoFollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; -import org.elasticsearch.xpack.core.ccr.action.FollowAction; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction; @@ -30,15 +30,15 @@ public CcrClient(final ElasticsearchClient client) { this.client = Objects.requireNonNull(client, "client"); } - public void follow( - final FollowAction.Request request, - final ActionListener listener) { - client.execute(FollowAction.INSTANCE, request, listener); + public void putFollow( + final PutFollowAction.Request request, + final ActionListener listener) { + client.execute(PutFollowAction.INSTANCE, request, listener); } - public ActionFuture follow(final FollowAction.Request request) { - final PlainActionFuture listener = PlainActionFuture.newFuture(); - client.execute(FollowAction.INSTANCE, request, listener); + public ActionFuture putFollow(final PutFollowAction.Request request) { + final PlainActionFuture listener = PlainActionFuture.newFuture(); + client.execute(PutFollowAction.INSTANCE, request, listener); return listener; } From 0875c69d0f1640182529b932e3bbb7b365367d31 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 16:07:02 +0200 Subject: [PATCH 5/6] fix security test --- .../org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java | 2 +- .../xpack/core/security/authz/privilege/IndexPrivilege.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java b/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java index 8f6a3c279af24..e20ffa9075513 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java +++ b/x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java @@ -107,7 +107,7 @@ public void testFollowIndex() throws Exception { Exception e = expectThrows(ResponseException.class, () -> follow("leader_cluster:" + unallowedIndex, unallowedIndex)); assertThat(e.getMessage(), - containsString("action [indices:admin/xpack/ccr/follow] is unauthorized for user [test_ccr]")); + containsString("action [indices:admin/xpack/ccr/put_follow] is unauthorized for user [test_ccr]")); // Verify that the follow index has not been created and no node tasks are running assertThat(indexExists(adminClient(), unallowedIndex), is(false)); assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0))); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java index 11795ff98c28d..bc8c408731b59 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryAction; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.MapBuilder; +import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.security.support.Automatons; import java.util.Arrays; @@ -55,7 +56,7 @@ public final class IndexPrivilege extends Privilege { private static final Automaton VIEW_METADATA_AUTOMATON = patterns(GetAliasesAction.NAME, AliasesExistAction.NAME, GetIndexAction.NAME, IndicesExistsAction.NAME, GetFieldMappingsAction.NAME + "*", GetMappingsAction.NAME, ClusterSearchShardsAction.NAME, TypesExistsAction.NAME, ValidateQueryAction.NAME + "*", GetSettingsAction.NAME); - private static final Automaton CREATE_FOLLOW_INDEX_AUTOMATON = patterns("indices:admin/xpack/ccr/follow"); + private static final Automaton CREATE_FOLLOW_INDEX_AUTOMATON = patterns(PutFollowAction.NAME); public static final IndexPrivilege NONE = new IndexPrivilege("none", Automatons.EMPTY); public static final IndexPrivilege ALL = new IndexPrivilege("all", ALL_AUTOMATON); From 514d23fb5438153f9e547dcff84ed05d4a1605a9 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Sep 2018 16:08:17 +0200 Subject: [PATCH 6/6] rename left over tests --- ...wIndexRequestTests.java => PutFollowActionRequestTests.java} | 2 +- ...ndexResponseTests.java => PutFollowActionResponseTests.java} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/{CreateAndFollowIndexRequestTests.java => PutFollowActionRequestTests.java} (86%) rename x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/{CreateAndFollowIndexResponseTests.java => PutFollowActionResponseTests.java} (86%) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionRequestTests.java similarity index 86% rename from x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java rename to x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionRequestTests.java index 8d9bb781582b5..3c21abcfbf5e9 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionRequestTests.java @@ -8,7 +8,7 @@ import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; -public class CreateAndFollowIndexRequestTests extends AbstractStreamableTestCase { +public class PutFollowActionRequestTests extends AbstractStreamableTestCase { @Override protected PutFollowAction.Request createBlankInstance() { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionResponseTests.java similarity index 86% rename from x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java rename to x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionResponseTests.java index 86118e2d0b8a7..506a5e6ffbb22 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutFollowActionResponseTests.java @@ -8,7 +8,7 @@ import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; -public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { +public class PutFollowActionResponseTests extends AbstractStreamableTestCase { @Override protected PutFollowAction.Response createBlankInstance() {