Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/reference/ccr/apis/ccr-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

You can use the following APIs to perform {ccr} operations.

[float]
[[ccr-api-top-level]]
=== Top-Level

* <<ccr-get-stats,Get {ccr} stats>>

[float]
[[ccr-api-follow]]
=== Follow
Expand All @@ -23,6 +29,9 @@ You can use the following APIs to perform {ccr} operations.
* <<ccr-delete-auto-follow-pattern,Delete auto-follow pattern>>
* <<ccr-get-auto-follow-pattern,Get auto-follow patterns>>

// top-level
include::get-ccr-stats.asciidoc[]

// follow
include::follow/put-follow.asciidoc[]
include::follow/post-pause-follow.asciidoc[]
Expand Down
21 changes: 21 additions & 0 deletions docs/reference/ccr/apis/get-ccr-stats.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[role="xpack"]
[testenv="platinum"]
[[ccr-get-stats]]
=== Get Cross-Cluster Replication Stats API
++++
<titleabbrev>Get Follower Stats</titleabbrev>
++++

Get {ccr} stats.

==== Description

This API gets {ccr} stats.

==== Request

[source,js]
--------------------------------------------------
GET /_ccr/stats
--------------------------------------------------
// CONSOLE
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
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;
Expand Down Expand Up @@ -164,7 +164,7 @@ public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(ClusterServic
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),
Expand All @@ -187,7 +187,7 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
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<StatsAction.Request, StatsAction.Response> {
public class TransportStatsAction extends TransportMasterNodeAction<CcrStatsAction.Request, CcrStatsAction.Response> {

private final Client client;
private final CcrLicenseChecker ccrLicenseChecker;
Expand All @@ -50,12 +50,12 @@ public TransportStatsAction(
) {
super(
settings,
StatsAction.NAME,
CcrStatsAction.NAME,
transportService,
clusterService,
threadPool,
actionFilters,
StatsAction.Request::new,
CcrStatsAction.Request::new,
indexNameExpressionResolver
);
this.client = client;
Expand All @@ -69,12 +69,12 @@ protected String executor() {
}

@Override
protected StatsAction.Response newResponse() {
return new StatsAction.Response();
protected CcrStatsAction.Response newResponse() {
return new CcrStatsAction.Response();
}

@Override
protected void doExecute(Task task, StatsAction.Request request, ActionListener<StatsAction.Response> listener) {
protected void doExecute(Task task, CcrStatsAction.Request request, ActionListener<CcrStatsAction.Response> listener) {
if (ccrLicenseChecker.isCcrAllowed() == false) {
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
return;
Expand All @@ -84,20 +84,20 @@ protected void doExecute(Task task, StatsAction.Request request, ActionListener<

@Override
protected void masterOperation(
StatsAction.Request request,
CcrStatsAction.Request request,
ClusterState state,
ActionListener<StatsAction.Response> listener
ActionListener<CcrStatsAction.Response> listener
) throws Exception {
CheckedConsumer<FollowStatsAction.StatsResponses, Exception> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
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);
}
Expand All @@ -30,8 +30,8 @@ public String getName() {

@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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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;

Expand Down Expand Up @@ -260,8 +260,8 @@ private void deleteAutoFollowPatternSetting() {
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
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<StatsAction.Response> {
public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase<CcrStatsAction.Response> {

@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(),
randomNonNegativeLong(),
randomReadExceptions()
);
FollowStatsAction.StatsResponses statsResponse = createStatsResponse();
return new StatsAction.Response(autoFollowStats, statsResponse);
return new CcrStatsAction.Response(autoFollowStats, statsResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
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 org.elasticsearch.xpack.core.ccr.client.CcrClient;
import org.elasticsearch.xpack.core.monitoring.MonitoredSystem;
import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringDoc;
Expand Down Expand Up @@ -139,8 +139,8 @@ public void testDoCollect() throws Exception {
when(statsResponse.getStatsResponses()).thenReturn(statuses);

@SuppressWarnings("unchecked")
final ActionFuture<StatsAction.Response> future = (ActionFuture<StatsAction.Response>) mock(ActionFuture.class);
final StatsAction.Response response = new StatsAction.Response(autoFollowStats, statsResponse);
final ActionFuture<CcrStatsAction.Response> future = (ActionFuture<CcrStatsAction.Response>) mock(ActionFuture.class);
final CcrStatsAction.Response response = new CcrStatsAction.Response(autoFollowStats, statsResponse);

when(client.stats(any())).thenReturn(future);
when(future.actionGet(timeout)).thenReturn(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.io.IOException;
import java.util.Objects;

public class StatsAction extends Action<StatsAction.Response> {
public class CcrStatsAction extends Action<CcrStatsAction.Response> {

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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;
Expand Down Expand Up @@ -65,13 +65,13 @@ public ActionFuture<FollowStatsAction.StatsResponses> followStats(final FollowSt
return listener;
}

public void stats(final StatsAction.Request request,
final ActionListener<StatsAction.Response> listener) {
client.execute(StatsAction.INSTANCE, request, listener);
public void stats(final CcrStatsAction.Request request,
final ActionListener<CcrStatsAction.Response> listener) {
client.execute(CcrStatsAction.INSTANCE, request, listener);
}

public ActionFuture<StatsAction.Response> stats(final StatsAction.Request request) {
final PlainActionFuture<StatsAction.Response> listener = PlainActionFuture.newFuture();
public ActionFuture<CcrStatsAction.Response> stats(final CcrStatsAction.Request request) {
final PlainActionFuture<CcrStatsAction.Response> listener = PlainActionFuture.newFuture();
stats(request, listener);
return listener;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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;
Expand Down Expand Up @@ -77,8 +77,8 @@ protected Collection<MonitoringDoc> doCollect(
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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"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",
"paths": [ "/{index}/_ccr/stats" ],
"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"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down