@@ -229,23 +229,20 @@ record Inputs(
229229 double writeIndexRecentLoad ,
230230 double writeIndexPeakLoad ,
231231 int currentNumberOfWriteIndexShards
232- ) {
233- }
232+ ) {}
234233
235234 record IncreaseCalculation (
236235 double writeIndexLoadForIncrease ,
237236 int optimalShardCountForIncrease ,
238237 @ Nullable AutoShardingResult increaseResult
239- ) {
240- }
238+ ) {}
241239
242240 record DecreaseCalculation (
243241 MaxLoadWithinCooldown maxLoadWithinCooldownForDecrease ,
244242 int optimalShardCountForDecrease ,
245243 @ Nullable AutoShardingResult decreaseResult
246244 ) {
247- record MaxLoadWithinCooldown (double load , @ Nullable String previousIndexWithMaxLoad ) {
248- }
245+ record MaxLoadWithinCooldown (double load , @ Nullable String previousIndexWithMaxLoad ) {}
249246 }
250247
251248 @ Override
@@ -271,14 +268,14 @@ public String toString() {
271268 decreaseCalculation == null
272269 ? ""
273270 : Strings .format (
274- "using %s value %g for dec based on %s gives %d" ,
275- inputs .decreaseShardsMetric ,
276- decreaseCalculation .maxLoadWithinCooldownForDecrease .load ,
277- decreaseCalculation .maxLoadWithinCooldownForDecrease .previousIndexWithMaxLoad != null
278- ? decreaseCalculation .maxLoadWithinCooldownForDecrease .previousIndexWithMaxLoad
279- : "write index" ,
280- decreaseCalculation .optimalShardCountForDecrease
281- )
271+ "using %s value %g for dec based on %s gives %d" ,
272+ inputs .decreaseShardsMetric ,
273+ decreaseCalculation .maxLoadWithinCooldownForDecrease .load ,
274+ decreaseCalculation .maxLoadWithinCooldownForDecrease .previousIndexWithMaxLoad != null
275+ ? decreaseCalculation .maxLoadWithinCooldownForDecrease .previousIndexWithMaxLoad
276+ : "write index" ,
277+ decreaseCalculation .optimalShardCountForDecrease
278+ )
282279 );
283280 }
284281 }
@@ -446,16 +443,16 @@ private TimeValue getRemainingDecreaseShardsCooldown(ProjectMetadata project, Da
446443 // without a pre-existing auto sharding event we wait until the oldest index has been created longer than the decrease_shards
447444 // cool down period "ago" so we don't immediately reduce the number of shards after a data stream is created
448445 ? TimeValue .timeValueMillis (
449- Math .max (0L , oldestIndexMeta .getCreationDate () + decreaseShardsCooldown .millis () - nowSupplier .getAsLong ())
450- )
451- : TimeValue .timeValueMillis (
452- Math .max (
453- 0L ,
454- decreaseShardsCooldown .millis () - dataStream .getAutoShardingEvent ()
455- .getTimeSinceLastAutoShardingEvent (nowSupplier )
456- .millis ()
446+ Math .max (0L , oldestIndexMeta .getCreationDate () + decreaseShardsCooldown .millis () - nowSupplier .getAsLong ())
457447 )
458- );
448+ : TimeValue .timeValueMillis (
449+ Math .max (
450+ 0L ,
451+ decreaseShardsCooldown .millis () - dataStream .getAutoShardingEvent ()
452+ .getTimeSinceLastAutoShardingEvent (nowSupplier )
453+ .millis ()
454+ )
455+ );
459456 }
460457
461458 private Decision .DecreaseCalculation calculateIncreaseShardsDecision (
@@ -465,8 +462,12 @@ private Decision.DecreaseCalculation calculateIncreaseShardsDecision(
465462 LongSupplier nowSupplier
466463 ) {
467464 TimeValue remainingCooldownForDecrease = getRemainingDecreaseShardsCooldown (project , dataStream , inputs .decreaseShardsCooldown ());
468- Decision .DecreaseCalculation .MaxLoadWithinCooldown maxLoadWithinCooldownForDecrease =
469- getMaxIndexLoadWithinCoolingPeriod (project , dataStream , inputs , nowSupplier );
465+ Decision .DecreaseCalculation .MaxLoadWithinCooldown maxLoadWithinCooldownForDecrease = getMaxIndexLoadWithinCoolingPeriod (
466+ project ,
467+ dataStream ,
468+ inputs ,
469+ nowSupplier
470+ );
470471 int optimalShardCountForDecrease = computeOptimalNumberOfShards (
471472 inputs .minWriteThreads (),
472473 inputs .maxWriteThreads (),
@@ -531,11 +532,11 @@ static Decision.DecreaseCalculation.MaxLoadWithinCooldown getMaxIndexLoadWithinC
531532 ) {
532533 // for reducing the number of shards we look at more than just the write index
533534 Map <String , IndexWriteLoad > writeLoadsWithinCoolingPeriod = DataStream .getIndicesWithinMaxAgeRange (
534- dataStream ,
535- project ::getIndexSafe ,
536- inputs .decreaseShardsCooldown (),
537- nowSupplier
538- )
535+ dataStream ,
536+ project ::getIndexSafe ,
537+ inputs .decreaseShardsCooldown (),
538+ nowSupplier
539+ )
539540 .stream ()
540541 .filter (index -> index .equals (dataStream .getWriteIndex ()) == false )
541542 .map (project ::index )
@@ -695,8 +696,7 @@ static class PeriodicDecisionLogger {
695696 }
696697 }
697698
698- record FlushedDecisions (List <Decision > highestLoadIncreaseDecisions , List <Decision > highestLoadNonIncreaseDecisions ) {
699- }
699+ record FlushedDecisions (List <Decision > highestLoadIncreaseDecisions , List <Decision > highestLoadNonIncreaseDecisions ) {}
700700
701701 void maybeLogDecision (Decision Decision ) {
702702 assert Decision .result != null : "Attempting to log a decision with no result" ;
0 commit comments