Skip to content

Commit

Permalink
remove unused variables
Browse files Browse the repository at this point in the history
Signed-off-by: panguixin <panguixin@bytedance.com>
  • Loading branch information
bugmakerrrrrr committed Nov 21, 2023
1 parent 386f948 commit b931f3c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public class LocalShardsBalancer extends ShardsBalancer {

private final float threshold;
private final Metadata metadata;
private final float avgShardsPerNode;

private final float avgPrimaryShardsPerNode;
private final BalancedShardsAllocator.NodeSorter sorter;
Expand All @@ -85,7 +84,6 @@ public LocalShardsBalancer(
this.threshold = threshold;
this.routingNodes = allocation.routingNodes();
this.metadata = allocation.metadata();
avgShardsPerNode = ((float) metadata.getTotalNumberOfShards()) / routingNodes.size();
avgPrimaryShardsPerNode = (float) (StreamSupport.stream(metadata.spliterator(), false)
.mapToInt(IndexMetadata::getNumberOfShards)
.sum()) / routingNodes.size();
Expand Down Expand Up @@ -663,7 +661,6 @@ MoveDecision decideMove(final ShardRouting shardRouting) {
RoutingNode targetNode = null;
final List<NodeAllocationResult> nodeExplanationMap = explain ? new ArrayList<>() : null;
int weightRanking = 0;
int targetNodeProcessed = 0;
for (BalancedShardsAllocator.ModelNode currentNode : sorter.modelNodes) {
if (currentNode != sourceNode) {
RoutingNode target = currentNode.getRoutingNode();
Expand All @@ -677,7 +674,6 @@ MoveDecision decideMove(final ShardRouting shardRouting) {
continue;
}
}
targetNodeProcessed++;
// don't use canRebalance as we want hard filtering rules to apply. See #17698
Decision allocationDecision = allocation.deciders().canAllocate(shardRouting, target, allocation);
if (explain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private void tryAllocateUnassignedShard(Queue<RoutingNode> nodeQueue, ShardRouti
allocation.metadata(),
allocation.routingTable()
);
ShardRouting initShard = routingNodes.initializeShard(shard, node.nodeId(), null, shardSize, allocation.changes());
routingNodes.initializeShard(shard, node.nodeId(), null, shardSize, allocation.changes());
nodeQueue.offer(node);
allocated = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public Decision canAllocateAnyShardToNode(RoutingNode node, RoutingAllocation al
Decision.Multi ret = new Decision.Multi();
for (AllocationDecider decider : allocations) {
Decision decision = decider.canAllocateAnyShardToNode(node, allocation);
if (decision.type().canPremptivelyReturn()) {
if (decision.type().canPreemptivelyReturn()) {
if (logger.isTraceEnabled()) {
logger.trace("Shard can not be allocated on node [{}] due to [{}]", node.nodeId(), decider.getClass().getSimpleName());
}
Expand All @@ -279,7 +279,7 @@ public Decision canMoveAway(ShardRouting shardRouting, RoutingAllocation allocat
for (AllocationDecider decider : allocations) {
Decision decision = decider.canMoveAway(shardRouting, allocation);
// short track if a NO is returned.
if (decision.type().canPremptivelyReturn()) {
if (decision.type().canPreemptivelyReturn()) {
if (logger.isTraceEnabled()) {
logger.trace("Shard [{}] can not be moved away due to [{}]", shardRouting, decider.getClass().getSimpleName());
}
Expand All @@ -301,7 +301,7 @@ public Decision canMoveAnyShard(RoutingAllocation allocation) {
for (AllocationDecider decider : allocations) {
Decision decision = decider.canMoveAnyShard(allocation);
// short track if a NO is returned.
if (decision.type().canPremptivelyReturn()) {
if (decision.type().canPreemptivelyReturn()) {
if (allocation.debugDecision() == false) {
return decision;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public boolean higherThan(Type other) {
return false;
}

public boolean canPremptivelyReturn() {
public boolean canPreemptivelyReturn() {
return this == THROTTLE || this == NO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testPrimaryAllocation() {
}

/**
* Test remote unassigned shard allocation when deciders decide no.
* Test remote unassigned shard allocation when deciders make NO or THROTTLED decision.
*/
public void testNoRemoteAllocation() {
final int localOnlyNodes = 10;
Expand Down

0 comments on commit b931f3c

Please sign in to comment.