本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKAssign.transitionNodeOpening方法的典型用法代码示例。如果您正苦于以下问题:Java ZKAssign.transitionNodeOpening方法的具体用法?Java ZKAssign.transitionNodeOpening怎么用?Java ZKAssign.transitionNodeOpening使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.zookeeper.ZKAssign
的用法示例。
在下文中一共展示了ZKAssign.transitionNodeOpening方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OpenRegion
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
private void OpenRegion(Server server, RegionServerServices rss,
HTableDescriptor htd, HRegionInfo hri)
throws IOException, NodeExistsException, KeeperException {
// Create it OFFLINE node, which is what Master set before sending OPEN RPC
ZKAssign.createNodeOffline(server.getZooKeeper(), hri, server.getServerName());
int version = ZKAssign.transitionNodeOpening(server.getZooKeeper(), hri, server.getServerName());
OpenRegionHandler openHandler = new OpenRegionHandler(server, rss, hri, htd, version);
openHandler.process();
RegionTransitionData data = ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName());
// delete the node, which is what Master do after the region is opened
ZKAssign.deleteNode(server.getZooKeeper(), hri.getEncodedName(),
EventType.RS_ZK_REGION_OPENED);
}
示例2: testFailedOpenRegion
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testFailedOpenRegion() throws Exception {
Server server = new MockServer(HTU);
RegionServerServices rsServices = new MockRegionServerServices();
// Create it OFFLINE, which is what it expects
ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());
// Create the handler
OpenRegionHandler handler =
new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
@Override
HRegion openRegion() {
// Fake failure of opening a region due to an IOE, which is caught
return null;
}
};
handler.process();
// Handler should have transitioned it to FAILED_OPEN
RegionTransitionData data =
ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
}
示例3: testFailedUpdateMeta
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testFailedUpdateMeta() throws Exception {
Server server = new MockServer(HTU);
RegionServerServices rsServices = new MockRegionServerServices();
// Create it OFFLINE, which is what it expects
ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());
// Create the handler
OpenRegionHandler handler =
new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
@Override
boolean updateMeta(final HRegion r) {
// Fake failure of updating META
return false;
}
};
handler.process();
// Handler should have transitioned it to FAILED_OPEN
RegionTransitionData data =
ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
}
示例4: createAndForceNodeToOpenedState
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
* Creates a znode with OPENED state.
* @param TEST_UTIL
* @param region
* @param serverName
* @return
* @throws IOException
* @throws org.apache.hadoop.hbase.ZooKeeperConnectionException
* @throws KeeperException
* @throws NodeExistsException
*/
public static ZooKeeperWatcher createAndForceNodeToOpenedState(
HBaseTestingUtility TEST_UTIL, HRegion region,
ServerName serverName) throws ZooKeeperConnectionException,
IOException, KeeperException, NodeExistsException {
ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
ZKAssign.createNodeOffline(zkw, region.getRegionInfo(), serverName);
int version = ZKAssign.transitionNodeOpening(zkw, region
.getRegionInfo(), serverName);
ZKAssign.transitionNodeOpened(zkw, region.getRegionInfo(), serverName,
version);
return zkw;
}
示例5: createAndForceNodeToOpenedState
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
* Creates a znode with OPENED state.
* @param TEST_UTIL
* @param region
* @param serverName
* @return
* @throws IOException
* @throws ZooKeeperConnectionException
* @throws KeeperException
* @throws NodeExistsException
*/
public static ZooKeeperWatcher createAndForceNodeToOpenedState(
HBaseTestingUtility TEST_UTIL, HRegion region,
ServerName serverName) throws ZooKeeperConnectionException,
IOException, KeeperException, NodeExistsException {
ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
ZKAssign.createNodeOffline(zkw, region.getRegionInfo(), serverName);
int version = ZKAssign.transitionNodeOpening(zkw, region
.getRegionInfo(), serverName);
ZKAssign.transitionNodeOpened(zkw, region.getRegionInfo(), serverName,
version);
return zkw;
}
示例6: testTransitionToFailedOpenEvenIfCleanupFails
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testTransitionToFailedOpenEvenIfCleanupFails() throws Exception {
MiniHBaseCluster cluster = HTU.getHBaseCluster();
HRegionServer server =
cluster.getLiveRegionServerThreads().get(0).getRegionServer();
// Create it OFFLINE, which is what it expects
ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());
// Create the handler
OpenRegionHandler handler = new OpenRegionHandler(server, server, TEST_HRI, TEST_HTD) {
@Override
boolean updateMeta(HRegion r) {
return false;
};
@Override
void cleanupFailedOpen(HRegion region) throws IOException {
throw new IOException("FileSystem got closed.");
}
};
((TestOpenRegionHandlerRegionServer)server).addRegionsInTransition(TEST_HRI, "OPEN");
try {
handler.process();
} catch (Exception e) {
// Ignore the IOException that we have thrown from cleanupFailedOpen
}
RegionTransitionData data =
ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
}
示例7: testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test (timeout=60000)
public void testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState() throws Exception {
final TableName table =
TableName.valueOf
("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);
ZooKeeperWatcher zkw = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper();
am.getRegionStates().updateRegionState(hri, State.PENDING_OPEN, destServerName);
if (ConfigUtil.useZKForAssignment(conf)) {
ZKAssign.createNodeOffline(zkw, hri, destServerName);
ZKAssign.transitionNodeOpening(zkw, hri, destServerName);
// Wait till the event is processed and the region is in transition
long timeoutTime = System.currentTimeMillis() + 20000;
while (!am.getRegionStates().isRegionInTransition(hri)) {
assertTrue("Failed to process ZK opening event in time",
System.currentTimeMillis() < timeoutTime);
Thread.sleep(100);
}
}
am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLING);
List<HRegionInfo> toAssignRegions = am.cleanOutCrashedServerReferences(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 {
if (hri != null && serverName != null) {
am.regionOnline(hri, serverName);
}
am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLED);
TEST_UTIL.deleteTable(table);
}
}
示例8: testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test (timeout=60000)
public void testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState() throws Exception {
final TableName table =
TableName.valueOf
("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);
ZooKeeperWatcher zkw = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper();
am.getRegionStates().updateRegionState(hri, State.PENDING_OPEN, destServerName);
if (ConfigUtil.useZKForAssignment(conf)) {
ZKAssign.createNodeOffline(zkw, hri, destServerName);
ZKAssign.transitionNodeOpening(zkw, hri, destServerName);
// Wait till the event is processed and the region is in transition
long timeoutTime = System.currentTimeMillis() + 20000;
while (!am.getRegionStates().isRegionInTransition(hri)) {
assertTrue("Failed to process ZK opening event in time",
System.currentTimeMillis() < timeoutTime);
Thread.sleep(100);
}
}
am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLING);
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 {
if (hri != null && serverName != null) {
am.regionOnline(hri, serverName);
}
am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLED);
TEST_UTIL.deleteTable(table);
}
}
示例9: testAssignmentEventIgnoredIfNotExpected
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
* Test assignment related ZK events are ignored by AM if the region is not known
* by AM to be in transition. During normal operation, all assignments are started
* by AM (not considering split/merge), if an event is received but the region
* is not in transition, the event must be a very late one. So it can be ignored.
* During master failover, since AM watches assignment znodes after failover cleanup
* is completed, when an event comes in, AM should already have the region in transition
* if ZK is used during the assignment action (only hbck doesn't use ZK for region
* assignment). So during master failover, we can ignored such events too.
*/
@Test (timeout=180000)
public void testAssignmentEventIgnoredIfNotExpected() throws KeeperException, IOException,
CoordinatedStateException {
// Region to use in test.
final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(
server.getConfiguration());
final AtomicBoolean zkEventProcessed = new AtomicBoolean(false);
// Create an AM.
AssignmentManager am = new AssignmentManager(this.server,
this.serverManager, balancer, null, null, master.getTableLockManager()) {
@Override
void handleRegion(final RegionTransition rt, OpenRegionCoordination coordination,
OpenRegionCoordination.OpenRegionDetails ord) {
super.handleRegion(rt, coordination, ord);
if (rt != null && Bytes.equals(hri.getRegionName(),
rt.getRegionName()) && rt.getEventType() == EventType.RS_ZK_REGION_OPENING) {
zkEventProcessed.set(true);
}
}
};
try {
// First make sure the region is not in transition
am.getRegionStates().regionOffline(hri);
zkEventProcessed.set(false); // Reset it before faking zk transition
this.watcher.registerListenerFirst(am);
assertFalse("The region should not be in transition",
am.getRegionStates().isRegionInTransition(hri));
ZKAssign.createNodeOffline(this.watcher, hri, SERVERNAME_A);
// Trigger a transition event
ZKAssign.transitionNodeOpening(this.watcher, hri, SERVERNAME_A);
long startTime = EnvironmentEdgeManager.currentTime();
while (!zkEventProcessed.get()) {
assertTrue("Timed out in waiting for ZK event to be processed",
EnvironmentEdgeManager.currentTime() - startTime < 30000);
Threads.sleepWithoutInterrupt(100);
}
assertFalse(am.getRegionStates().isRegionInTransition(hri));
} finally {
am.shutdown();
}
}
示例10: testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test (timeout=60000)
public void testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState() throws Exception {
final TableName table =
TableName.valueOf
("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);
ZooKeeperWatcher zkw = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper();
am.getRegionStates().updateRegionState(hri, State.OFFLINE);
ZKAssign.createNodeOffline(zkw, hri, destServerName);
ZKAssign.transitionNodeOpening(zkw, hri, destServerName);
// Wait till the event is processed and the region is in transition
long timeoutTime = System.currentTimeMillis() + 20000;
while (!am.getRegionStates().isRegionInTransition(hri)) {
assertTrue("Failed to process ZK opening event in time",
System.currentTimeMillis() < timeoutTime);
Thread.sleep(100);
}
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 {
if (hri != null && serverName != null) {
am.regionOnline(hri, serverName);
}
am.getZKTable().setDisabledTable(table);
TEST_UTIL.deleteTable(table);
}
}
示例11: testAssignmentEventIgnoredIfNotExpected
import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
* Test assignment related ZK events are ignored by AM if the region is not known
* by AM to be in transition. During normal operation, all assignments are started
* by AM (not considering split/merge), if an event is received but the region
* is not in transition, the event must be a very late one. So it can be ignored.
* During master failover, since AM watches assignment znodes after failover cleanup
* is completed, when an event comes in, AM should already have the region in transition
* if ZK is used during the assignment action (only hbck doesn't use ZK for region
* assignment). So during master failover, we can ignored such events too.
*/
@Test
public void testAssignmentEventIgnoredIfNotExpected() throws KeeperException, IOException {
// Region to use in test.
final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
// Need a mocked catalog tracker.
CatalogTracker ct = Mockito.mock(CatalogTracker.class);
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(
server.getConfiguration());
final AtomicBoolean zkEventProcessed = new AtomicBoolean(false);
// Create an AM.
AssignmentManager am = new AssignmentManager(this.server,
this.serverManager, ct, balancer, null, null, master.getTableLockManager()) {
@Override
void handleRegion(final RegionTransition rt, int expectedVersion) {
super.handleRegion(rt, expectedVersion);
if (rt != null && Bytes.equals(hri.getRegionName(),
rt.getRegionName()) && rt.getEventType() == EventType.RS_ZK_REGION_OPENING) {
zkEventProcessed.set(true);
}
}
};
try {
// First make sure the region is not in transition
am.getRegionStates().regionOffline(hri);
zkEventProcessed.set(false); // Reset it before faking zk transition
this.watcher.registerListenerFirst(am);
assertFalse("The region should not be in transition",
am.getRegionStates().isRegionInTransition(hri));
ZKAssign.createNodeOffline(this.watcher, hri, SERVERNAME_A);
// Trigger a transition event
ZKAssign.transitionNodeOpening(this.watcher, hri, SERVERNAME_A);
long startTime = EnvironmentEdgeManager.currentTimeMillis();
while (!zkEventProcessed.get()) {
assertTrue("Timed out in waiting for ZK event to be processed",
EnvironmentEdgeManager.currentTimeMillis() - startTime < 30000);
Threads.sleepWithoutInterrupt(100);
}
assertFalse(am.getRegionStates().isRegionInTransition(hri));
} finally {
am.shutdown();
}
}