Skip to content

Commit

Permalink
Fix spotless errors
Browse files Browse the repository at this point in the history
Signed-off-by: Arpit Bandejiya <[email protected]>
  • Loading branch information
Arpit-Bandejiya committed Mar 14, 2024
1 parent d1b90aa commit 11943f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public float weightWithRebalanceConstraints(ShardsBalancer balancer, ModelNode n
int primaryShardCount = node.numPrimaryShards();
int allowedPrimaryShardCount = (int) Math.ceil(balancer.avgPrimaryShardsPerNode());

if(primaryShardCount > allowedPrimaryShardCount) {
if (primaryShardCount > allowedPrimaryShardCount) {
extraWt += 1000000L;
}

Expand Down Expand Up @@ -461,10 +461,10 @@ public void addShard(ShardRouting shard) {
index.addShard(shard);
numShards++;

if(shard.primary()) {
if (shard.primary()) {
totalPrimary++;
} else {
totalReplica ++;
totalReplica++;
}
}

Expand All @@ -478,7 +478,7 @@ public void removeShard(ShardRouting shard) {
}
numShards--;

if(shard.primary()) {
if (shard.primary()) {
totalPrimary--;
} else {
totalReplica--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -120,9 +119,10 @@ public void resetRelocationCount() {
totalRelocation = 0;
}

public void printRelocationCount(){
public void printRelocationCount() {
logger.info("Total relocation count is: {}", Integer.toString(totalRelocation));
}

/**
* Returns the average of shards per node for the given index
*/
Expand Down Expand Up @@ -362,7 +362,6 @@ private void balanceByWeights() {
for (String index : buildWeightOrderedIndices()) {
IndexMetadata indexMetadata = metadata.index(index);


// find nodes that have a shard of this index or where shards of this index are allowed to be allocated to,
// move these nodes to the front of modelNodes so that we can only balance based on these nodes
int relevantNodes = 0;
Expand Down Expand Up @@ -1009,7 +1008,7 @@ AllocateUnassignedDecision decideAllocateUnassigned(final ShardRouting shard) {
}
}

if (minNodes.isEmpty()){
if (minNodes.isEmpty()) {
minNode = null;
} else {
minNode = minNodes.get(Randomness.get().nextInt(minNodes.size()));
Expand Down Expand Up @@ -1051,9 +1050,7 @@ private boolean tryRelocateShard(BalancedShardsAllocator.ModelNode minNode, Bala
}
// This is a safety net which prevents un-necessary primary shard relocations from maxNode to minNode when
// doing such relocation wouldn't help in primary balance.
if (preferPrimaryBalance == true
&& shard.primary()
&& maxNode.numPrimaryShards() - minNode.numPrimaryShards() < 2) {
if (preferPrimaryBalance == true && shard.primary() && maxNode.numPrimaryShards() - minNode.numPrimaryShards() < 2) {
continue;
}

Expand Down

0 comments on commit 11943f9

Please sign in to comment.