moved profiler

This commit is contained in:
Dhruv Parthasarathy 2013-07-25 14:37:03 -07:00
parent 34a9525966
commit 8e4fba431c
3 changed files with 13 additions and 18 deletions

View File

@ -22,7 +22,9 @@ package com.metamx.druid.master;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.metamx.druid.client.DataSegment; import com.metamx.druid.client.DataSegment;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
public class RandomBalancerStrategy implements BalancerStrategy public class RandomBalancerStrategy implements BalancerStrategy
{ {
@ -33,7 +35,8 @@ public class RandomBalancerStrategy implements BalancerStrategy
DataSegment proposalSegment, Iterable<ServerHolder> serverHolders DataSegment proposalSegment, Iterable<ServerHolder> serverHolders
) )
{ {
return sampler.getRandomServerHolder(Lists.newArrayList(serverHolders)); ArrayList<ServerHolder> serverHoldersList = Lists.newArrayList(serverHolders);
return serverHoldersList.get(new Random().nextInt(serverHoldersList.size()));
} }
@Override @Override

View File

@ -47,20 +47,4 @@ public class ReservoirSegmentSampler
} }
return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment); return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment);
} }
public ServerHolder getRandomServerHolder(final List<ServerHolder> serverHolders)
{
ServerHolder serverHolder = null;
int numSoFar = 0;
for (ServerHolder server : serverHolders) {
int randNum = rand.nextInt(numSoFar + 1);
if (randNum == numSoFar) {
serverHolder = server;
}
numSoFar++;
}
return serverHolder;
}
} }

View File

@ -1,4 +1,4 @@
package com.metamx.druid.master; package com.metamx.druid.utils;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -7,6 +7,14 @@ import com.google.common.collect.Maps;
import com.google.common.collect.MinMaxPriorityQueue; import com.google.common.collect.MinMaxPriorityQueue;
import com.metamx.druid.client.DataSegment; import com.metamx.druid.client.DataSegment;
import com.metamx.druid.client.DruidServer; import com.metamx.druid.client.DruidServer;
import com.metamx.druid.master.DruidCluster;
import com.metamx.druid.master.DruidMaster;
import com.metamx.druid.master.DruidMasterBalancerTester;
import com.metamx.druid.master.DruidMasterRuntimeParams;
import com.metamx.druid.master.LoadPeonCallback;
import com.metamx.druid.master.LoadQueuePeon;
import com.metamx.druid.master.LoadQueuePeonTester;
import com.metamx.druid.master.ServerHolder;
import com.metamx.druid.shard.NoneShardSpec; import com.metamx.druid.shard.NoneShardSpec;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.joda.time.DateTime; import org.joda.time.DateTime;