Skip to content

Commit 29f51c0

Browse files
authored
HBASE-27203 Clean up error-prone findings in hbase-client [branch-2] (#4651)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
1 parent 5f231d3 commit 29f51c0

File tree

180 files changed

+1193
-1081
lines changed

Some content is hidden

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

180 files changed

+1193
-1081
lines changed

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

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?
101101
return future;
102102
}
103103

104-
/**
105-
* Returns the HRegionLocation from meta for the given region n * @param regionName region we're
106-
* looking for
107-
* @return HRegionLocation for the given region
108-
*/
104+
/** Returns the HRegionLocation from meta for the given region */
109105
public static CompletableFuture<Optional<HRegionLocation>>
110106
getRegionLocation(AsyncTable<?> metaTable, byte[] regionName) {
111107
CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>();
@@ -127,11 +123,7 @@ public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?
127123
return future;
128124
}
129125

130-
/**
131-
* Returns the HRegionLocation from meta for the given encoded region name n * @param
132-
* encodedRegionName region we're looking for
133-
* @return HRegionLocation for the given region
134-
*/
126+
/** Returns the HRegionLocation from meta for the given encoded region name */
135127
public static CompletableFuture<Optional<HRegionLocation>>
136128
getRegionLocationWithEncodedName(AsyncTable<?> metaTable, byte[] encodedRegionName) {
137129
CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>();
@@ -176,8 +168,9 @@ private static Optional<TableState> getTableState(Result r) throws IOException {
176168
}
177169

178170
/**
179-
* Used to get all region locations for the specific table. n * @param tableName table we're
180-
* looking for, can be null for getting all regions
171+
* Used to get all region locations for the specific table
172+
* @param metaTable scanner over meta table
173+
* @param tableName table we're looking for, can be null for getting all regions
181174
* @return the list of region locations. The return value will be wrapped by a
182175
* {@link CompletableFuture}.
183176
*/
@@ -200,8 +193,9 @@ public static CompletableFuture<List<HRegionLocation>> getTableHRegionLocations(
200193
}
201194

202195
/**
203-
* Used to get table regions' info and server. n * @param tableName table we're looking for, can
204-
* be null for getting all regions
196+
* Used to get table regions' info and server.
197+
* @param metaTable scanner over meta table
198+
* @param tableName table we're looking for, can be null for getting all regions
205199
* @param excludeOfflinedSplitParents don't return split parents
206200
* @return the list of regioninfos and server. The return value will be wrapped by a
207201
* {@link CompletableFuture}.
@@ -259,9 +253,11 @@ void add(Result r) {
259253
}
260254

261255
/**
262-
* Performs a scan of META table for given table. n * @param tableName table withing we scan
263-
* @param type scanned part of meta
264-
* @param visitor Visitor invoked against each row
256+
* Performs a scan of META table for given table.
257+
* @param metaTable scanner over meta table
258+
* @param tableName table within we scan
259+
* @param type scanned part of meta
260+
* @param visitor Visitor invoked against each row
265261
*/
266262
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable,
267263
TableName tableName, QueryType type, final Visitor visitor) {
@@ -270,11 +266,13 @@ private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultCon
270266
}
271267

272268
/**
273-
* Performs a scan of META table for given table. n * @param startRow Where to start the scan
274-
* @param stopRow Where to stop the scan
275-
* @param type scanned part of meta
276-
* @param maxRows maximum rows to return
277-
* @param visitor Visitor invoked against each row
269+
* Performs a scan of META table for given table.
270+
* @param metaTable scanner over meta table
271+
* @param startRow Where to start the scan
272+
* @param stopRow Where to stop the scan
273+
* @param type scanned part of meta
274+
* @param maxRows maximum rows to return
275+
* @param visitor Visitor invoked against each row
278276
*/
279277
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable,
280278
byte[] startRow, byte[] stopRow, QueryType type, int maxRows, final Visitor visitor) {
@@ -410,25 +408,32 @@ private static Scan getMetaScan(AsyncTable<?> metaTable, int rowUpperLimit) {
410408
* can't deserialize the result.
411409
*/
412410
private static Optional<RegionLocations> getRegionLocations(final Result r) {
413-
if (r == null) return Optional.empty();
411+
if (r == null) {
412+
return Optional.empty();
413+
}
414414
Optional<RegionInfo> regionInfo = getHRegionInfo(r, getRegionInfoColumn());
415-
if (!regionInfo.isPresent()) return Optional.empty();
415+
if (!regionInfo.isPresent()) {
416+
return Optional.empty();
417+
}
416418

417419
List<HRegionLocation> locations = new ArrayList<HRegionLocation>(1);
418420
NavigableMap<byte[], NavigableMap<byte[], byte[]>> familyMap = r.getNoVersionMap();
419421

420422
locations.add(getRegionLocation(r, regionInfo.get(), 0));
421423

422424
NavigableMap<byte[], byte[]> infoMap = familyMap.get(getCatalogFamily());
423-
if (infoMap == null) return Optional.of(new RegionLocations(locations));
425+
if (infoMap == null) {
426+
return Optional.of(new RegionLocations(locations));
427+
}
424428

425429
// iterate until all serverName columns are seen
426430
int replicaId = 0;
427431
byte[] serverColumn = getServerColumn(replicaId);
428-
SortedMap<byte[], byte[]> serverMap = null;
429-
serverMap = infoMap.tailMap(serverColumn, false);
432+
SortedMap<byte[], byte[]> serverMap = infoMap.tailMap(serverColumn, false);
430433

431-
if (serverMap.isEmpty()) return Optional.of(new RegionLocations(locations));
434+
if (serverMap.isEmpty()) {
435+
return Optional.of(new RegionLocations(locations));
436+
}
432437

433438
for (Map.Entry<byte[], byte[]> entry : serverMap.entrySet()) {
434439
replicaId = parseReplicaIdFromServerColumn(entry.getKey());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public byte[] toByteArray() {
5151
}
5252

5353
/**
54+
* Parse the serialized representation of the {@link ClusterId}
5455
* @param bytes A pb serialized {@link ClusterId} instance with pb magic prefix
5556
* @return An instance of {@link ClusterId} made from <code>bytes</code> n * @see #toByteArray()
5657
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public static ClusterStatusProtos.ClusterStatus toClusterStatus(ClusterMetrics m
6767
.collect(Collectors.toList()))
6868
.addAllTableRegionStatesCount(metrics.getTableRegionStatesCount().entrySet().stream()
6969
.map(status -> ClusterStatusProtos.TableRegionStatesCount.newBuilder()
70-
.setTableName(ProtobufUtil.toProtoTableName((status.getKey())))
70+
.setTableName(ProtobufUtil.toProtoTableName(status.getKey()))
7171
.setRegionStatesCount(ProtobufUtil.toTableRegionStatesCount(status.getValue())).build())
7272
.collect(Collectors.toList()));
7373
if (metrics.getMasterName() != null) {
74-
builder.setMaster(ProtobufUtil.toServerName((metrics.getMasterName())));
74+
builder.setMaster(ProtobufUtil.toServerName(metrics.getMasterName()));
7575
}
7676
if (metrics.getMasterTasks() != null) {
7777
builder.addAllMasterTasks(metrics.getMasterTasks().stream()

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public List<RegionState> getRegionStatesInTransition() {
186186
}
187187

188188
/** Returns the HBase version string as reported by the HMaster */
189+
@Override
189190
public String getHBaseVersion() {
190191
return metrics.getHBaseVersion();
191192
}
@@ -279,6 +280,7 @@ public ServerLoad getLoad(final ServerName sn) {
279280
return serverMetrics == null ? null : new ServerLoad(serverMetrics);
280281
}
281282

283+
@Override
282284
public String getClusterId() {
283285
return metrics.getClusterId();
284286
}
@@ -289,6 +291,7 @@ public List<String> getMasterCoprocessorNames() {
289291
}
290292

291293
/**
294+
* Get the list of master coprocessor names.
292295
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 Use
293296
* {@link #getMasterCoprocessorNames} instead.
294297
*/
@@ -299,6 +302,7 @@ public String[] getMasterCoprocessors() {
299302
}
300303

301304
/**
305+
* Get the last major compaction time for a given table.
302306
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 Use
303307
* {@link #getLastMajorCompactionTimestamp(TableName)} instead.
304308
*/
@@ -308,6 +312,7 @@ public long getLastMajorCompactionTsForTable(TableName table) {
308312
}
309313

310314
/**
315+
* Get the last major compaction time for a given region.
311316
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 Use
312317
* {@link #getLastMajorCompactionTimestamp(byte[])} instead.
313318
*/
@@ -317,6 +322,7 @@ public long getLastMajorCompactionTsForRegion(final byte[] region) {
317322
}
318323

319324
/**
325+
* Returns true if the balancer is enabled.
320326
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 No flag in 2.0
321327
*/
322328
@Deprecated

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public interface CoprocessorEnvironment<C extends Coprocessor> {
4444
int getLoadSequence();
4545

4646
/**
47-
* @return a Read-only Configuration; throws {@link UnsupportedOperationException} if you try to
48-
* set a configuration.
47+
* Returns a Read-only Configuration; throws {@link UnsupportedOperationException} if you try to
48+
* set a configuration.
4949
*/
5050
Configuration getConfiguration();
5151

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ public HBaseServerException(boolean serverOverloaded, String message) {
4444
this.serverOverloaded = serverOverloaded;
4545
}
4646

47-
/**
48-
* @param t throwable to check for server overloaded state
49-
* @return True if the server was considered overloaded when the exception was thrown
50-
*/
47+
/** Returns True if the server was considered overloaded when the exception was thrown */
5148
public static boolean isServerOverloaded(Throwable t) {
5249
if (t instanceof HBaseServerException) {
5350
return ((HBaseServerException) t).isServerOverloaded();

0 commit comments

Comments
 (0)