Skip to content

Commit 1d5aa27

Browse files
jasontedorkcm
authored andcommitted
Rename CCR stats implementation (#34300)
In the CCR docs we want to refer to the endpoint that returns following stats as the follow stats API. This commit renames the internal implementation of this endpoint to reflect this usage.
1 parent 108d5e9 commit 1d5aa27

File tree

15 files changed

+124
-119
lines changed

15 files changed

+124
-119
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import org.elasticsearch.xpack.ccr.action.ShardChangesAction;
5454
import org.elasticsearch.xpack.ccr.action.ShardFollowTask;
5555
import org.elasticsearch.xpack.ccr.action.ShardFollowTasksExecutor;
56-
import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction;
56+
import org.elasticsearch.xpack.ccr.action.TransportFollowStatsAction;
5757
import org.elasticsearch.xpack.ccr.action.TransportPutFollowAction;
5858
import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction;
5959
import org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction;
@@ -62,15 +62,15 @@
6262
import org.elasticsearch.xpack.ccr.action.bulk.BulkShardOperationsAction;
6363
import org.elasticsearch.xpack.ccr.action.bulk.TransportBulkShardOperationsAction;
6464
import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory;
65-
import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction;
65+
import org.elasticsearch.xpack.ccr.rest.RestFollowStatsAction;
6666
import org.elasticsearch.xpack.ccr.rest.RestPutFollowAction;
6767
import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction;
6868
import org.elasticsearch.xpack.ccr.rest.RestResumeFollowAction;
6969
import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction;
7070
import org.elasticsearch.xpack.ccr.rest.RestPauseFollowAction;
7171
import org.elasticsearch.xpack.core.XPackPlugin;
7272
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
73-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
73+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
7474
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
7575
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
7676
import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction;
@@ -161,7 +161,7 @@ public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(ClusterServic
161161
new ActionHandler<>(BulkShardOperationsAction.INSTANCE, TransportBulkShardOperationsAction.class),
162162
new ActionHandler<>(ShardChangesAction.INSTANCE, ShardChangesAction.TransportAction.class),
163163
// stats action
164-
new ActionHandler<>(CcrStatsAction.INSTANCE, TransportCcrStatsAction.class),
164+
new ActionHandler<>(FollowStatsAction.INSTANCE, TransportFollowStatsAction.class),
165165
new ActionHandler<>(AutoFollowStatsAction.INSTANCE, TransportAutoFollowStatsAction.class),
166166
// follow actions
167167
new ActionHandler<>(PutFollowAction.INSTANCE, TransportPutFollowAction.class),
@@ -184,7 +184,7 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
184184

185185
return Arrays.asList(
186186
// stats API
187-
new RestCcrStatsAction(settings, restController),
187+
new RestFollowStatsAction(settings, restController),
188188
new RestAutoFollowStatsAction(settings, restController),
189189
// follow APIs
190190
new RestPutFollowAction(settings, restController),
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.transport.TransportService;
2323
import org.elasticsearch.xpack.ccr.Ccr;
2424
import org.elasticsearch.xpack.ccr.CcrLicenseChecker;
25-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
25+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
2626

2727
import java.io.IOException;
2828
import java.util.Arrays;
@@ -32,16 +32,16 @@
3232
import java.util.Set;
3333
import java.util.function.Consumer;
3434

35-
public class TransportCcrStatsAction extends TransportTasksAction<
35+
public class TransportFollowStatsAction extends TransportTasksAction<
3636
ShardFollowNodeTask,
37-
CcrStatsAction.StatsRequest,
38-
CcrStatsAction.StatsResponses, CcrStatsAction.StatsResponse> {
37+
FollowStatsAction.StatsRequest,
38+
FollowStatsAction.StatsResponses, FollowStatsAction.StatsResponse> {
3939

4040
private final IndexNameExpressionResolver resolver;
4141
private final CcrLicenseChecker ccrLicenseChecker;
4242

4343
@Inject
44-
public TransportCcrStatsAction(
44+
public TransportFollowStatsAction(
4545
final Settings settings,
4646
final ClusterService clusterService,
4747
final TransportService transportService,
@@ -50,12 +50,12 @@ public TransportCcrStatsAction(
5050
final CcrLicenseChecker ccrLicenseChecker) {
5151
super(
5252
settings,
53-
CcrStatsAction.NAME,
53+
FollowStatsAction.NAME,
5454
clusterService,
5555
transportService,
5656
actionFilters,
57-
CcrStatsAction.StatsRequest::new,
58-
CcrStatsAction.StatsResponses::new,
57+
FollowStatsAction.StatsRequest::new,
58+
FollowStatsAction.StatsResponses::new,
5959
Ccr.CCR_THREAD_POOL_NAME);
6060
this.resolver = Objects.requireNonNull(resolver);
6161
this.ccrLicenseChecker = Objects.requireNonNull(ccrLicenseChecker);
@@ -64,8 +64,8 @@ public TransportCcrStatsAction(
6464
@Override
6565
protected void doExecute(
6666
final Task task,
67-
final CcrStatsAction.StatsRequest request,
68-
final ActionListener<CcrStatsAction.StatsResponses> listener) {
67+
final FollowStatsAction.StatsRequest request,
68+
final ActionListener<FollowStatsAction.StatsResponses> listener) {
6969
if (ccrLicenseChecker.isCcrAllowed() == false) {
7070
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
7171
return;
@@ -74,21 +74,21 @@ protected void doExecute(
7474
}
7575

7676
@Override
77-
protected CcrStatsAction.StatsResponses newResponse(
78-
final CcrStatsAction.StatsRequest request,
79-
final List<CcrStatsAction.StatsResponse> statsRespons,
77+
protected FollowStatsAction.StatsResponses newResponse(
78+
final FollowStatsAction.StatsRequest request,
79+
final List<FollowStatsAction.StatsResponse> statsRespons,
8080
final List<TaskOperationFailure> taskOperationFailures,
8181
final List<FailedNodeException> failedNodeExceptions) {
82-
return new CcrStatsAction.StatsResponses(taskOperationFailures, failedNodeExceptions, statsRespons);
82+
return new FollowStatsAction.StatsResponses(taskOperationFailures, failedNodeExceptions, statsRespons);
8383
}
8484

8585
@Override
86-
protected CcrStatsAction.StatsResponse readTaskResponse(final StreamInput in) throws IOException {
87-
return new CcrStatsAction.StatsResponse(in);
86+
protected FollowStatsAction.StatsResponse readTaskResponse(final StreamInput in) throws IOException {
87+
return new FollowStatsAction.StatsResponse(in);
8888
}
8989

9090
@Override
91-
protected void processTasks(final CcrStatsAction.StatsRequest request, final Consumer<ShardFollowNodeTask> operation) {
91+
protected void processTasks(final FollowStatsAction.StatsRequest request, final Consumer<ShardFollowNodeTask> operation) {
9292
final ClusterState state = clusterService.state();
9393
final Set<String> concreteIndices = new HashSet<>(Arrays.asList(resolver.concreteIndexNames(state, request)));
9494
for (final Task task : taskManager.getTasks().values()) {
@@ -103,10 +103,10 @@ protected void processTasks(final CcrStatsAction.StatsRequest request, final Con
103103

104104
@Override
105105
protected void taskOperation(
106-
final CcrStatsAction.StatsRequest request,
106+
final FollowStatsAction.StatsRequest request,
107107
final ShardFollowNodeTask task,
108-
final ActionListener<CcrStatsAction.StatsResponse> listener) {
109-
listener.onResponse(new CcrStatsAction.StatsResponse(task.getStatus()));
108+
final ActionListener<FollowStatsAction.StatsResponse> listener) {
109+
listener.onResponse(new FollowStatsAction.StatsResponse(task.getStatus()));
110110
}
111111

112112
}

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestCcrStatsAction.java renamed to x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/rest/RestFollowStatsAction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
import org.elasticsearch.rest.RestController;
1414
import org.elasticsearch.rest.RestRequest;
1515
import org.elasticsearch.rest.action.RestToXContentListener;
16-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
16+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
1717

1818
import java.io.IOException;
1919

20-
public class RestCcrStatsAction extends BaseRestHandler {
20+
public class RestFollowStatsAction extends BaseRestHandler {
2121

22-
public RestCcrStatsAction(final Settings settings, final RestController controller) {
22+
public RestFollowStatsAction(final Settings settings, final RestController controller) {
2323
super(settings);
2424
controller.registerHandler(RestRequest.Method.GET, "/_ccr/stats", this);
2525
controller.registerHandler(RestRequest.Method.GET, "/{index}/_ccr/stats", this);
@@ -32,9 +32,9 @@ public String getName() {
3232

3333
@Override
3434
protected RestChannelConsumer prepareRequest(final RestRequest restRequest, final NodeClient client) throws IOException {
35-
final CcrStatsAction.StatsRequest request = new CcrStatsAction.StatsRequest();
35+
final FollowStatsAction.StatsRequest request = new FollowStatsAction.StatsRequest();
3636
request.setIndices(Strings.splitStringByCommaToArray(restRequest.param("index")));
37-
return channel -> client.execute(CcrStatsAction.INSTANCE, request, new RestToXContentListener<>(channel));
37+
return channel -> client.execute(FollowStatsAction.INSTANCE, request, new RestToXContentListener<>(channel));
3838
}
3939

4040
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrLicenseIT.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.test.ESSingleNodeTestCase;
2323
import org.elasticsearch.test.MockLogAppender;
2424
import org.elasticsearch.xpack.ccr.action.AutoFollowCoordinator;
25-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
25+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
2626
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
2727
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
2828
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
@@ -88,21 +88,24 @@ public void onFailure(final Exception e) {
8888
latch.await();
8989
}
9090

91-
public void testThatCcrStatsAreUnavailableWithNonCompliantLicense() throws InterruptedException {
91+
public void testThatFollowStatsAreUnavailableWithNonCompliantLicense() throws InterruptedException {
9292
final CountDownLatch latch = new CountDownLatch(1);
93-
client().execute(CcrStatsAction.INSTANCE, new CcrStatsAction.StatsRequest(), new ActionListener<CcrStatsAction.StatsResponses>() {
94-
@Override
95-
public void onResponse(final CcrStatsAction.StatsResponses statsResponses) {
96-
latch.countDown();
97-
fail();
98-
}
93+
client().execute(
94+
FollowStatsAction.INSTANCE,
95+
new FollowStatsAction.StatsRequest(),
96+
new ActionListener<FollowStatsAction.StatsResponses>() {
97+
@Override
98+
public void onResponse(final FollowStatsAction.StatsResponses statsResponses) {
99+
latch.countDown();
100+
fail();
101+
}
99102

100-
@Override
101-
public void onFailure(final Exception e) {
102-
assertNonCompliantLicense(e);
103-
latch.countDown();
104-
}
105-
});
103+
@Override
104+
public void onFailure(final Exception e) {
105+
assertNonCompliantLicense(e);
106+
latch.countDown();
107+
}
108+
});
106109

107110
latch.await();
108111
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
import org.elasticsearch.xpack.ccr.index.engine.FollowingEngine;
6060
import org.elasticsearch.xpack.core.XPackSettings;
6161
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
62-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
63-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction.StatsRequest;
64-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction.StatsResponses;
62+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
63+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction.StatsRequest;
64+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction.StatsResponses;
6565
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
6666
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
6767
import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction;
@@ -570,7 +570,7 @@ public void testCloseLeaderIndex() throws Exception {
570570

571571
client().admin().indices().close(new CloseIndexRequest("index1")).actionGet();
572572
assertBusy(() -> {
573-
StatsResponses response = client().execute(CcrStatsAction.INSTANCE, new StatsRequest()).actionGet();
573+
StatsResponses response = client().execute(FollowStatsAction.INSTANCE, new StatsRequest()).actionGet();
574574
assertThat(response.getNodeFailures(), empty());
575575
assertThat(response.getTaskFailures(), empty());
576576
assertThat(response.getStatsResponses(), hasSize(1));
@@ -605,7 +605,7 @@ public void testCloseFollowIndex() throws Exception {
605605
client().admin().indices().close(new CloseIndexRequest("index2")).actionGet();
606606
client().prepareIndex("index1", "doc", "2").setSource("{}", XContentType.JSON).get();
607607
assertBusy(() -> {
608-
StatsResponses response = client().execute(CcrStatsAction.INSTANCE, new StatsRequest()).actionGet();
608+
StatsResponses response = client().execute(FollowStatsAction.INSTANCE, new StatsRequest()).actionGet();
609609
assertThat(response.getNodeFailures(), empty());
610610
assertThat(response.getTaskFailures(), empty());
611611
assertThat(response.getStatsResponses(), hasSize(1));

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/StatsRequestTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
package org.elasticsearch.xpack.ccr.action;
77

88
import org.elasticsearch.test.AbstractStreamableTestCase;
9-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
9+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
1010

11-
public class StatsRequestTests extends AbstractStreamableTestCase<CcrStatsAction.StatsRequest> {
11+
public class StatsRequestTests extends AbstractStreamableTestCase<FollowStatsAction.StatsRequest> {
1212

1313
@Override
14-
protected CcrStatsAction.StatsRequest createBlankInstance() {
15-
return new CcrStatsAction.StatsRequest();
14+
protected FollowStatsAction.StatsRequest createBlankInstance() {
15+
return new FollowStatsAction.StatsRequest();
1616
}
1717

1818
@Override
19-
protected CcrStatsAction.StatsRequest createTestInstance() {
20-
CcrStatsAction.StatsRequest statsRequest = new CcrStatsAction.StatsRequest();
19+
protected FollowStatsAction.StatsRequest createTestInstance() {
20+
FollowStatsAction.StatsRequest statsRequest = new FollowStatsAction.StatsRequest();
2121
if (randomBoolean()) {
2222
statsRequest.setIndices(generateRandomStringArray(8, 4, false));
2323
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/StatsResponsesTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
import org.elasticsearch.test.AbstractStreamableTestCase;
99
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
10-
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
10+
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
1111

1212
import java.util.ArrayList;
1313
import java.util.Collections;
1414
import java.util.List;
1515

16-
public class StatsResponsesTests extends AbstractStreamableTestCase<CcrStatsAction.StatsResponses> {
16+
public class StatsResponsesTests extends AbstractStreamableTestCase<FollowStatsAction.StatsResponses> {
1717

1818
@Override
19-
protected CcrStatsAction.StatsResponses createBlankInstance() {
20-
return new CcrStatsAction.StatsResponses();
19+
protected FollowStatsAction.StatsResponses createBlankInstance() {
20+
return new FollowStatsAction.StatsResponses();
2121
}
2222

2323
@Override
24-
protected CcrStatsAction.StatsResponses createTestInstance() {
24+
protected FollowStatsAction.StatsResponses createTestInstance() {
2525
int numResponses = randomIntBetween(0, 8);
26-
List<CcrStatsAction.StatsResponse> responses = new ArrayList<>(numResponses);
26+
List<FollowStatsAction.StatsResponse> responses = new ArrayList<>(numResponses);
2727
for (int i = 0; i < numResponses; i++) {
2828
ShardFollowNodeTaskStatus status = new ShardFollowNodeTaskStatus(
2929
randomAlphaOfLength(4),
@@ -49,8 +49,8 @@ protected CcrStatsAction.StatsResponses createTestInstance() {
4949
randomNonNegativeLong(),
5050
Collections.emptyNavigableMap(),
5151
randomLong());
52-
responses.add(new CcrStatsAction.StatsResponse(status));
52+
responses.add(new FollowStatsAction.StatsResponse(status));
5353
}
54-
return new CcrStatsAction.StatsResponses(Collections.emptyList(), Collections.emptyList(), responses);
54+
return new FollowStatsAction.StatsResponses(Collections.emptyList(), Collections.emptyList(), responses);
5555
}
5656
}

0 commit comments

Comments
 (0)