diff --git a/.gitignore b/.gitignore index 845a2ddc007..c952bc075ac 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ examples/rand/RealtimeNode.out examples/twitter/RealtimeNode.out *.log *.DS_Store +server/src/main/resources/static/js/SlickGrid-master/ \ No newline at end of file diff --git a/server/src/main/java/com/metamx/druid/master/BalancerStrategy.java b/server/src/main/java/com/metamx/druid/master/BalancerStrategy.java index 9430f22bbc1..7f3b857820e 100644 --- a/server/src/main/java/com/metamx/druid/master/BalancerStrategy.java +++ b/server/src/main/java/com/metamx/druid/master/BalancerStrategy.java @@ -25,7 +25,7 @@ import java.util.List; public interface BalancerStrategy { - public ServerHolder findNewSegmentHome(final DataSegment proposalSegment,final Iterable serverHolders); + public ServerHolder findNewSegmentHome(final DataSegment proposalSegment,final List serverHolders); public BalancerSegmentHolder pickSegmentToMove(final List serverHolders); public void emitStats(String tier, MasterStats stats, List serverHolderList); } diff --git a/server/src/main/java/com/metamx/druid/master/CostBalancerStrategy.java b/server/src/main/java/com/metamx/druid/master/CostBalancerStrategy.java index b841324da73..feacd374c44 100644 --- a/server/src/main/java/com/metamx/druid/master/CostBalancerStrategy.java +++ b/server/src/main/java/com/metamx/druid/master/CostBalancerStrategy.java @@ -44,7 +44,7 @@ public class CostBalancerStrategy implements BalancerStrategy @Override public ServerHolder findNewSegmentHome( - DataSegment proposalSegment, Iterable serverHolders + DataSegment proposalSegment, List serverHolders ) { return computeCosts(proposalSegment, serverHolders).rhs; diff --git a/server/src/main/java/com/metamx/druid/master/DruidMasterBalancer.java b/server/src/main/java/com/metamx/druid/master/DruidMasterBalancer.java index 2c765e8f23d..cc8dd39eac2 100644 --- a/server/src/main/java/com/metamx/druid/master/DruidMasterBalancer.java +++ b/server/src/main/java/com/metamx/druid/master/DruidMasterBalancer.java @@ -115,7 +115,7 @@ public class DruidMasterBalancer implements DruidMasterHelper for (int iter = 0; iter < maxSegmentsToMove; iter++) { final BalancerSegmentHolder segmentToMove = strategy.pickSegmentToMove(serverHolderList); - if (params.getAvailableSegments().contains(segmentToMove.getSegment())) { + if (segmentToMove!=null && params.getAvailableSegments().contains(segmentToMove.getSegment())) { final ServerHolder holder = strategy.findNewSegmentHome(segmentToMove.getSegment(), serverHolderList); if (holder != null) { diff --git a/server/src/main/java/com/metamx/druid/master/RandomBalancerStrategy.java b/server/src/main/java/com/metamx/druid/master/RandomBalancerStrategy.java index 279eab46008..b1cff01d782 100644 --- a/server/src/main/java/com/metamx/druid/master/RandomBalancerStrategy.java +++ b/server/src/main/java/com/metamx/druid/master/RandomBalancerStrategy.java @@ -19,10 +19,8 @@ package com.metamx.druid.master; -import com.google.common.collect.Lists; import com.metamx.druid.client.DataSegment; -import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -32,11 +30,10 @@ public class RandomBalancerStrategy implements BalancerStrategy @Override public ServerHolder findNewSegmentHome( - DataSegment proposalSegment, Iterable serverHolders + DataSegment proposalSegment, List serverHolders ) { - ArrayList serverHoldersList = Lists.newArrayList(serverHolders); - return serverHoldersList.get(new Random().nextInt(serverHoldersList.size())); + return serverHolders.get(new Random().nextInt(serverHolders.size())); } @Override diff --git a/server/src/main/java/com/metamx/druid/master/ReservoirSegmentSampler.java b/server/src/main/java/com/metamx/druid/master/ReservoirSegmentSampler.java index 8ac2d949d5a..17c4b38f94a 100644 --- a/server/src/main/java/com/metamx/druid/master/ReservoirSegmentSampler.java +++ b/server/src/main/java/com/metamx/druid/master/ReservoirSegmentSampler.java @@ -45,6 +45,12 @@ public class ReservoirSegmentSampler numSoFar++; } } - return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment); + if (fromServerHolder!=null) + { + return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment); + } + else{ + return null; + } } }