Skip to content

Commit

Permalink
auto expand replicas for logtype index (#568) (#571)
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored Sep 13, 2023
1 parent 2080abb commit ae57d3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,16 @@ public void ensureConfigIndexIsInitialized(ActionListener<Void> listener) {

if (state.routingTable().hasIndex(LOG_TYPE_INDEX) == false) {
isConfigIndexInitialized = false;
Settings indexSettings = Settings.builder()
.put("index.hidden", true)
.put("index.auto_expand_replicas", "0-all")
.build();

CreateIndexRequest createIndexRequest = new CreateIndexRequest();
createIndexRequest.settings(logTypeIndexSettings());
createIndexRequest.index(LOG_TYPE_INDEX);
createIndexRequest.mapping(logTypeIndexMapping());
createIndexRequest.settings(indexSettings);
createIndexRequest.cause("auto(sap-logtype api)");
client.admin().indices().create(createIndexRequest, new ActionListener<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ public static String customLogTypeMappings() throws IOException {

public void initCustomLogTypeIndex(ActionListener<CreateIndexResponse> actionListener) throws IOException {
if (!customLogTypeIndexExists()) {
Settings indexSettings = Settings.builder()
.put("index.hidden", true)
.put("index.auto_expand_replicas", "0-all")
.build();
CreateIndexRequest indexRequest = new CreateIndexRequest(LogTypeService.LOG_TYPE_INDEX)
.mapping(customLogTypeMappings())
.settings(Settings.builder().put("index.hidden", true).build());
.settings(indexSettings);
client.indices().create(indexRequest, actionListener);
}
}
Expand Down

0 comments on commit ae57d3a

Please sign in to comment.