Skip to content

Commit b054fa2

Browse files
committed
HBASE-22275 Removed deprecated getRegionInfo in HRegionLocation
1 parent 0e79e70 commit b054fa2

File tree

77 files changed

+299
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+299
-309
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.hadoop.hbase;
2020

21-
import org.apache.hadoop.hbase.client.ImmutableHRegionInfo;
2221
import org.apache.hadoop.hbase.client.RegionInfo;
2322
import org.apache.hadoop.hbase.util.Addressing;
2423
import org.apache.yetus.audience.InterfaceAudience;
@@ -86,16 +85,6 @@ public int hashCode() {
8685
return this.serverName.hashCode();
8786
}
8887

89-
/**
90-
*
91-
* @return Immutable HRegionInfo
92-
* @deprecated Since 2.0.0. Will remove in 3.0.0. Use {@link #getRegion()}} instead.
93-
*/
94-
@Deprecated
95-
public HRegionInfo getRegionInfo(){
96-
return regionInfo == null ? null : new ImmutableHRegionInfo(regionInfo);
97-
}
98-
9988
/**
10089
* @return regionInfo
10190
*/

hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public boolean visitInternal(Result result) throws IOException {
169169
if (locations == null) return true;
170170
for (HRegionLocation loc : locations.getRegionLocations()) {
171171
if (loc != null) {
172-
RegionInfo regionInfo = loc.getRegionInfo();
172+
RegionInfo regionInfo = loc.getRegion();
173173
regions.put(regionInfo, loc.getServerName());
174174
}
175175
}
@@ -295,7 +295,7 @@ public static Pair<RegionInfo, ServerName> getRegion(Connection connection, byte
295295
HRegionLocation location = getRegionLocation(connection, regionName);
296296
return location == null
297297
? null
298-
: new Pair<>(location.getRegionInfo(), location.getServerName());
298+
: new Pair<>(location.getRegion(), location.getServerName());
299299
}
300300

301301
/**

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private <CResult> AsyncRequestFuture submit(AsyncProcessTask<CResult> task,
307307
setNonce(ng, r, action);
308308
retainedActions.add(action);
309309
// TODO: replica-get is not supported on this path
310-
byte[] regionName = loc.getRegionInfo().getRegionName();
310+
byte[] regionName = loc.getRegion().getRegionName();
311311
addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
312312
it.remove();
313313
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void addReplicaActions(int index, Map<ServerName, MultiAction> actionsBy
154154
for (int i = 1; i < locs.length; ++i) {
155155
Action replicaAction = new Action(action, i);
156156
if (locs[i] != null) {
157-
asyncProcess.addAction(locs[i].getServerName(), locs[i].getRegionInfo().getRegionName(),
157+
asyncProcess.addAction(locs[i].getServerName(), locs[i].getRegion().getRegionName(),
158158
replicaAction, actionsByServer, nonceGroup);
159159
} else {
160160
unknownReplicaActions.add(replicaAction);
@@ -169,7 +169,7 @@ private void addReplicaActionsAgain(
169169
}
170170
HRegionLocation loc = getReplicaLocationOrFail(action);
171171
if (loc == null) return;
172-
asyncProcess.addAction(loc.getServerName(), loc.getRegionInfo().getRegionName(),
172+
asyncProcess.addAction(loc.getServerName(), loc.getRegion().getRegionName(),
173173
action, actionsByServer, nonceGroup);
174174
}
175175
}
@@ -437,7 +437,7 @@ void groupAndSendMultiAction(List<Action> currentActions, int numAttempt) {
437437
manageLocationError(action, null);
438438
}
439439
} else {
440-
byte[] regionName = loc.getRegionInfo().getRegionName();
440+
byte[] regionName = loc.getRegion().getRegionName();
441441
AsyncProcess.addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
442442
}
443443
}
@@ -455,7 +455,7 @@ void groupAndSendMultiAction(List<Action> currentActions, int numAttempt) {
455455
for (Action action : unknownReplicaActions) {
456456
HRegionLocation loc = getReplicaLocationOrFail(action);
457457
if (loc == null) continue;
458-
byte[] regionName = loc.getRegionInfo().getRegionName();
458+
byte[] regionName = loc.getRegion().getRegionName();
459459
AsyncProcess.addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);
460460
}
461461
if (!actionsByServer.isEmpty()) {

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.hadoop.conf.Configuration;
3131
import org.apache.hadoop.hbase.DoNotRetryIOException;
3232
import org.apache.hadoop.hbase.HConstants;
33-
import org.apache.hadoop.hbase.HRegionInfo;
3433
import org.apache.hadoop.hbase.NotServingRegionException;
3534
import org.apache.hadoop.hbase.TableName;
3635
import org.apache.hadoop.hbase.UnknownScannerException;
@@ -60,7 +59,7 @@ public abstract class ClientScanner extends AbstractClientScanner {
6059
protected boolean closed = false;
6160
// Current region scanner is against. Gets cleared if current region goes
6261
// wonky: e.g. if it splits on us.
63-
protected HRegionInfo currentRegion = null;
62+
protected RegionInfo currentRegion = null;
6463
protected ScannerCallableWithReplicas callable = null;
6564
protected Queue<Result> cache;
6665
private final ScanResultCache scanResultCache;
@@ -262,7 +261,7 @@ private Result[] call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Re
262261
// we do a callWithRetries
263262
Result[] rrs = caller.callWithoutRetries(callable, scannerTimeout);
264263
if (currentRegion == null && updateCurrentRegion) {
265-
currentRegion = callable.getHRegionInfo();
264+
currentRegion = callable.getRegionInfo();
266265
}
267266
return rrs;
268267
}
@@ -411,7 +410,7 @@ protected void loadCache() throws IOException {
411410
// Any accumulated partial results are no longer valid since the callable will
412411
// openScanner with the correct startkey and we must pick up from there
413412
scanResultCache.clear();
414-
this.currentRegion = callable.getHRegionInfo();
413+
this.currentRegion = callable.getRegionInfo();
415414
}
416415
retryAfterOutOfOrderException.setValue(true);
417416
} catch (DoNotRetryIOException e) {

hbase-client/src/main/java/org/apache/hadoop/hbase/client/FlushRegionCallable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public void prepare(boolean reload) throws IOException {
6767
protected FlushRegionResponse call(HBaseRpcController controller) throws Exception {
6868
// Check whether we should still do the flush to this region. If the regions are changed due
6969
// to splits or merges, etc return success
70-
if (!Bytes.equals(location.getRegionInfo().getRegionName(), regionName)) {
70+
if (!Bytes.equals(location.getRegion().getRegionName(), regionName)) {
7171
if (!reload) {
7272
throw new IOException("Cached location seems to be different than requested region.");
7373
}
7474
LOG.info("Skipping flush region, because the located region "
75-
+ Bytes.toStringBinary(location.getRegionInfo().getRegionName()) + " is different than "
75+
+ Bytes.toStringBinary(location.getRegion().getRegionName()) + " is different than "
7676
+ " requested region " + Bytes.toStringBinary(regionName));
7777
return FlushRegionResponse.newBuilder()
7878
.setLastFlushTime(EnvironmentEdgeManager.currentTime())

hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
272272
HRegionLocation regionLocation = getRegionLocator().getRegionLocation(currentKey, reload);
273273
keysInRange.add(currentKey);
274274
regionsInRange.add(regionLocation);
275-
currentKey = regionLocation.getRegionInfo().getEndKey();
275+
currentKey = regionLocation.getRegion().getEndKey();
276276
} while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
277277
&& (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0
278278
|| (includeEndKey && Bytes.compareTo(currentKey, endKey) == 0)));
@@ -362,7 +362,7 @@ private Result get(Get get, final boolean checkExistenceOnly) throws IOException
362362
@Override
363363
protected Result rpcCall() throws Exception {
364364
ClientProtos.GetRequest request = RequestConverter.buildGetRequest(
365-
getLocation().getRegionInfo().getRegionName(), configuredGet);
365+
getLocation().getRegion().getRegionName(), configuredGet);
366366
ClientProtos.GetResponse response = doGet(request);
367367
return response == null? null:
368368
ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
@@ -479,7 +479,7 @@ public void delete(final Delete delete) throws IOException {
479479
@Override
480480
protected Void rpcCall() throws Exception {
481481
MutateRequest request = RequestConverter
482-
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), delete);
482+
.buildMutateRequest(getLocation().getRegion().getRegionName(), delete);
483483
doMutate(request);
484484
return null;
485485
}
@@ -519,7 +519,7 @@ public void put(final Put put) throws IOException {
519519
@Override
520520
protected Void rpcCall() throws Exception {
521521
MutateRequest request =
522-
RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), put);
522+
RequestConverter.buildMutateRequest(getLocation().getRegion().getRegionName(), put);
523523
doMutate(request);
524524
return null;
525525
}
@@ -550,7 +550,7 @@ public void mutateRow(final RowMutations rm) throws IOException {
550550
@Override
551551
protected MultiResponse rpcCall() throws Exception {
552552
RegionAction.Builder regionMutationBuilder = RequestConverter.buildRegionAction(
553-
getLocation().getRegionInfo().getRegionName(), rm);
553+
getLocation().getRegion().getRegionName(), rm);
554554
regionMutationBuilder.setAtomic(true);
555555
MultiRequest request =
556556
MultiRequest.newBuilder().addRegionAction(regionMutationBuilder.build()).build();
@@ -591,7 +591,7 @@ public Result append(final Append append) throws IOException {
591591
@Override
592592
protected Result rpcCall() throws Exception {
593593
MutateRequest request = RequestConverter.buildMutateRequest(
594-
getLocation().getRegionInfo().getRegionName(), append, getNonceGroup(), getNonce());
594+
getLocation().getRegion().getRegionName(), append, getNonceGroup(), getNonce());
595595
MutateResponse response = doMutate(request);
596596
if (!response.hasResult()) return null;
597597
return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
@@ -610,7 +610,7 @@ public Result increment(final Increment increment) throws IOException {
610610
@Override
611611
protected Result rpcCall() throws Exception {
612612
MutateRequest request = RequestConverter.buildMutateRequest(
613-
getLocation().getRegionInfo().getRegionName(), increment, getNonceGroup(), getNonce());
613+
getLocation().getRegion().getRegionName(), increment, getNonceGroup(), getNonce());
614614
MutateResponse response = doMutate(request);
615615
// Should this check for null like append does?
616616
return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
@@ -648,7 +648,7 @@ public long incrementColumnValue(final byte [] row, final byte [] family,
648648
@Override
649649
protected Long rpcCall() throws Exception {
650650
MutateRequest request = RequestConverter.buildIncrementRequest(
651-
getLocation().getRegionInfo().getRegionName(), row, family,
651+
getLocation().getRegion().getRegionName(), row, family,
652652
qualifier, amount, durability, getNonceGroup(), getNonce());
653653
MutateResponse response = doMutate(request);
654654
Result result = ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
@@ -685,7 +685,7 @@ private boolean doCheckAndPut(final byte[] row, final byte[] family, final byte[
685685
protected Boolean rpcCall() throws Exception {
686686
CompareType compareType = CompareType.valueOf(opName);
687687
MutateRequest request = RequestConverter.buildMutateRequest(
688-
getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
688+
getLocation().getRegion().getRegionName(), row, family, qualifier,
689689
new BinaryComparator(value), compareType, timeRange, put);
690690
MutateResponse response = doMutate(request);
691691
return Boolean.valueOf(response.getProcessed());
@@ -721,7 +721,7 @@ private boolean doCheckAndDelete(final byte[] row, final byte[] family, final by
721721
protected SingleResponse rpcCall() throws Exception {
722722
CompareType compareType = CompareType.valueOf(opName);
723723
MutateRequest request = RequestConverter
724-
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family,
724+
.buildMutateRequest(getLocation().getRegion().getRegionName(), row, family,
725725
qualifier, new BinaryComparator(value), compareType, timeRange, delete);
726726
MutateResponse response = doMutate(request);
727727
return ResponseConverter.getResult(request, response, getRpcControllerCellScanner());
@@ -760,7 +760,7 @@ private boolean doCheckAndMutate(final byte[] row, final byte[] family, final by
760760
protected MultiResponse rpcCall() throws Exception {
761761
CompareType compareType = CompareType.valueOf(opName);
762762
MultiRequest request = RequestConverter
763-
.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
763+
.buildMutateRequest(getLocation().getRegion().getRegionName(), row, family, qualifier,
764764
new BinaryComparator(value), compareType, timeRange, rm);
765765
ClientProtos.MultiResponse response = doMulti(request);
766766
ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0);
@@ -1097,7 +1097,7 @@ public <R extends Message> void batchCoprocessorService(
10971097
final Map<byte[], RegionCoprocessorServiceExec> execsByRow = new TreeMap<>(Bytes.BYTES_COMPARATOR);
10981098
for (int i = 0; i < keys.size(); i++) {
10991099
final byte[] rowKey = keys.get(i);
1100-
final byte[] region = regions.get(i).getRegionInfo().getRegionName();
1100+
final byte[] region = regions.get(i).getRegion().getRegionName();
11011101
RegionCoprocessorServiceExec exec =
11021102
new RegionCoprocessorServiceExec(region, rowKey, methodDescriptor, request);
11031103
execs.add(exec);

hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.hadoop.hbase.CellScannable;
2727
import org.apache.hadoop.hbase.CellUtil;
2828
import org.apache.hadoop.hbase.DoNotRetryIOException;
29-
import org.apache.hadoop.hbase.HRegionInfo;
3029
import org.apache.hadoop.hbase.HRegionLocation;
3130
import org.apache.hadoop.hbase.ServerName;
3231
import org.apache.hadoop.hbase.TableName;
@@ -76,7 +75,7 @@ protected HRegionLocation getLocation() {
7675
}
7776

7877
@Override
79-
public HRegionInfo getHRegionInfo() {
78+
public RegionInfo getRegionInfo() {
8079
throw new RuntimeException("Cannot get region info for multi-region request");
8180
}
8281

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionAdminServiceCallable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public HRegionLocation getLocation(boolean useCache) throws IOException {
110110
@Override
111111
public void throwable(Throwable t, boolean retrying) {
112112
if (location != null) {
113-
connection.updateCachedLocations(tableName, location.getRegionInfo().getRegionName(), row,
113+
connection.updateCachedLocations(tableName, location.getRegion().getRegionName(), row,
114114
t, location.getServerName());
115115
}
116116
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionCoprocessorRpcChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected Message callExecService(final RpcController controller,
8181
this.table, this.row, this.conn.getRpcControllerFactory().newController(), HConstants.PRIORITY_UNSET) {
8282
@Override
8383
protected CoprocessorServiceResponse rpcCall() throws Exception {
84-
byte [] regionName = getLocation().getRegionInfo().getRegionName();
84+
byte [] regionName = getLocation().getRegion().getRegionName();
8585
CoprocessorServiceRequest csr =
8686
CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
8787
return getStub().execService(getRpcController(), csr);

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionCoprocessorRpcChannelImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message requ
7272
ClientService.Interface stub) {
7373
CompletableFuture<Message> future = new CompletableFuture<>();
7474
if (region != null
75-
&& !Bytes.equals(loc.getRegionInfo().getRegionName(), region.getRegionName())) {
75+
&& !Bytes.equals(loc.getRegion().getRegionName(), region.getRegionName())) {
7676
future.completeExceptionally(new DoNotRetryIOException(
7777
"Region name is changed, expected " + region.getRegionNameAsString() + ", actual "
78-
+ loc.getRegionInfo().getRegionNameAsString()));
78+
+ loc.getRegion().getRegionNameAsString()));
7979
return future;
8080
}
8181
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method,
82-
request, row, loc.getRegionInfo().getRegionName());
82+
request, row, loc.getRegion().getRegionName());
8383
stub.execService(controller, csr,
8484
new org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback<CoprocessorServiceResponse>() {
8585

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.apache.hadoop.hbase.CellScanner;
2424
import org.apache.hadoop.hbase.HConstants;
25-
import org.apache.hadoop.hbase.HRegionInfo;
2625
import org.apache.hadoop.hbase.HRegionLocation;
2726
import org.apache.hadoop.hbase.ServerName;
2827
import org.apache.hadoop.hbase.TableName;
@@ -187,7 +186,7 @@ public TableName getTableName() {
187186
@Override
188187
public void throwable(Throwable t, boolean retrying) {
189188
if (location != null) {
190-
getConnection().updateCachedLocations(tableName, location.getRegionInfo().getRegionName(),
189+
getConnection().updateCachedLocations(tableName, location.getRegion().getRegionName(),
191190
row, t, location.getServerName());
192191
}
193192
}
@@ -203,13 +202,13 @@ public long sleep(long pause, int tries) {
203202
}
204203

205204
/**
206-
* @return the HRegionInfo for the current region
205+
* @return the RegionInfo for the current region
207206
*/
208-
public HRegionInfo getHRegionInfo() {
207+
public RegionInfo getRegionInfo() {
209208
if (this.location == null) {
210209
return null;
211210
}
212-
return this.location.getRegionInfo();
211+
return this.location.getRegion();
213212
}
214213

215214
@Override

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultStatsUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static <T> T updateStats(T r, ServerStatisticTracker stats,
7171
ServerName server = null;
7272
if (regionLocation != null) {
7373
server = regionLocation.getServerName();
74-
regionName = regionLocation.getRegionInfo().getRegionName();
74+
regionName = regionLocation.getRegion().getRegionName();
7575
}
7676

7777
return updateStats(r, stats, server, regionName);

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ReversedScannerCallable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ private List<HRegionLocation> locateRegionsInRange(byte[] startKey,
143143
RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload, id,
144144
getConnection(), getTableName(), currentKey);
145145
HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null;
146-
if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) {
146+
if (regionLocation != null && regionLocation.getRegion().containsRow(currentKey)) {
147147
regionList.add(regionLocation);
148148
} else {
149149
throw new DoNotRetryIOException("Does hbase:meta exist hole? Locating row "
150150
+ Bytes.toStringBinary(currentKey) + " returns incorrect region "
151-
+ (regionLocation == null ? null : regionLocation.getRegionInfo()));
151+
+ (regionLocation == null ? null : regionLocation.getRegion()));
152152
}
153-
currentKey = regionLocation.getRegionInfo().getEndKey();
153+
currentKey = regionLocation.getRegion().getEndKey();
154154
} while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
155155
&& (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0));
156156
return regionList;

hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected Result rpcCall() throws Exception {
138138
if (Thread.interrupted()) {
139139
throw new InterruptedIOException();
140140
}
141-
byte[] reg = location.getRegionInfo().getRegionName();
141+
byte[] reg = location.getRegion().getRegionName();
142142
ClientProtos.GetRequest request = RequestConverter.buildGetRequest(reg, get);
143143
HBaseRpcController hrc = (HBaseRpcController)getRpcController();
144144
hrc.reset();

0 commit comments

Comments
 (0)