From fad968d99f4693278edcaefff92738e67ad8e8a0 Mon Sep 17 00:00:00 2001 From: Umesh Agashe Date: Tue, 22 Aug 2017 16:23:21 -0700 Subject: [PATCH] HBASE-18575 [AMv2] Fixed and enabled TestRestartCluster#testRetainAssignmentOnRestart on master * Fixed ServerCrashProcedure to set forceNewPlan to false for instances AssignProcedure. This enables balancer to find most suitable target server * Fixed and enabled TestRestartCluster#testRetainAssignmentOnRestart on master * Renamed method ServerName@isSameHostnameAndPort() to isSameAddress() Signed-off-by: Michael Stack --- .../java/org/apache/hadoop/hbase/ServerName.java | 4 ++-- .../hadoop/hbase/DistributedHBaseCluster.java | 4 ++-- .../balancer/TestRSGroupBasedLoadBalancer.java | 2 +- .../hbase/favored/FavoredNodeAssignmentHelper.java | 3 +-- .../hbase/favored/FavoredNodeLoadBalancer.java | 2 +- .../hadoop/hbase/favored/FavoredNodesPlan.java | 2 +- .../hadoop/hbase/master/ActiveMasterManager.java | 2 +- .../org/apache/hadoop/hbase/master/DeadServer.java | 4 ++-- .../apache/hadoop/hbase/master/ServerManager.java | 3 +-- .../master/balancer/FavoredStochasticBalancer.java | 4 ++-- .../master/procedure/ServerCrashProcedure.java | 4 +++- .../hadoop/hbase/regionserver/HRegionServer.java | 3 +-- .../org/apache/hadoop/hbase/TestServerName.java | 2 +- .../favored/TestStartcodeAgnosticServerName.java | 4 ++-- .../hadoop/hbase/master/TestRegionPlacement.java | 8 ++++---- .../hadoop/hbase/master/TestRegionPlacement2.java | 14 +++++++------- .../hadoop/hbase/master/TestRestartCluster.java | 7 ++++--- .../TestFavoredStochasticBalancerPickers.java | 4 ++-- .../TestFavoredStochasticLoadBalancer.java | 7 +++---- 19 files changed, 41 insertions(+), 42 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java index 88abc3f5843..5f837820e5e 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java @@ -347,8 +347,8 @@ public class ServerName implements Comparable, Serializable { * @param right * @return True if other has same hostname and port. */ - public static boolean isSameHostnameAndPort(final ServerName left, - final ServerName right) { + public static boolean isSameAddress(final ServerName left, + final ServerName right) { // TODO: Make this left.getAddress().equals(right.getAddress()) if (left == null) return false; if (right == null) return false; diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/DistributedHBaseCluster.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/DistributedHBaseCluster.java index 431ba421e57..55c6e28b6a4 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/DistributedHBaseCluster.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/DistributedHBaseCluster.java @@ -320,7 +320,7 @@ public class DistributedHBaseCluster extends HBaseCluster { List deferred = new ArrayList<>(); //check whether current master has changed final ServerName initMaster = initial.getMaster(); - if (!ServerName.isSameHostnameAndPort(initMaster, current.getMaster())) { + if (!ServerName.isSameAddress(initMaster, current.getMaster())) { LOG.info("Restoring cluster - Initial active master : " + initMaster.getHostAndPort() + " has changed to : " @@ -340,7 +340,7 @@ public class DistributedHBaseCluster extends HBaseCluster { // 2. Stop current master // 3. Start backup masters for (ServerName currentBackup : current.getBackupMasters()) { - if (!ServerName.isSameHostnameAndPort(currentBackup, initMaster)) { + if (!ServerName.isSameAddress(currentBackup, initMaster)) { LOG.info("Restoring cluster - stopping backup master: " + currentBackup); stopMaster(currentBackup); } diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java index fa170febf2f..488afdf0e81 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java @@ -420,7 +420,7 @@ public class TestRSGroupBasedLoadBalancer { ServerAndLoad newSAL = null; ServerAndLoad oldSAL = null; for (ServerAndLoad sal : previousLoad.get(groupName)) { - if (ServerName.isSameHostnameAndPort(sn, sal.getServerName())) { + if (ServerName.isSameAddress(sn, sal.getServerName())) { oldSAL = sal; newSAL = new ServerAndLoad(sn, sal.getLoad() + diff); break; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java index f20c876f087..c0010106103 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeAssignmentHelper.java @@ -31,7 +31,6 @@ import java.util.Map.Entry; import java.util.Random; import java.util.Set; -import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -105,7 +104,7 @@ public class FavoredNodeAssignmentHelper { this.rackToRegionServerMap.put(rackName, serverList); } for (ServerName serverName : serverList) { - if (ServerName.isSameHostnameAndPort(sn, serverName)) { + if (ServerName.isSameAddress(sn, serverName)) { // The server is already present, ignore. break; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeLoadBalancer.java index 8b57ce6f5ec..680a902c6f8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodeLoadBalancer.java @@ -278,7 +278,7 @@ public class FavoredNodeLoadBalancer extends BaseLoadBalancer implements Favored // server with the legit startcode private ServerName availableServersContains(List servers, ServerName favoredNode) { for (ServerName server : servers) { - if (ServerName.isSameHostnameAndPort(favoredNode, server)) { + if (ServerName.isSameAddress(favoredNode, server)) { return server; } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesPlan.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesPlan.java index ff6d9e16f2b..0f91cc8ce17 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesPlan.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/favored/FavoredNodesPlan.java @@ -92,7 +92,7 @@ public class FavoredNodesPlan { return null; } for (Position p : Position.values()) { - if (ServerName.isSameHostnameAndPort(favoredNodes.get(p.ordinal()),server)) { + if (ServerName.isSameAddress(favoredNodes.get(p.ordinal()),server)) { return p; } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java index 0466e98bba3..d0634521a88 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java @@ -200,7 +200,7 @@ public class ActiveMasterManager extends ZooKeeperListener { // Hopefully next time around we won't fail the parse. Dangerous. continue; } - if (ServerName.isSameHostnameAndPort(currentMaster, this.sn)) { + if (ServerName.isSameAddress(currentMaster, this.sn)) { msg = ("Current master has this master's address, " + currentMaster + "; master was restarted? Deleting node."); // Hurry along the expiration of the znode. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java index c3944241d62..fc862540580 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java @@ -75,7 +75,7 @@ public class DeadServer { Iterator it = deadServers.keySet().iterator(); while (it.hasNext()) { ServerName sn = it.next(); - if (ServerName.isSameHostnameAndPort(sn, newServerName)) { + if (ServerName.isSameAddress(sn, newServerName)) { it.remove(); return true; } @@ -149,7 +149,7 @@ public class DeadServer { Iterator it = deadServers.keySet().iterator(); while (it.hasNext()) { ServerName sn = it.next(); - if (ServerName.isSameHostnameAndPort(sn, newServerName)) { + if (ServerName.isSameAddress(sn, newServerName)) { it.remove(); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index 86177b822a6..23160c140e6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -55,7 +55,6 @@ import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.client.RetriesExhaustedException; import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.ipc.RpcControllerFactory; -import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer; import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.shaded.com.google.protobuf.UnsafeByteOperations; @@ -414,7 +413,7 @@ public class ServerManager { ServerName r = onlineServers.lowerKey(end); if (r != null) { - if (ServerName.isSameHostnameAndPort(r, serverName)) { + if (ServerName.isSameAddress(r, serverName)) { return r; } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java index 86ccd4776bd..8dc2a85d58e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java @@ -252,7 +252,7 @@ public class FavoredStochasticBalancer extends StochasticLoadBalancer implements */ private ServerName getServerFromFavoredNode(List servers, ServerName fn) { for (ServerName server : servers) { - if (ServerName.isSameHostnameAndPort(fn, server)) { + if (ServerName.isSameAddress(fn, server)) { return server; } } @@ -463,7 +463,7 @@ public class FavoredStochasticBalancer extends StochasticLoadBalancer implements List result = Lists.newArrayList(); for (ServerName sn : serversWithoutStartCodes) { for (ServerName online : onlineServers) { - if (ServerName.isSameHostnameAndPort(sn, online)) { + if (ServerName.isSameAddress(sn, online)) { result.add(online); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ServerCrashProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ServerCrashProcedure.java index 4370a8c9c05..c7af53fd0e6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ServerCrashProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ServerCrashProcedure.java @@ -164,8 +164,10 @@ implements ServerProcedureInterface { } handleRIT(env, regionsOnCrashedServer); AssignmentManager am = env.getAssignmentManager(); + // forceNewPlan is set to false. Balancer is expected to find most suitable target + // server if retention is not possible. addChildProcedure(am. - createAssignProcedures(am.getOrderedRegions(regionsOnCrashedServer), true)); + createAssignProcedures(am.getOrderedRegions(regionsOnCrashedServer), false)); } setNextState(ServerCrashState.SERVER_CRASH_FINISH); break; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 0c1814f67b2..28b7a43eb69 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -118,7 +118,6 @@ import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.LoadBalancer; import org.apache.hadoop.hbase.master.RegionState.State; -import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer; import org.apache.hadoop.hbase.mob.MobCacheConfig; import org.apache.hadoop.hbase.procedure.RegionServerProcedureManagerHost; import org.apache.hadoop.hbase.quotas.FileSystemUtilizationChore; @@ -3406,7 +3405,7 @@ public class HRegionServer extends HasThread implements private static final int TIMEOUT_REGION_MOVED = (2 * 60 * 1000); protected void addToMovedRegions(String encodedName, ServerName destination, long closeSeqNum) { - if (ServerName.isSameHostnameAndPort(destination, this.getServerName())) { + if (ServerName.isSameAddress(destination, this.getServerName())) { LOG.warn("Not adding moved region record: " + encodedName + " to self."); return; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerName.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerName.java index d1b2145224c..c1b5dac0511 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerName.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerName.java @@ -108,7 +108,7 @@ public class TestServerName { assertEquals(lower.hashCode(), upper.hashCode()); assertTrue(lower.equals(upper)); assertTrue(upper.equals(lower)); - assertTrue(ServerName.isSameHostnameAndPort(lower, upper)); + assertTrue(ServerName.isSameAddress(lower, upper)); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/favored/TestStartcodeAgnosticServerName.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/favored/TestStartcodeAgnosticServerName.java index 6e9f19c0429..50a02a1accb 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/favored/TestStartcodeAgnosticServerName.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/favored/TestStartcodeAgnosticServerName.java @@ -35,14 +35,14 @@ public class TestStartcodeAgnosticServerName { StartcodeAgnosticServerName snStartCode = new StartcodeAgnosticServerName("www.example.org", 1234, 5678); - assertTrue(ServerName.isSameHostnameAndPort(sn, snStartCode)); + assertTrue(ServerName.isSameAddress(sn, snStartCode)); assertTrue(snStartCode.equals(sn)); assertTrue(sn.equals(snStartCode)); assertEquals(0, snStartCode.compareTo(sn)); StartcodeAgnosticServerName snStartCodeFNPort = new StartcodeAgnosticServerName("www.example.org", 1234, ServerName.NON_STARTCODE); - assertTrue(ServerName.isSameHostnameAndPort(snStartCodeFNPort, snStartCode)); + assertTrue(ServerName.isSameAddress(snStartCodeFNPort, snStartCode)); assertTrue(snStartCode.equals(snStartCodeFNPort)); assertTrue(snStartCodeFNPort.equals(snStartCode)); assertEquals(0, snStartCode.compareTo(snStartCodeFNPort)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java index b3859ff6370..ccc5b17d18c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java @@ -201,14 +201,14 @@ public class TestRegionPlacement { break; } } - } while (ServerName.isSameHostnameAndPort(metaServer, serverToKill) || isNamespaceServer || + } while (ServerName.isSameAddress(metaServer, serverToKill) || isNamespaceServer || TEST_UTIL.getHBaseCluster().getRegionServer(killIndex).getNumberOfOnlineRegions() == 0); LOG.debug("Stopping RS " + serverToKill); Map> regionsToVerify = new HashMap<>(); // mark the regions to track for (Map.Entry entry : favoredNodesAssignmentPlan.entrySet()) { ServerName s = entry.getValue()[0]; - if (ServerName.isSameHostnameAndPort(s, serverToKill)) { + if (ServerName.isSameAddress(s, serverToKill)) { regionsToVerify.put(entry.getKey(), new Pair<>(entry.getValue()[1], entry.getValue()[2])); LOG.debug("Adding " + entry.getKey() + " with sedcondary/tertiary " + entry.getValue()[1] + " " + entry.getValue()[2]); @@ -232,8 +232,8 @@ public class TestRegionPlacement { LOG.debug("New destination for region " + entry.getKey().getEncodedName() + " " + newDestination +". Secondary/Tertiary are " + secondaryTertiaryServers.getFirst() + "/" + secondaryTertiaryServers.getSecond()); - if (!(ServerName.isSameHostnameAndPort(newDestination, secondaryTertiaryServers.getFirst())|| - ServerName.isSameHostnameAndPort(newDestination, secondaryTertiaryServers.getSecond()))){ + if (!(ServerName.isSameAddress(newDestination, secondaryTertiaryServers.getFirst())|| + ServerName.isSameAddress(newDestination, secondaryTertiaryServers.getSecond()))){ fail("Region " + entry.getKey() + " not present on any of the expected servers"); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement2.java index f10c3687e9d..86aca40d53a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement2.java @@ -94,7 +94,7 @@ public class TestRegionPlacement2 { ((FavoredNodeLoadBalancer)balancer).getFavoredNodes(region); assertTrue(favoredNodesBefore.size() == FavoredNodeAssignmentHelper.FAVORED_NODES_NUM); // the primary RS should be the one that the balancer's assignment returns - assertTrue(ServerName.isSameHostnameAndPort(serverBefore.iterator().next(), + assertTrue(ServerName.isSameAddress(serverBefore.iterator().next(), favoredNodesBefore.get(PRIMARY))); // now remove the primary from the list of available servers List removedServers = removeMatchingServers(serverBefore, servers); @@ -110,9 +110,9 @@ public class TestRegionPlacement2 { Set serverAfter = assignmentMap.keySet(); // We expect the new RegionServer assignee to be one of the favored nodes // chosen earlier. - assertTrue(ServerName.isSameHostnameAndPort(serverAfter.iterator().next(), + assertTrue(ServerName.isSameAddress(serverAfter.iterator().next(), favoredNodesBefore.get(SECONDARY)) || - ServerName.isSameHostnameAndPort(serverAfter.iterator().next(), + ServerName.isSameAddress(serverAfter.iterator().next(), favoredNodesBefore.get(TERTIARY))); // put back the primary in the list of available servers @@ -153,7 +153,7 @@ public class TestRegionPlacement2 { ((FavoredNodeLoadBalancer)balancer).getFavoredNodes(region); assertTrue(favoredNodesBefore.size() == FavoredNodeAssignmentHelper.FAVORED_NODES_NUM); // the primary RS should be the one that the balancer's assignment returns - assertTrue(ServerName.isSameHostnameAndPort(serverBefore,favoredNodesBefore.get(PRIMARY))); + assertTrue(ServerName.isSameAddress(serverBefore,favoredNodesBefore.get(PRIMARY))); // now remove the primary from the list of servers removeMatchingServers(serverBefore, servers); // call randomAssignment with the modified servers list @@ -167,8 +167,8 @@ public class TestRegionPlacement2 { assertTrue(favoredNodesAfter.containsAll(favoredNodesBefore)); // We expect the new RegionServer assignee to be one of the favored nodes // chosen earlier. - assertTrue(ServerName.isSameHostnameAndPort(serverAfter, favoredNodesBefore.get(SECONDARY)) || - ServerName.isSameHostnameAndPort(serverAfter, favoredNodesBefore.get(TERTIARY))); + assertTrue(ServerName.isSameAddress(serverAfter, favoredNodesBefore.get(SECONDARY)) || + ServerName.isSameAddress(serverAfter, favoredNodesBefore.get(TERTIARY))); // Make all the favored nodes unavailable for assignment removeMatchingServers(favoredNodesAfter, servers); // call randomAssignment with the modified servers list @@ -194,7 +194,7 @@ public class TestRegionPlacement2 { List servers) { List serversToRemove = new ArrayList<>(); for (ServerName s : servers) { - if (ServerName.isSameHostnameAndPort(s, serverWithoutStartCode)) { + if (ServerName.isSameAddress(s, serverWithoutStartCode)) { serversToRemove.add(s); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java index 351fca41d0f..4eb4e530462 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java @@ -36,6 +36,8 @@ import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableExistsException; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.master.assignment.RegionStates; +import org.apache.hadoop.hbase.net.Address; +import org.apache.hadoop.hbase.shaded.com.google.common.net.HostAndPort; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.util.Bytes; @@ -109,7 +111,6 @@ public class TestRestartCluster { * This tests retaining assignments on a cluster restart */ @Test (timeout=300000) - @Ignore // Does not work in new AMv2 currently. public void testRetainAssignmentOnRestart() throws Exception { UTIL.startMiniCluster(2); while (!UTIL.getMiniHBaseCluster().getMaster().isInitialized()) { @@ -163,7 +164,7 @@ public class TestRestartCluster { LOG.info("\n\nStarting cluster the second time with the same ports"); try { cluster.getConf().setInt( - ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 4); + ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 3); master = cluster.startMaster().getMaster(); for (int i = 0; i < 3; i++) { cluster.getConf().setInt(HConstants.REGIONSERVER_PORT, rsPorts[i]); @@ -178,7 +179,7 @@ public class TestRestartCluster { // Make sure live regionservers are on the same host/port List localServers = master.getServerManager().getOnlineServersList(); - assertEquals(4, localServers.size()); + assertEquals(3, localServers.size()); for (int i = 0; i < 3; i++) { boolean found = false; for (ServerName serverName: localServers) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticBalancerPickers.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticBalancerPickers.java index d86d62dff79..fef7d30e2a3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticBalancerPickers.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredStochasticBalancerPickers.java @@ -133,7 +133,7 @@ public class TestFavoredStochasticBalancerPickers extends BalancerTestBase { Map> serverAssignments = Maps.newHashMap(); ClusterStatus status = admin.getClusterStatus(); for (ServerName sn : status.getServers()) { - if (!ServerName.isSameHostnameAndPort(sn, masterServerName)) { + if (!ServerName.isSameAddress(sn, masterServerName)) { serverAssignments.put(sn, admin.getOnlineRegions(sn)); } } @@ -195,7 +195,7 @@ public class TestFavoredStochasticBalancerPickers extends BalancerTestBase { private boolean doesMatchExcludeNodes(ArrayList excludeNodes, ServerName sn) { for (ServerName excludeSN : excludeNodes) { - if (ServerName.isSameHostnameAndPort(sn, excludeSN)) { + if (ServerName.isSameAddress(sn, excludeSN)) { return true; } } 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 03285c679aa..ddba7ce46dc 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 @@ -44,7 +44,6 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper; import org.apache.hadoop.hbase.favored.FavoredNodesPlan; import org.apache.hadoop.hbase.master.HMaster; -import org.apache.hadoop.hbase.master.RegionState; import org.apache.hadoop.hbase.master.assignment.RegionStates; import org.apache.hadoop.hbase.master.assignment.RegionStates.RegionStateNode; import org.apache.hadoop.hbase.master.ServerManager; @@ -220,7 +219,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { assertNotNull(favoredNodes); boolean containsFN = false; for (ServerName sn : favoredNodes) { - if (ServerName.isSameHostnameAndPort(destination, sn)) { + if (ServerName.isSameAddress(destination, sn)) { containsFN = true; } } @@ -305,7 +304,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { @Override public boolean evaluate() throws Exception { ServerName host = regionStates.getRegionServerOfRegion(misplacedRegion); - return !ServerName.isSameHostnameAndPort(host, current); + return !ServerName.isSameAddress(host, current); } }); checkFavoredNodeAssignments(tableName, fnm, regionStates); @@ -516,7 +515,7 @@ public class TestFavoredStochasticLoadBalancer extends BalancerTestBase { private void stopServersAndWaitUntilProcessed(List currentFN) throws Exception { for (ServerName sn : currentFN) { for (JVMClusterUtil.RegionServerThread rst : cluster.getLiveRegionServerThreads()) { - if (ServerName.isSameHostnameAndPort(sn, rst.getRegionServer().getServerName())) { + if (ServerName.isSameAddress(sn, rst.getRegionServer().getServerName())) { LOG.info("Shutting down server: " + sn); cluster.stopRegionServer(rst.getRegionServer().getServerName()); cluster.waitForRegionServerToStop(rst.getRegionServer().getServerName(), 60000);