Removed CostBalancerStrategy, made default = 1 thread

This commit is contained in:
Himadri Singh 2014-02-17 14:57:05 +05:30
parent bec264bdf7
commit 9b6fe2d003
5 changed files with 3 additions and 103 deletions

View File

@ -1,53 +0,0 @@
/*
* Druid - a distributed column store.
* Copyright (C) 2012, 2013 Metamarkets Group Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.druid.server.coordinator;
import com.metamx.common.Pair;
import com.metamx.emitter.EmittingLogger;
import io.druid.timeline.DataSegment;
import org.joda.time.DateTime;
public class CostBalancerStrategy extends AbstractCostBalancerStrategy
{
private static final EmittingLogger log = new EmittingLogger(CostBalancerStrategy.class);
public CostBalancerStrategy(DateTime referenceTimestamp)
{
super(referenceTimestamp);
}
protected Pair<Double, ServerHolder> chooseBestServer(
final DataSegment proposalSegment,
final Iterable<ServerHolder> serverHolders,
boolean includeCurrentServer
)
{
Pair<Double, ServerHolder> bestServer = Pair.of(Double.POSITIVE_INFINITY, null);
for (ServerHolder server : serverHolders) {
double cost = computeCost(proposalSegment, server, includeCurrentServer);
if (cost < bestServer.lhs) {
bestServer = Pair.of(cost, server);
}
}
return bestServer;
}
}

View File

@ -1,31 +0,0 @@
/*
* Druid - a distributed column store.
* Copyright (C) 2012, 2013 Metamarkets Group Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.druid.server.coordinator;
import org.joda.time.DateTime;
public class CostBalancerStrategyFactory implements BalancerStrategyFactory
{
@Override
public BalancerStrategy createBalancerStrategy(DateTime referenceTimestamp)
{
return new CostBalancerStrategy(referenceTimestamp);
}
}

View File

@ -739,13 +739,8 @@ public class DruidCoordinator
}
}
BalancerStrategyFactory factory= null;
if (COST.equals(config.getCoordinatorBalancerStrategy()))
factory = new CostBalancerStrategyFactory();
else if (RANDOM.equals(config.getCoordinatorBalancerStrategy()))
factory= new RandomBalancerStrategyFactory();
else if (COST_MULTI.equals(config.getCoordinatorBalancerStrategy()))
factory = new CostBalancerMultithreadStrategyFactory(getDynamicConfigs().getCostBalancerThreads());
BalancerStrategyFactory factory =
new CostBalancerMultithreadStrategyFactory(getDynamicConfigs().getCostBalancerThreads());
// Do coordinator stuff.
DruidCoordinatorRuntimeParams params =

View File

@ -206,7 +206,7 @@ public class DruidCoordinatorRuntimeParams
this.stats = new CoordinatorStats();
this.coordinatorDynamicConfig = new CoordinatorDynamicConfig.Builder().build();
this.balancerReferenceTimestamp = null;
this.strategyFactory = new CostBalancerStrategyFactory();
this.strategyFactory = new CostBalancerMultithreadStrategyFactory(1);
}
Builder(

View File

@ -5,7 +5,6 @@ import com.google.common.collect.Maps;
import io.druid.client.DruidServer;
import io.druid.server.coordinator.BalancerStrategy;
import io.druid.server.coordinator.CostBalancerMultithreadStrategy;
import io.druid.server.coordinator.CostBalancerStrategy;
import io.druid.server.coordinator.LoadQueuePeonTester;
import io.druid.server.coordinator.ServerHolder;
import io.druid.timeline.DataSegment;
@ -75,16 +74,6 @@ public class CostBalancerStrategyTest
return segment;
}
@Test
public void testCostBalancerStrategy() throws InterruptedException {
DataSegment segment = getSegment(1000);
BalancerStrategy strategy = new CostBalancerStrategy(DateTime.now(DateTimeZone.UTC));
ServerHolder holder = strategy.findNewSegmentHomeReplicator(segment, serverHolderList);
Assert.assertNotNull("Should be able to find a place for new segment!!", holder);
Assert.assertEquals("Best Server should be BEST_SERVER", "BEST_SERVER", holder.getServer().getName());
}
@Test
public void testCostBalancerMultithreadStrategy() throws InterruptedException {
DataSegment segment = getSegment(1000);