[CCR] Renamed leader_cluster to remote_cluster (#34776)

and also some occurrences of clusterAlias to remoteCluster.

Closes #34682
This commit is contained in:
Martijn van Groningen 2018-10-24 13:39:36 +02:00 committed by GitHub
parent be907516ad
commit 76240e6bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 144 additions and 143 deletions

View File

@ -25,7 +25,7 @@ public class CcrMultiClusterLicenseIT extends ESCCRRestTestCase {
public void testFollow() {
if ("follow".equals(targetCluster)) {
final Request request = new Request("PUT", "/follower/_ccr/follow");
request.setJsonEntity("{\"leader_cluster\": \"leader_cluster\", \"leader_index\": \"leader\"}");
request.setJsonEntity("{\"remote_cluster\": \"leader_cluster\", \"leader_index\": \"leader\"}");
assertNonCompliantLicense(request);
}
}
@ -34,7 +34,7 @@ public class CcrMultiClusterLicenseIT extends ESCCRRestTestCase {
assumeFalse("windows is the worst", Constants.WINDOWS);
if ("follow".equals(targetCluster)) {
final Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
request.setJsonEntity("{\"leader_index_patterns\":[\"*\"], \"leader_cluster\": \"leader_cluster\"}");
request.setJsonEntity("{\"leader_index_patterns\":[\"*\"], \"remote_cluster\": \"leader_cluster\"}");
client().performRequest(request);
// parse the logs and ensure that the auto-coordinator skipped coordination on the leader cluster

View File

@ -132,13 +132,13 @@ public class FollowIndexSecurityIT extends ESCCRRestTestCase {
{
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"leader_cluster\": \"leader_cluster\"}");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
Exception e = expectThrows(ResponseException.class, () -> assertOK(client().performRequest(request)));
assertThat(e.getMessage(), containsString("insufficient privileges to follow index [logs-*]"));
}
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-eu-*\"], \"leader_cluster\": \"leader_cluster\"}");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-eu-*\"], \"remote_cluster\": \"leader_cluster\"}");
assertOK(client().performRequest(request));
try (RestClient leaderClient = buildLeaderClient()) {

View File

@ -83,7 +83,7 @@ public class FollowIndexIT extends ESCCRRestTestCase {
assumeFalse("Test should only run when both clusters are running", "leader".equals(targetCluster));
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"leader_cluster\": \"leader_cluster\"}");
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
assertOK(client().performRequest(request));
try (RestClient leaderClient = buildLeaderClient()) {

View File

@ -23,7 +23,7 @@
ccr.put_auto_follow_pattern:
name: my_pattern
body:
leader_cluster: local
remote_cluster: local
leader_index_patterns: ['logs-*']
max_concurrent_read_batches: 2
- is_true: acknowledged
@ -31,13 +31,13 @@
- do:
ccr.get_auto_follow_pattern:
name: my_pattern
- match: { my_pattern.leader_cluster: 'local' }
- match: { my_pattern.remote_cluster: 'local' }
- match: { my_pattern.leader_index_patterns: ['logs-*'] }
- match: { my_pattern.max_concurrent_read_batches: 2 }
- do:
ccr.get_auto_follow_pattern: {}
- match: { my_pattern.leader_cluster: 'local' }
- match: { my_pattern.remote_cluster: 'local' }
- match: { my_pattern.leader_index_patterns: ['logs-*'] }
- match: { my_pattern.max_concurrent_read_batches: 2 }

View File

@ -38,7 +38,7 @@
ccr.follow:
index: bar
body:
leader_cluster: local
remote_cluster: local
leader_index: foo
- is_true: follow_index_created
- is_true: follow_index_shards_acked

View File

@ -37,7 +37,7 @@
ccr.follow:
index: bar
body:
leader_cluster: local
remote_cluster: local
leader_index: foo
- is_true: follow_index_created
- is_true: follow_index_shards_acked

View File

@ -73,7 +73,7 @@ public class ESCCRRestTestCase extends ESRestTestCase {
protected static void followIndex(RestClient client, String leaderCluster, String leaderIndex, String followIndex) throws IOException {
final Request request = new Request("PUT", "/" + followIndex + "/_ccr/follow");
request.setJsonEntity("{\"leader_cluster\": \"" + leaderCluster + "\", \"leader_index\": \"" + leaderIndex +
request.setJsonEntity("{\"remote_cluster\": \"" + leaderCluster + "\", \"leader_index\": \"" + leaderIndex +
"\", \"poll_timeout\": \"10ms\"}");
assertOK(client.performRequest(request));
}

View File

@ -98,7 +98,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS = "leader_index_shard_history_uuids";
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY = "leader_index_uuid";
public static final String CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY = "leader_index_name";
public static final String CCR_CUSTOM_METADATA_LEADER_CLUSTER_NAME_KEY = "leader_cluster_name";
public static final String CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY = "remote_cluster_name";
private final boolean enabled;
private final Settings settings;

View File

@ -159,7 +159,7 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
@Override
void getLeaderClusterState(final Map<String, String> headers,
final String leaderClusterAlias,
final String remoteCluster,
final BiConsumer<ClusterState, Exception> handler) {
final ClusterStateRequest request = new ClusterStateRequest();
request.clear();
@ -168,7 +168,7 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
ccrLicenseChecker.checkRemoteClusterLicenseAndFetchClusterState(
client,
headers,
leaderClusterAlias,
remoteCluster,
request,
e -> handler.accept(null, e),
leaderClusterState -> handler.accept(leaderClusterState, null));
@ -245,14 +245,14 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
final int slot = i;
final String autoFollowPattenName = entry.getKey();
final AutoFollowPattern autoFollowPattern = entry.getValue();
final String leaderCluster = autoFollowPattern.getLeaderCluster();
final String remoteCluster = autoFollowPattern.getRemoteCluster();
Map<String, String> headers = autoFollowMetadata.getHeaders().get(autoFollowPattenName);
getLeaderClusterState(headers, leaderCluster, (leaderClusterState, e) -> {
getLeaderClusterState(headers, remoteCluster, (leaderClusterState, e) -> {
if (leaderClusterState != null) {
assert e == null;
final List<String> followedIndices = autoFollowMetadata.getFollowedLeaderIndexUUIDs().get(autoFollowPattenName);
final List<Index> leaderIndicesToFollow = getLeaderIndicesToFollow(leaderCluster, autoFollowPattern,
final List<Index> leaderIndicesToFollow = getLeaderIndicesToFollow(remoteCluster, autoFollowPattern,
leaderClusterState, followerClusterState, followedIndices);
if (leaderIndicesToFollow.isEmpty()) {
finalise(slot, new AutoFollowResult(autoFollowPattenName));
@ -260,12 +260,12 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
List<Tuple<String, AutoFollowPattern>> patternsForTheSameLeaderCluster = autoFollowMetadata.getPatterns()
.entrySet().stream()
.filter(item -> autoFollowPattenName.equals(item.getKey()) == false)
.filter(item -> leaderCluster.equals(item.getValue().getLeaderCluster()))
.filter(item -> remoteCluster.equals(item.getValue().getRemoteCluster()))
.map(item -> new Tuple<>(item.getKey(), item.getValue()))
.collect(Collectors.toList());
Consumer<AutoFollowResult> resultHandler = result -> finalise(slot, result);
checkAutoFollowPattern(autoFollowPattenName, leaderCluster, autoFollowPattern, leaderIndicesToFollow, headers,
checkAutoFollowPattern(autoFollowPattenName, remoteCluster, autoFollowPattern, leaderIndicesToFollow, headers,
patternsForTheSameLeaderCluster, resultHandler);
}
} else {
@ -313,7 +313,7 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
}
private void followLeaderIndex(String autoFollowPattenName,
String leaderCluster,
String remoteCluster,
Index indexToFollow,
AutoFollowPattern pattern,
Map<String,String> headers,
@ -332,7 +332,7 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
followRequest.setPollTimeout(pattern.getPollTimeout());
PutFollowAction.Request request = new PutFollowAction.Request();
request.setLeaderCluster(leaderCluster);
request.setRemoteCluster(remoteCluster);
request.setLeaderIndex(indexToFollow.getName());
request.setFollowRequest(followRequest);
@ -357,7 +357,7 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
}
}
static List<Index> getLeaderIndicesToFollow(String clusterAlias,
static List<Index> getLeaderIndicesToFollow(String remoteCluster,
AutoFollowPattern autoFollowPattern,
ClusterState leaderClusterState,
ClusterState followerClusterState,
@ -409,12 +409,12 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
* Fetch the cluster state from the leader with the specified cluster alias
*
* @param headers the client headers
* @param leaderClusterAlias the cluster alias of the leader
* @param remoteCluster the name of the leader cluster
* @param handler the callback to invoke
*/
abstract void getLeaderClusterState(
Map<String, String> headers,
String leaderClusterAlias,
String remoteCluster,
BiConsumer<ClusterState, Exception> handler
);

View File

@ -443,7 +443,7 @@ public abstract class ShardFollowNodeTask extends AllocatedPersistentTask {
timeSinceLastFetchMillis = -1;
}
return new ShardFollowNodeTaskStatus(
params.getLeaderCluster(),
params.getRemoteCluster(),
params.getLeaderShardId().getIndexName(),
params.getFollowShardId().getIndexName(),
getFollowShardId().getId(),

View File

@ -36,7 +36,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
public static final Set<String> HEADER_FILTERS =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("es-security-runas-user", "_xpack_security_authentication")));
static final ParseField LEADER_CLUSTER_FIELD = new ParseField("leader_cluster");
static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
static final ParseField FOLLOW_SHARD_INDEX_FIELD = new ParseField("follow_shard_index");
static final ParseField FOLLOW_SHARD_INDEX_UUID_FIELD = new ParseField("follow_shard_index_uuid");
static final ParseField FOLLOW_SHARD_SHARDID_FIELD = new ParseField("follow_shard_shard");
@ -59,7 +59,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
(int) a[10], (int) a[11], (TimeValue) a[12], (TimeValue) a[13], (Map<String, String>) a[14]));
static {
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), LEADER_CLUSTER_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), REMOTE_CLUSTER_FIELD);
PARSER.declareString(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_INDEX_FIELD);
PARSER.declareString(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_INDEX_UUID_FIELD);
PARSER.declareInt(ConstructingObjectParser.constructorArg(), FOLLOW_SHARD_SHARDID_FIELD);
@ -84,7 +84,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> p.mapStrings(), HEADERS);
}
private final String leaderCluster;
private final String remoteCluster;
private final ShardId followShardId;
private final ShardId leaderShardId;
private final int maxBatchOperationCount;
@ -97,7 +97,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
private final Map<String, String> headers;
ShardFollowTask(
final String leaderCluster,
final String remoteCluster,
final ShardId followShardId,
final ShardId leaderShardId,
final int maxBatchOperationCount,
@ -108,7 +108,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
final TimeValue maxRetryDelay,
final TimeValue pollTimeout,
final Map<String, String> headers) {
this.leaderCluster = leaderCluster;
this.remoteCluster = remoteCluster;
this.followShardId = followShardId;
this.leaderShardId = leaderShardId;
this.maxBatchOperationCount = maxBatchOperationCount;
@ -122,7 +122,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
}
public ShardFollowTask(StreamInput in) throws IOException {
this.leaderCluster = in.readString();
this.remoteCluster = in.readString();
this.followShardId = ShardId.readShardId(in);
this.leaderShardId = ShardId.readShardId(in);
this.maxBatchOperationCount = in.readVInt();
@ -135,8 +135,8 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
}
public String getLeaderCluster() {
return leaderCluster;
public String getRemoteCluster() {
return remoteCluster;
}
public ShardId getFollowShardId() {
@ -190,7 +190,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(leaderCluster);
out.writeString(remoteCluster);
followShardId.writeTo(out);
leaderShardId.writeTo(out);
out.writeVLong(maxBatchOperationCount);
@ -210,7 +210,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
builder.field(REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
builder.field(FOLLOW_SHARD_INDEX_FIELD.getPreferredName(), followShardId.getIndex().getName());
builder.field(FOLLOW_SHARD_INDEX_UUID_FIELD.getPreferredName(), followShardId.getIndex().getUUID());
builder.field(FOLLOW_SHARD_SHARDID_FIELD.getPreferredName(), followShardId.id());
@ -233,7 +233,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ShardFollowTask that = (ShardFollowTask) o;
return Objects.equals(leaderCluster, that.leaderCluster) &&
return Objects.equals(remoteCluster, that.remoteCluster) &&
Objects.equals(followShardId, that.followShardId) &&
Objects.equals(leaderShardId, that.leaderShardId) &&
maxBatchOperationCount == that.maxBatchOperationCount &&
@ -249,7 +249,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
@Override
public int hashCode() {
return Objects.hash(
leaderCluster,
remoteCluster,
followShardId,
leaderShardId,
maxBatchOperationCount,

View File

@ -79,8 +79,8 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor<ShardFollo
Map<String, String> headers) {
ShardFollowTask params = taskInProgress.getParams();
final Client leaderClient;
if (params.getLeaderCluster() != null) {
leaderClient = wrapClient(client.getRemoteClusterClient(params.getLeaderCluster()), params.getHeaders());
if (params.getRemoteCluster() != null) {
leaderClient = wrapClient(client.getRemoteClusterClient(params.getRemoteCluster()), params.getHeaders());
} else {
leaderClient = wrapClient(client, params.getHeaders());
}

View File

@ -76,7 +76,7 @@ public class TransportPutAutoFollowPatternAction extends
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
return;
}
final Client leaderClient = client.getRemoteClusterClient(request.getLeaderCluster());
final Client leaderClient = client.getRemoteClusterClient(request.getRemoteCluster());
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
clusterStateRequest.clear();
clusterStateRequest.metaData(true);
@ -93,7 +93,7 @@ public class TransportPutAutoFollowPatternAction extends
ActionListener.wrap(
clusterStateResponse -> {
final ClusterState leaderClusterState = clusterStateResponse.getState();
clusterService.submitStateUpdateTask("put-auto-follow-pattern-" + request.getLeaderCluster(),
clusterService.submitStateUpdateTask("put-auto-follow-pattern-" + request.getRemoteCluster(),
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
@Override
@ -157,7 +157,7 @@ public class TransportPutAutoFollowPatternAction extends
}
AutoFollowPattern autoFollowPattern = new AutoFollowPattern(
request.getLeaderCluster(),
request.getRemoteCluster(),
request.getLeaderIndexPatterns(),
request.getFollowIndexNamePattern(),
request.getMaxBatchOperationCount(),

View File

@ -95,22 +95,22 @@ public final class TransportPutFollowAction
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
return;
}
String leaderCluster = request.getLeaderCluster();
String remoteCluster = request.getRemoteCluster();
// Validates whether the leader cluster has been configured properly:
client.getRemoteClusterClient(leaderCluster);
client.getRemoteClusterClient(remoteCluster);
String leaderIndex = request.getLeaderIndex();
createFollowerIndexAndFollowRemoteIndex(request, leaderCluster, leaderIndex, listener);
createFollowerIndexAndFollowRemoteIndex(request, remoteCluster, leaderIndex, listener);
}
private void createFollowerIndexAndFollowRemoteIndex(
final PutFollowAction.Request request,
final String leaderCluster,
final String remoteCluster,
final String leaderIndex,
final ActionListener<PutFollowAction.Response> listener) {
ccrLicenseChecker.checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs(
client,
leaderCluster,
remoteCluster,
leaderIndex,
listener::onFailure,
(historyUUID, leaderIndexMetaData) -> createFollowerIndex(leaderIndexMetaData, historyUUID, request, listener));
@ -160,7 +160,7 @@ public final class TransportPutFollowAction
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, String.join(",", historyUUIDs));
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, leaderIndexMetaData.getIndexUUID());
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY, leaderIndexMetaData.getIndex().getName());
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_CLUSTER_NAME_KEY, request.getLeaderCluster());
metadata.put(Ccr.CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY, request.getRemoteCluster());
imdBuilder.putCustom(Ccr.CCR_CUSTOM_METADATA_KEY, metadata);
// Copy all settings, but overwrite a few settings.

View File

@ -107,7 +107,7 @@ public class TransportResumeFollowAction extends HandledTransportAction<ResumeFo
if (ccrMetadata == null) {
throw new IllegalArgumentException("follow index ["+ request.getFollowerIndex() + "] does not have ccr metadata");
}
final String leaderCluster = ccrMetadata.get(Ccr.CCR_CUSTOM_METADATA_LEADER_CLUSTER_NAME_KEY);
final String leaderCluster = ccrMetadata.get(Ccr.CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY);
// Validates whether the leader cluster has been configured properly:
client.getRemoteClusterClient(leaderCluster);
final String leaderIndex = ccrMetadata.get(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY);

View File

@ -74,7 +74,7 @@ public abstract class CcrSingleNodeTestCase extends ESSingleNodeTestCase {
protected PutFollowAction.Request getPutFollowRequest() {
PutFollowAction.Request request = new PutFollowAction.Request();
request.setLeaderCluster("local");
request.setRemoteCluster("local");
request.setLeaderIndex("leader");
request.setFollowRequest(getResumeFollowRequest());
return request;

View File

@ -121,7 +121,7 @@ public class AutoFollowIT extends CcrIntegTestCase {
// Enabling auto following:
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName("my-pattern");
request.setLeaderCluster("leader_cluster");
request.setRemoteCluster("leader_cluster");
request.setLeaderIndexPatterns(Collections.singletonList("logs-*"));
// Need to set this, because following an index in the same cluster
request.setFollowIndexNamePattern("copy-{{leader_index}}");
@ -228,7 +228,7 @@ public class AutoFollowIT extends CcrIntegTestCase {
private void putAutoFollowPatterns(String name, String[] patterns) {
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName(name);
request.setLeaderCluster("leader_cluster");
request.setRemoteCluster("leader_cluster");
request.setLeaderIndexPatterns(Arrays.asList(patterns));
// Need to set this, because following an index in the same cluster
request.setFollowIndexNamePattern("copy-{{leader_index}}");

View File

@ -118,7 +118,7 @@ public class CcrLicenseIT extends CcrSingleNodeTestCase {
final CountDownLatch latch = new CountDownLatch(1);
final PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName("name");
request.setLeaderCluster("leader");
request.setRemoteCluster("leader");
request.setLeaderIndexPatterns(Collections.singletonList("*"));
client().execute(
PutAutoFollowPatternAction.INSTANCE,

View File

@ -640,13 +640,13 @@ public class IndexFollowingIT extends CcrIntegTestCase {
assertAcked(leaderClient().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON));
ensureLeaderGreen("index1");
PutFollowAction.Request followRequest = putFollow("index1", "index2");
followRequest.setLeaderCluster("another_cluster");
followRequest.setRemoteCluster("another_cluster");
Exception e = expectThrows(IllegalArgumentException.class,
() -> followerClient().execute(PutFollowAction.INSTANCE, followRequest).actionGet());
assertThat(e.getMessage(), equalTo("unknown cluster alias [another_cluster]"));
PutAutoFollowPatternAction.Request putAutoFollowRequest = new PutAutoFollowPatternAction.Request();
putAutoFollowRequest.setName("name");
putAutoFollowRequest.setLeaderCluster("another_cluster");
putAutoFollowRequest.setRemoteCluster("another_cluster");
putAutoFollowRequest.setLeaderIndexPatterns(Collections.singletonList("logs-*"));
e = expectThrows(IllegalArgumentException.class,
() -> followerClient().execute(PutAutoFollowPatternAction.INSTANCE, putAutoFollowRequest).actionGet());
@ -961,7 +961,7 @@ public class IndexFollowingIT extends CcrIntegTestCase {
public static PutFollowAction.Request putFollow(String leaderIndex, String followerIndex) {
PutFollowAction.Request request = new PutFollowAction.Request();
request.setLeaderCluster("leader_cluster");
request.setRemoteCluster("leader_cluster");
request.setLeaderIndex(leaderIndex);
request.setFollowRequest(resumeFollow(followerIndex));
return request;

View File

@ -83,7 +83,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
AutoFollower autoFollower = new AutoFollower(handler, currentState) {
@Override
void getLeaderClusterState(Map<String, String> headers,
String leaderClusterAlias,
String remoteCluster,
BiConsumer<ClusterState, Exception> handler) {
assertThat(headers, equalTo(autoFollowHeaders.get("remote")));
handler.accept(leaderState, null);
@ -95,7 +95,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
Runnable successHandler,
Consumer<Exception> failureHandler) {
assertThat(headers, equalTo(autoFollowHeaders.get("remote")));
assertThat(followRequest.getLeaderCluster(), equalTo("remote"));
assertThat(followRequest.getRemoteCluster(), equalTo("remote"));
assertThat(followRequest.getLeaderIndex(), equalTo("logs-20190101"));
assertThat(followRequest.getFollowRequest().getFollowerIndex(), equalTo("logs-20190101"));
successHandler.run();
@ -143,7 +143,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
AutoFollower autoFollower = new AutoFollower(handler, followerState) {
@Override
void getLeaderClusterState(Map<String, String> headers,
String leaderClusterAlias,
String remoteCluster,
BiConsumer<ClusterState, Exception> handler) {
handler.accept(null, failure);
}
@ -204,7 +204,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
AutoFollower autoFollower = new AutoFollower(handler, followerState) {
@Override
void getLeaderClusterState(Map<String, String> headers,
String leaderClusterAlias,
String remoteCluster,
BiConsumer<ClusterState, Exception> handler) {
handler.accept(leaderState, null);
}
@ -214,7 +214,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
PutFollowAction.Request followRequest,
Runnable successHandler,
Consumer<Exception> failureHandler) {
assertThat(followRequest.getLeaderCluster(), equalTo("remote"));
assertThat(followRequest.getRemoteCluster(), equalTo("remote"));
assertThat(followRequest.getLeaderIndex(), equalTo("logs-20190101"));
assertThat(followRequest.getFollowRequest().getFollowerIndex(), equalTo("logs-20190101"));
successHandler.run();
@ -267,7 +267,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
AutoFollower autoFollower = new AutoFollower(handler, followerState) {
@Override
void getLeaderClusterState(Map<String, String> headers,
String leaderClusterAlias,
String remoteCluster,
BiConsumer<ClusterState, Exception> handler) {
handler.accept(leaderState, null);
}
@ -277,7 +277,7 @@ public class AutoFollowCoordinatorTests extends ESTestCase {
PutFollowAction.Request followRequest,
Runnable successHandler,
Consumer<Exception> failureHandler) {
assertThat(followRequest.getLeaderCluster(), equalTo("remote"));
assertThat(followRequest.getRemoteCluster(), equalTo("remote"));
assertThat(followRequest.getLeaderIndex(), equalTo("logs-20190101"));
assertThat(followRequest.getFollowRequest().getFollowerIndex(), equalTo("logs-20190101"));
failureHandler.accept(failure);

View File

@ -42,7 +42,7 @@ public class PutAutoFollowPatternRequestTests extends AbstractStreamableXContent
protected PutAutoFollowPatternAction.Request createTestInstance() {
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName(randomAlphaOfLength(4));
request.setLeaderCluster(randomAlphaOfLength(4));
request.setRemoteCluster(randomAlphaOfLength(4));
request.setLeaderIndexPatterns(Arrays.asList(generateRandomStringArray(4, 4, false)));
if (randomBoolean()) {
request.setFollowIndexNamePattern(randomAlphaOfLength(4));
@ -80,9 +80,9 @@ public class PutAutoFollowPatternRequestTests extends AbstractStreamableXContent
request.setName("name");
validationException = request.validate();
assertThat(validationException, notNullValue());
assertThat(validationException.getMessage(), containsString("[leader_cluster] is missing"));
assertThat(validationException.getMessage(), containsString("[remote_cluster] is missing"));
request.setLeaderCluster("_alias");
request.setRemoteCluster("_alias");
validationException = request.validate();
assertThat(validationException, notNullValue());
assertThat(validationException.getMessage(), containsString("[leader_index_patterns] is missing"));

View File

@ -21,7 +21,7 @@ public class PutFollowActionRequestTests extends AbstractStreamableXContentTestC
@Override
protected PutFollowAction.Request createTestInstance() {
PutFollowAction.Request request = new PutFollowAction.Request();
request.setLeaderCluster(randomAlphaOfLength(4));
request.setRemoteCluster(randomAlphaOfLength(4));
request.setLeaderIndex(randomAlphaOfLength(4));
request.setFollowRequest(ResumeFollowActionRequestTests.createTestRequest());
return request;

View File

@ -65,7 +65,7 @@ public class ShardFollowNodeTaskStatusTests extends AbstractSerializingTestCase<
@Override
protected void assertEqualInstances(final ShardFollowNodeTaskStatus expectedInstance, final ShardFollowNodeTaskStatus newInstance) {
assertNotSame(expectedInstance, newInstance);
assertThat(newInstance.getLeaderCluster(), equalTo(expectedInstance.getLeaderCluster()));
assertThat(newInstance.getRemoteCluster(), equalTo(expectedInstance.getRemoteCluster()));
assertThat(newInstance.leaderIndex(), equalTo(expectedInstance.leaderIndex()));
assertThat(newInstance.followerIndex(), equalTo(expectedInstance.followerIndex()));
assertThat(newInstance.getShardId(), equalTo(expectedInstance.getShardId()));

View File

@ -63,7 +63,7 @@ public class TransportDeleteAutoFollowPatternActionTests extends ESTestCase {
.custom(AutoFollowMetadata.TYPE);
assertThat(result.getPatterns().size(), equalTo(1));
assertThat(result.getPatterns().get("name2"), notNullValue());
assertThat(result.getPatterns().get("name2").getLeaderCluster(), equalTo("asia_cluster"));
assertThat(result.getPatterns().get("name2").getRemoteCluster(), equalTo("asia_cluster"));
assertThat(result.getFollowedLeaderIndexUUIDs().size(), equalTo(1));
assertThat(result.getFollowedLeaderIndexUUIDs().get("name2"), notNullValue());
assertThat(result.getHeaders().size(), equalTo(1));

View File

@ -30,7 +30,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
public void testInnerPut() {
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName("name1");
request.setLeaderCluster("eu_cluster");
request.setRemoteCluster("eu_cluster");
request.setLeaderIndexPatterns(Collections.singletonList("logs-*"));
ClusterState localState = ClusterState.builder(new ClusterName("us_cluster"))
@ -45,7 +45,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
AutoFollowMetadata autoFollowMetadata = result.metaData().custom(AutoFollowMetadata.TYPE);
assertThat(autoFollowMetadata, notNullValue());
assertThat(autoFollowMetadata.getPatterns().size(), equalTo(1));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getRemoteCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().size(), equalTo(1));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().get(0), equalTo("logs-*"));
assertThat(autoFollowMetadata.getFollowedLeaderIndexUUIDs().size(), equalTo(1));
@ -55,7 +55,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
public void testInnerPut_existingLeaderIndices() {
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName("name1");
request.setLeaderCluster("eu_cluster");
request.setRemoteCluster("eu_cluster");
request.setLeaderIndexPatterns(Collections.singletonList("logs-*"));
ClusterState localState = ClusterState.builder(new ClusterName("us_cluster"))
@ -86,7 +86,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
AutoFollowMetadata autoFollowMetadata = result.metaData().custom(AutoFollowMetadata.TYPE);
assertThat(autoFollowMetadata, notNullValue());
assertThat(autoFollowMetadata.getPatterns().size(), equalTo(1));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getRemoteCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().size(), equalTo(1));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().get(0), equalTo("logs-*"));
assertThat(autoFollowMetadata.getFollowedLeaderIndexUUIDs().size(), equalTo(1));
@ -96,7 +96,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
public void testInnerPut_existingLeaderIndicesAndAutoFollowMetadata() {
PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request();
request.setName("name1");
request.setLeaderCluster("eu_cluster");
request.setRemoteCluster("eu_cluster");
request.setLeaderIndexPatterns(Arrays.asList("logs-*", "transactions-*"));
Map<String, AutoFollowPattern> existingAutoFollowPatterns = new HashMap<>();
@ -133,7 +133,7 @@ public class TransportPutAutoFollowPatternActionTests extends ESTestCase {
AutoFollowMetadata autoFollowMetadata = result.metaData().custom(AutoFollowMetadata.TYPE);
assertThat(autoFollowMetadata, notNullValue());
assertThat(autoFollowMetadata.getPatterns().size(), equalTo(1));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getRemoteCluster(), equalTo("eu_cluster"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().size(), equalTo(2));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().get(0), equalTo("logs-*"));
assertThat(autoFollowMetadata.getPatterns().get("name1").getLeaderIndexPatterns().get(1), equalTo("transactions-*"));

View File

@ -154,7 +154,7 @@ public class FollowStatsMonitoringDocTests extends BaseMonitoringDocTestCase<Fol
+ "\"timestamp\":\"" + new DateTime(nodeTimestamp, DateTimeZone.UTC).toString() + "\""
+ "},"
+ "\"ccr_stats\":{"
+ "\"leader_cluster\":\"leader_cluster\","
+ "\"remote_cluster\":\"leader_cluster\","
+ "\"leader_index\":\"leader_index\","
+ "\"follower_index\":\"follower_index\","
+ "\"shard_id\":" + shardId + ","
@ -168,7 +168,7 @@ public class FollowStatsMonitoringDocTests extends BaseMonitoringDocTestCase<Fol
+ "\"number_of_queued_writes\":" + numberOfQueuedWrites + ","
+ "\"mapping_version\":" + mappingVersion + ","
+ "\"total_fetch_time_millis\":" + totalFetchTimeMillis + ","
+ "\"total_fetch_leader_time_millis\":" + totalFetchTookTimeMillis + ","
+ "\"total_fetch_remote_time_millis\":" + totalFetchTookTimeMillis + ","
+ "\"number_of_successful_fetches\":" + numberOfSuccessfulFetches + ","
+ "\"number_of_failed_fetches\":" + numberOfFailedFetches + ","
+ "\"operations_received\":" + operationsReceived + ","
@ -197,7 +197,7 @@ public class FollowStatsMonitoringDocTests extends BaseMonitoringDocTestCase<Fol
final NavigableMap<Long, Tuple<Integer, ElasticsearchException>> fetchExceptions =
new TreeMap<>(Collections.singletonMap(1L, Tuple.tuple(2, new ElasticsearchException("shard is sad"))));
final ShardFollowNodeTaskStatus status = new ShardFollowNodeTaskStatus(
"leader_cluster",
"remote_cluster",
"leader_index",
"follower_index",
0,

View File

@ -175,7 +175,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
public static class AutoFollowPattern implements Writeable, ToXContentObject {
public static final ParseField LEADER_CLUSTER_FIELD = new ParseField("leader_cluster");
public static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
public static final ParseField LEADER_PATTERNS_FIELD = new ParseField("leader_index_patterns");
public static final ParseField FOLLOW_PATTERN_FIELD = new ParseField("follow_index_pattern");
public static final ParseField MAX_BATCH_OPERATION_COUNT = new ParseField("max_batch_operation_count");
@ -194,7 +194,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
(TimeValue) args[9]));
static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_CLUSTER_FIELD);
PARSER.declareString(ConstructingObjectParser.constructorArg(), REMOTE_CLUSTER_FIELD);
PARSER.declareStringArray(ConstructingObjectParser.constructorArg(), LEADER_PATTERNS_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), FOLLOW_PATTERN_FIELD);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAX_BATCH_OPERATION_COUNT);
@ -214,7 +214,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
POLL_TIMEOUT, ObjectParser.ValueType.STRING);
}
private final String leaderCluster;
private final String remoteCluster;
private final List<String> leaderIndexPatterns;
private final String followIndexPattern;
private final Integer maxBatchOperationCount;
@ -225,7 +225,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
private final TimeValue maxRetryDelay;
private final TimeValue pollTimeout;
public AutoFollowPattern(String leaderCluster,
public AutoFollowPattern(String remoteCluster,
List<String> leaderIndexPatterns,
String followIndexPattern,
Integer maxBatchOperationCount,
@ -235,7 +235,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
Integer maxWriteBufferSize,
TimeValue maxRetryDelay,
TimeValue pollTimeout) {
this.leaderCluster = leaderCluster;
this.remoteCluster = remoteCluster;
this.leaderIndexPatterns = leaderIndexPatterns;
this.followIndexPattern = followIndexPattern;
this.maxBatchOperationCount = maxBatchOperationCount;
@ -248,7 +248,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
}
public AutoFollowPattern(StreamInput in) throws IOException {
leaderCluster = in.readString();
remoteCluster = in.readString();
leaderIndexPatterns = in.readList(StreamInput::readString);
followIndexPattern = in.readOptionalString();
maxBatchOperationCount = in.readOptionalVInt();
@ -268,8 +268,8 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
return Regex.simpleMatch(leaderIndexPatterns, indexName);
}
public String getLeaderCluster() {
return leaderCluster;
public String getRemoteCluster() {
return remoteCluster;
}
public List<String> getLeaderIndexPatterns() {
@ -310,7 +310,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(leaderCluster);
out.writeString(remoteCluster);
out.writeStringList(leaderIndexPatterns);
out.writeOptionalString(followIndexPattern);
out.writeOptionalVInt(maxBatchOperationCount);
@ -324,7 +324,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
builder.field(REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
builder.array(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns.toArray(new String[0]));
if (followIndexPattern != null) {
builder.field(FOLLOW_PATTERN_FIELD.getPreferredName(), followIndexPattern);
@ -363,7 +363,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AutoFollowPattern that = (AutoFollowPattern) o;
return Objects.equals(leaderCluster, that.leaderCluster) &&
return Objects.equals(remoteCluster, that.remoteCluster) &&
Objects.equals(leaderIndexPatterns, that.leaderIndexPatterns) &&
Objects.equals(followIndexPattern, that.followIndexPattern) &&
Objects.equals(maxBatchOperationCount, that.maxBatchOperationCount) &&
@ -378,7 +378,7 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
@Override
public int hashCode() {
return Objects.hash(
leaderCluster,
remoteCluster,
leaderIndexPatterns,
followIndexPattern,
maxBatchOperationCount,

View File

@ -34,7 +34,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
public static final String STATUS_PARSER_NAME = "shard-follow-node-task-status";
private static final ParseField LEADER_CLUSTER = new ParseField("leader_cluster");
private static final ParseField LEADER_CLUSTER = new ParseField("remote_cluster");
private static final ParseField LEADER_INDEX = new ParseField("leader_index");
private static final ParseField FOLLOWER_INDEX = new ParseField("follower_index");
private static final ParseField SHARD_ID = new ParseField("shard_id");
@ -48,7 +48,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
private static final ParseField NUMBER_OF_QUEUED_WRITES_FIELD = new ParseField("number_of_queued_writes");
private static final ParseField MAPPING_VERSION_FIELD = new ParseField("mapping_version");
private static final ParseField TOTAL_FETCH_TIME_MILLIS_FIELD = new ParseField("total_fetch_time_millis");
private static final ParseField TOTAL_FETCH_LEADER_TIME_MILLIS_FIELD = new ParseField("total_fetch_leader_time_millis");
private static final ParseField TOTAL_FETCH_REMOTE_TIME_MILLIS_FIELD = new ParseField("total_fetch_remote_time_millis");
private static final ParseField NUMBER_OF_SUCCESSFUL_FETCHES_FIELD = new ParseField("number_of_successful_fetches");
private static final ParseField NUMBER_OF_FAILED_FETCHES_FIELD = new ParseField("number_of_failed_fetches");
private static final ParseField OPERATIONS_RECEIVED_FIELD = new ParseField("operations_received");
@ -118,7 +118,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
STATUS_PARSER.declareInt(ConstructingObjectParser.constructorArg(), NUMBER_OF_QUEUED_WRITES_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), MAPPING_VERSION_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), TOTAL_FETCH_TIME_MILLIS_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), TOTAL_FETCH_LEADER_TIME_MILLIS_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), TOTAL_FETCH_REMOTE_TIME_MILLIS_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_SUCCESSFUL_FETCHES_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_FAILED_FETCHES_FIELD);
STATUS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), OPERATIONS_RECEIVED_FIELD);
@ -147,10 +147,10 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
FETCH_EXCEPTIONS_ENTRY_EXCEPTION);
}
private final String leaderCluster;
private final String remoteCluster;
public String getLeaderCluster() {
return leaderCluster;
public String getRemoteCluster() {
return remoteCluster;
}
private final String leaderIndex;
@ -231,10 +231,10 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
return totalFetchTimeMillis;
}
private final long totalFetchLeaderTimeMillis;
private final long totalFetchRemoteTimeMillis;
public long totalFetchLeaderTimeMillis() {
return totalFetchLeaderTimeMillis;
public long totalFetchRemoteTimeMillis() {
return totalFetchRemoteTimeMillis;
}
private final long numberOfSuccessfulFetches;
@ -304,7 +304,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
}
public ShardFollowNodeTaskStatus(
final String leaderCluster,
final String remoteCluster,
final String leaderIndex,
final String followerIndex,
final int shardId,
@ -318,7 +318,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
final int numberOfQueuedWrites,
final long mappingVersion,
final long totalFetchTimeMillis,
final long totalFetchLeaderTimeMillis,
final long totalFetchRemoteTimeMillis,
final long numberOfSuccessfulFetches,
final long numberOfFailedFetches,
final long operationsReceived,
@ -330,7 +330,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
final NavigableMap<Long, Tuple<Integer, ElasticsearchException>> fetchExceptions,
final long timeSinceLastFetchMillis,
final ElasticsearchException fatalException) {
this.leaderCluster = leaderCluster;
this.remoteCluster = remoteCluster;
this.leaderIndex = leaderIndex;
this.followerIndex = followerIndex;
this.shardId = shardId;
@ -344,7 +344,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
this.numberOfQueuedWrites = numberOfQueuedWrites;
this.mappingVersion = mappingVersion;
this.totalFetchTimeMillis = totalFetchTimeMillis;
this.totalFetchLeaderTimeMillis = totalFetchLeaderTimeMillis;
this.totalFetchRemoteTimeMillis = totalFetchRemoteTimeMillis;
this.numberOfSuccessfulFetches = numberOfSuccessfulFetches;
this.numberOfFailedFetches = numberOfFailedFetches;
this.operationsReceived = operationsReceived;
@ -359,7 +359,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
}
public ShardFollowNodeTaskStatus(final StreamInput in) throws IOException {
this.leaderCluster = in.readOptionalString();
this.remoteCluster = in.readOptionalString();
this.leaderIndex = in.readString();
this.followerIndex = in.readString();
this.shardId = in.readVInt();
@ -373,7 +373,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
this.numberOfQueuedWrites = in.readVInt();
this.mappingVersion = in.readVLong();
this.totalFetchTimeMillis = in.readVLong();
this.totalFetchLeaderTimeMillis = in.readVLong();
this.totalFetchRemoteTimeMillis = in.readVLong();
this.numberOfSuccessfulFetches = in.readVLong();
this.numberOfFailedFetches = in.readVLong();
this.operationsReceived = in.readVLong();
@ -395,7 +395,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
@Override
public void writeTo(final StreamOutput out) throws IOException {
out.writeOptionalString(leaderCluster);
out.writeOptionalString(remoteCluster);
out.writeString(leaderIndex);
out.writeString(followerIndex);
out.writeVInt(shardId);
@ -409,7 +409,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
out.writeVInt(numberOfQueuedWrites);
out.writeVLong(mappingVersion);
out.writeVLong(totalFetchTimeMillis);
out.writeVLong(totalFetchLeaderTimeMillis);
out.writeVLong(totalFetchRemoteTimeMillis);
out.writeVLong(numberOfSuccessfulFetches);
out.writeVLong(numberOfFailedFetches);
out.writeVLong(operationsReceived);
@ -440,7 +440,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
}
public XContentBuilder toXContentFragment(final XContentBuilder builder, final Params params) throws IOException {
builder.field(LEADER_CLUSTER.getPreferredName(), leaderCluster);
builder.field(LEADER_CLUSTER.getPreferredName(), remoteCluster);
builder.field(LEADER_INDEX.getPreferredName(), leaderIndex);
builder.field(FOLLOWER_INDEX.getPreferredName(), followerIndex);
builder.field(SHARD_ID.getPreferredName(), shardId);
@ -458,9 +458,9 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
"total_fetch_time",
new TimeValue(totalFetchTimeMillis, TimeUnit.MILLISECONDS));
builder.humanReadableField(
TOTAL_FETCH_LEADER_TIME_MILLIS_FIELD.getPreferredName(),
TOTAL_FETCH_REMOTE_TIME_MILLIS_FIELD.getPreferredName(),
"total_fetch_leader_time",
new TimeValue(totalFetchLeaderTimeMillis, TimeUnit.MILLISECONDS));
new TimeValue(totalFetchRemoteTimeMillis, TimeUnit.MILLISECONDS));
builder.field(NUMBER_OF_SUCCESSFUL_FETCHES_FIELD.getPreferredName(), numberOfSuccessfulFetches);
builder.field(NUMBER_OF_FAILED_FETCHES_FIELD.getPreferredName(), numberOfFailedFetches);
builder.field(OPERATIONS_RECEIVED_FIELD.getPreferredName(), operationsReceived);
@ -519,7 +519,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
final ShardFollowNodeTaskStatus that = (ShardFollowNodeTaskStatus) o;
String fatalExceptionMessage = fatalException != null ? fatalException.getMessage() : null;
String otherFatalExceptionMessage = that.fatalException != null ? that.fatalException.getMessage() : null;
return leaderCluster.equals(that.leaderCluster) &&
return remoteCluster.equals(that.remoteCluster) &&
leaderIndex.equals(that.leaderIndex) &&
followerIndex.equals(that.followerIndex) &&
shardId == that.shardId &&
@ -533,7 +533,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
numberOfQueuedWrites == that.numberOfQueuedWrites &&
mappingVersion == that.mappingVersion &&
totalFetchTimeMillis == that.totalFetchTimeMillis &&
totalFetchLeaderTimeMillis == that.totalFetchLeaderTimeMillis &&
totalFetchRemoteTimeMillis == that.totalFetchRemoteTimeMillis &&
numberOfSuccessfulFetches == that.numberOfSuccessfulFetches &&
numberOfFailedFetches == that.numberOfFailedFetches &&
operationsReceived == that.operationsReceived &&
@ -556,7 +556,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
public int hashCode() {
String fatalExceptionMessage = fatalException != null ? fatalException.getMessage() : null;
return Objects.hash(
leaderCluster,
remoteCluster,
leaderIndex,
followerIndex,
shardId,
@ -570,7 +570,7 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
numberOfQueuedWrites,
mappingVersion,
totalFetchTimeMillis,
totalFetchLeaderTimeMillis,
totalFetchRemoteTimeMillis,
numberOfSuccessfulFetches,
numberOfFailedFetches,
operationsReceived,

View File

@ -25,6 +25,7 @@ import java.util.List;
import java.util.Objects;
import static org.elasticsearch.action.ValidateActions.addValidationError;
import static org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern.REMOTE_CLUSTER_FIELD;
public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
@ -48,7 +49,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
static {
PARSER.declareString(Request::setName, NAME_FIELD);
PARSER.declareString(Request::setLeaderCluster, AutoFollowPattern.LEADER_CLUSTER_FIELD);
PARSER.declareString(Request::setRemoteCluster, REMOTE_CLUSTER_FIELD);
PARSER.declareStringArray(Request::setLeaderIndexPatterns, AutoFollowPattern.LEADER_PATTERNS_FIELD);
PARSER.declareString(Request::setFollowIndexNamePattern, AutoFollowPattern.FOLLOW_PATTERN_FIELD);
PARSER.declareInt(Request::setMaxBatchOperationCount, AutoFollowPattern.MAX_BATCH_OPERATION_COUNT);
@ -83,7 +84,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
}
private String name;
private String leaderCluster;
private String remoteCluster;
private List<String> leaderIndexPatterns;
private String followIndexNamePattern;
@ -101,8 +102,8 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
if (name == null) {
validationException = addValidationError("[" + NAME_FIELD.getPreferredName() + "] is missing", validationException);
}
if (leaderCluster == null) {
validationException = addValidationError("[" + AutoFollowPattern.LEADER_CLUSTER_FIELD.getPreferredName() +
if (remoteCluster == null) {
validationException = addValidationError("[" + REMOTE_CLUSTER_FIELD.getPreferredName() +
"] is missing", validationException);
}
if (leaderIndexPatterns == null || leaderIndexPatterns.isEmpty()) {
@ -133,12 +134,12 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
this.name = name;
}
public String getLeaderCluster() {
return leaderCluster;
public String getRemoteCluster() {
return remoteCluster;
}
public void setLeaderCluster(String leaderCluster) {
this.leaderCluster = leaderCluster;
public void setRemoteCluster(String remoteCluster) {
this.remoteCluster = remoteCluster;
}
public List<String> getLeaderIndexPatterns() {
@ -217,7 +218,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
name = in.readString();
leaderCluster = in.readString();
remoteCluster = in.readString();
leaderIndexPatterns = in.readList(StreamInput::readString);
followIndexNamePattern = in.readOptionalString();
maxBatchOperationCount = in.readOptionalVInt();
@ -233,7 +234,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(name);
out.writeString(leaderCluster);
out.writeString(remoteCluster);
out.writeStringList(leaderIndexPatterns);
out.writeOptionalString(followIndexNamePattern);
out.writeOptionalVInt(maxBatchOperationCount);
@ -250,7 +251,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
builder.startObject();
{
builder.field(NAME_FIELD.getPreferredName(), name);
builder.field(AutoFollowPattern.LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
builder.field(REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
builder.field(AutoFollowPattern.LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
if (followIndexNamePattern != null) {
builder.field(AutoFollowPattern.FOLLOW_PATTERN_FIELD.getPreferredName(), followIndexNamePattern);
@ -287,7 +288,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
if (o == null || getClass() != o.getClass()) return false;
Request request = (Request) o;
return Objects.equals(name, request.name) &&
Objects.equals(leaderCluster, request.leaderCluster) &&
Objects.equals(remoteCluster, request.remoteCluster) &&
Objects.equals(leaderIndexPatterns, request.leaderIndexPatterns) &&
Objects.equals(followIndexNamePattern, request.followIndexNamePattern) &&
Objects.equals(maxBatchOperationCount, request.maxBatchOperationCount) &&
@ -303,7 +304,7 @@ public class PutAutoFollowPatternAction extends Action<AcknowledgedResponse> {
public int hashCode() {
return Objects.hash(
name,
leaderCluster,
remoteCluster,
leaderIndexPatterns,
followIndexNamePattern,
maxBatchOperationCount,

View File

@ -51,7 +51,7 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
public static class Request extends AcknowledgedRequest<Request> implements IndicesRequest, ToXContentObject {
private static final ParseField LEADER_CLUSTER_FIELD = new ParseField("leader_cluster");
private static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
private static final ParseField LEADER_INDEX_FIELD = new ParseField("leader_index");
private static final ObjectParser<Request, String> PARSER = new ObjectParser<>(NAME, () -> {
@ -61,7 +61,7 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
});
static {
PARSER.declareString(Request::setLeaderCluster, LEADER_CLUSTER_FIELD);
PARSER.declareString(Request::setRemoteCluster, REMOTE_CLUSTER_FIELD);
PARSER.declareString(Request::setLeaderIndex, LEADER_INDEX_FIELD);
PARSER.declareString((request, value) -> request.followRequest.setFollowerIndex(value), FOLLOWER_INDEX_FIELD);
PARSER.declareInt((request, value) -> request.followRequest.setMaxBatchOperationCount(value), MAX_BATCH_OPERATION_COUNT);
@ -99,19 +99,19 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
return request;
}
private String leaderCluster;
private String remoteCluster;
private String leaderIndex;
private ResumeFollowAction.Request followRequest;
public Request() {
}
public String getLeaderCluster() {
return leaderCluster;
public String getRemoteCluster() {
return remoteCluster;
}
public void setLeaderCluster(String leaderCluster) {
this.leaderCluster = leaderCluster;
public void setRemoteCluster(String remoteCluster) {
this.remoteCluster = remoteCluster;
}
public String getLeaderIndex() {
@ -133,8 +133,8 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException e = followRequest.validate();
if (leaderCluster == null) {
e = addValidationError(LEADER_CLUSTER_FIELD.getPreferredName() + " is missing", e);
if (remoteCluster == null) {
e = addValidationError(REMOTE_CLUSTER_FIELD.getPreferredName() + " is missing", e);
}
if (leaderIndex == null) {
e = addValidationError(LEADER_INDEX_FIELD.getPreferredName() + " is missing", e);
@ -155,7 +155,7 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
leaderCluster = in.readString();
remoteCluster = in.readString();
leaderIndex = in.readString();
followRequest = new ResumeFollowAction.Request();
followRequest.readFrom(in);
@ -164,7 +164,7 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(leaderCluster);
out.writeString(remoteCluster);
out.writeString(leaderIndex);
followRequest.writeTo(out);
}
@ -173,7 +173,7 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
{
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
builder.field(REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
builder.field(LEADER_INDEX_FIELD.getPreferredName(), leaderIndex);
followRequest.toXContentFragment(builder, params);
}
@ -186,14 +186,14 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Request request = (Request) o;
return Objects.equals(leaderCluster, request.leaderCluster) &&
return Objects.equals(remoteCluster, request.remoteCluster) &&
Objects.equals(leaderIndex, request.leaderIndex) &&
Objects.equals(followRequest, request.followRequest);
}
@Override
public int hashCode() {
return Objects.hash(leaderCluster, leaderIndex, followRequest);
return Objects.hash(remoteCluster, leaderIndex, followRequest);
}
}

View File

@ -929,7 +929,7 @@
},
"ccr_stats": {
"properties": {
"leader_cluster": {
"remote_cluster": {
"type": "keyword"
},
"leader_index": {
@ -971,7 +971,7 @@
"total_fetch_time_millis": {
"type": "long"
},
"total_fetch_leader_time_millis": {
"total_fetch_remote_time_millis": {
"type": "long"
},
"number_of_successful_fetches": {