public TableState findLastTableState(final TableName table) throws IOException {
    final AtomicReference<TableState> lastTableState = new AtomicReference<>(null);
    ClientMetaTableAccessor.Visitor visitor = new ClientMetaTableAccessor.Visitor() {
      @Override
      public boolean visit(Result r) throws IOException {
        if (!Arrays.equals(r.getRow(), table.getName())) {
          return false;
        }
        TableState state = CatalogFamilyFormat.getTableState(r);
        if (state != null) {
          lastTableState.set(state);
        }
        return true;
      }
    };
    MetaTableAccessor.scanMeta(getConnection(), null, null, ClientMetaTableAccessor.QueryType.TABLE,
      Integer.MAX_VALUE, visitor);
    return lastTableState.get();
  }
Wait until all regions in a table have been assigned
@param table         Table to wait on.
@param timeoutMillis Timeout.
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java