Skip to content

Commit

Permalink
HBASE-22275 Removed deprecated getRegionInfo in HRegionLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
HorizonNet committed May 3, 2019
1 parent 3f40df8 commit 1d3fb6f
Show file tree
Hide file tree
Showing 77 changed files with 301 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.hadoop.hbase;

import org.apache.hadoop.hbase.client.ImmutableHRegionInfo;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.yetus.audience.InterfaceAudience;
Expand Down Expand Up @@ -86,16 +85,6 @@ public int hashCode() {
return this.serverName.hashCode();
}

/**
*
* @return Immutable HRegionInfo
* @deprecated Since 2.0.0. Will remove in 3.0.0. Use {@link #getRegion()}} instead.
*/
@Deprecated
public HRegionInfo getRegionInfo(){
return regionInfo == null ? null : new ImmutableHRegionInfo(regionInfo);
}

/**
* @return regionInfo
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public boolean visitInternal(Result result) throws IOException {
if (locations == null) return true;
for (HRegionLocation loc : locations.getRegionLocations()) {
if (loc != null) {
RegionInfo regionInfo = loc.getRegionInfo();
RegionInfo regionInfo = loc.getRegion();
regions.put(regionInfo, loc.getServerName());
}
}
Expand Down Expand Up @@ -295,7 +295,7 @@ public static Pair<RegionInfo, ServerName> getRegion(Connection connection, byte
HRegionLocation location = getRegionLocation(connection, regionName);
return location == null
? null
: new Pair<>(location.getRegionInfo(), location.getServerName());
: new Pair<>(location.getRegion(), location.getServerName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private <CResult> AsyncRequestFuture submit(AsyncProcessTask<CResult> task,
setNonce(ng, r, action);
retainedActions.add(action);
// TODO: replica-get is not supported on this path
byte[] regionName = loc.getRegionInfo().getRegionName();
byte[] regionName = loc.getRegion().getRegionName();
addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
it.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void addReplicaActions(int index, Map<ServerName, MultiAction> actionsBy
for (int i = 1; i < locs.length; ++i) {
Action replicaAction = new Action(action, i);
if (locs[i] != null) {
asyncProcess.addAction(locs[i].getServerName(), locs[i].getRegionInfo().getRegionName(),
asyncProcess.addAction(locs[i].getServerName(), locs[i].getRegion().getRegionName(),
replicaAction, actionsByServer, nonceGroup);
} else {
unknownReplicaActions.add(replicaAction);
Expand All @@ -169,7 +169,7 @@ private void addReplicaActionsAgain(
}
HRegionLocation loc = getReplicaLocationOrFail(action);
if (loc == null) return;
asyncProcess.addAction(loc.getServerName(), loc.getRegionInfo().getRegionName(),
asyncProcess.addAction(loc.getServerName(), loc.getRegion().getRegionName(),
action, actionsByServer, nonceGroup);
}
}
Expand Down Expand Up @@ -437,7 +437,7 @@ void groupAndSendMultiAction(List<Action> currentActions, int numAttempt) {
manageLocationError(action, null);
}
} else {
byte[] regionName = loc.getRegionInfo().getRegionName();
byte[] regionName = loc.getRegion().getRegionName();
AsyncProcess.addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
}
}
Expand All @@ -455,7 +455,7 @@ void groupAndSendMultiAction(List<Action> currentActions, int numAttempt) {
for (Action action : unknownReplicaActions) {
HRegionLocation loc = getReplicaLocationOrFail(action);
if (loc == null) continue;
byte[] regionName = loc.getRegionInfo().getRegionName();
byte[] regionName = loc.getRegion().getRegionName();
AsyncProcess.addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
}
if (!actionsByServer.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.UnknownScannerException;
Expand Down Expand Up @@ -60,7 +59,7 @@ public abstract class ClientScanner extends AbstractClientScanner {
protected boolean closed = false;
// Current region scanner is against. Gets cleared if current region goes
// wonky: e.g. if it splits on us.
protected HRegionInfo currentRegion = null;
protected RegionInfo currentRegion = null;
protected ScannerCallableWithReplicas callable = null;
protected Queue<Result> cache;
private final ScanResultCache scanResultCache;
Expand Down Expand Up @@ -262,7 +261,7 @@ private Result[] call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Re
// we do a callWithRetries
Result[] rrs = caller.callWithoutRetries(callable, scannerTimeout);
if (currentRegion == null && updateCurrentRegion) {
currentRegion = callable.getHRegionInfo();
currentRegion = callable.getRegionInfo();
}
return rrs;
}
Expand Down Expand Up @@ -411,7 +410,7 @@ protected void loadCache() throws IOException {
// Any accumulated partial results are no longer valid since the callable will
// openScanner with the correct startkey and we must pick up from there
scanResultCache.clear();
this.currentRegion = callable.getHRegionInfo();
this.currentRegion = callable.getRegionInfo();
}
retryAfterOutOfOrderException.setValue(true);
} catch (DoNotRetryIOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public void prepare(boolean reload) throws IOException {
protected FlushRegionResponse call(HBaseRpcController controller) throws Exception {
// Check whether we should still do the flush to this region. If the regions are changed due
// to splits or merges, etc return success
if (!Bytes.equals(location.getRegionInfo().getRegionName(), regionName)) {
if (!Bytes.equals(location.getRegion().getRegionName(), regionName)) {
if (!reload) {
throw new IOException("Cached location seems to be different than requested region.");
}
LOG.info("Skipping flush region, because the located region "
+ Bytes.toStringBinary(location.getRegionInfo().getRegionName()) + " is different than "
+ Bytes.toStringBinary(location.getRegion().getRegionName()) + " is different than "
+ " requested region " + Bytes.toStringBinary(regionName));
return FlushRegionResponse.newBuilder()
.setLastFlushTime(EnvironmentEdgeManager.currentTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
HRegionLocation regionLocation = getRegionLocator().getRegionLocation(currentKey, reload);
keysInRange.add(currentKey);
regionsInRange.add(regionLocation);
currentKey = regionLocation.getRegionInfo().getEndKey();
currentKey = regionLocation.getRegion().getEndKey();
} while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
&& (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0
|| (includeEndKey && Bytes.compareTo(currentKey, endKey) == 0)));
Expand Down Expand Up @@ -362,7 +362,7 @@ private Result get(Get get, final boolean checkExistenceOnly) throws IOException
@Override
protected Result rpcCall() throws Exception {
ClientProtos.GetRequest request = RequestConverter.buildGetRequest(
getLocation().getRegionInfo().getRegionName(), configuredGet);
getLocation().getRegion().getRegionName(), configuredGet);
ClientProtos.GetResponse response = doGet(request);
return response == null? null:
ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
Expand Down Expand Up @@ -479,7 +479,7 @@ public void delete(final Delete delete) throws IOException {
@Override
protected Void rpcCall() throws Exception {
MutateRequest request = RequestConverter
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), delete);
.buildMutateRequest(getLocation().getRegion().getRegionName(), delete);
doMutate(request);
return null;
}
Expand Down Expand Up @@ -519,7 +519,7 @@ public void put(final Put put) throws IOException {
@Override
protected Void rpcCall() throws Exception {
MutateRequest request =
RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), put);
RequestConverter.buildMutateRequest(getLocation().getRegion().getRegionName(), put);
doMutate(request);
return null;
}
Expand Down Expand Up @@ -550,7 +550,7 @@ public void mutateRow(final RowMutations rm) throws IOException {
@Override
protected MultiResponse rpcCall() throws Exception {
RegionAction.Builder regionMutationBuilder = RequestConverter.buildRegionAction(
getLocation().getRegionInfo().getRegionName(), rm);
getLocation().getRegion().getRegionName(), rm);
regionMutationBuilder.setAtomic(true);
MultiRequest request =
MultiRequest.newBuilder().addRegionAction(regionMutationBuilder.build()).build();
Expand Down Expand Up @@ -591,7 +591,7 @@ public Result append(final Append append) throws IOException {
@Override
protected Result rpcCall() throws Exception {
MutateRequest request = RequestConverter.buildMutateRequest(
getLocation().getRegionInfo().getRegionName(), append, getNonceGroup(), getNonce());
getLocation().getRegion().getRegionName(), append, getNonceGroup(), getNonce());
MutateResponse response = doMutate(request);
if (!response.hasResult()) return null;
return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
Expand All @@ -610,7 +610,7 @@ public Result increment(final Increment increment) throws IOException {
@Override
protected Result rpcCall() throws Exception {
MutateRequest request = RequestConverter.buildMutateRequest(
getLocation().getRegionInfo().getRegionName(), increment, getNonceGroup(), getNonce());
getLocation().getRegion().getRegionName(), increment, getNonceGroup(), getNonce());
MutateResponse response = doMutate(request);
// Should this check for null like append does?
return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
Expand Down Expand Up @@ -648,7 +648,7 @@ public long incrementColumnValue(final byte [] row, final byte [] family,
@Override
protected Long rpcCall() throws Exception {
MutateRequest request = RequestConverter.buildIncrementRequest(
getLocation().getRegionInfo().getRegionName(), row, family,
getLocation().getRegion().getRegionName(), row, family,
qualifier, amount, durability, getNonceGroup(), getNonce());
MutateResponse response = doMutate(request);
Result result = ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
Expand Down Expand Up @@ -685,7 +685,7 @@ private boolean doCheckAndPut(final byte[] row, final byte[] family, final byte[
protected Boolean rpcCall() throws Exception {
CompareType compareType = CompareType.valueOf(opName);
MutateRequest request = RequestConverter.buildMutateRequest(
getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
getLocation().getRegion().getRegionName(), row, family, qualifier,
new BinaryComparator(value), compareType, timeRange, put);
MutateResponse response = doMutate(request);
return Boolean.valueOf(response.getProcessed());
Expand Down Expand Up @@ -721,7 +721,7 @@ private boolean doCheckAndDelete(final byte[] row, final byte[] family, final by
protected SingleResponse rpcCall() throws Exception {
CompareType compareType = CompareType.valueOf(opName);
MutateRequest request = RequestConverter
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family,
.buildMutateRequest(getLocation().getRegion().getRegionName(), row, family,
qualifier, new BinaryComparator(value), compareType, timeRange, delete);
MutateResponse response = doMutate(request);
return ResponseConverter.getResult(request, response, getRpcControllerCellScanner());
Expand Down Expand Up @@ -760,7 +760,7 @@ private boolean doCheckAndMutate(final byte[] row, final byte[] family, final by
protected MultiResponse rpcCall() throws Exception {
CompareType compareType = CompareType.valueOf(opName);
MultiRequest request = RequestConverter
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
.buildMutateRequest(getLocation().getRegion().getRegionName(), row, family, qualifier,
new BinaryComparator(value), compareType, timeRange, rm);
ClientProtos.MultiResponse response = doMulti(request);
ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0);
Expand Down Expand Up @@ -1097,7 +1097,7 @@ public <R extends Message> void batchCoprocessorService(
final Map<byte[], RegionCoprocessorServiceExec> execsByRow = new TreeMap<>(Bytes.BYTES_COMPARATOR);
for (int i = 0; i < keys.size(); i++) {
final byte[] rowKey = keys.get(i);
final byte[] region = regions.get(i).getRegionInfo().getRegionName();
final byte[] region = regions.get(i).getRegion().getRegionName();
RegionCoprocessorServiceExec exec =
new RegionCoprocessorServiceExec(region, rowKey, methodDescriptor, request);
execs.add(exec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
Expand Down Expand Up @@ -76,7 +75,7 @@ protected HRegionLocation getLocation() {
}

@Override
public HRegionInfo getHRegionInfo() {
public RegionInfo getRegionInfo() {
throw new RuntimeException("Cannot get region info for multi-region request");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public HRegionLocation getLocation(boolean useCache) throws IOException {
@Override
public void throwable(Throwable t, boolean retrying) {
if (location != null) {
connection.updateCachedLocations(tableName, location.getRegionInfo().getRegionName(), row,
connection.updateCachedLocations(tableName, location.getRegion().getRegionName(), row,
t, location.getServerName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected Message callExecService(final RpcController controller,
this.table, this.row, this.conn.getRpcControllerFactory().newController(), HConstants.PRIORITY_UNSET) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
byte [] regionName = getLocation().getRegionInfo().getRegionName();
byte [] regionName = getLocation().getRegion().getRegionName();
CoprocessorServiceRequest csr =
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
return getStub().execService(getRpcController(), csr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message requ
ClientService.Interface stub) {
CompletableFuture<Message> future = new CompletableFuture<>();
if (region != null
&& !Bytes.equals(loc.getRegionInfo().getRegionName(), region.getRegionName())) {
&& !Bytes.equals(loc.getRegion().getRegionName(), region.getRegionName())) {
future.completeExceptionally(new DoNotRetryIOException(
"Region name is changed, expected " + region.getRegionNameAsString() + ", actual "
+ loc.getRegionInfo().getRegionNameAsString()));
+ loc.getRegion().getRegionNameAsString()));
return future;
}
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method,
request, row, loc.getRegionInfo().getRegionName());
request, row, loc.getRegion().getRegionName());
stub.execService(controller, csr,
new org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback<CoprocessorServiceResponse>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
Expand Down Expand Up @@ -187,7 +186,7 @@ public TableName getTableName() {
@Override
public void throwable(Throwable t, boolean retrying) {
if (location != null) {
getConnection().updateCachedLocations(tableName, location.getRegionInfo().getRegionName(),
getConnection().updateCachedLocations(tableName, location.getRegion().getRegionName(),
row, t, location.getServerName());
}
}
Expand All @@ -203,13 +202,13 @@ public long sleep(long pause, int tries) {
}

/**
* @return the HRegionInfo for the current region
* @return the RegionInfo for the current region
*/
public HRegionInfo getHRegionInfo() {
public RegionInfo getRegionInfo() {
if (this.location == null) {
return null;
}
return this.location.getRegionInfo();
return this.location.getRegion();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static <T> T updateStats(T r, ServerStatisticTracker stats,
ServerName server = null;
if (regionLocation != null) {
server = regionLocation.getServerName();
regionName = regionLocation.getRegionInfo().getRegionName();
regionName = regionLocation.getRegion().getRegionName();
}

return updateStats(r, stats, server, regionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ private List<HRegionLocation> locateRegionsInRange(byte[] startKey,
RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload, id,
getConnection(), getTableName(), currentKey);
HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null;
if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) {
if (regionLocation != null && regionLocation.getRegion().containsRow(currentKey)) {
regionList.add(regionLocation);
} else {
throw new DoNotRetryIOException("Does hbase:meta exist hole? Locating row "
+ Bytes.toStringBinary(currentKey) + " returns incorrect region "
+ (regionLocation == null ? null : regionLocation.getRegionInfo()));
+ (regionLocation == null ? null : regionLocation.getRegion()));
}
currentKey = regionLocation.getRegionInfo().getEndKey();
currentKey = regionLocation.getRegion().getEndKey();
} while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
&& (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0));
return regionList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected Result rpcCall() throws Exception {
if (Thread.interrupted()) {
throw new InterruptedIOException();
}
byte[] reg = location.getRegionInfo().getRegionName();
byte[] reg = location.getRegion().getRegionName();
ClientProtos.GetRequest request = RequestConverter.buildGetRequest(reg, get);
HBaseRpcController hrc = (HBaseRpcController)getRpcController();
hrc.reset();
Expand Down
Loading

0 comments on commit 1d3fb6f

Please sign in to comment.