@Override protected void clearCache(TableName tableName) throws IOException { CONN.getRegionLocator(tableName).clearRegionLocationCache(); } }
@Override protected byte[][] getStartKeys(TableName tableName) throws IOException { return get(CONN.getRegionLocator(tableName).getStartKeys()).toArray(new byte[0][]); }
@Override protected byte[][] getEndKeys(TableName tableName) throws IOException { return get(CONN.getRegionLocator(tableName).getEndKeys()).toArray(new byte[0][]); }
@Override protected HRegionLocation getRegionLocation(TableName tableName, byte[] row, int replicaId) throws IOException { return get(CONN.getRegionLocator(tableName).getRegionLocation(row, replicaId)); }
@Override protected List<HRegionLocation> getRegionLocations(TableName tableName, byte[] row) throws IOException { return get(CONN.getRegionLocator(tableName).getRegionLocations(row)); }
@Override protected List<HRegionLocation> getAllRegionLocations(TableName tableName) throws IOException { return get(CONN.getRegionLocator(tableName).getAllRegionLocations()); }
@Override protected Pair<byte[][], byte[][]> getStartEndKeys(TableName tableName) throws IOException { List<Pair<byte[], byte[]>> startEndKeys = get(CONN.getRegionLocator(tableName).getStartEndKeys()); byte[][] startKeys = new byte[startEndKeys.size()][]; byte[][] endKeys = new byte[startEndKeys.size()][]; for (int i = 0, n = startEndKeys.size(); i < n; i++) { Pair<byte[], byte[]> pair = startEndKeys.get(i); startKeys[i] = pair.getFirst(); endKeys[i] = pair.getSecond(); } return Pair.newPair(startKeys, endKeys); }
byte[] regionName = ASYNC_CONN.getRegionLocator(tableName) .getRegionLocation(Bytes.toBytes("row1")).get().getRegion().getRegionName(); Optional<Long> ts1 = admin.getLastMajorCompactionTimestampForRegion(regionName).get();
@Test public void testGetRegionLocation() throws Exception { RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin(); TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY); AsyncTableRegionLocator locator = ASYNC_CONN.getRegionLocator(tableName); HRegionLocation regionLocation = locator.getRegionLocation(Bytes.toBytes("mmm")).get(); RegionInfo region = regionLocation.getRegion(); byte[] regionName = regionLocation.getRegion().getRegionName(); HRegionLocation location = rawAdmin.getRegionLocation(regionName).get(); assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName())); location = rawAdmin.getRegionLocation(region.getEncodedNameAsBytes()).get(); assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName())); }
try (AsyncConnection asyncConn = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get()) { assertEquals(expected, asyncConn.getRegionLocator(tableName) .getRegionLocation(Bytes.toBytes(1), true).get().getServerName());
byte[] regionName = ASYNC_CONN.getRegionLocator(tableName) .getRegionLocation(Bytes.toBytes("row1")).get().getRegion().getRegionName(); Optional<Long> ts1 = admin.getLastMajorCompactionTimestampForRegion(regionName).get();
@Test public void testGetRegionLocation() throws Exception { RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin(); TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY); AsyncTableRegionLocator locator = ASYNC_CONN.getRegionLocator(tableName); HRegionLocation regionLocation = locator.getRegionLocation(Bytes.toBytes("mmm")).get(); RegionInfo region = regionLocation.getRegion(); byte[] regionName = regionLocation.getRegion().getRegionName(); HRegionLocation location = rawAdmin.getRegionLocation(regionName).get(); assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName())); location = rawAdmin.getRegionLocation(region.getEncodedNameAsBytes()).get(); assertTrue(Bytes.equals(regionName, location.getRegion().getRegionName())); }
try (AsyncConnection asyncConn = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get()) { assertEquals(expected, asyncConn.getRegionLocator(tableName) .getRegionLocation(Bytes.toBytes(1), true).get().getServerName());