mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-03 01:19:10 +00:00
Set auto expand replicas on enrich index after force merge is done. (#43600)
This commit is contained in:
parent
b4b2ad3593
commit
7ad9beb087
@ -17,6 +17,8 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||
@ -227,7 +229,7 @@ public class EnrichPolicyRunner implements Runnable {
|
||||
long nowTimestamp = nowSupplier.getAsLong();
|
||||
String enrichIndexName = EnrichPolicy.getBaseName(policyName) + "-" + nowTimestamp;
|
||||
Settings enrichIndexSettings = Settings.builder()
|
||||
.put("index.auto_expand_replicas", "0-all")
|
||||
.put("index.number_of_replicas", 0)
|
||||
.build();
|
||||
CreateIndexRequest createEnrichIndexRequest = new CreateIndexRequest(enrichIndexName, enrichIndexSettings);
|
||||
createEnrichIndexRequest.mapping(MapperService.SINGLE_MAPPING_NAME, resolveEnrichMapping(policy));
|
||||
@ -319,10 +321,27 @@ public class EnrichPolicyRunner implements Runnable {
|
||||
logger.debug("Policy [{}]: Setting new enrich index [{}] to be read only", policyName, destinationIndexName);
|
||||
UpdateSettingsRequest request = new UpdateSettingsRequest(destinationIndexName)
|
||||
.setPreserveExisting(true)
|
||||
.settings(Settings.builder().put("index.blocks.write", "true"));
|
||||
.settings(Settings.builder()
|
||||
.put("index.auto_expand_replicas", "0-all")
|
||||
.put("index.blocks.write", "true"));
|
||||
client.admin().indices().updateSettings(request, new ActionListener<AcknowledgedResponse>() {
|
||||
@Override
|
||||
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
|
||||
waitForIndexGreen(destinationIndexName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForIndexGreen(final String destinationIndexName) {
|
||||
ClusterHealthRequest request = new ClusterHealthRequest(destinationIndexName).waitForGreenStatus();
|
||||
client.admin().cluster().health(request, new ActionListener<ClusterHealthResponse>() {
|
||||
@Override
|
||||
public void onResponse(ClusterHealthResponse clusterHealthResponse) {
|
||||
updateEnrichPolicyAlias(destinationIndexName);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user