Fix CCR API specification (#34963)

This commit fixes two issues with the CCR API specification:
 - remove the CCR stats endpoint, it is not currently implemented
 - fix the documentation links
This commit is contained in:
Jason Tedor 2018-10-29 09:37:13 -04:00 committed by GitHub
parent 329a94be0c
commit 26f5c509af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 83 additions and 53 deletions

View File

@ -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
@ -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[]

View File

@ -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

View File

@ -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),

View File

@ -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<StatsAction.Request, StatsAction.Response> {
public class TransportStatsAction extends TransportMasterNodeAction<CcrStatsAction.Request, CcrStatsAction.Response> {
private final Client client;
private final CcrLicenseChecker ccrLicenseChecker;
@ -50,12 +50,12 @@ public class TransportStatsAction extends TransportMasterNodeAction<StatsAction.
) {
super(
settings,
StatsAction.NAME,
CcrStatsAction.NAME,
transportService,
clusterService,
threadPool,
actionFilters,
StatsAction.Request::new,
CcrStatsAction.Request::new,
indexNameExpressionResolver
);
this.client = client;
@ -69,12 +69,12 @@ public class TransportStatsAction extends TransportMasterNodeAction<StatsAction.
}
@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;
@ -84,20 +84,20 @@ public class TransportStatsAction extends TransportMasterNodeAction<StatsAction.
@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);
}
}

View File

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

View File

@ -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) {

View File

@ -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<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(),
@ -29,6 +29,6 @@ public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase<Sta
randomReadExceptions()
);
FollowStatsAction.StatsResponses statsResponse = createStatsResponse();
return new StatsAction.Response(autoFollowStats, statsResponse);
return new CcrStatsAction.Response(autoFollowStats, statsResponse);
}
}

View File

@ -16,7 +16,7 @@ import org.elasticsearch.xpack.core.XPackSettings;
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;
@ -139,8 +139,8 @@ public class StatsCollectorTests extends BaseCollectorTestCase {
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);

View File

@ -19,12 +19,12 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
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);
}

View File

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

View File

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

View File

@ -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}",

View File

@ -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",

View File

@ -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"
}
}
}

View File

@ -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}",

View File

@ -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",

View File

@ -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}",

View File

@ -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",

View File

@ -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",