本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.isTableAvailable方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.isTableAvailable方法的具體用法?Java HBaseAdmin.isTableAvailable怎麽用?Java HBaseAdmin.isTableAvailable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.isTableAvailable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sniff
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Canary entry point for specified table.
* @throws Exception
*/
private static void sniff(final HBaseAdmin admin, final Sink sink, String tableName)
throws Exception {
if (admin.isTableAvailable(tableName)) {
sniff(admin, sink, admin.getTableDescriptor(tableName.getBytes()));
} else {
LOG.warn(String.format("Table %s is not available", tableName));
}
}
示例2: waitTableAvailable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public void waitTableAvailable(HBaseAdmin admin, byte[] table, long timeoutMillis)
throws InterruptedException, IOException {
long startWait = System.currentTimeMillis();
while (!admin.isTableAvailable(table)) {
assertTrue("Timed out waiting for table to become available " +
Bytes.toStringBinary(table),
System.currentTimeMillis() - startWait < timeoutMillis);
Thread.sleep(200);
}
}
示例3: testSplitBeforeSettingSplittingInZK
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void testSplitBeforeSettingSplittingInZK(boolean nodeCreated) throws Exception {
final byte[] tableName = Bytes.toBytes("testSplitBeforeSettingSplittingInZK");
HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
// Create table then get the single region for our new table.
HTableDescriptor htd = new HTableDescriptor(tableName);
htd.addFamily(new HColumnDescriptor("cf"));
admin.createTable(htd);
List<HRegion> regions = null;
for (int i=0; i<100; i++) {
regions = cluster.getRegions(tableName);
if (regions.size() > 0) break;
Thread.sleep(100);
}
int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName());
HRegionServer regionServer = cluster.getRegionServer(regionServerIndex);
SplitTransaction st = null;
if (nodeCreated) {
st = new MockedSplitTransaction(regions.get(0), null) {
@Override
int transitionNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo parent,
ServerName serverName, int version) throws KeeperException, IOException {
throw new TransitionToSplittingFailedException();
}
};
} else {
st = new MockedSplitTransaction(regions.get(0), null) {
@Override
void createNodeSplitting(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
throws KeeperException, IOException {
throw new SplittingNodeCreationFailedException ();
}
};
}
String node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
.getRegionInfo().getEncodedName());
// make sure the client is uptodate
regionServer.getZooKeeper().sync(node);
for (int i = 0; i < 100; i++) {
// We expect the znode to be deleted by this time. Here the znode could be in OPENED state and the
// master has not yet deleted the znode.
if (ZKUtil.checkExists(regionServer.getZooKeeper(), node) != -1) {
Thread.sleep(100);
}
}
try {
st.execute(regionServer, regionServer);
} catch (IOException e) {
// check for the specific instance in case the Split failed due to the existence of the znode in OPENED state.
// This will at least make the test to fail;
if (nodeCreated) {
assertTrue("Should be instance of TransitionToSplittingFailedException",
e instanceof TransitionToSplittingFailedException);
} else {
assertTrue("Should be instance of CreateSplittingNodeFailedException",
e instanceof SplittingNodeCreationFailedException );
}
node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
.getRegionInfo().getEncodedName());
// make sure the client is uptodate
regionServer.getZooKeeper().sync(node);
if (nodeCreated) {
assertFalse(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
} else {
assertTrue(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
}
assertTrue(st.rollback(regionServer, regionServer));
assertTrue(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
}
if (admin.isTableAvailable(tableName) && admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
}
示例4: testShouldClearRITWhenNodeFoundInSplittingState
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testShouldClearRITWhenNodeFoundInSplittingState() throws Exception {
final byte[] tableName = Bytes.toBytes("testShouldClearRITWhenNodeFoundInSplittingState");
HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
// Create table then get the single region for our new table.
HTableDescriptor htd = new HTableDescriptor(tableName);
htd.addFamily(new HColumnDescriptor("cf"));
admin.createTable(htd);
for (int i = 0; cluster.getRegions(tableName).size() == 0 && i < 100; i++) {
Thread.sleep(100);
}
assertTrue("Table not online", cluster.getRegions(tableName).size() != 0);
HRegion region = cluster.getRegions(tableName).get(0);
int regionServerIndex = cluster.getServerWith(region.getRegionName());
HRegionServer regionServer = cluster.getRegionServer(regionServerIndex);
SplitTransaction st = null;
st = new MockedSplitTransaction(region, null) {
@Override
void createSplitDir(FileSystem fs, Path splitdir) throws IOException {
throw new IOException("");
}
};
try {
st.execute(regionServer, regionServer);
} catch (IOException e) {
String node = ZKAssign.getNodeName(regionServer.getZooKeeper(), region
.getRegionInfo().getEncodedName());
assertFalse(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
AssignmentManager am = cluster.getMaster().getAssignmentManager();
for (int i = 0; !am.getRegionsInTransition().containsKey(
region.getRegionInfo().getEncodedName())
&& i < 100; i++) {
Thread.sleep(200);
}
assertTrue("region is not in transition "+region,
am.getRegionsInTransition().containsKey(region.getRegionInfo().getEncodedName()));
RegionState regionState = am.getRegionsInTransition().get(region.getRegionInfo()
.getEncodedName());
assertTrue(regionState.getState() == RegionState.State.SPLITTING);
assertTrue(st.rollback(regionServer, regionServer));
assertTrue(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
for (int i=0; am.getRegionsInTransition().containsKey(region.getRegionInfo().getEncodedName()) && i<100; i++) {
// Just in case the nodeDeleted event did not get executed.
Thread.sleep(200);
}
assertFalse("region is still in transition",
am.getRegionsInTransition().containsKey(region.getRegionInfo().getEncodedName()));
}
if (admin.isTableAvailable(tableName) && admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
admin.close();
}
}