public static void scanMeta(Connection connection, TableName table, QueryType type, int maxRows, final Visitor visitor) throws IOException { scanMeta(connection, getTableStartRowForMeta(table, type), getTableStopRowForMeta(table, type), type, maxRows, visitor); }
public static List<String> getTableEncodedRegionNamesForSerialReplication(Connection conn, TableName tableName) throws IOException { List<String> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, new FirstKeyOnlyFilter(), Integer.MAX_VALUE, r -> { list.add(RegionInfo.encodeRegionName(r.getRow())); return true; }); return list; }
public static List<Pair<String, Long>> getTableEncodedRegionNameAndLastBarrier(Connection conn, TableName tableName) throws IOException { List<Pair<String, Long>> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, r -> { byte[] value = r.getValue(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER); if (value == null) { return true; } long lastBarrier = Bytes.toLong(value); String encodedRegionName = RegionInfo.encodeRegionName(r.getRow()); list.add(Pair.newPair(encodedRegionName, lastBarrier)); return true; }); return list; }
/** * This method creates a Scan object that will only scan catalog rows that * belong to the specified table. It doesn't specify any columns. * This is a better alternative to just using a start row and scan until * it hits a new table since that requires parsing the HRI to get the table * name. * @param tableName bytes of table's name * @return configured Scan object */ @Deprecated public static Scan getScanForTableName(Connection connection, TableName tableName) { // Start key is just the table name with delimiters byte[] startKey = getTableStartRowForMeta(tableName, QueryType.REGION); // Stop key appends the smallest possible char to the table name byte[] stopKey = getTableStopRowForMeta(tableName, QueryType.REGION); Scan scan = getMetaScan(connection, -1); scan.setStartRow(startKey); scan.setStopRow(stopKey); return scan; }
barrierScan.addFamily(HConstants.REPLICATION_BARRIER_FAMILY); barrierScan .withStartRow(MetaTableAccessor.getTableStartRowForMeta(cleanReplicationBarrierTable, MetaTableAccessor.QueryType.REGION)) .withStopRow(MetaTableAccessor.getTableStopRowForMeta(cleanReplicationBarrierTable,
metaTable .scanAll(new Scan().setReadType(ReadType.PREAD).addFamily(HConstants.CATALOG_FAMILY) .withStartRow(MetaTableAccessor.getTableStartRowForMeta(tableName, QueryType.REGION)) .withStopRow(MetaTableAccessor.getTableStopRowForMeta(tableName, QueryType.REGION))), (results, err2) -> {
getTableStartRowForMeta(tableName, QueryType.REGION), getTableStopRowForMeta(tableName, QueryType.REGION), QueryType.REGION, visitor);
/** * Performs a scan of META table for given table starting from * given row. * * @param connection connection we're using * @param visitor visitor to call * @param tableName table withing we scan * @param row start scan from this row * @param rowLimit max number of rows to return */ public static void scanMeta(Connection connection, final Visitor visitor, final TableName tableName, final byte[] row, final int rowLimit) throws IOException { byte[] startRow = null; byte[] stopRow = null; if (tableName != null) { startRow = getTableStartRowForMeta(tableName, QueryType.REGION); if (row != null) { RegionInfo closestRi = getClosestRegionInfo(connection, tableName, row); startRow = RegionInfo.createRegionName(tableName, closestRi.getStartKey(), HConstants.ZEROES, false); } stopRow = getTableStopRowForMeta(tableName, QueryType.REGION); } scanMeta(connection, startRow, stopRow, QueryType.REGION, rowLimit, visitor); }
public static void scanMeta(Connection connection, TableName table, QueryType type, int maxRows, final Visitor visitor) throws IOException { scanMeta(connection, getTableStartRowForMeta(table, type), getTableStopRowForMeta(table, type), type, maxRows, visitor); }
barrierScan .withStartRow( MetaTableAccessor.getTableStartRowForMeta(tableName, MetaTableAccessor.QueryType.REGION)) .withStopRow( MetaTableAccessor.getTableStopRowForMeta(tableName, MetaTableAccessor.QueryType.REGION));
public static List<String> getTableEncodedRegionNamesForSerialReplication(Connection conn, TableName tableName) throws IOException { List<String> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, new FirstKeyOnlyFilter(), Integer.MAX_VALUE, r -> { list.add(RegionInfo.encodeRegionName(r.getRow())); return true; }); return list; }
public static List<Pair<String, Long>> getTableEncodedRegionNameAndLastBarrier(Connection conn, TableName tableName) throws IOException { List<Pair<String, Long>> list = new ArrayList<>(); scanMeta(conn, getTableStartRowForMeta(tableName, QueryType.REPLICATION), getTableStopRowForMeta(tableName, QueryType.REPLICATION), QueryType.REPLICATION, r -> { byte[] value = r.getValue(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER); if (value == null) { return true; } long lastBarrier = Bytes.toLong(value); String encodedRegionName = RegionInfo.encodeRegionName(r.getRow()); list.add(Pair.newPair(encodedRegionName, lastBarrier)); return true; }); return list; }
/** * This method creates a Scan object that will only scan catalog rows that * belong to the specified table. It doesn't specify any columns. * This is a better alternative to just using a start row and scan until * it hits a new table since that requires parsing the HRI to get the table * name. * @param tableName bytes of table's name * @return configured Scan object */ @Deprecated public static Scan getScanForTableName(Connection connection, TableName tableName) { // Start key is just the table name with delimiters byte[] startKey = getTableStartRowForMeta(tableName, QueryType.REGION); // Stop key appends the smallest possible char to the table name byte[] stopKey = getTableStopRowForMeta(tableName, QueryType.REGION); Scan scan = getMetaScan(connection, -1); scan.setStartRow(startKey); scan.setStopRow(stopKey); return scan; }
.withStartRow(MetaTableAccessor.getTableStartRowForMeta(tableName, QueryType.REGION)) .withStopRow(MetaTableAccessor.getTableStopRowForMeta(tableName, QueryType.REGION))) .whenComplete((results, err2) -> {
getTableStartRowForMeta(tableName, QueryType.REGION), getTableStopRowForMeta(tableName, QueryType.REGION), QueryType.REGION, visitor);
/** * Performs a scan of META table for given table starting from * given row. * * @param connection connection we're using * @param visitor visitor to call * @param tableName table withing we scan * @param row start scan from this row * @param rowLimit max number of rows to return */ public static void scanMeta(Connection connection, final Visitor visitor, final TableName tableName, final byte[] row, final int rowLimit) throws IOException { byte[] startRow = null; byte[] stopRow = null; if (tableName != null) { startRow = getTableStartRowForMeta(tableName, QueryType.REGION); if (row != null) { RegionInfo closestRi = getClosestRegionInfo(connection, tableName, row); startRow = RegionInfo.createRegionName(tableName, closestRi.getStartKey(), HConstants.ZEROES, false); } stopRow = getTableStopRowForMeta(tableName, QueryType.REGION); } scanMeta(connection, startRow, stopRow, QueryType.REGION, rowLimit, visitor); }
public static void scanMeta(Connection connection, TableName table, QueryType type, int maxRows, final Visitor visitor) throws IOException { scanMeta(connection, getTableStartRowForMeta(table, type), getTableStopRowForMeta(table, type), type, maxRows, visitor); }
/** * This method creates a Scan object that will only scan catalog rows that * belong to the specified table. It doesn't specify any columns. * This is a better alternative to just using a start row and scan until * it hits a new table since that requires parsing the HRI to get the table * name. * @param tableName bytes of table's name * @return configured Scan object */ @Deprecated public static Scan getScanForTableName(Connection connection, TableName tableName) { // Start key is just the table name with delimiters byte[] startKey = getTableStartRowForMeta(tableName, QueryType.REGION); // Stop key appends the smallest possible char to the table name byte[] stopKey = getTableStopRowForMeta(tableName, QueryType.REGION); Scan scan = getMetaScan(connection, -1); scan.setStartRow(startKey); scan.setStopRow(stopKey); return scan; }
if (tableName != null) { startRow = getTableStartRowForMeta(tableName, QueryType.REGION); if (row != null) { RegionInfo closestRi =
barrierScan .withStartRow( MetaTableAccessor.getTableStartRowForMeta(tableName, MetaTableAccessor.QueryType.REGION)) .withStopRow( MetaTableAccessor.getTableStopRowForMeta(tableName, MetaTableAccessor.QueryType.REGION));