Java 类org.apache.hadoop.hbase.zookeeper.ZKTable.TableState 实例源码

项目:hindex    文件:HBaseFsck.java   
/**
 * 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;
    }
  });
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestZKTable.java   
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);
}
项目:LCIndex-HBase-0.94.16    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:IRIndex    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:IRIndex    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:IRIndex    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:IRIndex    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:IRIndex    文件:TestZKTable.java   
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);
}
项目:IRIndex    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:HBase-Research    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:HBase-Research    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:HBase-Research    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:HBase-Research    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:HBase-Research    文件:TestZKTable.java   
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);
}
项目:HBase-Research    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:hbase-0.94.8-qod    文件:TestZKTable.java   
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);
}
项目:hbase-0.94.8-qod    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hbase-0.94.8-qod    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:hbase-0.94.8-qod    文件:TestZKTable.java   
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);
}
项目:hbase-0.94.8-qod    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:hindex    文件:SecondaryIndexColocator.java   
private void setTablesInZK() throws IOException {
  if (tablesToBeSetInZK != null && !tablesToBeSetInZK.isEmpty()) {
    for (Pair<String, TableState> p : tablesToBeSetInZK) {
      setStateInZK(p.getFirst(), p.getSecond());
    }
  }
}
项目:hindex    文件:SecondaryIndexColocator.java   
private void setStateInZK(String tableName, TableState state) throws IOException {
  if (state == TableState.ENABLED) {
    admin.setEnableTable(tableName);
  }
  if (state == TableState.DISABLED) {
    admin.setDisableTable(tableName);
  }
}
项目:hindex    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hindex    文件:ZKTableReadOnly.java   
/**
 * 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;
}
项目:hindex    文件:ZKTableReadOnly.java   
/**
 * @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);
  }
}
项目:hindex    文件:TestZKTable.java   
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);
}
项目:hindex    文件:TestAssignmentManager.java   
/**
 * 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);
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
static boolean isTableState(final TableState expectedState,
  final TableState currentState) {
  return currentState != null && currentState.equals(expectedState);
}
项目:LCIndex-HBase-0.94.16    文件:ZKTableReadOnly.java   
/**
 * Read the TableState from ZooKeeper
 * @throws KeeperException
 */
static TableState getTableState(final ZooKeeperWatcher zkw,
  final String child) throws KeeperException {
  return getTableState(zkw, zkw.clientTableZNode, child);
}