Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
  • Loading branch information
imRishN committed Aug 27, 2024
1 parent c072f27 commit b1b5b99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public ShardAllocationDecision decideShardAllocation(final ShardRouting shard, f
preferPrimaryShardBalance,
preferPrimaryShardRebalance,
ignoreThrottleInRestore,
this::allocatorTimedOut
null // as we don't need to check if timed out or not while just understanding ShardAllocationDecision
);
AllocateUnassignedDecision allocateUnassignedDecision = AllocateUnassignedDecision.NOT_TAKEN;
MoveDecision moveDecision = MoveDecision.NOT_TAKEN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void balanceByWeights() {
final float[] weights = sorter.weights;
for (String index : buildWeightOrderedIndices()) {
// Terminate if the time allocated to the balanced shards allocator has elapsed
if (timedOutFunc.apply(System.nanoTime())) {
if (timedOutFunc != null && timedOutFunc.apply(System.nanoTime())) {
logger.info(
"Cannot balance any shard in the cluster as time allocated to balanced shards allocator has elapsed"
+ ". Skipping indices iteration"
Expand Down Expand Up @@ -381,12 +381,12 @@ private void balanceByWeights() {
int highIdx = relevantNodes - 1;
while (true) {
// break if the time allocated to the balanced shards allocator has elapsed
if (timedOutFunc.apply(System.nanoTime())) {
if (timedOutFunc != null && timedOutFunc.apply(System.nanoTime())) {
logger.info(
"Cannot balance any shard in the cluster as time allocated to balanced shards allocator has elapsed"
+ ". Skipping relevant nodes iteration"
);
break;
return;
}
final BalancedShardsAllocator.ModelNode minNode = modelNodes[lowIdx];
final BalancedShardsAllocator.ModelNode maxNode = modelNodes[highIdx];
Expand Down Expand Up @@ -593,7 +593,7 @@ void moveShards() {
}

// Terminate if the time allocated to the balanced shards allocator has elapsed
if (timedOutFunc.apply(System.nanoTime())) {
if (timedOutFunc != null && timedOutFunc.apply(System.nanoTime())) {
logger.info(
"Cannot move any shard in the cluster as time allocated to balanced shards allocator has elapsed"
+ ". Skipping shard iteration"
Expand Down Expand Up @@ -833,7 +833,7 @@ void allocateUnassigned() {
}
do {
for (int i = 0; i < primaryLength; i++) {
if (timedOutFunc.apply(System.nanoTime())) {
if (timedOutFunc != null && timedOutFunc.apply(System.nanoTime())) {
// TODO - maybe check if we can allow wait for active shards thingy bypass this condition
logger.info(
"Ignoring [{}] unassigned shards for allocation as time allocated to balanced shards allocator has elapsed",
Expand Down

0 comments on commit b1b5b99

Please sign in to comment.