-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce DOCUMENT Replication for AD Indices and Adjust Primary Shards #948
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
package org.opensearch.timeseries.indices; | ||
|
||
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE; | ||
import static org.opensearch.indices.replication.common.ReplicationType.DOCUMENT; | ||
import static org.opensearch.timeseries.constant.CommonMessages.CAN_NOT_FIND_RESULT_INDEX; | ||
|
||
import java.io.IOException; | ||
|
@@ -426,7 +428,10 @@ public void initConfigIndexIfAbsent(ActionListener<CreateIndexResponse> actionLi | |
* @throws IOException IOException from {@link IndexManagement#getConfigMappings} | ||
*/ | ||
public void initConfigIndex(ActionListener<CreateIndexResponse> actionListener) throws IOException { | ||
CreateIndexRequest request = new CreateIndexRequest(CommonName.CONFIG_INDEX) | ||
// AD indices need RAW (e.g., we want users to be able to consume AD results as soon as possible and send out an alert if anomalies | ||
// found). | ||
Settings replicationSettings = Settings.builder().put(SETTING_REPLICATION_TYPE, DOCUMENT.name()).build(); | ||
CreateIndexRequest request = new CreateIndexRequest(CommonName.CONFIG_INDEX, replicationSettings) | ||
.mapping(getConfigMappings(), XContentType.JSON) | ||
.settings(settings); | ||
adminClient.indices().create(request, actionListener); | ||
|
@@ -477,7 +482,11 @@ public static String getJobMappings() throws IOException { | |
*/ | ||
public void initJobIndex(ActionListener<CreateIndexResponse> actionListener) { | ||
try { | ||
CreateIndexRequest request = new CreateIndexRequest(CommonName.JOB_INDEX).mapping(getJobMappings(), XContentType.JSON); | ||
// AD indices need RAW (e.g., we want users to be able to consume AD results as soon as possible and send out an alert if | ||
// anomalies found). | ||
Settings replicationSettings = Settings.builder().put(SETTING_REPLICATION_TYPE, DOCUMENT.name()).build(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good and is a positive change. Would this cause existing detectors to have any issues? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not. Segment replication should not be enabled for existing indices. |
||
CreateIndexRequest request = new CreateIndexRequest(CommonName.JOB_INDEX, replicationSettings) | ||
.mapping(getJobMappings(), XContentType.JSON); | ||
request | ||
.settings( | ||
Settings | ||
|
@@ -928,7 +937,10 @@ protected void rolloverAndDeleteHistoryIndex( | |
|
||
CreateIndexRequest createRequest = rollOverRequest.getCreateIndexRequest(); | ||
|
||
createRequest.index(rolloverIndexPattern).mapping(resultMapping, XContentType.JSON); | ||
// AD indices need RAW (e.g., we want users to be able to consume AD results as soon as possible and send out an alert if anomalies | ||
// found). | ||
Settings replicationSettings = Settings.builder().put(SETTING_REPLICATION_TYPE, DOCUMENT.name()).build(); | ||
createRequest.index(rolloverIndexPattern).settings(replicationSettings).mapping(resultMapping, XContentType.JSON); | ||
|
||
choosePrimaryShards(createRequest, true); | ||
|
||
|
@@ -953,7 +965,10 @@ protected void initResultIndexDirectly( | |
IndexType resultIndex, | ||
ActionListener<CreateIndexResponse> actionListener | ||
) { | ||
CreateIndexRequest request = new CreateIndexRequest(resultIndexName).mapping(resultMapping, XContentType.JSON); | ||
// AD indices need RAW (e.g., we want users to be able to consume AD results as soon as possible and send out an alert if anomalies | ||
// found). | ||
Settings replicationSettings = Settings.builder().put(SETTING_REPLICATION_TYPE, DOCUMENT.name()).build(); | ||
CreateIndexRequest request = new CreateIndexRequest(resultIndexName, replicationSettings).mapping(resultMapping, XContentType.JSON); | ||
if (alias != null) { | ||
request.alias(new Alias(alias)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be changed to "forecasting indices ..." here and "timeseries indices..." later. can be done in future work too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. Fixed.