Skip to content

Commit 8a9ec8b

Browse files
committed
[CCR] Renamed leader_cluster to remote_cluster (#34776)
and also some occurrences of clusterAlias to remoteCluster. Closes #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(),

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
3636
public static final Set<String> HEADER_FILTERS =
3737
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("es-security-runas-user", "_xpack_security_authentication")));
3838

39-
static final ParseField LEADER_CLUSTER_FIELD = new ParseField("leader_cluster");
39+
static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
4040
static final ParseField FOLLOW_SHARD_INDEX_FIELD = new ParseField("follow_shard_index");
4141
static final ParseField FOLLOW_SHARD_INDEX_UUID_FIELD = new ParseField("follow_shard_index_uuid");
4242
static final ParseField FOLLOW_SHARD_SHARDID_FIELD = new ParseField("follow_shard_shard");
@@ -59,7 +59,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
5959
(int) a[10], (int) a[11], (TimeValue) a[12], (TimeValue) a[13], (Map<String, String>) a[14]));
6060

6161
static {
62-
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), LEADER_CLUSTER_FIELD);
62+
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), REMOTE_CLUSTER_FIELD);
6363
PARSER.declareString(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_INDEX_FIELD);
6464
PARSER.declareString(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_INDEX_UUID_FIELD);
6565
PARSER.declareInt(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_SHARDID_FIELD);
@@ -84,7 +84,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
8484
PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> p.mapStrings(), HEADERS);
8585
}
8686

87-
private final String leaderCluster;
87+
private final String remoteCluster;
8888
private final ShardId followShardId;
8989
private final ShardId leaderShardId;
9090
private final int maxBatchOperationCount;
@@ -97,7 +97,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
9797
private final Map<String, String> headers;
9898

9999
ShardFollowTask(
100-
final String leaderCluster,
100+
final String remoteCluster,
101101
final ShardId followShardId,
102102
final ShardId leaderShardId,
103103
final int maxBatchOperationCount,
@@ -108,7 +108,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
108108
final TimeValue maxRetryDelay,
109109
final TimeValue pollTimeout,
110110
final Map<String, String> headers) {
111-
this.leaderCluster = leaderCluster;
111+
this.remoteCluster = remoteCluster;
112112
this.followShardId = followShardId;
113113
this.leaderShardId = leaderShardId;
114114
this.maxBatchOperationCount = maxBatchOperationCount;
@@ -122,7 +122,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
122122
}
123123

124124
public ShardFollowTask(StreamInput in) throws IOException {
125-
this.leaderCluster = in.readString();
125+
this.remoteCluster = in.readString();
126126
this.followShardId = ShardId.readShardId(in);
127127
this.leaderShardId = ShardId.readShardId(in);
128128
this.maxBatchOperationCount = in.readVInt();
@@ -135,8 +135,8 @@ public ShardFollowTask(StreamInput in) throws IOException {
135135
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
136136
}
137137

138-
public String getLeaderCluster() {
139-
return leaderCluster;
138+
public String getRemoteCluster() {
139+
return remoteCluster;
140140
}
141141

142142
public ShardId getFollowShardId() {
@@ -190,7 +190,7 @@ public String getWriteableName() {
190190

191191
@Override
192192
public void writeTo(StreamOutput out) throws IOException {
193-
out.writeString(leaderCluster);
193+
out.writeString(remoteCluster);
194194
followShardId.writeTo(out);
195195
leaderShardId.writeTo(out);
196196
out.writeVLong(maxBatchOperationCount);
@@ -210,7 +210,7 @@ public static ShardFollowTask fromXContent(XContentParser parser) {
210210
@Override
211211
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
212212
builder.startObject();
213-
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
213+
builder.field(REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
214214
builder.field(FOLLOW_SHARD_INDEX_FIELD.getPreferredName(), followShardId.getIndex().getName());
215215
builder.field(FOLLOW_SHARD_INDEX_UUID_FIELD.getPreferredName(), followShardId.getIndex().getUUID());
216216
builder.field(FOLLOW_SHARD_SHARDID_FIELD.getPreferredName(), followShardId.id());
@@ -233,7 +233,7 @@ public boolean equals(Object o) {
233233
if (this == o) return true;
234234
if (o == null || getClass() != o.getClass()) return false;
235235
ShardFollowTask that = (ShardFollowTask) o;
236-
return Objects.equals(leaderCluster, that.leaderCluster) &&
236+
return Objects.equals(remoteCluster, that.remoteCluster) &&
237237
Objects.equals(followShardId, that.followShardId) &&
238238
Objects.equals(leaderShardId, that.leaderShardId) &&
239239
maxBatchOperationCount == that.maxBatchOperationCount &&
@@ -249,7 +249,7 @@ public boolean equals(Object o) {
249249
@Override
250250
public int hashCode() {
251251
return Objects.hash(
252-
leaderCluster,
252+
remoteCluster,
253253
followShardId,
254254
leaderShardId,
255255
maxBatchOperationCount,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ protected AllocatedPersistentTask createTask(long id, String type, String action
7979
Map<String, String> headers) {
8080
ShardFollowTask params = taskInProgress.getParams();
8181
final Client leaderClient;
82-
if (params.getLeaderCluster() != null) {
83-
leaderClient = wrapClient(client.getRemoteClusterClient(params.getLeaderCluster()), params.getHeaders());
82+
if (params.getRemoteCluster() != null) {
83+
leaderClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
8484
} else {
8585
leaderClient = wrapClient(client, params.getHeaders());
8686
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
7676
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
7777
return;
7878
}
79-
final Client leaderClient = client.getRemoteClusterClient(request.getLeaderCluster());
79+
final Client leaderClient = client.getRemoteClusterClient(request.getRemoteCluster());
8080
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
8181
clusterStateRequest.clear();
8282
clusterStateRequest.metaData(true);
@@ -93,7 +93,7 @@ protected void masterOperation(PutAutoFollowPatternAction.Request request,
9393
ActionListener.wrap(
9494
clusterStateResponse -> {
9595
final ClusterState leaderClusterState = clusterStateResponse.getState();
96-
clusterService.submitStateUpdateTask("put-auto-follow-pattern-" + request.getLeaderCluster(),
96+
clusterService.submitStateUpdateTask("put-auto-follow-pattern-" + request.getRemoteCluster(),
9797
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
9898

9999
@Override
@@ -157,7 +157,7 @@ static ClusterState innerPut(PutAutoFollowPatternAction.Request request,
157157
}
158158

159159
AutoFollowPattern autoFollowPattern = new AutoFollowPattern(
160-
request.getLeaderCluster(),
160+
request.getRemoteCluster(),
161161
request.getLeaderIndexPatterns(),
162162
request.getFollowIndexNamePattern(),
163163
request.getMaxBatchOperationCount(),

0 commit comments

Comments
 (0)