Remove primitive value instead of CoordinatorStats from LoadRule.assign method (#4469)

This commit is contained in:
dgolitsyn 2017-06-29 21:48:49 +04:00 committed by Roman Leventov
parent ae900a4934
commit a5651ea474
1 changed files with 7 additions and 9 deletions

View File

@ -89,7 +89,7 @@ public abstract class LoadRule implements Rule
final BalancerStrategy strategy = params.getBalancerStrategy();
if (availableSegments.contains(segment)) {
CoordinatorStats assignStats = assign(
int assignedCount = assign(
params.getReplicationManager(),
tier,
totalReplicantsInCluster,
@ -99,8 +99,8 @@ public abstract class LoadRule implements Rule
serverHolderList,
segment
);
stats.accumulate(assignStats);
totalReplicantsInCluster += assignStats.getTieredStat(ASSIGNED_COUNT, tier);
stats.addToTieredStat(ASSIGNED_COUNT, tier, assignedCount);
totalReplicantsInCluster += assignedCount;
}
loadStatus.put(tier, expectedReplicantsInTier - loadedReplicantsInTier);
@ -112,7 +112,7 @@ public abstract class LoadRule implements Rule
return stats;
}
private CoordinatorStats assign(
private int assign(
final ReplicationThrottler replicationManager,
final String tier,
final int totalReplicantsInCluster,
@ -123,9 +123,7 @@ public abstract class LoadRule implements Rule
final DataSegment segment
)
{
final CoordinatorStats stats = new CoordinatorStats();
stats.addToTieredStat(ASSIGNED_COUNT, tier, 0);
int assignedCount = 0;
int currReplicantsInTier = totalReplicantsInTier;
int currTotalReplicantsInCluster = totalReplicantsInCluster;
while (currReplicantsInTier < expectedReplicantsInTier) {
@ -169,12 +167,12 @@ public abstract class LoadRule implements Rule
}
);
stats.addToTieredStat(ASSIGNED_COUNT, tier, 1);
++assignedCount;
++currReplicantsInTier;
++currTotalReplicantsInCluster;
}
return stats;
return assignedCount;
}
private CoordinatorStats drop(