/** * Fetch table states from META table * @param conn connection to use * @return map {tableName -> state} * @throws IOException */ public static Map<TableName, TableState> getTableStates(Connection conn) throws IOException { final Map<TableName, TableState> states = new LinkedHashMap<>(); Visitor collector = new Visitor() { @Override public boolean visit(Result r) throws IOException { TableState state = getTableState(r); if (state != null) states.put(state.getTableName(), state); return true; } }; fullScanTables(conn, collector); return states; }
/** * Return all tables in given states. * @param states filter by states * @return tables in given states */ public Set<TableName> getTablesInStates(TableState.State... states) throws IOException { // Only be called in region normalizer, will not use cache. final Set<TableName> rv = Sets.newHashSet(); MetaTableAccessor.fullScanTables(master.getConnection(), new MetaTableAccessor.Visitor() { @Override public boolean visit(Result r) throws IOException { TableState tableState = MetaTableAccessor.getTableState(r); if (tableState != null && tableState.inStates(states)) { rv.add(tableState.getTableName()); } return true; } }); return rv; }
Map<String, TableState> states = new HashMap<>(); MetaTableAccessor.fullScanTables(connection, new MetaTableAccessor.Visitor() { @Override public boolean visit(Result r) throws IOException {
/** * Fetch table states from META table * @param conn connection to use * @return map {tableName -> state} * @throws IOException */ public static Map<TableName, TableState> getTableStates(Connection conn) throws IOException { final Map<TableName, TableState> states = new LinkedHashMap<>(); Visitor collector = new Visitor() { @Override public boolean visit(Result r) throws IOException { TableState state = getTableState(r); if (state != null) states.put(state.getTableName(), state); return true; } }; fullScanTables(conn, collector); return states; }
/** * Fetch table states from META table * @param conn connection to use * @return map {tableName -> state} * @throws IOException */ public static Map<TableName, TableState> getTableStates(Connection conn) throws IOException { final Map<TableName, TableState> states = new LinkedHashMap<>(); Visitor collector = new Visitor() { @Override public boolean visit(Result r) throws IOException { TableState state = getTableState(r); if (state != null) states.put(state.getTableName(), state); return true; } }; fullScanTables(conn, collector); return states; }