Java 类org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State 实例源码

项目:ditb    文件:TestUpgradeTo96.java   
/**
 * Sets znodes used in 0.94 version. Only table and replication znodes will be upgraded to PB,
 * others would be deleted.
 * @throws KeeperException
 */
private static void setUp94Znodes() throws IOException, KeeperException {
  // add some old znodes, which would be deleted after upgrade.
  String rootRegionServerZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  ZKUtil.createWithParents(zkw, rootRegionServerZnode);
  ZKUtil.createWithParents(zkw, zkw.backupMasterAddressesZNode);
  // add table znode, data of its children would be protobuffized
  tableAZnode = ZKUtil.joinZNode(zkw.tableZNode, "a");
  ZKUtil.createWithParents(zkw, tableAZnode,
    Bytes.toBytes(ZooKeeperProtos.Table.State.ENABLED.toString()));
  // add replication znodes, data of its children would be protobuffized
  String replicationZnode = ZKUtil.joinZNode(zkw.baseZNode, "replication");
  replicationPeerZnode = ZKUtil.joinZNode(replicationZnode, "peers");
  peer1Znode = ZKUtil.joinZNode(replicationPeerZnode, "1");
  peer1 = ReplicationPeer.newBuilder().setClusterkey("abc:123:/hbase").build();
  ZKUtil.createWithParents(zkw, peer1Znode, Bytes.toBytes(peer1.getClusterkey()));
}
项目:pbase    文件:TestUpgradeTo96.java   
/**
 * Sets znodes used in 0.94 version. Only table and replication znodes will be upgraded to PB,
 * others would be deleted.
 * @throws KeeperException
 */
private static void setUp94Znodes() throws IOException, KeeperException {
  // add some old znodes, which would be deleted after upgrade.
  String rootRegionServerZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  ZKUtil.createWithParents(zkw, rootRegionServerZnode);
  ZKUtil.createWithParents(zkw, zkw.backupMasterAddressesZNode);
  // add table znode, data of its children would be protobuffized
  tableAZnode = ZKUtil.joinZNode(zkw.tableZNode, "a");
  ZKUtil.createWithParents(zkw, tableAZnode,
    Bytes.toBytes(ZooKeeperProtos.Table.State.ENABLED.toString()));
  // add replication znodes, data of its children would be protobuffized
  String replicationZnode = ZKUtil.joinZNode(zkw.baseZNode, "replication");
  replicationPeerZnode = ZKUtil.joinZNode(replicationZnode, "peers");
  peer1Znode = ZKUtil.joinZNode(replicationPeerZnode, "1");
  peer1 = ReplicationPeer.newBuilder().setClusterkey("abc:123:/hbase").build();
  ZKUtil.createWithParents(zkw, peer1Znode, Bytes.toBytes(peer1.getClusterkey()));
}
项目:HIndex    文件:TestUpgradeTo96.java   
/**
 * Sets znodes used in 0.94 version. Only table and replication znodes will be upgraded to PB,
 * others would be deleted.
 * @throws KeeperException
 */
private static void setUp94Znodes() throws IOException, KeeperException {
  // add some old znodes, which would be deleted after upgrade.
  String rootRegionServerZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  ZKUtil.createWithParents(zkw, rootRegionServerZnode);
  ZKUtil.createWithParents(zkw, zkw.backupMasterAddressesZNode);
  // add table znode, data of its children would be protobuffized
  tableAZnode = ZKUtil.joinZNode(zkw.tableZNode, "a");
  ZKUtil.createWithParents(zkw, tableAZnode,
    Bytes.toBytes(ZooKeeperProtos.Table.State.ENABLED.toString()));
  // add replication znodes, data of its children would be protobuffized
  String replicationZnode = ZKUtil.joinZNode(zkw.baseZNode, "replication");
  replicationPeerZnode = ZKUtil.joinZNode(replicationZnode, "peers");
  peer1Znode = ZKUtil.joinZNode(replicationPeerZnode, "1");
  peer1 = ReplicationPeer.newBuilder().setClusterkey("abc:123:/hbase").build();
  ZKUtil.createWithParents(zkw, peer1Znode, Bytes.toBytes(peer1.getClusterkey()));
}
项目: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<TableName> getDisabledOrDisablingTables(ZooKeeperWatcher zkw)
throws KeeperException {
  Set<TableName> disabledTables = new HashSet<TableName>();
  List<String> children =
    ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode);
  for (String child: children) {
    TableName tableName =
        TableName.valueOf(child);
    ZooKeeperProtos.Table.State state = getTableState(zkw, tableName);
    if (state == ZooKeeperProtos.Table.State.DISABLED ||
        state == ZooKeeperProtos.Table.State.DISABLING)
      disabledTables.add(tableName);
  }
  return disabledTables;
}
项目:HIndex    文件:ZKTableReadOnly.java   
/**
 * Gets all the tables by state.
 * @return map of state vs tables.
 * @throws KeeperException
 */
public static Map<State, Set<TableName>>
    getTableNamesByState(ZooKeeperWatcher zkw) throws KeeperException {
  Map<State, Set<TableName>> tablesByState = new HashMap<State, Set<TableName>>();
  List<String> children = ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode);
  for (String child : children) {
    TableName tableName = TableName.valueOf(child);
    ZooKeeperProtos.Table.State state = getTableState(zkw, tableName);
    if (tablesByState.containsKey(state)) {
      tablesByState.get(state).add(tableName);
    } else {
      HashSet<TableName> set = new HashSet<TableName>();
      set.add(tableName);
      tablesByState.put(state, set);
    }
  }
  return tablesByState;
}
项目:PyroDB    文件:TestUpgradeTo96.java   
/**
 * Sets znodes used in 0.94 version. Only table and replication znodes will be upgraded to PB,
 * others would be deleted.
 * @throws KeeperException
 */
private static void setUp94Znodes() throws IOException, KeeperException {
  // add some old znodes, which would be deleted after upgrade.
  String rootRegionServerZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  ZKUtil.createWithParents(zkw, rootRegionServerZnode);
  ZKUtil.createWithParents(zkw, zkw.backupMasterAddressesZNode);
  // add table znode, data of its children would be protobuffized
  tableAZnode = ZKUtil.joinZNode(zkw.tableZNode, "a");
  ZKUtil.createWithParents(zkw, tableAZnode,
    Bytes.toBytes(ZooKeeperProtos.Table.State.ENABLED.toString()));
  // add replication znodes, data of its children would be protobuffized
  String replicationZnode = ZKUtil.joinZNode(zkw.baseZNode, "replication");
  replicationPeerZnode = ZKUtil.joinZNode(replicationZnode, "peers");
  peer1Znode = ZKUtil.joinZNode(replicationPeerZnode, "1");
  peer1 = ReplicationPeer.newBuilder().setClusterkey("abc:123:/hbase").build();
  ZKUtil.createWithParents(zkw, peer1Znode, Bytes.toBytes(peer1.getClusterkey()));
}
项目:c5    文件:TestUpgradeTo96.java   
/**
 * Sets znodes used in 0.94 version. Only table and replication znodes will be upgraded to PB,
 * others would be deleted.
 * @throws KeeperException
 */
private static void setUp94Znodes() throws IOException, KeeperException {
  // add some old znodes, which would be deleted after upgrade.
  String rootRegionServerZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  ZKUtil.createWithParents(zkw, rootRegionServerZnode);
  ZKUtil.createWithParents(zkw, zkw.backupMasterAddressesZNode);
  // add table znode, data of its children would be protobuffized
  tableAZnode = ZKUtil.joinZNode(zkw.tableZNode, "a");
  ZKUtil.createWithParents(zkw, tableAZnode,
    Bytes.toBytes(ZooKeeperProtos.Table.State.ENABLED.toString()));
  // add replication znodes, data of its children would be protobuffized
  String replicationZnode = ZKUtil.joinZNode(zkw.baseZNode, "replication");
  replicationPeerZnode = ZKUtil.joinZNode(replicationZnode, "peers");
  peer1Znode = ZKUtil.joinZNode(replicationPeerZnode, "1");
  peer1 = ReplicationPeer.newBuilder().setClusterkey("abc:123:/hbase").build();
  ZKUtil.createWithParents(zkw, peer1Znode, Bytes.toBytes(peer1.getClusterkey()));
}
项目:ditb    文件:TestUpgradeTo96.java   
@Test
public void testZnodeMigration() throws Exception {
  String rootRSZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  assertTrue(ZKUtil.checkExists(zkw, rootRSZnode) > -1);
  ToolRunner.run(TEST_UTIL.getConfiguration(), new UpgradeTo96(), new String[] { "-execute" });
  assertEquals(-1, ZKUtil.checkExists(zkw, rootRSZnode));
  byte[] data = ZKUtil.getData(zkw, tableAZnode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkTableState(data, ZooKeeperProtos.Table.State.ENABLED);
  // ensure replication znodes are there, and protobuffed.
  data = ZKUtil.getData(zkw, peer1Znode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkReplicationPeerData(data, peer1);
}
项目:ditb    文件:TestUpgradeTo96.java   
private void checkTableState(byte[] data, State expectedState)
    throws InvalidProtocolBufferException {
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ZooKeeperProtos.Table t = builder.mergeFrom(data, magicLen, data.length - magicLen).build();
  assertTrue(t.getState() == expectedState);
}
项目:pbase    文件:TestUpgradeTo96.java   
@Test
public void testZnodeMigration() throws Exception {
  String rootRSZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  assertTrue(ZKUtil.checkExists(zkw, rootRSZnode) > -1);
  ToolRunner.run(TEST_UTIL.getConfiguration(), new UpgradeTo96(), new String[] { "-execute" });
  assertEquals(-1, ZKUtil.checkExists(zkw, rootRSZnode));
  byte[] data = ZKUtil.getData(zkw, tableAZnode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkTableState(data, ZooKeeperProtos.Table.State.ENABLED);
  // ensure replication znodes are there, and protobuffed.
  data = ZKUtil.getData(zkw, peer1Znode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkReplicationPeerData(data, peer1);
}
项目:pbase    文件:TestUpgradeTo96.java   
private void checkTableState(byte[] data, State expectedState)
    throws InvalidProtocolBufferException {
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ZooKeeperProtos.Table t = builder.mergeFrom(data, magicLen, data.length - magicLen).build();
  assertTrue(t.getState() == expectedState);
}
项目:HIndex    文件:TestUpgradeTo96.java   
@Test
public void testZnodeMigration() throws Exception {
  String rootRSZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  assertTrue(ZKUtil.checkExists(zkw, rootRSZnode) > -1);
  ToolRunner.run(TEST_UTIL.getConfiguration(), new UpgradeTo96(), new String[] { "-execute" });
  assertEquals(-1, ZKUtil.checkExists(zkw, rootRSZnode));
  byte[] data = ZKUtil.getData(zkw, tableAZnode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkTableState(data, ZooKeeperProtos.Table.State.ENABLED);
  // ensure replication znodes are there, and protobuffed.
  data = ZKUtil.getData(zkw, peer1Znode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkReplicationPeerData(data, peer1);
}
项目:HIndex    文件:TestUpgradeTo96.java   
private void checkTableState(byte[] data, State expectedState)
    throws InvalidProtocolBufferException {
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ZooKeeperProtos.Table t = builder.mergeFrom(data, magicLen, data.length - magicLen).build();
  assertTrue(t.getState() == expectedState);
}
项目: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<TableName> getDisabledTables(ZooKeeperWatcher zkw)
throws KeeperException {
  Set<TableName> disabledTables = new HashSet<TableName>();
  List<String> children =
    ZKUtil.listChildrenNoWatch(zkw, zkw.tableZNode);
  for (String child: children) {
    TableName tableName =
        TableName.valueOf(child);
    ZooKeeperProtos.Table.State state = getTableState(zkw, tableName);
    if (state == ZooKeeperProtos.Table.State.DISABLED) disabledTables.add(tableName);
  }
  return disabledTables;
}
项目:HIndex    文件:SecondaryIndexColocator.java   
private void setTablesInZK() throws IOException, KeeperException {
  if (tablesToBeSetInZK != null && !tablesToBeSetInZK.isEmpty()) {
    ZKTable zkTable = new ZKTable(this.watcher);
    for (Pair<String, State> p : tablesToBeSetInZK) {
      setStateInZK(zkTable, p.getFirst(), p.getSecond());
    }
  }
}
项目:HIndex    文件:SecondaryIndexColocator.java   
private void setStateInZK(ZKTable zkTable, String tableName, State state) throws IOException,
    KeeperException {
  if (state == State.ENABLED) {
    zkTable.setEnabledTable(TableName.valueOf(tableName));
  }
  if (state == State.DISABLED) {
    zkTable.setDisabledTable(TableName.valueOf(tableName));
  }
}
项目:PyroDB    文件:TestUpgradeTo96.java   
@Test
public void testZnodeMigration() throws Exception {
  String rootRSZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  assertTrue(ZKUtil.checkExists(zkw, rootRSZnode) > -1);
  ToolRunner.run(TEST_UTIL.getConfiguration(), new UpgradeTo96(), new String[] { "-execute" });
  assertEquals(-1, ZKUtil.checkExists(zkw, rootRSZnode));
  byte[] data = ZKUtil.getData(zkw, tableAZnode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkTableState(data, ZooKeeperProtos.Table.State.ENABLED);
  // ensure replication znodes are there, and protobuffed.
  data = ZKUtil.getData(zkw, peer1Znode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkReplicationPeerData(data, peer1);
}
项目:PyroDB    文件:TestUpgradeTo96.java   
private void checkTableState(byte[] data, State expectedState)
    throws InvalidProtocolBufferException {
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ZooKeeperProtos.Table t = builder.mergeFrom(data, magicLen, data.length - magicLen).build();
  assertTrue(t.getState() == expectedState);
}
项目:c5    文件:TestUpgradeTo96.java   
@Test
public void testZnodeMigration() throws Exception {
  String rootRSZnode = ZKUtil.joinZNode(zkw.baseZNode, "root-region-server");
  assertTrue(ZKUtil.checkExists(zkw, rootRSZnode) > -1);
  ToolRunner.run(TEST_UTIL.getConfiguration(), new UpgradeTo96(), new String[] { "-execute" });
  assertEquals(-1, ZKUtil.checkExists(zkw, rootRSZnode));
  byte[] data = ZKUtil.getData(zkw, tableAZnode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkTableState(data, ZooKeeperProtos.Table.State.ENABLED);
  // ensure replication znodes are there, and protobuffed.
  data = ZKUtil.getData(zkw, peer1Znode);
  assertTrue(ProtobufUtil.isPBMagicPrefix(data));
  checkReplicationPeerData(data, peer1);
}
项目:c5    文件:TestUpgradeTo96.java   
private void checkTableState(byte[] data, State expectedState)
    throws InvalidProtocolBufferException {
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ZooKeeperProtos.Table t = builder.mergeFrom(data, magicLen, data.length - magicLen).build();
  assertTrue(t.getState() == expectedState);
}
项目:HIndex    文件:ZKTableReadOnly.java   
static boolean isTableState(final ZooKeeperProtos.Table.State expectedState,
    final ZooKeeperProtos.Table.State currentState) {
  return currentState != null && currentState.equals(expectedState);
}
项目:HIndex    文件:SecondaryIndexColocator.java   
private void checkDisabledAndEnabledTables() throws IOException, KeeperException {
  if (disabledandDisablingTables != null && !disabledandDisablingTables.isEmpty()) {
    Map<byte[], State> disabledHere = new TreeMap<byte[], State>(Bytes.BYTES_COMPARATOR);
    Iterator<Entry<byte[], State>> itr = disabledandDisablingTables.entrySet().iterator();
    while (itr.hasNext()) {
      Entry<byte[], State> tableEntry = itr.next();
      if (!IndexUtils.isIndexTable(tableEntry.getKey())) {
        byte[] indexTableName = Bytes.toBytes(IndexUtils.getIndexTableName(tableEntry.getKey()));
        if (null == tableMap.get(Bytes.toString(indexTableName))) {
          continue;
        }
        boolean present = disabledandDisablingTables.containsKey(indexTableName);
        if (!present && (enabledOrEnablingTables.get(indexTableName) == State.ENABLED)) {
          // TODO How to handle ENABLING state(if it could happen). If try to disable ENABLING
          // table
          // it throws.
          if (LOG.isDebugEnabled()) {
            LOG.debug("Table " + Bytes.toString(tableEntry.getKey())
                + " is disabled but corresponding index table is " + "enabled. So disabling "
                + Bytes.toString(indexTableName));
          }
          this.admin.disableTable(indexTableName);
          disabledHere.put(indexTableName, State.DISABLED);
        }
      } else {
        if (tableEntry.getValue() != State.DISABLED) {
          continue;
        }
        byte[] userTableName =
            Bytes.toBytes(IndexUtils.getActualTableName(Bytes.toString(tableEntry.getKey())));
        if (!disabledandDisablingTables.containsKey(userTableName)) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Index Table " + Bytes.toString(tableEntry.getKey())
                + " is disabled but corresponding user table is enabled. So Enabling "
                + Bytes.toString(tableEntry.getKey()));
          }
          // Here we are not enabling the table. We will do it in the next step
          // checkMetaInfoCosistency().
          // Because if we do here, META will be updated and our in-memory map will have old
          // entries.
          // So it will surely cause unnecessary unassignments and assignments in the next step.
          // In the next
          // step anyway we are moving regions. So no problem doing it there.
          // this.admin.enableTable(tableName);
          itr.remove();
        }
      }
    }
    disabledandDisablingTables.putAll(disabledHere);
  }
}
项目:HIndex    文件:ZKTableReadOnly.java   
/**
 * Go to zookeeper and see if state of table is {@code ZooKeeperProtos.Table.State#DISABLED}.
 * This method does not use cache.
 * This method is for clients other than AssignmentManager
 * @param zkw
 * @param tableName
 * @return True if table is enabled.
 * @throws KeeperException
 */
public static boolean isDisabledTable(final ZooKeeperWatcher zkw,
    final TableName tableName)
throws KeeperException {
  ZooKeeperProtos.Table.State state = getTableState(zkw, tableName);
  return isTableState(ZooKeeperProtos.Table.State.DISABLED, state);
}
项目:HIndex    文件:ZKTableReadOnly.java   
/**
 * Go to zookeeper and see if state of table is {@code ZooKeeperProtos.Table.State#DISABLING}
 * of {@code ZooKeeperProtos.Table.State#DISABLED}.
 * This method does not use cache.
 * This method is for clients other than AssignmentManager.
 * @param zkw
 * @param tableName
 * @return True if table is enabled.
 * @throws KeeperException
 */
public static boolean isDisablingOrDisabledTable(final ZooKeeperWatcher zkw,
    final TableName tableName)
throws KeeperException {
  ZooKeeperProtos.Table.State state = getTableState(zkw, tableName);
  return isTableState(ZooKeeperProtos.Table.State.DISABLING, state) ||
    isTableState(ZooKeeperProtos.Table.State.DISABLED, state);
}
项目:HIndex    文件:ZKTableReadOnly.java   
/**
 * Go to zookeeper and see if state of table is {@code ZooKeeperProtos.Table.State#ENABLED}.
 * This method does not use cache.
 * This method is for clients other than AssignmentManager
 * @param zkw
 * @param tableName
 * @return True if table is enabled.
 * @throws KeeperException
 */
public static boolean isEnabledTable(final ZooKeeperWatcher zkw,
    final TableName tableName)
throws KeeperException {
  return getTableState(zkw, tableName) == ZooKeeperProtos.Table.State.ENABLED;
}