Skip to content

Commit

Permalink
HBASE-19498 Fix findbugs and error-prone warnings in hbase-client (br…
Browse files Browse the repository at this point in the history
…anch-2)

Signed-off-by: Michael Stack <stack@apache.org>
Signed-off-by: Apekshit Sharma <appy@apache.org>
  • Loading branch information
petersomogyi authored and saintstack committed Dec 15, 2017
1 parent 20b42d2 commit 59529a7
Show file tree
Hide file tree
Showing 96 changed files with 617 additions and 361 deletions.
Expand Up @@ -185,7 +185,7 @@ public int getRegionsCount() {
int count = 0;
if (liveServers != null && !liveServers.isEmpty()) {
for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) {
count += e.getValue().getNumberOfRegions();
count = count + e.getValue().getNumberOfRegions();
}
}
return count;
Expand Down Expand Up @@ -217,9 +217,7 @@ public String getHBaseVersion() {
return hbaseVersion;
}

/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
Expand All @@ -238,16 +236,13 @@ public boolean equals(Object o) {
getMasterInfoPort() == other.getMasterInfoPort();
}

/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return Objects.hashCode(hbaseVersion, liveServers, deadServers, master, backupMasters,
clusterId, masterInfoPort);
}

/**
*
* @return the object version number
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
*/
Expand Down Expand Up @@ -352,6 +347,7 @@ public int getMasterInfoPort() {
return masterInfoPort;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder(1024);
sb.append("Master: " + master);
Expand Down
Expand Up @@ -428,6 +428,7 @@ public HColumnDescriptor setKeepDeletedCells(KeepDeletedCells value) {
* will mask a later Put with lower ts. Set this to true to enable new semantics of versions.
* We will also consider mvcc in versions. See HBASE-15968 for details.
*/
@Override
public boolean isNewVersionBehavior() {
return delegatee.isNewVersionBehavior();
}
Expand Down
Expand Up @@ -120,6 +120,7 @@ public static String encodeRegionName(final byte [] regionName) {
/**
* @return Return a short, printable name for this region (usually encoded name) for us logging.
*/
@Override
public String getShortNameToLog() {
return prettyPrint(this.getEncodedName());
}
Expand Down Expand Up @@ -189,7 +190,7 @@ public static String prettyPrint(final String encodedRegionName) {

private void setHashCode() {
int result = Arrays.hashCode(this.regionName);
result ^= this.regionId;
result = (int) (result ^ this.regionId);
result ^= Arrays.hashCode(this.startKey);
result ^= Arrays.hashCode(this.endKey);
result ^= Boolean.valueOf(this.offLine).hashCode();
Expand Down Expand Up @@ -473,6 +474,7 @@ public static boolean isEncodedRegionName(byte[] regionName) throws IOException
}

/** @return the regionId */
@Override
public long getRegionId(){
return regionId;
}
Expand All @@ -481,13 +483,15 @@ public long getRegionId(){
* @return the regionName as an array of bytes.
* @see #getRegionNameAsString()
*/
@Override
public byte [] getRegionName(){
return regionName;
}

/**
* @return Region name as a String for use in logging, etc.
*/
@Override
public String getRegionNameAsString() {
if (RegionInfo.hasEncodedName(this.regionName)) {
// new format region names already have their encoded name.
Expand All @@ -500,27 +504,37 @@ public String getRegionNameAsString() {
return Bytes.toStringBinary(this.regionName) + "." + this.getEncodedName();
}

/** @return the encoded region name */
/**
* @return the encoded region name
*/
@Override
public synchronized String getEncodedName() {
if (this.encodedName == null) {
this.encodedName = RegionInfo.encodeRegionName(this.regionName);
}
return this.encodedName;
}

@Override
public synchronized byte [] getEncodedNameAsBytes() {
if (this.encodedNameAsBytes == null) {
this.encodedNameAsBytes = Bytes.toBytes(getEncodedName());
}
return this.encodedNameAsBytes;
}

/** @return the startKey */
/**
* @return the startKey
*/
@Override
public byte [] getStartKey(){
return startKey;
}

/** @return the endKey */
/**
* @return the endKey
*/
@Override
public byte [] getEndKey(){
return endKey;
}
Expand All @@ -529,6 +543,7 @@ public synchronized String getEncodedName() {
* Get current table name of the region
* @return TableName
*/
@Override
public TableName getTable() {
// This method name should be getTableName but there was already a method getTableName
// that returned a byte array. It is unfortunate given everywhere else, getTableName returns
Expand All @@ -546,6 +561,7 @@ public TableName getTable() {
* ["b","z"] it will return false.
* @throws IllegalArgumentException if the range passed is invalid (ie. end &lt; start)
*/
@Override
public boolean containsRange(byte[] rangeStartKey, byte[] rangeEndKey) {
if (Bytes.compareTo(rangeStartKey, rangeEndKey) > 0) {
throw new IllegalArgumentException(
Expand All @@ -561,8 +577,9 @@ public boolean containsRange(byte[] rangeStartKey, byte[] rangeEndKey) {
}

/**
* Return true if the given row falls in this region.
* @return true if the given row falls in this region.
*/
@Override
public boolean containsRow(byte[] row) {
return Bytes.compareTo(row, startKey) >= 0 &&
(Bytes.compareTo(row, endKey) < 0 ||
Expand All @@ -576,7 +593,10 @@ public boolean isMetaTable() {
return isMetaRegion();
}

/** @return true if this region is a meta region */
/**
* @return true if this region is a meta region
*/
@Override
public boolean isMetaRegion() {
return tableName.equals(HRegionInfo.FIRST_META_REGIONINFO.getTable());
}
Expand All @@ -589,8 +609,9 @@ public boolean isSystemTable() {
}

/**
* @return True if has been split and has daughters.
* @return true if has been split and has daughters.
*/
@Override
public boolean isSplit() {
return this.split;
}
Expand All @@ -603,8 +624,9 @@ public void setSplit(boolean split) {
}

/**
* @return True if this region is offline.
* @return true if this region is offline.
*/
@Override
public boolean isOffline() {
return this.offLine;
}
Expand All @@ -619,8 +641,9 @@ public void setOffline(boolean offLine) {
}

/**
* @return True if this is a split parent region.
* @return true if this is a split parent region.
*/
@Override
public boolean isSplitParent() {
if (!isSplit()) return false;
if (!isOffline()) {
Expand All @@ -633,6 +656,7 @@ public boolean isSplitParent() {
* Returns the region replica id
* @return returns region replica id
*/
@Override
public int getReplicaId() {
return replicaId;
}
Expand Down
Expand Up @@ -26,7 +26,7 @@
*/
@InterfaceAudience.Public
public class InvalidFamilyOperationException extends DoNotRetryIOException {
private static final long serialVersionUID = 1L << 22 - 1L;
private static final long serialVersionUID = (1L << 22) - 1L;
/** default constructor */
public InvalidFamilyOperationException() {
super();
Expand Down
Expand Up @@ -27,7 +27,7 @@
*/
@InterfaceAudience.Public
public class MasterNotRunningException extends IOException {
private static final long serialVersionUID = 1L << 23 - 1L;
private static final long serialVersionUID = (1L << 23) - 1L;
/** default constructor */
public MasterNotRunningException() {
super();
Expand Down
Expand Up @@ -29,7 +29,7 @@
*/
@InterfaceAudience.Public
public class NotServingRegionException extends IOException {
private static final long serialVersionUID = 1L << 17 - 1L;
private static final long serialVersionUID = (1L << 17) - 1L;

/** default constructor */
public NotServingRegionException() {
Expand Down
Expand Up @@ -21,9 +21,9 @@
import java.util.Collection;

import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;

/**
* Container for holding a list of {@link HRegionLocation}'s that correspond to the
Expand Down
Expand Up @@ -25,7 +25,7 @@
*/
@InterfaceAudience.Public
public class TableExistsException extends DoNotRetryIOException {
private static final long serialVersionUID = 1L << 7 - 1L;
private static final long serialVersionUID = (1L << 7) - 1L;
/** default constructor */
public TableExistsException() {
super();
Expand Down
Expand Up @@ -26,7 +26,7 @@
*/
@InterfaceAudience.Public
public class TableNotDisabledException extends DoNotRetryIOException {
private static final long serialVersionUID = 1L << 19 - 1L;
private static final long serialVersionUID = (1L << 19) - 1L;
/** default constructor */
public TableNotDisabledException() {
super();
Expand Down
Expand Up @@ -27,7 +27,7 @@
*/
@InterfaceAudience.Public
public class ZooKeeperConnectionException extends IOException {
private static final long serialVersionUID = 1L << 23 - 1L;
private static final long serialVersionUID = (1L << 23) - 1L;
/** default constructor */
public ZooKeeperConnectionException() {
super();
Expand Down
Expand Up @@ -86,6 +86,7 @@ protected long extraHeapSize(){
* A client that is not interested in the result can save network
* bandwidth setting this to false.
*/
@Override
public Append setReturnResults(boolean returnResults) {
super.setReturnResults(returnResults);
return this;
Expand All @@ -95,6 +96,7 @@ public Append setReturnResults(boolean returnResults) {
* @return current setting for returnResults
*/
// This method makes public the superclasses's protected method.
@Override
public boolean isReturnResults() {
return super.isReturnResults();
}
Expand Down
Expand Up @@ -70,6 +70,7 @@ protected void doCall() {
});
}

@Override
CompletableFuture<T> call() {
doCall();
return future;
Expand Down
Expand Up @@ -67,6 +67,7 @@ protected void doCall() {
});
}

@Override
public CompletableFuture<T> call() {
doCall();
return future;
Expand Down
Expand Up @@ -153,7 +153,7 @@ public void waitUntilDone() throws InterruptedIOException {
final long pauseForCQTBE;// pause for CallQueueTooBigException, if specified
final int numTries;
@VisibleForTesting
int serverTrackerTimeout;
long serverTrackerTimeout;
final long primaryCallTimeoutMicroseconds;
/** Whether to log details for batch errors */
final boolean logBatchErrorDetails;
Expand Down Expand Up @@ -204,9 +204,9 @@ public void waitUntilDone() throws InterruptedIOException {
// If we keep hitting one server, the net effect will be the incremental backoff, and
// essentially the same number of retries as planned. If we have to do faster retries,
// we will do more retries in aggregate, but the user will be none the wiser.
this.serverTrackerTimeout = 0;
this.serverTrackerTimeout = 0L;
for (int i = 0; i < this.numTries; ++i) {
serverTrackerTimeout += ConnectionUtils.getPauseTime(this.pause, i);
serverTrackerTimeout = serverTrackerTimeout + ConnectionUtils.getPauseTime(this.pause, i);
}

this.rpcCallerFactory = rpcCaller;
Expand Down
Expand Up @@ -72,6 +72,7 @@ protected void doCall() {
});
}

@Override
CompletableFuture<T> call() {
doCall();
return future;
Expand Down
Expand Up @@ -151,6 +151,7 @@ public BufferedMutatorParams listener(BufferedMutator.ExceptionListener listener
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="CN_IDIOM_NO_SUPER_CALL",
justification="The clone below is complete")
@Override
public BufferedMutatorParams clone() {
BufferedMutatorParams clone = new BufferedMutatorParams(this.tableName);
clone.writeBufferSize = this.writeBufferSize;
Expand Down
Expand Up @@ -895,6 +895,7 @@ public ModifyableColumnFamilyDescriptor setKeepDeletedCells(KeepDeletedCells kee
* will mask a later Put with lower ts. Set this to true to enable new semantics of versions.
* We will also consider mvcc in versions. See HBASE-15968 for details.
*/
@Override
public boolean isNewVersionBehavior() {
return getStringOrDefault(NEW_VERSION_BEHAVIOR_BYTES,
Boolean::parseBoolean, DEFAULT_NEW_VERSION_BEHAVIOR);
Expand Down
Expand Up @@ -107,6 +107,7 @@ public void setTries(int tries) {
this.tries = tries;
}

@Override
public void clear() {
server = null;
fInfo = null;
Expand All @@ -117,10 +118,12 @@ public void clear() {
tries = 0;
}

@Override
public FastFailInterceptorContext prepare(RetryingCallable<?> callable) {
return prepare(callable, 0);
}

@Override
public FastFailInterceptorContext prepare(RetryingCallable<?> callable, int tries) {
if (callable instanceof RegionServerCallable) {
RegionServerCallable<?, ?> retryingCallable = (RegionServerCallable<?, ?>) callable;
Expand Down
Expand Up @@ -296,6 +296,7 @@ public Get readVersions(int versions) throws IOException {
return this;
}

@Override
public Get setLoadColumnFamiliesOnDemand(boolean value) {
return (Get) super.setLoadColumnFamiliesOnDemand(value);
}
Expand Down

0 comments on commit 59529a7

Please sign in to comment.