@@ -1082,7 +1082,7 @@ public void onClusterManager() {
1082
1082
1083
1083
// schedule the next rollover for approx MAX_AGE later
1084
1084
scheduledRollover = threadPool
1085
- .scheduleWithFixedDelay (() -> rolloverAndDeleteHistoryIndex (), TimeValue . timeValueMinutes ( 1 ) , executorName ());
1085
+ .scheduleWithFixedDelay (() -> rolloverAndDeleteHistoryIndex (), historyRolloverPeriod , executorName ());
1086
1086
} catch (Exception e ) {
1087
1087
// This should be run on cluster startup
1088
1088
logger .error ("Error rollover result indices. " + "Can't rollover result until clusterManager node is restarted." , e );
@@ -1240,36 +1240,28 @@ protected void rolloverAndDeleteHistoryIndex(
1240
1240
String rolloverIndexPattern ,
1241
1241
IndexType resultIndex
1242
1242
) {
1243
- // build rollover request for default result index
1244
- RolloverRequest defaultResultIndexRolloverRequest = buildRolloverRequest (resultIndexAlias , rolloverIndexPattern );
1245
- defaultResultIndexRolloverRequest .addMaxIndexDocsCondition (historyMaxDocs * getNumberOfPrimaryShards ());
1246
-
1247
- // get config files that have custom result index alias to perform rollover on
1248
- getConfigsWithCustomResultIndexAlias (ActionListener .wrap (candidateResultAliases -> {
1249
- if (candidateResultAliases == null || candidateResultAliases .isEmpty ()) {
1250
- // no custom result index alias found
1251
- if (!doesDefaultResultIndexExist ()) {
1252
- // no default result index found either
1253
- return ;
1254
- }
1255
- // perform rollover and delete on default result index
1256
- proceedWithDefaultRolloverAndDelete (
1243
+ // rollover and delete default result index
1244
+ if (doesDefaultResultIndexExist ()) {
1245
+ RolloverRequest defaultResultIndexRolloverRequest = buildRolloverRequest (resultIndexAlias , rolloverIndexPattern );
1246
+ defaultResultIndexRolloverRequest .addMaxIndexDocsCondition (historyMaxDocs * getNumberOfPrimaryShards ());
1247
+ proceedWithDefaultRolloverAndDelete (
1257
1248
resultIndexAlias ,
1258
1249
defaultResultIndexRolloverRequest ,
1259
1250
allResultIndicesPattern ,
1260
1251
resultIndex
1261
- );
1252
+ );
1253
+ }
1254
+
1255
+ // rollover and delete custom result index
1256
+ getConfigsWithCustomResultIndexAlias (ActionListener .wrap (candidateResultAliases -> {
1257
+ if (candidateResultAliases == null || candidateResultAliases .isEmpty ()) {
1262
1258
logger .info ("Candidate custom result indices are empty." );
1263
1259
return ;
1264
1260
}
1265
1261
1266
- // perform rollover and delete on found custom result index alias
1267
1262
candidateResultAliases .forEach (config -> handleCustomResultIndex (config , resultIndex ));
1268
-
1269
1263
}, e -> {
1270
1264
logger .error ("Failed to get configs with custom result index alias." , e );
1271
- // perform rollover and delete on default result index if getting error on getting custom result index alias
1272
- proceedWithDefaultRolloverAndDelete (resultIndexAlias , defaultResultIndexRolloverRequest , allResultIndicesPattern , resultIndex );
1273
1265
}));
1274
1266
}
1275
1267
0 commit comments