Skip to content

Commit 8a9ec8b

Browse files
committed
[CCR] Renamed leader_cluster to remote_cluster (elastic#34776)
and also some occurrences of clusterAlias to remoteCluster. Closes elastic#34682
1 parent 6948f8f commit 8a9ec8b

File tree

31 files changed

+144
-143
lines changed

31 files changed

+144
-143
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class CcrMultiClusterLicenseIT extends ESCCRRestTestCase {
2525
public void testFollow() {
2626
if ("follow".equals(targetCluster)) {
2727
final Request request = new Request("PUT", "/follower/_ccr/follow");
28-
request.setJsonEntity("{\"leader_cluster\": \"leader_cluster\", \"leader_index\": \"leader\"}");
28+
request.setJsonEntity("{\"remote_cluster\": \"leader_cluster\", \"leader_index\": \"leader\"}");
2929
assertNonCompliantLicense(request);
3030
}
3131
}
@@ -34,7 +34,7 @@ public void testAutoFollow() throws Exception {
3434
assumeFalse("windows is the worst", Constants.WINDOWS);
3535
if ("follow".equals(targetCluster)) {
3636
final Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
37-
request.setJsonEntity("{\"leader_index_patterns\":[\"*\"], \"leader_cluster\": \"leader_cluster\"}");
37+
request.setJsonEntity("{\"leader_index_patterns\":[\"*\"], \"remote_cluster\": \"leader_cluster\"}");
3838
client().performRequest(request);
3939

4040
// parse the logs and ensure that the auto-coordinator skipped coordination on the leader cluster

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ public void testAutoFollowPatterns() throws Exception {
132132

133133
{
134134
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
135-
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"leader_cluster\": \"leader_cluster\"}");
135+
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
136136
Exception e = expectThrows(ResponseException.class, () -> assertOK(client().performRequest(request)));
137137
assertThat(e.getMessage(), containsString("insufficient privileges to follow index [logs-*]"));
138138
}
139139

140140
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
141-
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-eu-*\"], \"leader_cluster\": \"leader_cluster\"}");
141+
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-eu-*\"], \"remote_cluster\": \"leader_cluster\"}");
142142
assertOK(client().performRequest(request));
143143

144144
try (RestClient leaderClient = buildLeaderClient()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void testAutoFollowPatterns() throws Exception {
8383
assumeFalse("Test should only run when both clusters are running", "leader".equals(targetCluster));
8484

8585
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
86-
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"leader_cluster\": \"leader_cluster\"}");
86+
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
8787
assertOK(client().performRequest(request));
8888

8989
try (RestClient leaderClient = buildLeaderClient()) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
ccr.put_auto_follow_pattern:
2424
name: my_pattern
2525
body:
26-
leader_cluster: local
26+
remote_cluster: local
2727
leader_index_patterns: ['logs-*']
2828
max_concurrent_read_batches: 2
2929
- is_true: acknowledged
3030

3131
- do:
3232
ccr.get_auto_follow_pattern:
3333
name: my_pattern
34-
- match: { my_pattern.leader_cluster: 'local' }
34+
- match: { my_pattern.remote_cluster: 'local' }
3535
- match: { my_pattern.leader_index_patterns: ['logs-*'] }
3636
- match: { my_pattern.max_concurrent_read_batches: 2 }
3737

3838
- do:
3939
ccr.get_auto_follow_pattern: {}
40-
- match: { my_pattern.leader_cluster: 'local' }
40+
- match: { my_pattern.remote_cluster: 'local' }
4141
- match: { my_pattern.leader_index_patterns: ['logs-*'] }
4242
- match: { my_pattern.max_concurrent_read_batches: 2 }
4343

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
ccr.follow:
3939
index: bar
4040
body:
41-
leader_cluster: local
41+
remote_cluster: local
4242
leader_index: foo
4343
- is_true: follow_index_created
4444
- is_true: follow_index_shards_acked

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
ccr.follow:
3939
index: bar
4040
body:
41-
leader_cluster: local
41+
remote_cluster: local
4242
leader_index: foo
4343
- is_true: follow_index_created
4444
- is_true: follow_index_shards_acked

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected static void followIndex(String leaderCluster, String leaderIndex, Stri
7373

7474
protected static void followIndex(RestClient client, String leaderCluster, String leaderIndex, String followIndex) throws IOException {
7575
final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow");
76-
request.setJsonEntity("{\"leader_cluster\": \"" + leaderCluster + "\", \"leader_index\": \"" + leaderIndex +
76+
request.setJsonEntity("{\"remote_cluster\": \"" + leaderCluster + "\", \"leader_index\": \"" + leaderIndex +
7777
"\", \"poll_timeout\": \"10ms\"}");
7878
assertOK(client.performRequest(request));
7979
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
9999
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS = "leader_index_shard_history_uuids";
100100
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY = "leader_index_uuid";
101101
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY = "leader_index_name";
102-
public static final String CCR_CUSTOM_METADATA_LEADER_CLUSTER_NAME_KEY = "leader_cluster_name";
102+
public static final String CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY = "remote_cluster_name";
103103

104104
private final boolean enabled;
105105
private final Settings settings;

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private void doAutoFollow() {
159159

160160
@Override
161161
void getLeaderClusterState(final Map<String, String> headers,
162-
final String leaderClusterAlias,
162+
final String remoteCluster,
163163
final BiConsumer<ClusterState, Exception> handler) {
164164
final ClusterStateRequest request = new ClusterStateRequest();
165165
request.clear();
@@ -168,7 +168,7 @@ void getLeaderClusterState(final Map<String, String> headers,
168168
ccrLicenseChecker.checkRemoteClusterLicenseAndFetchClusterState(
169169
client,
170170
headers,
171-
leaderClusterAlias,
171+
remoteCluster,
172172
request,
173173
e -> handler.accept(null, e),
174174
leaderClusterState -> handler.accept(leaderClusterState, null));
@@ -245,27 +245,27 @@ void autoFollowIndices() {
245245
final int slot = i;
246246
final String autoFollowPattenName = entry.getKey();
247247
final AutoFollowPattern autoFollowPattern = entry.getValue();
248-
final String leaderCluster = autoFollowPattern.getLeaderCluster();
248+
final String remoteCluster = autoFollowPattern.getRemoteCluster();
249249

250250
Map<String, String> headers = autoFollowMetadata.getHeaders().get(autoFollowPattenName);
251-
getLeaderClusterState(headers, leaderCluster, (leaderClusterState, e) -> {
251+
getLeaderClusterState(headers, remoteCluster, (leaderClusterState, e) -> {
252252
if (leaderClusterState != null) {
253253
assert e == null;
254254
final List<String> followedIndices = autoFollowMetadata.getFollowedLeaderIndexUUIDs().get(autoFollowPattenName);
255-
final List<Index> leaderIndicesToFollow = getLeaderIndicesToFollow(leaderCluster, autoFollowPattern,
255+
final List<Index> leaderIndicesToFollow = getLeaderIndicesToFollow(remoteCluster, autoFollowPattern,
256256
leaderClusterState, followerClusterState, followedIndices);
257257
if (leaderIndicesToFollow.isEmpty()) {
258258
finalise(slot, new AutoFollowResult(autoFollowPattenName));
259259
} else {
260260
List<Tuple<String, AutoFollowPattern>> patternsForTheSameLeaderCluster = autoFollowMetadata.getPatterns()
261261
.entrySet().stream()
262262
.filter(item -> autoFollowPattenName.equals(item.getKey()) == false)
263-
.filter(item -> leaderCluster.equals(item.getValue().getLeaderCluster()))
263+
.filter(item -> remoteCluster.equals(item.getValue().getRemoteCluster()))
264264
.map(item -> new Tuple<>(item.getKey(), item.getValue()))
265265
.collect(Collectors.toList());
266266

267267
Consumer<AutoFollowResult> resultHandler = result -> finalise(slot, result);
268-
checkAutoFollowPattern(autoFollowPattenName, leaderCluster, autoFollowPattern, leaderIndicesToFollow, headers,
268+
checkAutoFollowPattern(autoFollowPattenName, remoteCluster, autoFollowPattern, leaderIndicesToFollow, headers,
269269
patternsForTheSameLeaderCluster, resultHandler);
270270
}
271271
} else {
@@ -313,7 +313,7 @@ private void checkAutoFollowPattern(String autoFollowPattenName,
313313
}
314314

315315
private void followLeaderIndex(String autoFollowPattenName,
316-
String leaderCluster,
316+
String remoteCluster,
317317
Index indexToFollow,
318318
AutoFollowPattern pattern,
319319
Map<String,String> headers,
@@ -332,7 +332,7 @@ private void followLeaderIndex(String autoFollowPattenName,
332332
followRequest.setPollTimeout(pattern.getPollTimeout());
333333

334334
PutFollowAction.Request request = new PutFollowAction.Request();
335-
request.setLeaderCluster(leaderCluster);
335+
request.setRemoteCluster(remoteCluster);
336336
request.setLeaderIndex(indexToFollow.getName());
337337
request.setFollowRequest(followRequest);
338338

@@ -357,7 +357,7 @@ private void finalise(int slot, AutoFollowResult result) {
357357
}
358358
}
359359

360-
static List<Index> getLeaderIndicesToFollow(String clusterAlias,
360+
static List<Index> getLeaderIndicesToFollow(String remoteCluster,
361361
AutoFollowPattern autoFollowPattern,
362362
ClusterState leaderClusterState,
363363
ClusterState followerClusterState,
@@ -409,12 +409,12 @@ static Function<ClusterState, ClusterState> recordLeaderIndexAsFollowFunction(St
409409
* Fetch the cluster state from the leader with the specified cluster alias
410410
*
411411
* @param headers the client headers
412-
* @param leaderClusterAlias the cluster alias of the leader
412+
* @param remoteCluster the name of the leader cluster
413413
* @param handler the callback to invoke
414414
*/
415415
abstract void getLeaderClusterState(
416416
Map<String, String> headers,
417-
String leaderClusterAlias,
417+
String remoteCluster,
418418
BiConsumer<ClusterState, Exception> handler
419419
);
420420

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public synchronized ShardFollowNodeTaskStatus getStatus() {
437437
timeSinceLastFetchMillis = -1;
438438
}
439439
return new ShardFollowNodeTaskStatus(
440-
params.getLeaderCluster(),
440+
params.getRemoteCluster(),
441441
params.getLeaderShardId().getIndexName(),
442442
params.getFollowShardId().getIndexName(),
443443
getFollowShardId().getId(),

0 commit comments

Comments
 (0)