use existing currentlyMovingSegments instead of creating a reundant segmentsBeingMoved

This commit is contained in:
Nelson Ray 2013-01-29 18:16:34 -08:00
parent 034d652569
commit b205f7b3c4
1 changed files with 3 additions and 5 deletions

View File

@ -116,15 +116,13 @@ public class DruidMasterBalancer implements DruidMasterHelper
continue; continue;
} }
final Set<DataSegment> segmentsBeingMoved = new HashSet<DataSegment>();
int iter = 0; int iter = 0;
while (iter < maxSegmentsToMove) { while (iter < maxSegmentsToMove) {
BalancerSegmentHolder segmentToMove = analyzer.pickSegmentToMove(serverHolderList, numSegments); BalancerSegmentHolder segmentToMove = analyzer.pickSegmentToMove(serverHolderList, numSegments);
DruidServer toServer = analyzer.findNewSegmentHome(segmentToMove.getSegment(), serverHolderList).getServer(); DruidServer toServer = analyzer.findNewSegmentHome(segmentToMove.getSegment(), serverHolderList).getServer();
if (!segmentsBeingMoved.contains(segmentToMove.getSegment())) { if (!currentlyMovingSegments.get(tier).containsKey(segmentToMove.getSegment())) {
moveSegment(segmentToMove, toServer, params); moveSegment(segmentToMove, toServer, params);
segmentsBeingMoved.add(segmentToMove.getSegment());
} }
iter++; iter++;
} }
@ -135,13 +133,13 @@ public class DruidMasterBalancer implements DruidMasterHelper
stats.addToTieredStat("initialCost", tier, (long) initialTotalCost); stats.addToTieredStat("initialCost", tier, (long) initialTotalCost);
stats.addToTieredStat("normalization", tier, (long) normalization); stats.addToTieredStat("normalization", tier, (long) normalization);
stats.addToTieredStat("movedCount", tier, segmentsBeingMoved.size()); stats.addToTieredStat("movedCount", tier, currentlyMovingSegments.get(tier).size());
log.info( log.info(
"Initial Total Cost: [%f], Initial Normalized Cost: [%f], Segments Moved: [%d]", "Initial Total Cost: [%f], Initial Normalized Cost: [%f], Segments Moved: [%d]",
initialTotalCost, initialTotalCost,
normalizedInitialCost, normalizedInitialCost,
segmentsBeingMoved.size() currentlyMovingSegments.get(tier).size()
); );
if (serverHolderList.size() <= 1) { if (serverHolderList.size() <= 1) {