From 9b6fe2d00366f587d04f79a3df4f815ac7a17206 Mon Sep 17 00:00:00 2001 From: Himadri Singh Date: Mon, 17 Feb 2014 14:57:05 +0530 Subject: [PATCH] Removed CostBalancerStrategy, made default = 1 thread --- .../coordinator/CostBalancerStrategy.java | 53 ------------------- .../CostBalancerStrategyFactory.java | 31 ----------- .../server/coordinator/DruidCoordinator.java | 9 +--- .../DruidCoordinatorRuntimeParams.java | 2 +- .../CostBalancerStrategyTest.java | 11 ---- 5 files changed, 3 insertions(+), 103 deletions(-) delete mode 100644 server/src/main/java/io/druid/server/coordinator/CostBalancerStrategy.java delete mode 100644 server/src/main/java/io/druid/server/coordinator/CostBalancerStrategyFactory.java diff --git a/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategy.java b/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategy.java deleted file mode 100644 index 09f6efbb17b..00000000000 --- a/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategy.java +++ /dev/null @@ -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 chooseBestServer( - final DataSegment proposalSegment, - final Iterable serverHolders, - boolean includeCurrentServer - ) - { - Pair 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; - } -} - diff --git a/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategyFactory.java b/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategyFactory.java deleted file mode 100644 index 29342318a83..00000000000 --- a/server/src/main/java/io/druid/server/coordinator/CostBalancerStrategyFactory.java +++ /dev/null @@ -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); - } -} diff --git a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java index 19b4e2b0f68..c1e60a5e313 100644 --- a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java +++ b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java @@ -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 = diff --git a/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorRuntimeParams.java b/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorRuntimeParams.java index 6ce41051400..6553df1ac99 100644 --- a/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorRuntimeParams.java +++ b/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorRuntimeParams.java @@ -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( diff --git a/server/src/test/java/io/druid/server/coordination/CostBalancerStrategyTest.java b/server/src/test/java/io/druid/server/coordination/CostBalancerStrategyTest.java index 18962bfb8a1..61d0c3274e5 100644 --- a/server/src/test/java/io/druid/server/coordination/CostBalancerStrategyTest.java +++ b/server/src/test/java/io/druid/server/coordination/CostBalancerStrategyTest.java @@ -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);