diff --git a/docs/reference/ccr/apis/ccr-apis.asciidoc b/docs/reference/ccr/apis/ccr-apis.asciidoc index b8c958ab663..6411766350d 100644 --- a/docs/reference/ccr/apis/ccr-apis.asciidoc +++ b/docs/reference/ccr/apis/ccr-apis.asciidoc @@ -5,6 +5,12 @@ You can use the following APIs to perform {ccr} operations. +[float] +[[ccr-api-top-level]] +=== Top-Level + +* <> + [float] [[ccr-api-follow]] === Follow @@ -23,6 +29,9 @@ You can use the following APIs to perform {ccr} operations. * <> * <> +// top-level +include::get-ccr-stats.asciidoc[] + // follow include::follow/put-follow.asciidoc[] include::follow/post-pause-follow.asciidoc[] diff --git a/docs/reference/ccr/apis/get-ccr-stats.asciidoc b/docs/reference/ccr/apis/get-ccr-stats.asciidoc new file mode 100644 index 00000000000..9229e4c9406 --- /dev/null +++ b/docs/reference/ccr/apis/get-ccr-stats.asciidoc @@ -0,0 +1,21 @@ +[role="xpack"] +[testenv="platinum"] +[[ccr-get-stats]] +=== Get Cross-Cluster Replication Stats API +++++ +Get Follower Stats +++++ + +Get {ccr} stats. + +==== Description + +This API gets {ccr} stats. + +==== Request + +[source,js] +-------------------------------------------------- +GET /_ccr/stats +-------------------------------------------------- +// CONSOLE 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 4ff363b7d1e..ac11fc8523c 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 @@ -44,9 +44,9 @@ import org.elasticsearch.xpack.ccr.action.TransportGetAutoFollowPatternAction; import org.elasticsearch.xpack.ccr.action.TransportUnfollowAction; import org.elasticsearch.xpack.ccr.rest.RestGetAutoFollowPatternAction; import org.elasticsearch.xpack.ccr.action.TransportStatsAction; -import org.elasticsearch.xpack.ccr.rest.RestAutoFollowStatsAction; +import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction; import org.elasticsearch.xpack.ccr.rest.RestUnfollowAction; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction; @@ -164,7 +164,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E new ActionHandler<>(ShardChangesAction.INSTANCE, ShardChangesAction.TransportAction.class), // stats action new ActionHandler<>(FollowStatsAction.INSTANCE, TransportFollowStatsAction.class), - new ActionHandler<>(StatsAction.INSTANCE, TransportStatsAction.class), + new ActionHandler<>(CcrStatsAction.INSTANCE, TransportStatsAction.class), // follow actions new ActionHandler<>(PutFollowAction.INSTANCE, TransportPutFollowAction.class), new ActionHandler<>(ResumeFollowAction.INSTANCE, TransportResumeFollowAction.class), @@ -187,7 +187,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E return Arrays.asList( // stats API new RestFollowStatsAction(settings, restController), - new RestAutoFollowStatsAction(settings, restController), + new RestCcrStatsAction(settings, restController), // follow APIs new RestPutFollowAction(settings, restController), new RestResumeFollowAction(settings, restController), diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportStatsAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportStatsAction.java index 97234158042..45e76323ff1 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportStatsAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportStatsAction.java @@ -26,11 +26,11 @@ import org.elasticsearch.xpack.ccr.Ccr; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import java.util.Objects; -public class TransportStatsAction extends TransportMasterNodeAction { +public class TransportStatsAction extends TransportMasterNodeAction { private final Client client; private final CcrLicenseChecker ccrLicenseChecker; @@ -50,12 +50,12 @@ public class TransportStatsAction extends TransportMasterNodeAction listener) { + protected void doExecute(Task task, CcrStatsAction.Request request, ActionListener listener) { if (ccrLicenseChecker.isCcrAllowed() == false) { listener.onFailure(LicenseUtils.newComplianceException("ccr")); return; @@ -84,20 +84,20 @@ public class TransportStatsAction extends TransportMasterNodeAction listener + ActionListener listener ) throws Exception { CheckedConsumer handler = statsResponse -> { AutoFollowStats stats = autoFollowCoordinator.getStats(); - listener.onResponse(new StatsAction.Response(stats, statsResponse)); + listener.onResponse(new CcrStatsAction.Response(stats, statsResponse)); }; FollowStatsAction.StatsRequest statsRequest = new FollowStatsAction.StatsRequest(); client.execute(FollowStatsAction.INSTANCE, statsRequest, ActionListener.wrap(handler, listener::onFailure)); } @Override - protected ClusterBlockException checkBlock(StatsAction.Request request, ClusterState state) { + protected ClusterBlockException checkBlock(CcrStatsAction.Request request, ClusterState state) { return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ); } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestAutoFollowStatsAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java similarity index 70% rename from x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestAutoFollowStatsAction.java rename to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java index 434343e7cc0..943f85010e2 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestAutoFollowStatsAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java @@ -12,13 +12,13 @@ import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import java.io.IOException; -public class RestAutoFollowStatsAction extends BaseRestHandler { +public class RestCcrStatsAction extends BaseRestHandler { - public RestAutoFollowStatsAction(final Settings settings, final RestController controller) { + public RestCcrStatsAction(final Settings settings, final RestController controller) { super(settings); controller.registerHandler(RestRequest.Method.GET, "/_ccr/stats", this); } @@ -30,8 +30,8 @@ public class RestAutoFollowStatsAction extends BaseRestHandler { @Override protected RestChannelConsumer prepareRequest(final RestRequest restRequest, final NodeClient client) throws IOException { - final StatsAction.Request request = new StatsAction.Request(); - return channel -> client.execute(StatsAction.INSTANCE, request, new RestToXContentListener<>(channel)); + final CcrStatsAction.Request request = new CcrStatsAction.Request(); + return channel -> client.execute(CcrStatsAction.INSTANCE, request, new RestToXContentListener<>(channel)); } } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java index f9d375068ab..8a94ba606b0 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java @@ -19,7 +19,7 @@ import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.CcrIntegTestCase; import org.elasticsearch.xpack.ccr.action.ShardFollowTask; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction; @@ -260,8 +260,8 @@ public class AutoFollowIT extends CcrIntegTestCase { } private AutoFollowStats getAutoFollowStats() { - StatsAction.Request request = new StatsAction.Request(); - return followerClient().execute(StatsAction.INSTANCE, request).actionGet().getAutoFollowStats(); + CcrStatsAction.Request request = new CcrStatsAction.Request(); + return followerClient().execute(CcrStatsAction.INSTANCE, request).actionGet().getAutoFollowStats(); } private void createLeaderIndex(String index, Settings settings) { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowStatsResponseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowStatsResponseTests.java index 7e377f7abcd..3398cada2d0 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowStatsResponseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowStatsResponseTests.java @@ -8,20 +8,20 @@ package org.elasticsearch.xpack.ccr.action; import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.xpack.core.ccr.AutoFollowStats; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import static org.elasticsearch.xpack.ccr.action.AutoFollowStatsTests.randomReadExceptions; import static org.elasticsearch.xpack.ccr.action.StatsResponsesTests.createStatsResponse; -public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase { +public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase { @Override - protected StatsAction.Response createBlankInstance() { - return new StatsAction.Response(); + protected CcrStatsAction.Response createBlankInstance() { + return new CcrStatsAction.Response(); } @Override - protected StatsAction.Response createTestInstance() { + protected CcrStatsAction.Response createTestInstance() { AutoFollowStats autoFollowStats = new AutoFollowStats( randomNonNegativeLong(), randomNonNegativeLong(), @@ -29,6 +29,6 @@ public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase future = (ActionFuture) mock(ActionFuture.class); - final StatsAction.Response response = new StatsAction.Response(autoFollowStats, statsResponse); + final ActionFuture future = (ActionFuture) mock(ActionFuture.class); + final CcrStatsAction.Response response = new CcrStatsAction.Response(autoFollowStats, statsResponse); when(client.stats(any())).thenReturn(future); when(future.actionGet(timeout)).thenReturn(response); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/StatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CcrStatsAction.java similarity index 95% rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/StatsAction.java rename to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CcrStatsAction.java index e8cfe7f3682..b123c3e9db7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/StatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/CcrStatsAction.java @@ -19,12 +19,12 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowStats; import java.io.IOException; import java.util.Objects; -public class StatsAction extends Action { +public class CcrStatsAction extends Action { public static final String NAME = "cluster:monitor/ccr/stats"; - public static final StatsAction INSTANCE = new StatsAction(); + public static final CcrStatsAction INSTANCE = new CcrStatsAction(); - private StatsAction() { + private CcrStatsAction() { 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 9cab375a42b..43305b030be 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 @@ -11,7 +11,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; @@ -65,13 +65,13 @@ public class CcrClient { return listener; } - public void stats(final StatsAction.Request request, - final ActionListener listener) { - client.execute(StatsAction.INSTANCE, request, listener); + public void stats(final CcrStatsAction.Request request, + final ActionListener listener) { + client.execute(CcrStatsAction.INSTANCE, request, listener); } - public ActionFuture stats(final StatsAction.Request request) { - final PlainActionFuture listener = PlainActionFuture.newFuture(); + public ActionFuture stats(final CcrStatsAction.Request request) { + final PlainActionFuture listener = PlainActionFuture.newFuture(); stats(request, listener); return listener; } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java index e7c15cc4b27..b57c1f31ea6 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java @@ -16,7 +16,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackClient; import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.ccr.action.StatsAction; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.client.CcrClient; import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringDoc; import org.elasticsearch.xpack.monitoring.collector.Collector; @@ -77,8 +77,8 @@ public final class StatsCollector extends Collector { final long timestamp = timestamp(); final String clusterUuid = clusterUuid(clusterState); - final StatsAction.Request request = new StatsAction.Request(); - final StatsAction.Response response = ccrClient.stats(request).actionGet(getCollectionTimeout()); + final CcrStatsAction.Request request = new CcrStatsAction.Request(); + final CcrStatsAction.Response response = ccrClient.stats(request).actionGet(getCollectionTimeout()); final AutoFollowStatsMonitoringDoc autoFollowStatsDoc = new AutoFollowStatsMonitoringDoc(clusterUuid, timestamp, interval, node, response.getAutoFollowStats()); diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json index a5c8de74836..735387b173b 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.delete_auto_follow_pattern.json @@ -1,6 +1,6 @@ { "ccr.delete_auto_follow_pattern": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html", "methods": [ "DELETE" ], "url": { "path": "/_ccr/auto_follow/{name}", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json index ea6c2256794..635a4e62683 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow.json @@ -1,6 +1,6 @@ { "ccr.follow": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html", "methods": [ "PUT" ], "url": { "path": "/{index}/_ccr/follow", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_stats.json index 852a0dc05df..e860a590b52 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.follow_stats.json @@ -1,6 +1,6 @@ { "ccr.follow_stats": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html", "methods": [ "GET" ], "url": { "path": "/{index}/_ccr/stats", @@ -8,7 +8,7 @@ "parts": { "index": { "type": "list", - "description": "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + "description": "A comma-separated list of index patterns; use `_all` to perform the operation on all indices" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.get_auto_follow_pattern.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.get_auto_follow_pattern.json index 65d0b9c8dea..6aea678fc00 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.get_auto_follow_pattern.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.get_auto_follow_pattern.json @@ -1,6 +1,6 @@ { "ccr.get_auto_follow_pattern": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html", "methods": [ "GET" ], "url": { "path": "/_ccr/auto_follow/{name}", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json index b6cfbe9fd0c..e128dab917c 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.pause_follow.json @@ -1,6 +1,6 @@ { "ccr.pause_follow": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html", "methods": [ "POST" ], "url": { "path": "/{index}/_ccr/pause_follow", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json index 5f7aac790a0..128b262ec7a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.put_auto_follow_pattern.json @@ -1,6 +1,6 @@ { "ccr.put_auto_follow_pattern": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html", "methods": [ "PUT" ], "url": { "path": "/_ccr/auto_follow/{name}", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json index b4f806e8b7f..61bdf82372f 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.resume_follow.json @@ -1,6 +1,6 @@ { "ccr.resume_follow": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html", "methods": [ "POST" ], "url": { "path": "/{index}/_ccr/resume_follow", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json index 91867d05e03..ad9ab49bcbe 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ccr.stats.json @@ -1,6 +1,6 @@ { "ccr.stats": { - "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current", + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html", "methods": [ "GET" ], "url": { "path": "/_ccr/stats",