/** * Go to zookeeper and see if state of table is {@link org.apache.hadoop.hbase.zookeeper.ZKTable.TableState#DISABLED}. * This method does not use cache as {@link #isDisabledTable(String)} does. * This method is for clients other than {@link org.apache.hadoop.hbase.master.AssignmentManager} * * @param zkw * @param tableName * @return True if table is enabled. * @throws org.apache.zookeeper.KeeperException */ public static boolean isDisabledTable(final ZooKeeperWatcher zkw, final String tableName) throws KeeperException { ZooKeeperProtos.Table.State state = getTableState(zkw, tableName); return isTableState(ZooKeeperProtos.Table.State.DISABLED, state); }
private boolean testTableOnlineState(byte[] tableName, boolean online) throws IOException { getZooKeeperWatcher(); String tableNameStr = Bytes.toString(tableName); try { if (online) { return ZKTableReadOnly.isEnabledTable(this.zooKeeper, tableNameStr); } return ZKTableReadOnly.isDisabledTable(this.zooKeeper, tableNameStr); } catch (KeeperException e) { throw new IOException("Enable/Disable failed", e); } }
/** * Go to zookeeper and see if state of table is {@link org.apache.hadoop.hbase.zookeeper.ZKTable.TableState#ENABLED}. * This method does not use cache as {@link #isEnabledTable(String)} does. * This method is for clients other than {@link org.apache.hadoop.hbase.master.AssignmentManager} * * @param zkw * @param tableName * @return True if table is enabled. * @throws org.apache.zookeeper.KeeperException */ public static boolean isEnabledTable(final ZooKeeperWatcher zkw, final String tableName) throws KeeperException { return getTableState(zkw, tableName) == ZooKeeperProtos.Table.State.ENABLED; }
private boolean isTableState(final String tableName, final ZooKeeperProtos.Table.State state) { synchronized (this.cache) { ZooKeeperProtos.Table.State currentState = this.cache.get(tableName); return ZKTableReadOnly.isTableState(currentState, state); } }
/** * Gets a list of all the tables set as disabled in zookeeper. * * @return Set of disabled tables, empty Set if none * @throws org.apache.zookeeper.KeeperException */ public static Set<String> getDisabledTables(ZooKeeperWatcher zkw) throws KeeperException { Set<String> disabledTables = new HashSet<String>(); List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode); for (String child : children) { ZooKeeperProtos.Table.State state = getTableState(zkw, child); if (state == ZooKeeperProtos.Table.State.DISABLED) disabledTables.add(child); } return disabledTables; }
/** * Go to zookeeper and see if state of table is {@link org.apache.hadoop.hbase.zookeeper.ZKTable.TableState#DISABLING} * of {@link org.apache.hadoop.hbase.zookeeper.ZKTable.TableState#DISABLED}. This method does not use cache as * {@link #isEnabledTable(String)} does. This method is for clients other than * {@link org.apache.hadoop.hbase.master.AssignmentManager}. * * @param zkw * @param tableName * @return True if table is enabled. * @throws org.apache.zookeeper.KeeperException */ public static boolean isDisablingOrDisabledTable(final ZooKeeperWatcher zkw, final String tableName) throws KeeperException { ZooKeeperProtos.Table.State state = getTableState(zkw, tableName); return isTableState(ZooKeeperProtos.Table.State.DISABLING, state) || isTableState(ZooKeeperProtos.Table.State.DISABLED, state); }
/** * Gets a list of all the tables set as disabled in zookeeper. * * @return Set of disabled tables, empty Set if none * @throws org.apache.zookeeper.KeeperException */ public static Set<String> getDisabledOrDisablingTables(ZooKeeperWatcher zkw) throws KeeperException { Set<String> disabledTables = new HashSet<String>(); List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode); for (String child : children) { ZooKeeperProtos.Table.State state = getTableState(zkw, child); if (state == ZooKeeperProtos.Table.State.DISABLED || state == ZooKeeperProtos.Table.State.DISABLING) disabledTables.add(child); } return disabledTables; }
/** * Gets a list of all the tables set as disabled in zookeeper. * * @throws org.apache.zookeeper.KeeperException */ private void populateTableStates() throws KeeperException { synchronized (this.cache) { List<String> children = ZKUtil.listChildrenNoWatch(this.watcher, this.watcher.tableZNode); if (children == null) return; for (String child : children) { ZooKeeperProtos.Table.State state = ZKTableReadOnly.getTableState( this.watcher, child); if (state != null) this.cache.put(child, state); } } }
/** * Gets a list of all the tables of specified states in zookeeper. * * @return Set of tables of specified states, empty Set if none * @throws org.apache.zookeeper.KeeperException */ static Set<String> getAllTables(final ZooKeeperWatcher zkw, final ZooKeeperProtos.Table.State... states) throws KeeperException { Set<String> allTables = new HashSet<String>(); List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode); for (String child : children) { ZooKeeperProtos.Table.State state = ZKTableReadOnly.getTableState(zkw, child); for (ZooKeeperProtos.Table.State expectedState : states) { if (state == expectedState) { allTables.add(child); break; } } } return allTables; } }