-
Notifications
You must be signed in to change notification settings - Fork 0
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
add rollover and delete history custom result index conditions #16
base: forecasting18_3
Are you sure you want to change the base?
add rollover and delete history custom result index conditions #16
Conversation
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.
Finished the 1st pass of the code.
// We have to pass null for newIndexName in order to get Elastic to increment the index count. | ||
RolloverRequest rollOverRequest = new RolloverRequest(resultIndexAlias, null); | ||
// perform rollover and delete on AD custom result index alias | ||
if (config.getCustomResultIndexOrAlias().startsWith(ADCommonName.CUSTOM_RESULT_INDEX_PREFIX)) { |
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.
I already did the check in getConfigsWithCustomResultIndexAlias. You don't need it.
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.
Removed the part that's checking if config.getCustomResultIndexOrAlias()
starts with AD custom result index prefix or forecasting custom result index prefix
|
||
// perform rollover and delete on Forecasting custom result index 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.
You can remove forecasting code as the code is in base class. We will schedule two tasks: one for AD, and one for forecasting. The base case just abstracts out which it is run for (AD or forecasting). ADIndexManagement and ForecastIndexManagement will override rolloverAndDeleteHistoryIndex and rollover and delete their own indices.
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.
same as above, removed this part
@@ -1234,35 +1242,113 @@ protected void rolloverAndDeleteHistoryIndex( | |||
String rolloverIndexPattern, | |||
IndexType resultIndex | |||
) { | |||
if (!doesDefaultResultIndexExist()) { | |||
return; | |||
|
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.
You only roll over default indices when there is an error or there is no custom result indices.
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.
changed to perform rollover and delete on default result index first if default result index exist. Then perform rollover and delete custom result index
proceedWithRolloverAndDelete(resultIndexAlias, rolloverRequest, allResultIndicesPattern, resultIndex, null); | ||
} | ||
|
||
private RolloverRequest buildRolloverRequest(String resultIndexAlias, String rolloverIndexPattern) { |
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.
for custom result index, we don't need addMaxIndexDocsCondition. For default result index, we only need addMaxIndexDocsCondition. In this way, if customers don't elect any ISM option from AD dashboard, we won't touch it and cx can decide on their own. I think you can put addMaxIndexDocsCondition outside and only do it if you are handling default result index.
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.
changed to only build addMaxIndexDocsCondition when performing rollover on default result index
@@ -283,7 +289,7 @@ protected void choosePrimaryShards(CreateIndexRequest request, boolean hiddenInd | |||
); | |||
} | |||
|
|||
protected void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod) { | |||
protected void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod, Integer customResultIndexTtl) { |
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.
This is running for default result indices. But we want to check each custom index's custom ttl and do it one by one. Also, since there can be a lot of custom indices and the method is async, you may want to run the delete in batches. Finish batch of delete before the other custom indices.
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.
Also, can we still keep current method signature?
void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod)
If it is default index, you called it the old way. If it is custom index, you translate customResultIndexTtl of type integer to historyRetentionPeriod of type TimeValue.
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.
kept current method signature.
Not sure what you mean by run the delete in batches. Right now in deleteOldHistoryIndices, it seems like we already collecting candidates indices for deletion into a list, then perform deletion. Let's sync offline about this
config.getCustomResultIndexOrAlias(), | ||
rolloverRequest, | ||
getAllCustomResultIndexPattern(config.getCustomResultIndexOrAlias()), | ||
(IndexType) ADIndex.CUSTOM_RESULT, |
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.
You can make ADIndex.CUSTOM_RESULT as an input of the calling method and let the sublcass to pass in ADIndex.CUSTOM_RESULT or ForecastIndex.CUSTOM_RESULT.
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.
updated this part to not differentiate AD and Forecasting.
2730df5
to
d5ba7f5
Compare
Signed-off-by: Jackie Han <[email protected]>
fac3bbd
to
864de68
Compare
Signed-off-by: Jackie Han <[email protected]>
7a98581
to
3a07ec8
Compare
Signed-off-by: Jackie Han <[email protected]>
add rollover conditions (size & age) and delete history index condition (ttl) on custom result index