HBASE-10011 Fix some findbugs in the client

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1545210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2013-11-25 10:22:30 +00:00
parent 81f21ca409
commit 35cea57fe5
7 changed files with 35 additions and 21 deletions

View File

@ -166,40 +166,40 @@ public class RegionLoad {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores", StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
Integer.valueOf(this.getStores())); this.getStores());
sb = Strings.appendKeyValue(sb, "numberOfStorefiles", sb = Strings.appendKeyValue(sb, "numberOfStorefiles",
Integer.valueOf(this.getStorefiles())); this.getStorefiles());
sb = Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", sb = Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
Integer.valueOf(this.getStoreUncompressedSizeMB())); this.getStoreUncompressedSizeMB());
sb = Strings.appendKeyValue(sb, "storefileSizeMB", sb = Strings.appendKeyValue(sb, "storefileSizeMB",
Integer.valueOf(this.getStorefileSizeMB())); this.getStorefileSizeMB());
if (this.getStoreUncompressedSizeMB() != 0) { if (this.getStoreUncompressedSizeMB() != 0) {
sb = Strings.appendKeyValue(sb, "compressionRatio", sb = Strings.appendKeyValue(sb, "compressionRatio",
String.format("%.4f", (float)this.getStorefileSizeMB()/ String.format("%.4f", (float) this.getStorefileSizeMB() /
(float)this.getStoreUncompressedSizeMB())); (float) this.getStoreUncompressedSizeMB()));
} }
sb = Strings.appendKeyValue(sb, "memstoreSizeMB", sb = Strings.appendKeyValue(sb, "memstoreSizeMB",
Integer.valueOf(this.getMemStoreSizeMB())); this.getMemStoreSizeMB());
sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB", sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB",
Integer.valueOf(this.getStorefileIndexSizeMB())); this.getStorefileIndexSizeMB());
sb = Strings.appendKeyValue(sb, "readRequestsCount", sb = Strings.appendKeyValue(sb, "readRequestsCount",
Long.valueOf(this.getReadRequestsCount())); this.getReadRequestsCount());
sb = Strings.appendKeyValue(sb, "writeRequestsCount", sb = Strings.appendKeyValue(sb, "writeRequestsCount",
Long.valueOf(this.getWriteRequestsCount())); this.getWriteRequestsCount());
sb = Strings.appendKeyValue(sb, "rootIndexSizeKB", sb = Strings.appendKeyValue(sb, "rootIndexSizeKB",
Integer.valueOf(this.getRootIndexSizeKB())); this.getRootIndexSizeKB());
sb = Strings.appendKeyValue(sb, "totalStaticIndexSizeKB", sb = Strings.appendKeyValue(sb, "totalStaticIndexSizeKB",
Integer.valueOf(this.getTotalStaticIndexSizeKB())); this.getTotalStaticIndexSizeKB());
sb = Strings.appendKeyValue(sb, "totalStaticBloomSizeKB", sb = Strings.appendKeyValue(sb, "totalStaticBloomSizeKB",
Integer.valueOf(this.getTotalStaticBloomSizeKB())); this.getTotalStaticBloomSizeKB());
sb = Strings.appendKeyValue(sb, "totalCompactingKVs", sb = Strings.appendKeyValue(sb, "totalCompactingKVs",
Long.valueOf(this.getTotalCompactingKVs())); this.getTotalCompactingKVs());
sb = Strings.appendKeyValue(sb, "currentCompactedKVs", sb = Strings.appendKeyValue(sb, "currentCompactedKVs",
Long.valueOf(this.getCurrentCompactedKVs())); this.getCurrentCompactedKVs());
float compactionProgressPct = Float.NaN; float compactionProgressPct = Float.NaN;
if( this.getTotalCompactingKVs() > 0 ) { if (this.getTotalCompactingKVs() > 0) {
compactionProgressPct = Float.valueOf( compactionProgressPct = ((float) this.getCurrentCompactedKVs() /
this.getCurrentCompactedKVs() / this.getTotalCompactingKVs()); (float) this.getTotalCompactingKVs());
} }
sb = Strings.appendKeyValue(sb, "compactionProgressPct", sb = Strings.appendKeyValue(sb, "compactionProgressPct",
compactionProgressPct); compactionProgressPct);

View File

@ -463,6 +463,8 @@ public class HTableMultiplexer {
} }
@Override @Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings
(value = "REC_CATCH_EXCEPTION", justification = "na")
public void run() { public void run() {
List<PutStatus> processingList = new ArrayList<PutStatus>(); List<PutStatus> processingList = new ArrayList<PutStatus>();
/** /**

View File

@ -125,7 +125,7 @@ public class Result implements CellScannable {
if (exists != null){ if (exists != null){
return new Result(null, exists); return new Result(null, exists);
} }
return new Result(cells.toArray(new Cell[cells.size()]), exists); return new Result(cells.toArray(new Cell[cells.size()]), null);
} }
/** /**

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.client;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -97,6 +98,11 @@ public class RowMutations implements Row {
return false; return false;
} }
@Override
public int hashCode(){
return Arrays.hashCode(row);
}
@Override @Override
public byte[] getRow() { public byte[] getRow() {
return row; return row;

View File

@ -44,6 +44,8 @@ import com.google.protobuf.ServiceException;
* Dynamic rather than static so can set the generic appropriately. * Dynamic rather than static so can set the generic appropriately.
*/ */
@InterfaceAudience.Private @InterfaceAudience.Private
@edu.umd.cs.findbugs.annotations.SuppressWarnings
(value = "IS2_INCONSISTENT_SYNC", justification = "na")
public class RpcRetryingCaller<T> { public class RpcRetryingCaller<T> {
static final Log LOG = LogFactory.getLog(RpcRetryingCaller.class); static final Log LOG = LogFactory.getLog(RpcRetryingCaller.class);
/** /**
@ -102,6 +104,8 @@ public class RpcRetryingCaller<T> {
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
* @throws RuntimeException other unspecified error * @throws RuntimeException other unspecified error
*/ */
@edu.umd.cs.findbugs.annotations.SuppressWarnings
(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "na")
public synchronized T callWithRetries(RetryingCallable<T> callable, int callTimeout) public synchronized T callWithRetries(RetryingCallable<T> callable, int callTimeout)
throws IOException, RuntimeException { throws IOException, RuntimeException {
this.callTimeout = callTimeout; this.callTimeout = callTimeout;

View File

@ -44,6 +44,7 @@ public class NullComparator extends ByteArrayComparable {
} }
@Override @Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings (value="EQ_UNUSUAL", justification="")
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj == null; return obj == null;
} }

View File

@ -1944,8 +1944,9 @@ public class ZKUtil {
ZooKeeperProtos.StoreSequenceId.Builder storeSequenceIdBuilder = ZooKeeperProtos.StoreSequenceId.Builder storeSequenceIdBuilder =
ZooKeeperProtos.StoreSequenceId.newBuilder(); ZooKeeperProtos.StoreSequenceId.newBuilder();
if (storeSequenceIds != null) { if (storeSequenceIds != null) {
for (byte[] columnFamilyName : storeSequenceIds.keySet()) { for (Map.Entry<byte[], Long> e : storeSequenceIds.entrySet()){
Long curSeqId = storeSequenceIds.get(columnFamilyName); byte[] columnFamilyName = e.getKey();
Long curSeqId = e.getValue();
storeSequenceIdBuilder.setFamilyName(ZeroCopyLiteralByteString.wrap(columnFamilyName)); storeSequenceIdBuilder.setFamilyName(ZeroCopyLiteralByteString.wrap(columnFamilyName));
storeSequenceIdBuilder.setSequenceId(curSeqId); storeSequenceIdBuilder.setSequenceId(curSeqId);
regionSequenceIdsBuilder.addStoreSequenceId(storeSequenceIdBuilder.build()); regionSequenceIdsBuilder.addStoreSequenceId(storeSequenceIdBuilder.build());