本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKTable.TableState类的典型用法代码示例。如果您正苦于以下问题:Java TableState类的具体用法?Java TableState怎么用?Java TableState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableState类属于org.apache.hadoop.hbase.zookeeper.ZKTable包,在下文中一共展示了TableState类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadDisabledTables
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* Load the list of disabled tables in ZK into local set.
* @throws ZooKeeperConnectionException
* @throws IOException
*/
private void loadDisabledTables()
throws ZooKeeperConnectionException, IOException {
HConnectionManager.execute(new HConnectable<Void>(getConf()) {
@Override
public Void connect(HConnection connection) throws IOException {
ZooKeeperWatcher zkw = connection.getZooKeeperWatcher();
try {
for (Entry<TableState, Set<String>> e : ZKTableReadOnly.getDisabledOrDisablingTables(zkw)
.entrySet()) {
for (String tableName : e.getValue()) {
disabledTables.add(Bytes.toBytes(tableName));
}
}
} catch (KeeperException ke) {
throw new IOException(ke);
}
return null;
}
});
}
示例2: isEnabledTable
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* Go to zookeeper and see if state of table is {@link TableState#ENABLED}.
* @param zkw
* @param tableName
* @return True if table is enabled.
* @throws KeeperException
*/
public static boolean isEnabledTable(final ZooKeeperWatcher zkw,
final String tableName) throws KeeperException {
TableState state = getTableState(zkw, tableName);
// If a table is ENABLED then we are removing table state znode in 0.92
// but in 0.94 we keep it in ENABLED state.
return state == null || state == TableState.ENABLED;
}
示例3: getDisabledTables
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* Gets a list of all the tables set as disabled in zookeeper.
* @return Set of disabled tables, empty Set if none
* @throws KeeperException
*/
public static Set<String> getDisabledTables(ZooKeeperWatcher zkw)
throws KeeperException {
Set<String> disabledTables = new HashSet<String>();
List<String> children =
ZKUtil.listChildrenNoWatch(zkw, zkw.clientTableZNode);
for (String child: children) {
TableState state = getTableState(zkw, child);
if (state == TableState.DISABLED) disabledTables.add(child);
}
return disabledTables;
}
示例4: getDisabledOrDisablingTables
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* Gets a list of all the tables set as disabled in zookeeper.
* @return Set of disabled tables, empty Set if none
* @throws KeeperException
*/
public static Set<String> getDisabledOrDisablingTables(ZooKeeperWatcher zkw)
throws KeeperException {
Set<String> disabledTables = new HashSet<String>();
List<String> children =
ZKUtil.listChildrenNoWatch(zkw, zkw.clientTableZNode);
for (String child: children) {
TableState state = getTableState(zkw, child);
if (state == TableState.DISABLED || state == TableState.DISABLING)
disabledTables.add(child);
}
return disabledTables;
}
示例5: getTableState
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* @deprecated Only for 0.92/0.94 compatibility. Use getTableState(zkw, child) instead.
*/
static TableState getTableState(final ZooKeeperWatcher zkw,
final String parent, final String child) throws KeeperException {
String znode = ZKUtil.joinZNode(parent, child);
byte [] data = ZKUtil.getData(zkw, znode);
if (data == null || data.length <= 0) {
return null;
}
String str = Bytes.toString(data);
try {
return TableState.valueOf(str);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(str);
}
}
示例6: runTest9294CompatibilityTest
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
private void runTest9294CompatibilityTest(String tableName, Configuration conf)
throws Exception {
ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf,
tableName, abortable, true);
ZKTable zkt = new ZKTable(zkw);
zkt.setEnabledTable(tableName);
// check that current/0.94 format table has proper ENABLED format
assertTrue(
ZKTableReadOnly.getTableState(zkw, zkw.masterTableZNode, tableName) == TableState.ENABLED);
// check that 0.92 format table is null, as expected by 0.92.0/0.92.1 clients
assertTrue(ZKTableReadOnly.getTableState(zkw, zkw.masterTableZNode92, tableName) == null);
}
示例7: testSSHWhenDisableTableInProgress
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
/**
* To test closed region handler to remove rit and delete corresponding znode if region in pending
* close or closing while processing shutdown of a region server.(HBASE-5927).
* @throws KeeperException
* @throws IOException
*/
@Test
public void testSSHWhenDisableTableInProgress()
throws KeeperException, IOException {
testCaseWithPartiallyDisabledState(TableState.DISABLING, false);
testCaseWithPartiallyDisabledState(TableState.DISABLED, false);
}
示例8: setTablesInZK
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
private void setTablesInZK() throws IOException {
if (tablesToBeSetInZK != null && !tablesToBeSetInZK.isEmpty()) {
for (Pair<String, TableState> p : tablesToBeSetInZK) {
setStateInZK(p.getFirst(), p.getSecond());
}
}
}
示例9: setStateInZK
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
private void setStateInZK(String tableName, TableState state) throws IOException {
if (state == TableState.ENABLED) {
admin.setEnableTable(tableName);
}
if (state == TableState.DISABLED) {
admin.setDisableTable(tableName);
}
}
示例10: isTableState
import org.apache.hadoop.hbase.zookeeper.ZKTable.TableState; //导入依赖的package包/类
static boolean isTableState(final TableState expectedState,
final TableState currentState) {
return currentState != null && currentState.equals(expectedState);
}