Skip to content

Commit 9129948

Browse files
authored
Rename CCR APIs (#34027)
* 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
1 parent 17b3b97 commit 9129948

File tree

33 files changed

+294
-293
lines changed

33 files changed

+294
-293
lines changed

x-pack/plugin/ccr/qa/multi-cluster-with-non-compliant-license/src/test/java/org/elasticsearch/xpack/ccr/CcrMultiClusterLicenseIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ protected boolean preserveClusterUponCompletion() {
3131
return true;
3232
}
3333

34-
public void testFollowIndex() {
34+
public void testResumeFollow() {
3535
if (runningAgainstLeaderCluster == false) {
36-
final Request request = new Request("POST", "/follower/_ccr/follow");
36+
final Request request = new Request("POST", "/follower/_ccr/resume_follow");
3737
request.setJsonEntity("{\"leader_index\": \"leader_cluster:leader\"}");
3838
assertNonCompliantLicense(request);
3939
}
4040
}
4141

42-
public void testCreateAndFollowIndex() {
42+
public void testFollow() {
4343
if (runningAgainstLeaderCluster == false) {
44-
final Request request = new Request("POST", "/follower/_ccr/create_and_follow");
44+
final Request request = new Request("PUT", "/follower/_ccr/follow");
4545
request.setJsonEntity("{\"leader_index\": \"leader_cluster:leader\"}");
4646
assertNonCompliantLicense(request);
4747
}

x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public void testFollowIndex() throws Exception {
8080
refresh(allowedIndex);
8181
verifyDocuments(adminClient(), allowedIndex, numDocs);
8282
} else {
83-
createAndFollowIndex("leader_cluster:" + allowedIndex, allowedIndex);
83+
follow("leader_cluster:" + allowedIndex, allowedIndex);
8484
assertBusy(() -> verifyDocuments(client(), allowedIndex, numDocs));
8585
assertThat(countCcrNodeTasks(), equalTo(1));
8686
assertBusy(() -> verifyCcrMonitoring(allowedIndex, allowedIndex));
87-
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/unfollow")));
87+
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/pause_follow")));
8888
// Make sure that there are no other ccr relates operations running:
8989
assertBusy(() -> {
9090
Map<String, Object> clusterState = toMap(adminClient().performRequest(new Request("GET", "/_cluster/state")));
@@ -93,9 +93,9 @@ public void testFollowIndex() throws Exception {
9393
assertThat(countCcrNodeTasks(), equalTo(0));
9494
});
9595

96-
followIndex("leader_cluster:" + allowedIndex, allowedIndex);
96+
resumeFollow("leader_cluster:" + allowedIndex, allowedIndex);
9797
assertThat(countCcrNodeTasks(), equalTo(1));
98-
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/unfollow")));
98+
assertOK(client().performRequest(new Request("POST", "/" + allowedIndex + "/_ccr/pause_follow")));
9999
// Make sure that there are no other ccr relates operations running:
100100
assertBusy(() -> {
101101
Map<String, Object> clusterState = toMap(adminClient().performRequest(new Request("GET", "/_cluster/state")));
@@ -105,15 +105,15 @@ public void testFollowIndex() throws Exception {
105105
});
106106

107107
Exception e = expectThrows(ResponseException.class,
108-
() -> createAndFollowIndex("leader_cluster:" + unallowedIndex, unallowedIndex));
108+
() -> follow("leader_cluster:" + unallowedIndex, unallowedIndex));
109109
assertThat(e.getMessage(),
110-
containsString("action [indices:admin/xpack/ccr/create_and_follow_index] is unauthorized for user [test_ccr]"));
110+
containsString("action [indices:admin/xpack/ccr/put_follow] is unauthorized for user [test_ccr]"));
111111
// Verify that the follow index has not been created and no node tasks are running
112112
assertThat(indexExists(adminClient(), unallowedIndex), is(false));
113113
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0)));
114114

115115
e = expectThrows(ResponseException.class,
116-
() -> followIndex("leader_cluster:" + unallowedIndex, unallowedIndex));
116+
() -> resumeFollow("leader_cluster:" + unallowedIndex, unallowedIndex));
117117
assertThat(e.getMessage(), containsString("action [indices:monitor/stats] is unauthorized for user [test_ccr]"));
118118
assertThat(indexExists(adminClient(), unallowedIndex), is(false));
119119
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0)));
@@ -157,10 +157,10 @@ public void testAutoFollowPatterns() throws Exception {
157157
verifyAutoFollowMonitoring();
158158
});
159159

160-
// Cleanup by deleting auto follow pattern and unfollowing:
160+
// Cleanup by deleting auto follow pattern and pause following:
161161
request = new Request("DELETE", "/_ccr/auto_follow/leader_cluster");
162162
assertOK(client().performRequest(request));
163-
unfollowIndex(allowedIndex);
163+
pauseFollow(allowedIndex);
164164
}
165165

166166
private int countCcrNodeTasks() throws IOException {
@@ -201,14 +201,14 @@ private static void refresh(String index) throws IOException {
201201
assertOK(adminClient().performRequest(new Request("POST", "/" + index + "/_refresh")));
202202
}
203203

204-
private static void followIndex(String leaderIndex, String followIndex) throws IOException {
205-
final Request request = new Request("POST", "/" + followIndex + "/_ccr/follow");
204+
private static void resumeFollow(String leaderIndex, String followIndex) throws IOException {
205+
final Request request = new Request("POST", "/" + followIndex + "/_ccr/resume_follow");
206206
request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}");
207207
assertOK(client().performRequest(request));
208208
}
209209

210-
private static void createAndFollowIndex(String leaderIndex, String followIndex) throws IOException {
211-
final Request request = new Request("POST", "/" + followIndex + "/_ccr/create_and_follow");
210+
private static void follow(String leaderIndex, String followIndex) throws IOException {
211+
final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow");
212212
request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}");
213213
assertOK(client().performRequest(request));
214214
}
@@ -273,8 +273,8 @@ private static boolean indexExists(RestClient client, String index) throws IOExc
273273
return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode();
274274
}
275275

276-
private static void unfollowIndex(String followIndex) throws IOException {
277-
assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/unfollow")));
276+
private static void pauseFollow(String followIndex) throws IOException {
277+
assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/pause_follow")));
278278
}
279279

280280
private static void verifyCcrMonitoring(String expectedLeaderIndex, String expectedFollowerIndex) throws IOException {

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public void testFollowIndex() throws Exception {
6767
} else {
6868
logger.info("Running against follow cluster");
6969
final String followIndexName = "test_index2";
70-
createAndFollowIndex("leader_cluster:" + leaderIndexName, followIndexName);
70+
followIndex("leader_cluster:" + leaderIndexName, followIndexName);
7171
assertBusy(() -> verifyDocuments(followIndexName, numDocs));
7272
// unfollow and then follow and then index a few docs in leader index:
73-
unfollowIndex(followIndexName);
74-
followIndex("leader_cluster:" + leaderIndexName, followIndexName);
73+
pauseFollow(followIndexName);
74+
resumeFollow("leader_cluster:" + leaderIndexName, followIndexName);
7575
try (RestClient leaderClient = buildLeaderClient()) {
7676
int id = numDocs;
7777
index(leaderClient, leaderIndexName, Integer.toString(id), "field", id, "filtered_field", "true");
@@ -86,11 +86,11 @@ public void testFollowIndex() throws Exception {
8686
public void testFollowNonExistingLeaderIndex() throws Exception {
8787
assumeFalse("Test should only run when both clusters are running", runningAgainstLeaderCluster);
8888
ResponseException e = expectThrows(ResponseException.class,
89-
() -> followIndex("leader_cluster:non-existing-index", "non-existing-index"));
89+
() -> resumeFollow("leader_cluster:non-existing-index", "non-existing-index"));
9090
assertThat(e.getMessage(), containsString("no such index"));
9191
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
9292

93-
e = expectThrows(ResponseException.class, () -> createAndFollowIndex("leader_cluster:non-existing-index", "non-existing-index"));
93+
e = expectThrows(ResponseException.class, () -> followIndex("leader_cluster:non-existing-index", "non-existing-index"));
9494
assertThat(e.getMessage(), containsString("no such index"));
9595
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
9696
}
@@ -146,20 +146,20 @@ private static void refresh(String index) throws IOException {
146146
assertOK(client().performRequest(new Request("POST", "/" + index + "/_refresh")));
147147
}
148148

149-
private static void followIndex(String leaderIndex, String followIndex) throws IOException {
150-
final Request request = new Request("POST", "/" + followIndex + "/_ccr/follow");
149+
private static void resumeFollow(String leaderIndex, String followIndex) throws IOException {
150+
final Request request = new Request("POST", "/" + followIndex + "/_ccr/resume_follow");
151151
request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}");
152152
assertOK(client().performRequest(request));
153153
}
154154

155-
private static void createAndFollowIndex(String leaderIndex, String followIndex) throws IOException {
156-
final Request request = new Request("POST", "/" + followIndex + "/_ccr/create_and_follow");
155+
private static void followIndex(String leaderIndex, String followIndex) throws IOException {
156+
final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow");
157157
request.setJsonEntity("{\"leader_index\": \"" + leaderIndex + "\", \"poll_timeout\": \"10ms\"}");
158158
assertOK(client().performRequest(request));
159159
}
160160

161-
private static void unfollowIndex(String followIndex) throws IOException {
162-
assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/unfollow")));
161+
private static void pauseFollow(String followIndex) throws IOException {
162+
assertOK(client().performRequest(new Request("POST", "/" + followIndex + "/_ccr/pause_follow")));
163163
}
164164

165165
private static void verifyDocuments(String index, int expectedNumDocs) throws IOException {

x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/follow_and_unfollow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- is_true: acknowledged
1717

1818
- do:
19-
ccr.create_and_follow_index:
19+
ccr.follow:
2020
index: bar
2121
body:
2222
leader_index: foo
@@ -25,18 +25,18 @@
2525
- is_true: index_following_started
2626

2727
- do:
28-
ccr.unfollow_index:
28+
ccr.pause_follow:
2929
index: bar
3030
- is_true: acknowledged
3131

3232
- do:
33-
ccr.follow_index:
33+
ccr.resume_follow:
3434
index: bar
3535
body:
3636
leader_index: foo
3737
- is_true: acknowledged
3838

3939
- do:
40-
ccr.unfollow_index:
40+
ccr.pause_follow:
4141
index: bar
4242
- is_true: acknowledged

x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
type: keyword
1616

1717
- do:
18-
ccr.create_and_follow_index:
18+
ccr.follow:
1919
index: bar
2020
body:
2121
leader_index: foo
@@ -51,7 +51,7 @@
5151
- gte: { bar.0.time_since_last_fetch_millis: -1 }
5252

5353
- do:
54-
ccr.unfollow_index:
54+
ccr.pause_follow:
5555
index: bar
5656
- is_true: acknowledged
5757

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,26 @@
5252
import org.elasticsearch.xpack.ccr.action.ShardFollowTask;
5353
import org.elasticsearch.xpack.ccr.action.ShardFollowTasksExecutor;
5454
import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction;
55-
import org.elasticsearch.xpack.ccr.action.TransportCreateAndFollowIndexAction;
55+
import org.elasticsearch.xpack.ccr.action.TransportPutFollowAction;
5656
import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction;
57-
import org.elasticsearch.xpack.ccr.action.TransportFollowIndexAction;
57+
import org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction;
5858
import org.elasticsearch.xpack.ccr.action.TransportPutAutoFollowPatternAction;
59-
import org.elasticsearch.xpack.ccr.action.TransportUnfollowIndexAction;
59+
import org.elasticsearch.xpack.ccr.action.TransportPauseFollowAction;
6060
import org.elasticsearch.xpack.ccr.action.bulk.BulkShardOperationsAction;
6161
import org.elasticsearch.xpack.ccr.action.bulk.TransportBulkShardOperationsAction;
6262
import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory;
6363
import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction;
64-
import org.elasticsearch.xpack.ccr.rest.RestCreateAndFollowIndexAction;
64+
import org.elasticsearch.xpack.ccr.rest.RestPutFollowAction;
6565
import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction;
66-
import org.elasticsearch.xpack.ccr.rest.RestFollowIndexAction;
66+
import org.elasticsearch.xpack.ccr.rest.RestResumeFollowAction;
6767
import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction;
68-
import org.elasticsearch.xpack.ccr.rest.RestUnfollowIndexAction;
68+
import org.elasticsearch.xpack.ccr.rest.RestPauseFollowAction;
6969
import org.elasticsearch.xpack.core.XPackPlugin;
7070
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
7171
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
72-
import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction;
73-
import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction;
74-
import org.elasticsearch.xpack.core.ccr.action.UnfollowIndexAction;
72+
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
73+
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
74+
import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction;
7575

7676
import java.util.Arrays;
7777
import java.util.Collection;
@@ -161,9 +161,9 @@ public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(ClusterServic
161161
new ActionHandler<>(CcrStatsAction.INSTANCE, TransportCcrStatsAction.class),
162162
new ActionHandler<>(AutoFollowStatsAction.INSTANCE, TransportAutoFollowStatsAction.class),
163163
// follow actions
164-
new ActionHandler<>(CreateAndFollowIndexAction.INSTANCE, TransportCreateAndFollowIndexAction.class),
165-
new ActionHandler<>(FollowIndexAction.INSTANCE, TransportFollowIndexAction.class),
166-
new ActionHandler<>(UnfollowIndexAction.INSTANCE, TransportUnfollowIndexAction.class),
164+
new ActionHandler<>(PutFollowAction.INSTANCE, TransportPutFollowAction.class),
165+
new ActionHandler<>(ResumeFollowAction.INSTANCE, TransportResumeFollowAction.class),
166+
new ActionHandler<>(PauseFollowAction.INSTANCE, TransportPauseFollowAction.class),
167167
// auto-follow actions
168168
new ActionHandler<>(DeleteAutoFollowPatternAction.INSTANCE, TransportDeleteAutoFollowPatternAction.class),
169169
new ActionHandler<>(PutAutoFollowPatternAction.INSTANCE, TransportPutAutoFollowPatternAction.class),
@@ -183,9 +183,9 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
183183
new RestCcrStatsAction(settings, restController),
184184
new RestAutoFollowStatsAction(settings, restController),
185185
// follow APIs
186-
new RestCreateAndFollowIndexAction(settings, restController),
187-
new RestFollowIndexAction(settings, restController),
188-
new RestUnfollowIndexAction(settings, restController),
186+
new RestPutFollowAction(settings, restController),
187+
new RestResumeFollowAction(settings, restController),
188+
new RestPauseFollowAction(settings, restController),
189189
// auto-follow APIs
190190
new RestDeleteAutoFollowPatternAction(settings, restController),
191191
new RestPutAutoFollowPatternAction(settings, restController),

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
3535
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
3636
import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
37-
import org.elasticsearch.xpack.core.ccr.action.CreateAndFollowIndexAction;
38-
import org.elasticsearch.xpack.core.ccr.action.FollowIndexAction;
37+
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
38+
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
3939

4040
import java.util.ArrayList;
4141
import java.util.Collections;
@@ -184,13 +184,13 @@ void getLeaderClusterState(final Map<String, String> headers,
184184

185185
@Override
186186
void createAndFollow(Map<String, String> headers,
187-
FollowIndexAction.Request followRequest,
187+
ResumeFollowAction.Request followRequest,
188188
Runnable successHandler,
189189
Consumer<Exception> failureHandler) {
190190
Client followerClient = CcrLicenseChecker.wrapClient(client, headers);
191-
CreateAndFollowIndexAction.Request request = new CreateAndFollowIndexAction.Request(followRequest);
191+
PutFollowAction.Request request = new PutFollowAction.Request(followRequest);
192192
followerClient.execute(
193-
CreateAndFollowIndexAction.INSTANCE,
193+
PutFollowAction.INSTANCE,
194194
request,
195195
ActionListener.wrap(r -> successHandler.run(), failureHandler)
196196
);
@@ -306,7 +306,7 @@ private void followLeaderIndex(String clusterAlias,
306306

307307
String leaderIndexNameWithClusterAliasPrefix = clusterAlias.equals("_local_") ? leaderIndexName :
308308
clusterAlias + ":" + leaderIndexName;
309-
FollowIndexAction.Request request = new FollowIndexAction.Request();
309+
ResumeFollowAction.Request request = new ResumeFollowAction.Request();
310310
request.setLeaderIndex(leaderIndexNameWithClusterAliasPrefix);
311311
request.setFollowerIndex(followIndexName);
312312
request.setMaxBatchOperationCount(pattern.getMaxBatchOperationCount());
@@ -409,7 +409,7 @@ abstract void getLeaderClusterState(
409409

410410
abstract void createAndFollow(
411411
Map<String, String> headers,
412-
FollowIndexAction.Request followRequest,
412+
ResumeFollowAction.Request followRequest,
413413
Runnable successHandler,
414414
Consumer<Exception> failureHandler
415415
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public static class Request extends SingleShardRequest<Request> {
6363
private int maxOperationCount;
6464
private ShardId shardId;
6565
private String expectedHistoryUUID;
66-
private TimeValue pollTimeout = TransportFollowIndexAction.DEFAULT_POLL_TIMEOUT;
67-
private long maxOperationSizeInBytes = TransportFollowIndexAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES;
66+
private TimeValue pollTimeout = TransportResumeFollowAction.DEFAULT_POLL_TIMEOUT;
67+
private long maxOperationSizeInBytes = TransportResumeFollowAction.DEFAULT_MAX_BATCH_SIZE_IN_BYTES;
6868

6969
public Request(ShardId shardId, String expectedHistoryUUID) {
7070
super(shardId.getIndexName());

0 commit comments

Comments
 (0)