/** * Returns the HRegionLocation from meta for the given region * @param metaTable * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static CompletableFuture<Optional<HRegionLocation>> getRegionLocation( AsyncTable<?> metaTable, byte[] regionName) { CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>(); try { RegionInfo parsedRegionInfo = MetaTableAccessor.parseRegionInfoFromRegionName(regionName); metaTable.get( new Get(MetaTableAccessor.getMetaKeyForRegion(parsedRegionInfo)) .addFamily(HConstants.CATALOG_FAMILY)).whenComplete( (r, err) -> { if (err != null) { future.completeExceptionally(err); return; } future.complete(getRegionLocations(r).map( locations -> locations.getRegionLocation(parsedRegionInfo.getReplicaId()))); }); } catch (IOException parseEx) { LOG.warn("Failed to parse the passed region name: " + Bytes.toStringBinary(regionName)); future.completeExceptionally(parseEx); } return future; }
/** * Returns the HRegionLocation from meta for the given region * @param connection connection we're using * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static HRegionLocation getRegionLocation(Connection connection, byte[] regionName) throws IOException { byte[] row = regionName; RegionInfo parsedInfo = null; try { parsedInfo = parseRegionInfoFromRegionName(regionName); row = getMetaKeyForRegion(parsedInfo); } catch (Exception parseEx) { // Ignore. This is used with tableName passed as regionName. } Get get = new Get(row); get.addFamily(HConstants.CATALOG_FAMILY); Result r = get(getMetaHTable(connection), get); RegionLocations locations = getRegionLocations(r); return locations == null ? null : locations.getRegionLocation(parsedInfo == null ? 0 : parsedInfo.getReplicaId()); }
/** * Returns the HRegionLocation from meta for the given region * @param metaTable * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static CompletableFuture<Optional<HRegionLocation>> getRegionLocation( AsyncTable<?> metaTable, byte[] regionName) { CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>(); try { RegionInfo parsedRegionInfo = MetaTableAccessor.parseRegionInfoFromRegionName(regionName); metaTable.get( new Get(MetaTableAccessor.getMetaKeyForRegion(parsedRegionInfo)) .addFamily(HConstants.CATALOG_FAMILY)).whenComplete( (r, err) -> { if (err != null) { future.completeExceptionally(err); return; } future.complete(getRegionLocations(r).map( locations -> locations.getRegionLocation(parsedRegionInfo.getReplicaId()))); }); } catch (IOException parseEx) { LOG.warn("Failed to parse the passed region name: " + Bytes.toStringBinary(regionName)); future.completeExceptionally(parseEx); } return future; }
/** * Returns the HRegionLocation from meta for the given region * @param connection connection we're using * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static HRegionLocation getRegionLocation(Connection connection, byte[] regionName) throws IOException { byte[] row = regionName; RegionInfo parsedInfo = null; try { parsedInfo = parseRegionInfoFromRegionName(regionName); row = getMetaKeyForRegion(parsedInfo); } catch (Exception parseEx) { // Ignore. This is used with tableName passed as regionName. } Get get = new Get(row); get.addFamily(HConstants.CATALOG_FAMILY); Result r = get(getMetaHTable(connection), get); RegionLocations locations = getRegionLocations(r); return locations == null ? null : locations.getRegionLocation(parsedInfo == null ? 0 : parsedInfo.getReplicaId()); }
/** * Returns the HRegionLocation from meta for the given region * @param metaTable * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static CompletableFuture<Optional<HRegionLocation>> getRegionLocation( AsyncTable<?> metaTable, byte[] regionName) { CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>(); try { RegionInfo parsedRegionInfo = MetaTableAccessor.parseRegionInfoFromRegionName(regionName); metaTable.get( new Get(MetaTableAccessor.getMetaKeyForRegion(parsedRegionInfo)) .addFamily(HConstants.CATALOG_FAMILY)).whenComplete( (r, err) -> { if (err != null) { future.completeExceptionally(err); return; } future.complete(getRegionLocations(r).map( locations -> locations.getRegionLocation(parsedRegionInfo.getReplicaId()))); }); } catch (IOException parseEx) { LOG.warn("Failed to parse the passed region name: " + Bytes.toStringBinary(regionName)); future.completeExceptionally(parseEx); } return future; }
/** * Returns the HRegionLocation from meta for the given region * @param connection connection we're using * @param regionName region we're looking for * @return HRegionLocation for the given region */ public static HRegionLocation getRegionLocation(Connection connection, byte[] regionName) throws IOException { byte[] row = regionName; RegionInfo parsedInfo = null; try { parsedInfo = parseRegionInfoFromRegionName(regionName); row = getMetaKeyForRegion(parsedInfo); } catch (Exception parseEx) { // Ignore. This is used with tableName passed as regionName. } Get get = new Get(row); get.addFamily(HConstants.CATALOG_FAMILY); Result r = get(getMetaHTable(connection), get); RegionLocations locations = getRegionLocations(r); return locations == null ? null : locations.getRegionLocation(parsedInfo == null ? 0 : parsedInfo.getReplicaId()); }
/** * Returns the HRegionLocation from meta for the given region * @param connection connection we're using * @param regionName region we're looking for * @return HRegionLocation for the given region * @throws IOException */ public static HRegionLocation getRegionLocation(Connection connection, byte[] regionName) throws IOException { byte[] row = regionName; HRegionInfo parsedInfo = null; try { parsedInfo = parseRegionInfoFromRegionName(regionName); row = getMetaKeyForRegion(parsedInfo); } catch (Exception parseEx) { // Ignore. This is used with tableName passed as regionName. } Get get = new Get(row); get.addFamily(HConstants.CATALOG_FAMILY); Result r = get(getMetaHTable(connection), get); RegionLocations locations = getRegionLocations(r); return locations == null ? null : locations.getRegionLocation(parsedInfo == null ? 0 : parsedInfo.getReplicaId()); }