commit 3e946cf7bc596f41ca355d7e414c801ef322698f Author: Thiruvel Thirumoolan Date: Thu Mar 23 19:07:41 2017 -0700 HBASE-15533 Add RSGroup Favored Balancer diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/FavoredRSGroupLoadBalancer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/FavoredRSGroupLoadBalancer.java new file mode 100644 index 0000000..776c531 --- /dev/null +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/FavoredRSGroupLoadBalancer.java @@ -0,0 +1,88 @@ +/** + * Copyright The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.rsgroup; + +import static org.apache.hadoop.hbase.ServerName.NON_STARTCODE; + +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.hbase.ClusterStatus; +import org.apache.hadoop.hbase.HBaseIOException; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.favored.FavoredNodesPromoter; +import org.apache.hadoop.hbase.master.balancer.FavoredStochasticBalancer; + +import com.google.common.collect.Lists; +import org.apache.hadoop.hbase.net.Address; + +public class FavoredRSGroupLoadBalancer extends RSGroupBasedLoadBalancer + implements FavoredNodesPromoter { + + private FavoredNodesPromoter favoredNodesPromoter; + + @Override + public void initialize() throws HBaseIOException { + + internalBalancer = new FavoredStochasticBalancer(); + internalBalancer.setConf(config); + internalBalancer.setMasterServices(masterServices); + internalBalancer.setClusterStatus(clusterStatus); + internalBalancer.initialize(); + favoredNodesPromoter = (FavoredNodesPromoter) internalBalancer; + if (rsGroupInfoManager == null) { + initializeRSGroupInfoManager(); + } + } + + @Override + public void setClusterStatus(ClusterStatus st) { + super.setClusterStatus(st); + if (this.internalBalancer != null) { + this.internalBalancer.setClusterStatus(st); + } + } + + @Override + public void generateFavoredNodesForDaughter(List servers, HRegionInfo parent, + HRegionInfo hriA, HRegionInfo hriB) throws IOException { + + TableName table = parent.getTable(); + String group = rsGroupInfoManager.getRSGroupOfTable(table); + List groupServers = getGroupServerList(rsGroupInfoManager.getRSGroup(group)); + favoredNodesPromoter.generateFavoredNodesForDaughter(groupServers, parent, hriA, hriB); + } + + private List getGroupServerList(RSGroupInfo group) { + List groupServerList = Lists.newArrayList(); + for (Address addr : group.getServers()) { + groupServerList.add(ServerName.valueOf(addr.getHostname(), addr.getPort(), NON_STARTCODE)); + } + return groupServerList; + } + + @Override + public void generateFavoredNodesForMergedRegion(HRegionInfo merged, HRegionInfo hriA, + HRegionInfo hriB) throws IOException { + favoredNodesPromoter.generateFavoredNodesForMergedRegion(merged, hriA, hriB); + } +} diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java index 30efc0a..4b14f9a 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java @@ -73,11 +73,11 @@ import org.apache.hadoop.util.ReflectionUtils; public class RSGroupBasedLoadBalancer implements RSGroupableBalancer { private static final Log LOG = LogFactory.getLog(RSGroupBasedLoadBalancer.class); - private Configuration config; - private ClusterStatus clusterStatus; - private MasterServices masterServices; - private volatile RSGroupInfoManager rsGroupInfoManager; - private LoadBalancer internalBalancer; + protected Configuration config; + protected ClusterStatus clusterStatus; + protected MasterServices masterServices; + protected volatile RSGroupInfoManager rsGroupInfoManager; + protected LoadBalancer internalBalancer; /** * Used by reflection in {@link org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory}. @@ -353,10 +353,23 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer { @Override public void initialize() throws HBaseIOException { + initializeRSGroupInfoManager(); + + // Create the balancer + Class balancerKlass = config.getClass(HBASE_RSGROUP_LOADBALANCER_CLASS, + StochasticLoadBalancer.class, LoadBalancer.class); + internalBalancer = ReflectionUtils.newInstance(balancerKlass, config); + internalBalancer.setMasterServices(masterServices); + internalBalancer.setClusterStatus(clusterStatus); + internalBalancer.setConf(config); + internalBalancer.initialize(); + } + + protected void initializeRSGroupInfoManager() throws HBaseIOException { try { if (rsGroupInfoManager == null) { List cps = - masterServices.getMasterCoprocessorHost().findCoprocessors(RSGroupAdminEndpoint.class); + masterServices.getMasterCoprocessorHost().findCoprocessors(RSGroupAdminEndpoint.class); if (cps.size() != 1) { String msg = "Expected one implementation of GroupAdminEndpoint but found " + cps.size(); LOG.error(msg); @@ -367,15 +380,6 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer { } catch (IOException e) { throw new HBaseIOException("Failed to initialize GroupInfoManagerImpl", e); } - - // Create the balancer - Class balancerKlass = config.getClass(HBASE_RSGROUP_LOADBALANCER_CLASS, - StochasticLoadBalancer.class, LoadBalancer.class); - internalBalancer = ReflectionUtils.newInstance(balancerKlass, config); - internalBalancer.setMasterServices(masterServices); - internalBalancer.setClusterStatus(clusterStatus); - internalBalancer.setConf(config); - internalBalancer.initialize(); } public boolean isOnline() { diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestFavoredRSGroupLoadBalancer.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestFavoredRSGroupLoadBalancer.java new file mode 100644 index 0000000..6ed2c4c --- /dev/null +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestFavoredRSGroupLoadBalancer.java @@ -0,0 +1,214 @@ +/** + * Copyright The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.rsgroup; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.ConnectionFactory; +import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; +import org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper; +import org.apache.hadoop.hbase.favored.FavoredNodesManager; +import org.apache.hadoop.hbase.master.LoadBalancer; +import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.master.balancer.TestFavoredStochasticLoadBalancer; +import org.apache.hadoop.hbase.net.Address; +import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +@Category(LargeTests.class) +public class TestFavoredRSGroupLoadBalancer extends TestFavoredStochasticLoadBalancer { + + private static final Log LOG = LogFactory.getLog(TestFavoredRSGroupLoadBalancer.class); + + private static final String GROUP = "test"; + + private RSGroupAdmin rsGroupAdminClient; + + @BeforeClass + public static void setupBeforeClass() throws Exception { + Configuration conf = TEST_UTIL.getConfiguration(); + conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + FavoredRSGroupLoadBalancer.class, LoadBalancer.class); + conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName()); + conf.set(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, ""+ SLAVES); + } + + @Before + public void startCluster() throws Exception { + + super.startCluster(); + + Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); + rsGroupAdminClient = new RSGroupAdminClient(conn); + addGroup(rsGroupAdminClient, GROUP, SLAVES - 3); + NamespaceDescriptor nsDescriptor = NamespaceDescriptor.create(NAMESPACE) + .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, GROUP).build(); + admin.modifyNamespace(nsDescriptor); + LOG.debug("Created namespace: " + NAMESPACE); + } + + @After + public void stopCluster() throws Exception { + if (TEST_UTIL.getHBaseClusterInterface() != null) { + for (TableName tName : admin.listTableNames()) { + admin.disableTable(tName); + admin.deleteTable(tName); + } + for (NamespaceDescriptor nspDesc : admin.listNamespaceDescriptors()) { + if (nspDesc.getName().equals(NAMESPACE)) { + admin.deleteNamespace(NAMESPACE); + } + } + removeGroup(rsGroupAdminClient, GROUP); + super.stopCluster(); + } + } + + @Test + @Ignore + public void testCreateTableWithLessThanThreeRS() throws Exception { + String group = "lessgroup"; + addGroup(rsGroupAdminClient, group, 1); + NamespaceDescriptor nsp = NamespaceDescriptor.create(group) + .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, group).build(); + admin.createNamespace(nsp); + assertEquals(1, rsGroupAdminClient.getRSGroupInfo(group).getServers().size()); + String tableName = group + TableName.NAMESPACE_DELIM + "testCreateTableWithLessThanThreeRS"; + HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); + boolean failed = false; + try { + admin.createTable(desc, new byte[][] { Bytes.toBytes("aaa"), Bytes.toBytes("zzz") }); + } catch (IOException exp) { + failed = true; + } finally { + assertTrue(failed); + } + } + + protected Collection getServersForNewFN() throws IOException { + List groupServers = Lists.newArrayList(); + for (Address address : rsGroupAdminClient.getRSGroupInfo(GROUP).getServers()) { + groupServers.add(ServerName.valueOf(address.getHostname(), address.getPort(), + ServerName.NON_STARTCODE)); + } + return groupServers; + } + + @Test + public void testBasicRegionPlacement() throws Exception { + TableName tableName = getTableNameWithNS("testBasicRegionPlacement"); + HTableDescriptor desc = new HTableDescriptor(tableName); + desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); + admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); + FavoredNodesManager fnm = TEST_UTIL.getHBaseCluster().getMaster().getFavoredNodesManager(); + List regionsOfTable = admin.getTableRegions(tableName); + Set
groupServers = rsGroupAdminClient.getRSGroupInfo(GROUP).getServers(); + for (HRegionInfo rInfo : regionsOfTable) { + Set favNodes = Sets.newHashSet(fnm.getFavoredNodes(rInfo)); + assertNotNull(favNodes); + assertEquals(FavoredNodeAssignmentHelper.FAVORED_NODES_NUM, favNodes.size()); + for (ServerName sn : favNodes) { + Address fnAddress = Address.fromParts(sn.getHostname(), sn.getPort()); + assertTrue("Favored node not in group servers", groupServers.contains(fnAddress)); + } + } + Map> replicaLoadMap = + fnm.getReplicaLoad(Lists.newArrayList(admin.getClusterStatus().getServers())); + assertTrue("Not all replica load collected.", + admin.getClusterStatus().getServers().size() == replicaLoadMap.size()); + for (Entry> entry : replicaLoadMap.entrySet()) { + assertTrue(entry.getValue().size() == 3); + assertTrue(entry.getValue().get(0) >= 0); + assertTrue(entry.getValue().get(1) >= 0); + assertTrue(entry.getValue().get(2) >= 0); + } + admin.disableTable(tableName); + TEST_UTIL.waitTableDisabled(tableName.getName()); + admin.deleteTable(tableName); + for (HRegionInfo rInfo : regionsOfTable) { + List favNodes = fnm.getFavoredNodes(rInfo); + assertNull(favNodes); + } + replicaLoadMap = + fnm.getReplicaLoad(Lists.newArrayList(admin.getClusterStatus().getServers())); + assertTrue("replica load found " + replicaLoadMap.size() + " instead of 0.", + replicaLoadMap.size() == admin.getClusterStatus().getServers().size()); + } + + private RSGroupInfo addGroup(RSGroupAdmin gAdmin, String group, int servers) throws IOException { + + RSGroupInfo defaultInfo = gAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP); + assertTrue("Default group info can't be null", defaultInfo != null); + assertTrue("default group doesn't have enough servers", + defaultInfo.getServers().size() >= servers); + gAdmin.addRSGroup(group); + + Set
set = Sets.newHashSet(); + for(Address address: defaultInfo.getServers()) { + if(set.size() == servers) { + break; + } + set.add(address); + } + gAdmin.moveServers(set, group); + RSGroupInfo result = gAdmin.getRSGroupInfo(group); + assertTrue("Insufficient servers in group", result.getServers().size() == servers); + LOG.debug("Created group: " + group + " with servers: " + result.getServers()); + return result; + } + + private void removeGroup(RSGroupAdmin admin, String groupName) throws IOException { + RSGroupInfo groupInfo = admin.getRSGroupInfo(groupName); + admin.moveTables(groupInfo.getTables(), RSGroupInfo.DEFAULT_GROUP); + admin.moveServers(groupInfo.getServers(), RSGroupInfo.DEFAULT_GROUP); + admin.removeRSGroup(groupName); + } +} diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupTableFavoredNodes.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupTableFavoredNodes.java new file mode 100644 index 0000000..5b3a8e0 --- /dev/null +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupTableFavoredNodes.java @@ -0,0 +1,148 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.rsgroup; + +import java.io.IOException; +import java.util.List; +import java.util.Set; + +import com.google.common.collect.Lists; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.ConnectionFactory; +import org.apache.hadoop.hbase.client.TestTableFavoredNodes; +import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; +import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer; +import org.apache.hadoop.hbase.net.Address; +import org.apache.hadoop.hbase.testclassification.ClientTests; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +import com.google.common.collect.Sets; + +import static org.junit.Assert.assertTrue; + +@Category({ClientTests.class, MediumTests.class}) +public class TestRSGroupTableFavoredNodes extends TestTableFavoredNodes { + + private static final Log LOG = LogFactory.getLog(TestRSGroupTableFavoredNodes.class); + + private RSGroupAdmin rsGroupAdminClient; + private String group = "rsgroup"; + + @BeforeClass + public static void setupBeforeClass() throws Exception { + Configuration conf = TEST_UTIL.getConfiguration(); + // Setting FavoredGroupBalancer will enable favored nodes + conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + FavoredRSGroupLoadBalancer.class, RSGroupBasedLoadBalancer.class); + conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, + RSGroupAdminEndpoint.class.getName()); + conf.set(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, "" + SLAVES); + + // This helps test if RS get the appropriate FN updates. + conf.set(BaseLoadBalancer.TABLES_ON_MASTER, "none"); + TEST_UTIL.startMiniCluster(SLAVES); + TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(WAIT_TIMEOUT); + } + + @Before + public void setup() throws IOException { + super.setup(); + Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); + rsGroupAdminClient = new RSGroupAdminClient(conn); + addGroup(rsGroupAdminClient, group, SLAVES - 3); + NamespaceDescriptor nsDescriptor = NamespaceDescriptor.create(NAMESPACE) + .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, group).build(); + admin.createNamespace(nsDescriptor); + LOG.debug("Created namespace: " + NAMESPACE); + } + + @After + public void tearDown() throws IOException { + for (TableName tableName : admin.listTableNames()) { + if (!tableName.isSystemTable()) { + TEST_UTIL.deleteTable(tableName); + } + } + for (NamespaceDescriptor descriptor : admin.listNamespaceDescriptors()) { + String name = descriptor.getName(); + if (!NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) { + admin.deleteNamespace(name); + } + } + + RSGroupInfo rsGroupInfo = rsGroupAdminClient.getRSGroupInfo(group); + rsGroupAdminClient.moveServers(rsGroupInfo.getServers(), RSGroupInfo.DEFAULT_GROUP); + rsGroupAdminClient.removeRSGroup(group); + } + + /* + * Check if all favored nodes belong to the group servers. + */ + protected void checkIfFavoredNodeInformationIsCorrect(TableName tableName) throws Exception { + super.checkIfFavoredNodeInformationIsCorrect(tableName); + + RSGroupInfo rsGroupInfo = rsGroupAdminClient.getRSGroupInfo(group); + List groupServers = Lists.newArrayList(); + for (Address address : rsGroupInfo.getServers()) { + groupServers.add(ServerName.valueOf(address.getHostname(), address.getPort(), + ServerName.NON_STARTCODE)); + } + + for (HRegionInfo regionInfo : admin.getTableRegions(tableName)) { + List favoredNodes = fnm.getFavoredNodes(regionInfo); + assertTrue("Not all favored nodes belong to group for region: " + + regionInfo + " groupServers: " + groupServers + " favored nodes: " + favoredNodes, + groupServers.containsAll(favoredNodes)); + } + } + + private RSGroupInfo addGroup(RSGroupAdmin gAdmin, String group, int servers) throws IOException { + + RSGroupInfo defaultInfo = gAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP); + assertTrue("Default group info can't be null", defaultInfo != null); + assertTrue("default group doesn't have enough servers", + defaultInfo.getServers().size() >= servers); + gAdmin.addRSGroup(group); + + Set
set = Sets.newHashSet(); + for(Address address: defaultInfo.getServers()) { + if(set.size() == servers) { + break; + } + set.add(address); + } + gAdmin.moveServers(set, group); + RSGroupInfo result = gAdmin.getRSGroupInfo(group); + assertTrue("Insufficient servers in group", result.getServers().size() == servers); + LOG.debug("Created group: " + group + " with servers: " + result.getServers()); + return result; + } +} \ No newline at end of file diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestTableFavoredNodesRSGroupsImport.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestTableFavoredNodesRSGroupsImport.java new file mode 100644 index 0000000..ff1189f --- /dev/null +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestTableFavoredNodesRSGroupsImport.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.rsgroup; + +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; +import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.master.balancer.TestFavoredNodeTableImport; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.junit.experimental.categories.Category; + +/* + * This case tests a scenario when a cluster with tables is moved from RSGroupsLoadBalancer + * to FavoredRSGroupsLoadBalancer and the generation of favored nodes after switch. + */ +@Category(MediumTests.class) +public class TestTableFavoredNodesRSGroupsImport extends TestFavoredNodeTableImport { + + protected void setupConfig() { + conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + RSGroupBasedLoadBalancer.class.getName()); + conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, + RSGroupAdminEndpoint.class.getName()); + conf.set(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, "" + SLAVES); + } + + protected void setFavoredBalancer() { + UTIL.getConfiguration().set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + FavoredRSGroupLoadBalancer.class.getName()); + } +} \ No newline at end of file diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTableFavoredNodes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTableFavoredNodes.java index fa12577..c6a1208 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTableFavoredNodes.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTableFavoredNodes.java @@ -72,15 +72,18 @@ public class TestTableFavoredNodes { private static final Log LOG = LogFactory.getLog(TestTableFavoredNodes.class); - private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private final static int WAIT_TIMEOUT = 60000; - private final static int SLAVES = 8; - private FavoredNodesManager fnm; - private RegionStates regionStates; - private Admin admin; + protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + + protected final static int WAIT_TIMEOUT = 60000; + protected final static int SLAVES = 8; + + protected FavoredNodesManager fnm; + protected RegionStates regionStates; + protected Admin admin; private final byte[][] splitKeys = new byte[][] {Bytes.toBytes(1), Bytes.toBytes(9)}; private final int NUM_REGIONS = splitKeys.length + 1; + protected static final String NAMESPACE = "favorednodes"; @Rule public TestName name = new TestName(); @@ -97,6 +100,8 @@ public class TestTableFavoredNodes { conf.set(BaseLoadBalancer.TABLES_ON_MASTER, "none"); TEST_UTIL.startMiniCluster(SLAVES); TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(WAIT_TIMEOUT); + NamespaceDescriptor nsDescriptor = NamespaceDescriptor.create(NAMESPACE).build(); + TEST_UTIL.getHBaseAdmin().createNamespace(nsDescriptor); } @AfterClass @@ -115,12 +120,17 @@ public class TestTableFavoredNodes { TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates(); } + private TableName getTableNameWithNS(String tableName) { + return TableName.valueOf(NAMESPACE + TableName.NAMESPACE_DELIM + tableName); + } + /* * Create a table with FN enabled and check if all its regions have favored nodes set. */ @Test public void testCreateTable() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); + + TableName tableName = getTableNameWithNS("createTable"); TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); @@ -139,7 +149,8 @@ public class TestTableFavoredNodes { */ @Test public void testTruncateTable() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); + + TableName tableName = getTableNameWithNS("truncateTable"); TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); @@ -164,7 +175,8 @@ public class TestTableFavoredNodes { */ @Test public void testSplitTable() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); + + TableName tableName = getTableNameWithNS("splitRegions"); TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); @@ -221,7 +233,8 @@ public class TestTableFavoredNodes { */ @Test public void testMergeTable() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); + + TableName tableName = getTableNameWithNS("mergeRegions"); TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); @@ -277,7 +290,7 @@ public class TestTableFavoredNodes { * 2. Is the number of favored nodes correct for a region? Is the start code -1? * 3. Is the FN information consistent between Master and the respective RegionServer? */ - private void checkIfFavoredNodeInformationIsCorrect(TableName tableName) throws Exception { + protected void checkIfFavoredNodeInformationIsCorrect(TableName tableName) throws Exception { /* * Since we need HRegionServer to check for consistency of FN between Master and RS, @@ -336,7 +349,8 @@ public class TestTableFavoredNodes { */ @Test public void testSystemTables() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); + + TableName tableName = getTableNameWithNS("testSystemTables"); TEST_UTIL.createTable(tableName, Bytes.toBytes("f"), splitKeys); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); @@ -380,4 +394,4 @@ public class TestTableFavoredNodes { } }); } -} \ No newline at end of file +} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java index 2cd021b..8df7900 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.master.balancer; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.List; import java.util.Set; @@ -35,7 +34,9 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; +import org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper; import org.apache.hadoop.hbase.favored.FavoredNodesManager; +import org.apache.hadoop.hbase.master.ServerManager; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Threads; @@ -54,10 +55,10 @@ public class TestFavoredNodeTableImport { private static final Log LOG = LogFactory.getLog(TestFavoredNodeTableImport.class); - private static final int SLAVES = 3; - private static final int REGION_NUM = 20; - private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); - private static final Configuration conf = UTIL.getConfiguration(); + protected static final int SLAVES = 8; + protected static final int REGION_NUM = 20; + protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); + protected static final Configuration conf = UTIL.getConfiguration(); @After public void stopCluster() throws Exception { @@ -65,10 +66,21 @@ public class TestFavoredNodeTableImport { UTIL.shutdownMiniCluster(); } + protected void setupConfig() { + conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + StochasticLoadBalancer.class.getName()); + conf.set(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, "" + SLAVES); + } + + protected void setFavoredBalancer() { + UTIL.getConfiguration().set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, + FavoredStochasticBalancer.class.getName()); + } + @Test public void testTableCreation() throws Exception { - conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, StochasticLoadBalancer.class.getName()); + setupConfig(); LOG.info("Starting up cluster"); UTIL.startMiniCluster(SLAVES); @@ -89,8 +101,7 @@ public class TestFavoredNodeTableImport { Thread.sleep(2000); LOG.info("Starting cluster again with FN Balancer"); - UTIL.getConfiguration().set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, - FavoredStochasticBalancer.class.getName()); + setFavoredBalancer(); UTIL.restartHBaseCluster(SLAVES); while (!UTIL.getMiniHBaseCluster().getMaster().isInitialized()) { Threads.sleep(1); @@ -106,7 +117,8 @@ public class TestFavoredNodeTableImport { for (HRegionInfo rInfo : regionsOfTable) { Set favNodes = Sets.newHashSet(fnm.getFavoredNodes(rInfo)); assertNotNull(favNodes); - assertTrue("3 favored nodes not found.", favNodes.size() == 3); + assertEquals("3 favored nodes not found.", FavoredNodeAssignmentHelper.FAVORED_NODES_NUM, + favNodes.size()); for (ServerName fn : favNodes) { assertEquals("StartCode invalid for:" + fn, ServerName.NON_STARTCODE, fn.getStartcode()); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticLoadBalancer.java index 55ffdab..80c3e5e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticLoadBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticLoadBalancer.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -39,6 +40,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MiniHBaseCluster; +import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper; @@ -70,13 +72,14 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { private static final Log LOG = LogFactory.getLog(TestFavoredStochasticLoadBalancer.class); - private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private static final int SLAVES = 8; - private static final int REGION_NUM = SLAVES * 3; + protected static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + protected static final int SLAVES = 10; + protected static final int REGION_NUM = SLAVES * 3; + protected final String NAMESPACE = "favorednodes"; - private Admin admin; - private HMaster master; - private MiniHBaseCluster cluster; + protected Admin admin; + protected HMaster master; + protected MiniHBaseCluster cluster; @BeforeClass public static void setupBeforeClass() throws Exception { @@ -94,18 +97,36 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { master = TEST_UTIL.getMiniHBaseCluster().getMaster(); admin = TEST_UTIL.getAdmin(); admin.setBalancerRunning(false, true); + NamespaceDescriptor nsDescriptor = NamespaceDescriptor.create(NAMESPACE).build(); + admin.createNamespace(nsDescriptor); } @After public void stopCluster() throws Exception { + for (TableName tableName : admin.listTableNames()) { + if (!tableName.isSystemTable()) { + TEST_UTIL.deleteTable(tableName); + } + } + for (NamespaceDescriptor descriptor : admin.listNamespaceDescriptors()) { + String name = descriptor.getName(); + if (!NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) { + admin.deleteNamespace(name); + } + } + TEST_UTIL.cleanupTestDir(); TEST_UTIL.shutdownMiniCluster(); } + protected TableName getTableNameWithNS(String tableName) { + return TableName.valueOf(NAMESPACE + TableName.NAMESPACE_DELIM + tableName); + } + @Test public void testBasicBalance() throws Exception { - TableName tableName = TableName.valueOf("testBasicBalance"); + TableName tableName = getTableNameWithNS("testBasicBalance"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -139,7 +160,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testRoundRobinAssignment() throws Exception { - TableName tableName = TableName.valueOf("testRoundRobinAssignment"); + TableName tableName = getTableNameWithNS("testRoundRobinAssignment"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -151,7 +172,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { List regions = admin.getTableRegions(tableName); regions.addAll(admin.getTableRegions(TableName.META_TABLE_NAME)); regions.addAll(admin.getTableRegions(TableName.NAMESPACE_TABLE_NAME)); - List servers = Lists.newArrayList(admin.getClusterStatus().getServers()); + List servers = Lists.newArrayList(getServersForNewFN()); Map> map = balancer.roundRobinAssignment(regions, servers); for (List regionInfos : map.values()) { regions.removeAll(regionInfos); @@ -163,14 +184,14 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testBasicRegionPlacementAndReplicaLoad() throws Exception { - String tableName = "testBasicRegionPlacement"; - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + TableName tableName = getTableNameWithNS("testBasicRegionPlacement"); + HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); TEST_UTIL.waitTableAvailable(desc.getTableName()); FavoredNodesManager fnm = master.getFavoredNodesManager(); - List regionsOfTable = admin.getTableRegions(TableName.valueOf(tableName)); + List regionsOfTable = admin.getTableRegions(tableName); for (HRegionInfo rInfo : regionsOfTable) { Set favNodes = Sets.newHashSet(fnm.getFavoredNodes(rInfo)); assertNotNull(favNodes); @@ -178,9 +199,9 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { } Map> replicaLoadMap = - fnm.getReplicaLoad(Lists.newArrayList(admin.getClusterStatus().getServers())); + fnm.getReplicaLoad(Lists.newArrayList(getServersForNewFN())); assertTrue("Not all replica load collected.", - admin.getClusterStatus().getServers().size() == replicaLoadMap.size()); + getServersForNewFN().size() == replicaLoadMap.size()); for (Entry> entry : replicaLoadMap.entrySet()) { assertTrue(entry.getValue().size() == FavoredNodeAssignmentHelper.FAVORED_NODES_NUM); assertTrue(entry.getValue().get(0) >= 0); @@ -188,32 +209,31 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { assertTrue(entry.getValue().get(2) >= 0); } - admin.disableTable(TableName.valueOf(tableName)); - admin.deleteTable(TableName.valueOf(tableName)); + admin.disableTable(tableName); + admin.deleteTable(tableName); replicaLoadMap = - fnm.getReplicaLoad(Lists.newArrayList(admin.getClusterStatus().getServers())); + fnm.getReplicaLoad(Lists.newArrayList(getServersForNewFN())); assertTrue("replica load found " + replicaLoadMap.size() + " instead of 0.", - replicaLoadMap.size() == admin.getClusterStatus().getServers().size()); + replicaLoadMap.size() == getServersForNewFN().size()); } @Test public void testRandomAssignmentWithNoFavNodes() throws Exception { - final String tableName = "testRandomAssignmentWithNoFavNodes"; - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + final TableName tableName = getTableNameWithNS("testRandomAssignmentWithNoFavNodes"); + HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc); TEST_UTIL.waitTableAvailable(desc.getTableName()); - HRegionInfo hri = admin.getTableRegions(TableName.valueOf(tableName)).get(0); + HRegionInfo hri = admin.getTableRegions(tableName).get(0); FavoredNodesManager fnm = master.getFavoredNodesManager(); fnm.deleteFavoredNodesForRegions(Lists.newArrayList(hri)); assertNull("Favored nodes not found null after delete", fnm.getFavoredNodes(hri)); LoadBalancer balancer = master.getLoadBalancer(); - ServerName destination = balancer.randomAssignment(hri, Lists.newArrayList(admin - .getClusterStatus().getServers())); + ServerName destination = balancer.randomAssignment(hri, Lists.newArrayList(getServersForNewFN())); assertNotNull(destination); List favoredNodes = fnm.getFavoredNodes(hri); assertNotNull(favoredNodes); @@ -229,7 +249,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testBalancerWithoutFavoredNodes() throws Exception { - TableName tableName = TableName.valueOf("testBalancerWithoutFavoredNodes"); + TableName tableName = getTableNameWithNS("testBalancerWithoutFavoredNodes"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -267,7 +287,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testMisplacedRegions() throws Exception { - TableName tableName = TableName.valueOf("testMisplacedRegions"); + TableName tableName = getTableNameWithNS("testMisplacedRegions"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -279,7 +299,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { assertNotNull(currentFN); List serversForNewFN = Lists.newArrayList(); - for (ServerName sn : admin.getClusterStatus().getServers()) { + for (ServerName sn : getServersForNewFN()) { serversForNewFN.add(ServerName.valueOf(sn.getHostname(), sn.getPort(), NON_STARTCODE)); } for (ServerName sn : currentFN) { @@ -294,7 +314,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { regionFNMap.put(misplacedRegion, newFavoredNodes); fnm.updateFavoredNodes(regionFNMap); - RegionStates regionStates = master.getAssignmentManager().getRegionStates(); + final RegionStates regionStates = master.getAssignmentManager().getRegionStates(); final ServerName current = regionStates.getRegionServerOfRegion(misplacedRegion); assertNull("Misplaced region is still hosted on favored node, not expected.", FavoredNodesPlan.getFavoredServerPosition(fnm.getFavoredNodes(misplacedRegion), current)); @@ -310,10 +330,14 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { checkFavoredNodeAssignments(tableName, fnm, regionStates); } + protected Collection getServersForNewFN() throws IOException { + return admin.getClusterStatus().getServers(); + } + @Test public void test2FavoredNodesDead() throws Exception { - TableName tableName = TableName.valueOf("testAllFavoredNodesDead"); + TableName tableName = getTableNameWithNS("testAllFavoredNodesDead"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -332,7 +356,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { stopServersAndWaitUntilProcessed(serversToStop); TEST_UTIL.waitUntilNoRegionsInTransition(); - RegionStates regionStates = master.getAssignmentManager().getRegionStates(); + final RegionStates regionStates = master.getAssignmentManager().getRegionStates(); TEST_UTIL.waitFor(10000, new Waiter.Predicate() { @Override public boolean evaluate() throws Exception { @@ -351,7 +375,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testAllFavoredNodesDead() throws Exception { - TableName tableName = TableName.valueOf("testAllFavoredNodesDead"); + TableName tableName = getTableNameWithNS("testAllFavoredNodesDead"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -379,7 +403,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { // Regenerate FN and assign, everything else should be fine List serversForNewFN = Lists.newArrayList(); - for (ServerName sn : admin.getClusterStatus().getServers()) { + for (ServerName sn : getServersForNewFN()) { serversForNewFN.add(ServerName.valueOf(sn.getHostname(), sn.getPort(), NON_STARTCODE)); } @@ -412,7 +436,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Test public void testAllFavoredNodesDeadMasterRestarted() throws Exception { - TableName tableName = TableName.valueOf("testAllFavoredNodesDeadMasterRestarted"); + TableName tableName = getTableNameWithNS("testAllFavoredNodesDeadMasterRestarted"); HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), REGION_NUM); @@ -470,7 +494,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { // Regenerate FN and assign, everything else should be fine List serversForNewFN = Lists.newArrayList(); - for (ServerName sn : admin.getClusterStatus().getServers()) { + for (ServerName sn : getServersForNewFN()) { serversForNewFN.add(ServerName.valueOf(sn.getHostname(), sn.getPort(), NON_STARTCODE)); } @@ -528,6 +552,10 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { } }); + for(JVMClusterUtil.RegionServerThread t : cluster.getLiveRegionServerThreads()) { + LOG.debug("Server: " + t.getRegionServer().getServerName()); + } + assertEquals("Not all servers killed", SLAVES - currentFN.size(), cluster.getLiveRegionServerThreads().size()); }