HBASE-8133 avoid assign for disabling table regions(OPENING/PENDING_OPEN) in SSH (Rajeshbabu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1481599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a7ab8b8da
commit
86dc135a34
|
@ -3013,6 +3013,11 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
} catch (KeeperException ke) {
|
||||
server.abort("Unexpected ZK exception deleting node " + hri, ke);
|
||||
}
|
||||
if (zkTable.isDisablingOrDisabledTable(hri.getTableNameAsString())) {
|
||||
it.remove();
|
||||
regionStates.regionOffline(hri);
|
||||
continue;
|
||||
}
|
||||
// Mark the region closed and assign it again by SSH
|
||||
regionStates.updateRegionState(hri, RegionState.State.CLOSED);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer;
|
|||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKAssign;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -387,6 +388,41 @@ public class TestAssignmentManagerOnCluster {
|
|||
TEST_UTIL.deleteTable(Bytes.toBytes(table));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState() throws Exception {
|
||||
final String table = "testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState";
|
||||
AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
|
||||
HRegionInfo hri = null;
|
||||
ServerName serverName = null;
|
||||
try {
|
||||
hri = createTableAndGetOneRegion(table);
|
||||
serverName = am.getRegionStates().getRegionServerOfRegion(hri);
|
||||
ServerName destServerName = null;
|
||||
HRegionServer destServer = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
destServer = TEST_UTIL.getHBaseCluster().getRegionServer(i);
|
||||
if (!destServer.getServerName().equals(serverName)) {
|
||||
destServerName = destServer.getServerName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
am.regionOffline(hri);
|
||||
ZKAssign.createNodeOffline(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri,
|
||||
destServerName);
|
||||
ZKAssign.transitionNodeOpening(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri,
|
||||
destServerName);
|
||||
am.getZKTable().setDisablingTable(table);
|
||||
List<HRegionInfo> toAssignRegions = am.processServerShutdown(destServerName);
|
||||
assertTrue("Regions to be assigned should be empty.", toAssignRegions.isEmpty());
|
||||
assertTrue("Regions to be assigned should be empty.", am.getRegionStates()
|
||||
.getRegionState(hri).isOffline());
|
||||
} finally {
|
||||
am.regionOnline(hri, serverName);
|
||||
am.getZKTable().setDisabledTable(table);
|
||||
TEST_UTIL.deleteTable(Bytes.toBytes(table));
|
||||
}
|
||||
}
|
||||
|
||||
static class MockLoadBalancer extends StochasticLoadBalancer {
|
||||
// For this region, if specified, always assign to nowhere
|
||||
|
|
Loading…
Reference in New Issue