-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor AutoFollowCoordinator to track leader indices per remote clu…
…ster (#36031) and replaced poll interval setting with a hardcoded poll interval. The hard coded interval will be removed in a follow up change to make use of cluster state API's wait_for_metatdata_version. Before the auto following was bootstrapped from thread pool scheduler, but now auto followers for new remote clusters are bootstrapped when a new cluster state is published. Originates from #35895 Relates to #33007
- Loading branch information
Showing
7 changed files
with
317 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugin/ccr/qa/chain/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ccr; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.RestClient; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class AutoFollowIT extends ESCCRRestTestCase { | ||
|
||
public void testAutoFollowPatterns() throws Exception { | ||
if ("follow".equals(targetCluster) == false) { | ||
return; | ||
} | ||
Request putPatternRequest = new Request("PUT", "/_ccr/auto_follow/leader_cluster_pattern"); | ||
putPatternRequest.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}"); | ||
assertOK(client().performRequest(putPatternRequest)); | ||
putPatternRequest = new Request("PUT", "/_ccr/auto_follow/middle_cluster_pattern"); | ||
putPatternRequest.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"middle_cluster\"}"); | ||
assertOK(client().performRequest(putPatternRequest)); | ||
try (RestClient leaderClient = buildLeaderClient()) { | ||
Settings settings = Settings.builder() | ||
.put("index.soft_deletes.enabled", true) | ||
.build(); | ||
Request request = new Request("PUT", "/logs-20190101"); | ||
request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + | ||
", \"mappings\": {\"_doc\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}} }"); | ||
assertOK(leaderClient.performRequest(request)); | ||
for (int i = 0; i < 5; i++) { | ||
String id = Integer.toString(i); | ||
index(leaderClient, "logs-20190101", id, "field", i, "filtered_field", "true"); | ||
} | ||
} | ||
try (RestClient middleClient = buildMiddleClient()) { | ||
Settings settings = Settings.builder() | ||
.put("index.soft_deletes.enabled", true) | ||
.build(); | ||
Request request = new Request("PUT", "/logs-20200101"); | ||
request.setJsonEntity("{\"settings\": " + Strings.toString(settings) + | ||
", \"mappings\": {\"_doc\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}} }"); | ||
assertOK(middleClient.performRequest(request)); | ||
for (int i = 0; i < 5; i++) { | ||
String id = Integer.toString(i); | ||
index(middleClient, "logs-20200101", id, "field", i, "filtered_field", "true"); | ||
} | ||
} | ||
assertBusy(() -> { | ||
Request statsRequest = new Request("GET", "/_ccr/stats"); | ||
Map<?, ?> response = toMap(client().performRequest(statsRequest)); | ||
Map<?, ?> autoFollowStats = (Map<?, ?>) response.get("auto_follow_stats"); | ||
assertThat(autoFollowStats.get("number_of_successful_follow_indices"), equalTo(2)); | ||
|
||
ensureYellow("logs-20190101"); | ||
ensureYellow("logs-20200101"); | ||
verifyDocuments("logs-20190101", 5, "filtered_field:true"); | ||
verifyDocuments("logs-20200101", 5, "filtered_field:true"); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.