Skip to content

Commit d2454fb

Browse files
committed
HBASE-27203 Clean up error-prone findings in hbase-client
1 parent 31fc97e commit d2454fb

File tree

141 files changed

+881
-825
lines changed

Some content is hidden

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

141 files changed

+881
-825
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ public static TableState getTableState(Result r) throws IOException {
349349
}
350350

351351
/**
352-
* @return Deserialized values of <qualifier,regioninfo> pairs taken from column values that
353-
* match the regex 'info:merge.*' in array of <code>cells</code>.
352+
* Returns Deserialized values of &lt;qualifier,regioninfo&gt; pairs taken from column values that
353+
* match the regex 'info:merge.*' in array of <code>cells</code>.
354354
*/
355355
@Nullable
356356
public static Map<String, RegionInfo> getMergeRegionsWithName(Cell[] cells) {
@@ -376,8 +376,8 @@ public static Map<String, RegionInfo> getMergeRegionsWithName(Cell[] cells) {
376376
}
377377

378378
/**
379-
* @return Deserialized regioninfo values taken from column values that match the regex
380-
* 'info:merge.*' in array of <code>cells</code>.
379+
* Returns Deserialized regioninfo values taken from column values that match the regex
380+
* 'info:merge.*' in array of <code>cells</code>.
381381
*/
382382
@Nullable
383383
public static List<RegionInfo> getMergeRegions(Cell[] cells) {
@@ -386,8 +386,8 @@ public static List<RegionInfo> getMergeRegions(Cell[] cells) {
386386
}
387387

388388
/**
389-
* @return True if any merge regions present in <code>cells</code>; i.e. the column in
390-
* <code>cell</code> matches the regex 'info:merge.*'.
389+
* Returns True if any merge regions present in <code>cells</code>; i.e. the column in
390+
* <code>cell</code> matches the regex 'info:merge.*'.
391391
*/
392392
public static boolean hasMergeRegions(Cell[] cells) {
393393
for (Cell cell : cells) {

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

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private ClientMetaTableAccessor() {
5959
}
6060

6161
@InterfaceAudience.Private
62+
@SuppressWarnings("ImmutableEnumChecker")
6263
public enum QueryType {
6364
ALL(HConstants.TABLE_FAMILY, HConstants.CATALOG_FAMILY),
6465
REGION(HConstants.CATALOG_FAMILY),
@@ -100,11 +101,7 @@ public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?
100101
return future;
101102
}
102103

103-
/**
104-
* Returns the HRegionLocation from meta for the given region n * @param regionName region we're
105-
* looking for
106-
* @return HRegionLocation for the given region
107-
*/
104+
/** Returns the HRegionLocation from meta for the given region */
108105
public static CompletableFuture<Optional<HRegionLocation>>
109106
getRegionLocation(AsyncTable<?> metaTable, byte[] regionName) {
110107
CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>();
@@ -126,11 +123,7 @@ public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?
126123
return future;
127124
}
128125

129-
/**
130-
* Returns the HRegionLocation from meta for the given encoded region name n * @param
131-
* encodedRegionName region we're looking for
132-
* @return HRegionLocation for the given region
133-
*/
126+
/** Returns the HRegionLocation from meta for the given encoded region name */
134127
public static CompletableFuture<Optional<HRegionLocation>>
135128
getRegionLocationWithEncodedName(AsyncTable<?> metaTable, byte[] encodedRegionName) {
136129
CompletableFuture<Optional<HRegionLocation>> future = new CompletableFuture<>();
@@ -167,8 +160,9 @@ private static Optional<TableState> getTableState(Result r) throws IOException {
167160
}
168161

169162
/**
170-
* Used to get all region locations for the specific table. n * @param tableName table we're
171-
* looking for, can be null for getting all regions
163+
* Used to get all region locations for the specific table
164+
* @param metaTable scanner over meta table
165+
* @param tableName table we're looking for, can be null for getting all regions
172166
* @return the list of region locations. The return value will be wrapped by a
173167
* {@link CompletableFuture}.
174168
*/
@@ -191,8 +185,9 @@ public static CompletableFuture<List<HRegionLocation>> getTableHRegionLocations(
191185
}
192186

193187
/**
194-
* Used to get table regions' info and server. n * @param tableName table we're looking for, can
195-
* be null for getting all regions
188+
* Used to get table regions' info and server.
189+
* @param metaTable scanner over meta table
190+
* @param tableName table we're looking for, can be null for getting all regions
196191
* @param excludeOfflinedSplitParents don't return split parents
197192
* @return the list of regioninfos and server. The return value will be wrapped by a
198193
* {@link CompletableFuture}.
@@ -221,9 +216,11 @@ private static CompletableFuture<List<Pair<RegionInfo, ServerName>>> getTableReg
221216
}
222217

223218
/**
224-
* Performs a scan of META table for given table. n * @param tableName table withing we scan
225-
* @param type scanned part of meta
226-
* @param visitor Visitor invoked against each row
219+
* Performs a scan of META table for given table.
220+
* @param metaTable scanner over meta table
221+
* @param tableName table within we scan
222+
* @param type scanned part of meta
223+
* @param visitor Visitor invoked against each row
227224
*/
228225
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable,
229226
TableName tableName, QueryType type, final Visitor visitor) {
@@ -232,11 +229,13 @@ private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultCon
232229
}
233230

234231
/**
235-
* Performs a scan of META table for given table. n * @param startRow Where to start the scan
236-
* @param stopRow Where to stop the scan
237-
* @param type scanned part of meta
238-
* @param maxRows maximum rows to return
239-
* @param visitor Visitor invoked against each row
232+
* Performs a scan of META table for given table.
233+
* @param metaTable scanner over meta table
234+
* @param startRow Where to start the scan
235+
* @param stopRow Where to stop the scan
236+
* @param type scanned part of meta
237+
* @param maxRows maximum rows to return
238+
* @param visitor Visitor invoked against each row
240239
*/
241240
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable,
242241
byte[] startRow, byte[] stopRow, QueryType type, int maxRows, final Visitor visitor) {
@@ -456,19 +455,12 @@ private static Scan getMetaScan(AsyncTable<?> metaTable, int rowUpperLimit) {
456455
return scan;
457456
}
458457

459-
/**
460-
* Returns an HRegionLocationList extracted from the result.
461-
* @return an HRegionLocationList containing all locations for the region range or null if we
462-
* can't deserialize the result.
463-
*/
458+
/** Returns an HRegionLocationList extracted from the result. */
464459
private static Optional<RegionLocations> getRegionLocations(Result r) {
465460
return Optional.ofNullable(CatalogFamilyFormat.getRegionLocations(r));
466461
}
467462

468-
/**
469-
* @param tableName table we're working with
470-
* @return start row for scanning META according to query type
471-
*/
463+
/** Returns start row for scanning META according to query type */
472464
public static byte[] getTableStartRowForMeta(TableName tableName, QueryType type) {
473465
if (tableName == null) {
474466
return null;
@@ -490,10 +482,7 @@ public static byte[] getTableStartRowForMeta(TableName tableName, QueryType type
490482
}
491483
}
492484

493-
/**
494-
* @param tableName table we're working with
495-
* @return stop row for scanning META according to query type
496-
*/
485+
/** Returns stop row for scanning META according to query type */
497486
public static byte[] getTableStopRowForMeta(TableName tableName, QueryType type) {
498487
if (tableName == null) {
499488
return null;

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,13 +67,13 @@ 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
.addAllDecommissionedServers(metrics.getDecommissionedServerNames().stream()
7474
.map(ProtobufUtil::toServerName).collect(Collectors.toList()));
7575
if (metrics.getMasterName() != null) {
76-
builder.setMaster(ProtobufUtil.toServerName((metrics.getMasterName())));
76+
builder.setMaster(ProtobufUtil.toServerName(metrics.getMasterName()));
7777
}
7878
if (metrics.getMasterTasks() != null) {
7979
builder.addAllMasterTasks(metrics.getMasterTasks().stream()

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();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public long getSeqNum() {
100100
}
101101

102102
/**
103-
* @return String made of hostname and port formatted as per
104-
* {@link Addressing#createHostAndPortStr(String, int)}
103+
* Returns String made of hostname and port formatted as per
104+
* {@link Addressing#createHostAndPortStr(String, int)}
105105
*/
106106
public String getHostnamePort() {
107107
return Addressing.createHostAndPortStr(this.getHostname(), this.getPort());

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public RegionLocations removeElementsWithNullLocation() {
208208
* @param other the locations to merge with
209209
* @return an RegionLocations object with merged locations or the same object if nothing is merged
210210
*/
211+
@SuppressWarnings("ReferenceEquality")
211212
public RegionLocations mergeLocations(RegionLocations other) {
212213
assert other != null;
213214

@@ -280,6 +281,7 @@ private HRegionLocation selectRegionLocation(HRegionLocation oldLocation,
280281
* @return an RegionLocations object with updated locations or the same object if nothing is
281282
* updated
282283
*/
284+
@SuppressWarnings("ReferenceEquality")
283285
public RegionLocations updateLocation(HRegionLocation location, boolean checkForEquals,
284286
boolean force) {
285287
assert location != null;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public interface RegionMetrics {
5353
public long getCpRequestCount();
5454

5555
/**
56-
* @return the number of write requests and read requests and coprocessor service requests made to
57-
* region
56+
* Returns the number of write requests and read requests and coprocessor service requests made to
57+
* region
5858
*/
5959
default long getRequestCount() {
6060
return getReadRequestCount() + getWriteRequestCount() + getCpRequestCount();
@@ -113,8 +113,8 @@ default String getNameAsString() {
113113
int getStoreRefCount();
114114

115115
/**
116-
* @return the max reference count for any store file among all compacted stores files of this
117-
* region
116+
* Returns the max reference count for any store file among all compacted stores files of this
117+
* region
118118
*/
119119
int getMaxCompactedStoreFileRefCount();
120120

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
@InterfaceAudience.Private
4545
public final class ServerMetricsBuilder {
4646

47-
/**
48-
* @param sn the server name
49-
* @return a empty metrics
50-
*/
5147
public static ServerMetrics of(ServerName sn) {
5248
return newBuilder(sn).build();
5349
}
@@ -300,6 +296,7 @@ public int getVersionNumber() {
300296
return versionNumber;
301297
}
302298

299+
@Override
303300
public String getVersion() {
304301
return version;
305302
}
@@ -414,16 +411,18 @@ public String toString() {
414411
int currentMaxCompactedStoreFileRefCount = r.getMaxCompactedStoreFileRefCount();
415412
maxCompactedStoreFileRefCount =
416413
Math.max(maxCompactedStoreFileRefCount, currentMaxCompactedStoreFileRefCount);
417-
uncompressedStoreFileSizeMB += r.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
418-
storeFileSizeMB += r.getStoreFileSize().get(Size.Unit.MEGABYTE);
419-
memStoreSizeMB += r.getMemStoreSize().get(Size.Unit.MEGABYTE);
420-
storefileIndexSizeKB += r.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
414+
uncompressedStoreFileSizeMB +=
415+
(long) r.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
416+
storeFileSizeMB += (long) r.getStoreFileSize().get(Size.Unit.MEGABYTE);
417+
memStoreSizeMB += (long) r.getMemStoreSize().get(Size.Unit.MEGABYTE);
418+
storefileIndexSizeKB +=
419+
(long) r.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
421420
readRequestsCount += r.getReadRequestCount();
422421
cpRequestsCount += r.getCpRequestCount();
423422
writeRequestsCount += r.getWriteRequestCount();
424423
filteredReadRequestsCount += r.getFilteredReadRequestCount();
425-
rootLevelIndexSizeKB += r.getStoreFileRootLevelIndexSize().get(Size.Unit.KILOBYTE);
426-
bloomFilterSizeMB += r.getBloomFilterSize().get(Size.Unit.MEGABYTE);
424+
rootLevelIndexSizeKB += (long) r.getStoreFileRootLevelIndexSize().get(Size.Unit.KILOBYTE);
425+
bloomFilterSizeMB += (long) r.getBloomFilterSize().get(Size.Unit.MEGABYTE);
427426
compactedCellCount += r.getCompactedCellCount();
428427
compactingCellCount += r.getCompactingCellCount();
429428
}

0 commit comments

Comments
 (0)