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