HBASE-8248 HConnectionManager moved region tracking can cause the region server to redirect to itself; load balancer uses incorrect servername compare

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1465772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
sershe 2013-04-08 20:40:12 +00:00
parent d8a1dfdc69
commit ea423691d9
4 changed files with 7 additions and 9 deletions

View File

@ -551,7 +551,7 @@ public class AssignmentManager extends ZooKeeperListener {
public void process() throws IOException {
ReentrantLock lock = locker.acquireLock(regionInfo.getEncodedName());
try {
unassign(regionInfo, rs, expectedVersion, sn, true, null);
unassign(regionInfo, rs, expectedVersion, null, true, null);
} finally {
lock.unlock();
}

View File

@ -397,13 +397,13 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
private ServerName pickOtherServer(ServerName server, List<ServerName> allServers) {
ServerName s = null;
int count = 0;
while (count < 100 && (s == null || s.equals(server))) {
while (count < 100 && (s == null || ServerName.isSameHostnameAndPort(s, server))) {
count++;
s = allServers.get(RANDOM.nextInt(allServers.size()));
}
// If nothing but the current server was found return null.
return (s == null || s.equals(server)) ? null : s;
return (s == null || ServerName.isSameHostnameAndPort(s, server)) ? null : s;
}
/**

View File

@ -3887,6 +3887,10 @@ public class HRegionServer implements ClientProtocol,
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())) {
LOG.warn("Not adding moved region record: " + encodedName + " to self.");
return;
}
LOG.info("Adding moved region record: " + encodedName + " to "
+ destination.getServerName() + ":" + destination.getPort()
+ " as of " + closeSeqNum);

View File

@ -188,8 +188,6 @@ public class TestAssignmentManager {
@Test(timeout = 5000)
public void testBalanceOnMasterFailoverScenarioWithOpenedNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, REGIONINFO, 0, null, true)).
thenReturn(true);
AssignmentManagerWithExtrasForTesting am =
setUpMockedAssignmentManager(this.server, this.serverManager);
try {
@ -238,8 +236,6 @@ public class TestAssignmentManager {
@Test(timeout = 5000)
public void testBalanceOnMasterFailoverScenarioWithClosedNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, REGIONINFO, 0, null, true)).
thenReturn(true);
AssignmentManagerWithExtrasForTesting am =
setUpMockedAssignmentManager(this.server, this.serverManager);
try {
@ -289,8 +285,6 @@ public class TestAssignmentManager {
@Test(timeout = 5000)
public void testBalanceOnMasterFailoverScenarioWithOfflineNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, REGIONINFO, 0, null, true)).
thenReturn(true);
AssignmentManagerWithExtrasForTesting am =
setUpMockedAssignmentManager(this.server, this.serverManager);
try {