@Override public RegionLocations locateRegion(final TableName tableName, final byte[] row, boolean useCache, boolean retry) throws IOException { return locateRegion(tableName, row, useCache, retry, RegionReplicaUtil.DEFAULT_REPLICA_ID); }
@Override public HRegionLocation getRegionLocation(final TableName tableName, final byte[] row, boolean reload) throws IOException { return reload ? relocateRegion(tableName, row) : locateRegion(tableName, row); }
@Override public HRegionLocation locateRegion(final TableName tableName, final byte[] row) throws IOException { RegionLocations locations = locateRegion(tableName, row, true, true); return locations == null ? null : locations.getRegionLocation(); }
@Override public List<HRegionLocation> getRegionLocations(byte[] row, boolean reload) throws IOException { RegionLocations locs = connection.locateRegion(tableName, row, !reload, true, RegionInfo.DEFAULT_REPLICA_ID); return Arrays.asList(locs.getRegionLocations()); }
@Override public HRegionLocation getRegionLocation(byte[] row, int replicaId, boolean reload) throws IOException { return connection.locateRegion(tableName, row, !reload, true, replicaId) .getRegionLocation(replicaId); }
private List<RegionLocations> listRegionLocations() throws IOException { if (TableName.isMetaTableName(tableName)) { return Collections .singletonList(connection.locateRegion(tableName, HConstants.EMPTY_START_ROW, false, true)); } final List<RegionLocations> regions = new ArrayList<>(); MetaTableAccessor.Visitor visitor = new MetaTableAccessor.TableVisitorBase(tableName) { @Override public boolean visitInternal(Result result) throws IOException { RegionLocations locations = MetaTableAccessor.getRegionLocations(result); if (locations == null) { return true; } regions.add(locations); return true; } }; MetaTableAccessor.scanMetaForTableRegions(connection, visitor, tableName); return regions; } }
@Override public HRegionLocation locateRegion(final byte[] regionName) throws IOException { RegionLocations locations = locateRegion(RegionInfo.getTable(regionName), RegionInfo.getStartKey(regionName), false, true); return locations == null ? null : locations.getRegionLocation(); }
@Override public List<HRegionLocation> locateRegions(TableName tableName, boolean useCache, boolean offlined) throws IOException { List<RegionInfo> regions; if (TableName.isMetaTableName(tableName)) { regions = Collections.singletonList(RegionInfoBuilder.FIRST_META_REGIONINFO); } else { regions = MetaTableAccessor.getTableRegions(this, tableName, !offlined); } List<HRegionLocation> locations = new ArrayList<>(); for (RegionInfo regionInfo : regions) { if (!RegionReplicaUtil.isDefaultReplica(regionInfo)) { continue; } RegionLocations list = locateRegion(tableName, regionInfo.getStartKey(), useCache, true); if (list != null) { for (HRegionLocation loc : list.getRegionLocations()) { if (loc != null) { locations.add(loc); } } } } return locations; }
@Override public RegionLocations relocateRegion(final TableName tableName, final byte [] row, int replicaId) throws IOException{ // Since this is an explicit request not to use any caching, finding // disabled tables should not be desirable. This will ensure that an exception is thrown when // the first time a disabled table is interacted with. if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } return locateRegion(tableName, row, false, true, replicaId); }
(byte[]) Mockito.any(), Mockito.anyBoolean())). thenReturn(loc); Mockito.when(c.locateRegion((TableName) Mockito.any(), (byte[]) Mockito.any())). thenReturn(loc); Mockito.when(c.locateRegion((TableName) Mockito.any(), (byte[]) Mockito.any(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyInt())) .thenReturn(new RegionLocations(loc));
@Override public RegionLocations locateRegion(final TableName tableName, final byte[] row, boolean useCache, boolean retry) throws IOException { return locateRegion(tableName, row, useCache, retry, RegionReplicaUtil.DEFAULT_REPLICA_ID); }
@Override public HRegionLocation getRegionLocation(final TableName tableName, final byte[] row, boolean reload) throws IOException { return reload ? relocateRegion(tableName, row) : locateRegion(tableName, row); }
@Override public HRegionLocation locateRegion(final TableName tableName, final byte[] row) throws IOException { RegionLocations locations = locateRegion(tableName, row, true, true); return locations == null ? null : locations.getRegionLocation(); }
@Override public HRegionLocation locateRegion(final byte[] regionName) throws IOException { RegionLocations locations = locateRegion(RegionInfo.getTable(regionName), RegionInfo.getStartKey(regionName), false, true); return locations == null ? null : locations.getRegionLocation(); }
@Override public RegionLocations relocateRegion(final TableName tableName, final byte [] row, int replicaId) throws IOException{ // Since this is an explicit request not to use any caching, finding // disabled tables should not be desirable. This will ensure that an exception is thrown when // the first time a disabled table is interacted with. if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } return locateRegion(tableName, row, false, true, replicaId); }
@Override public List<HRegionLocation> locateRegions(TableName tableName, boolean useCache, boolean offlined) throws IOException { List<RegionInfo> regions; if (TableName.isMetaTableName(tableName)) { regions = Collections.singletonList(RegionInfoBuilder.FIRST_META_REGIONINFO); } else { regions = MetaTableAccessor.getTableRegions(this, tableName, !offlined); } List<HRegionLocation> locations = new ArrayList<>(); for (RegionInfo regionInfo : regions) { if (!RegionReplicaUtil.isDefaultReplica(regionInfo)) { continue; } RegionLocations list = locateRegion(tableName, regionInfo.getStartKey(), useCache, true); if (list != null) { for (HRegionLocation loc : list.getRegionLocations()) { if (loc != null) { locations.add(loc); } } } } return locations; }
@Override public RegionLocations locateRegion(final TableName tableName, final byte[] row, boolean useCache, boolean retry) throws IOException { return locateRegion(tableName, row, useCache, retry, RegionReplicaUtil.DEFAULT_REPLICA_ID); }
@Override public HRegionLocation getRegionLocation(final TableName tableName, final byte[] row, boolean reload) throws IOException { return reload ? relocateRegion(tableName, row) : locateRegion(tableName, row); }
@Override public HRegionLocation locateRegion(final TableName tableName, final byte[] row) throws IOException { RegionLocations locations = locateRegion(tableName, row, true, true); return locations == null ? null : locations.getRegionLocation(); }
@Override public RegionLocations relocateRegion(final TableName tableName, final byte [] row, int replicaId) throws IOException{ // Since this is an explicit request not to use any caching, finding // disabled tables should not be desirable. This will ensure that an exception is thrown when // the first time a disabled table is interacted with. if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } return locateRegion(tableName, row, false, true, replicaId); }