HBASE-18308 Eliminate the findbugs warnings for hbase-server

This commit is contained in:
Chia-Ping Tsai 2017-07-20 00:36:16 +08:00
parent 980209579b
commit 2da5b432a1
12 changed files with 40 additions and 40 deletions

View File

@ -313,12 +313,10 @@ public class LocalHBaseCluster {
*/ */
public HMaster getActiveMaster() { public HMaster getActiveMaster() {
for (JVMClusterUtil.MasterThread mt : masterThreads) { for (JVMClusterUtil.MasterThread mt : masterThreads) {
if (mt.getMaster().isActiveMaster()) { // Ensure that the current active master is not stopped.
// Ensure that the current active master is not stopped. // We don't want to return a stopping master as an active master.
// We don't want to return a stopping master as an active master. if (mt.getMaster().isActiveMaster() && !mt.getMaster().isStopped()) {
if (mt.getMaster().isActiveMaster() && !mt.getMaster().isStopped()) { return mt.getMaster();
return mt.getMaster();
}
} }
} }
return null; return null;

View File

@ -616,8 +616,8 @@ public final class Constraints {
@Override @Override
public int compare(Constraint c1, Constraint c2) { public int compare(Constraint c1, Constraint c2) {
// compare the priorities of the constraints stored in their configuration // compare the priorities of the constraints stored in their configuration
return Long.valueOf(c1.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY)) return Long.compare(c1.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY),
.compareTo(c2.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY)); c2.getConf().getLong(PRIORITY_KEY, DEFAULT_PRIORITY));
} }
}; };

View File

@ -90,6 +90,9 @@ public class JarFinder {
private static void zipDir(File dir, String relativePath, ZipOutputStream zos, private static void zipDir(File dir, String relativePath, ZipOutputStream zos,
boolean start) throws IOException { boolean start) throws IOException {
String[] dirList = dir.list(); String[] dirList = dir.list();
if (dirList == null) {
return;
}
for (String aDirList : dirList) { for (String aDirList : dirList) {
File f = new File(dir, aDirList); File f = new File(dir, aDirList);
if (!f.isHidden()) { if (!f.isHidden()) {

View File

@ -134,11 +134,6 @@ public class DeadServer {
assert numProcessing >= 0: "Number of dead servers in processing should always be non-negative"; assert numProcessing >= 0: "Number of dead servers in processing should always be non-negative";
if (numProcessing < 0) {
LOG.error("Number of dead servers in processing = " + numProcessing
+ ". Something went wrong, this should always be non-negative.");
numProcessing = 0;
}
if (numProcessing == 0) { processing = false; } if (numProcessing == 0) { processing = false; }
} }

View File

@ -709,9 +709,8 @@ public class ServerManager {
if (!services.getAssignmentManager().isFailoverCleanupDone()) { if (!services.getAssignmentManager().isFailoverCleanupDone()) {
LOG.info("AssignmentManager hasn't finished failover cleanup; waiting"); LOG.info("AssignmentManager hasn't finished failover cleanup; waiting");
} }
for (Map.Entry<ServerName, Boolean> entry : requeuedDeadServers.entrySet()) {
for(ServerName tmpServerName : requeuedDeadServers.keySet()){ processDeadServer(entry.getKey(), entry.getValue());
processDeadServer(tmpServerName, requeuedDeadServers.get(tmpServerName));
} }
requeuedDeadServers.clear(); requeuedDeadServers.clear();
} }

View File

@ -1096,6 +1096,8 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
protected MetricsBalancer metricsBalancer = null; protected MetricsBalancer metricsBalancer = null;
protected ClusterStatus clusterStatus = null; protected ClusterStatus clusterStatus = null;
protected ServerName masterServerName; protected ServerName masterServerName;
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="IS2_INCONSISTENT_SYNC",
justification="The services is just assigned once when master start")
protected MasterServices services; protected MasterServices services;
protected static String[] getTablesOnMaster(Configuration conf) { protected static String[] getTablesOnMaster(Configuration conf) {

View File

@ -2816,7 +2816,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
checkResources(); checkResources();
startRegionOperation(Operation.DELETE); startRegionOperation(Operation.DELETE);
try { try {
delete.getRow();
// All edits for the given row (across all column families) must happen atomically. // All edits for the given row (across all column families) must happen atomically.
doBatchMutate(delete); doBatchMutate(delete);
} finally { } finally {
@ -3148,7 +3147,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} }
} }
@SuppressWarnings("unchecked")
private long doMiniBatchMutation(BatchOperationInProgress<?> batchOp) throws IOException { private long doMiniBatchMutation(BatchOperationInProgress<?> batchOp) throws IOException {
boolean isInReplay = batchOp.isInReplay(); boolean isInReplay = batchOp.isInReplay();
// variable to note if all Put items are for the same CF -- metrics related // variable to note if all Put items are for the same CF -- metrics related
@ -3402,7 +3400,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// They don't have to be, it will still work, just write more WALEdits than needed. // They don't have to be, it will still work, just write more WALEdits than needed.
if (nonceGroup != currentNonceGroup || nonce != currentNonce) { if (nonceGroup != currentNonceGroup || nonce != currentNonce) {
if (walEdit.size() > 0) { if (walEdit.size() > 0) {
assert isInReplay;
if (!isInReplay) { if (!isInReplay) {
throw new IOException("Multiple nonces per batch and not in replay"); throw new IOException("Multiple nonces per batch and not in replay");
} }

View File

@ -816,7 +816,8 @@ public class HRegionServer extends HasThread implements
* @throws IOException * @throws IOException
* @throws InterruptedException * @throws InterruptedException
*/ */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE", @edu.umd.cs.findbugs.annotations.SuppressWarnings(
value={"RV_RETURN_VALUE_IGNORED_BAD_PRACTICE", "RV_RETURN_VALUE_IGNORED"},
justification="cluster Id znode read would give us correct response") justification="cluster Id znode read would give us correct response")
private void initializeZooKeeper() throws IOException, InterruptedException { private void initializeZooKeeper() throws IOException, InterruptedException {
// Create the master address tracker, register with zk, and start it. Then // Create the master address tracker, register with zk, and start it. Then

View File

@ -137,15 +137,13 @@ public class ExplicitColumnTracker implements ColumnTracker {
// is interested in. That means there is no more data for the column // is interested in. That means there is no more data for the column
// of interest. Advance the ExplicitColumnTracker state to next // of interest. Advance the ExplicitColumnTracker state to next
// column of interest, and check again. // column of interest, and check again.
if (ret <= -1) { ++this.index;
++this.index; if (done()) {
if (done()) { // No more to match, do not include, done with this row.
// No more to match, do not include, done with this row. return ScanQueryMatcher.MatchCode.SEEK_NEXT_ROW; // done_row
return ScanQueryMatcher.MatchCode.SEEK_NEXT_ROW; // done_row
}
// This is the recursive case.
this.column = this.columns[this.index];
} }
// This is the recursive case.
this.column = this.columns[this.index];
} while (true); } while (true);
} }

View File

@ -461,7 +461,7 @@ public class ReplicationSource extends Thread implements ReplicationSourceInterf
@Override @Override
public int compare(Path o1, Path o2) { public int compare(Path o1, Path o2) {
return Long.valueOf(getTS(o1)).compareTo(getTS(o2)); return Long.compare(getTS(o1), getTS(o2));
} }
/** /**

View File

@ -1077,10 +1077,11 @@ public final class Canary implements Tool {
} }
} }
Map<String, AtomicLong> actualReadTableLatency = regionSink.getReadLatencyMap(); Map<String, AtomicLong> actualReadTableLatency = regionSink.getReadLatencyMap();
for (String tableName : this.configuredReadTableTimeouts.keySet()) { for (Map.Entry<String, Long> entry : configuredReadTableTimeouts.entrySet()) {
String tableName = entry.getKey();
if (actualReadTableLatency.containsKey(tableName)) { if (actualReadTableLatency.containsKey(tableName)) {
Long actual = actualReadTableLatency.get(tableName).longValue(); Long actual = actualReadTableLatency.get(tableName).longValue();
Long configured = this.configuredReadTableTimeouts.get(tableName); Long configured = entry.getValue();
LOG.info("Read operation for " + tableName + " took " + actual + LOG.info("Read operation for " + tableName + " took " + actual +
" ms. The configured read timeout was " + configured + " ms."); " ms. The configured read timeout was " + configured + " ms.");
if (actual > configured) { if (actual > configured) {

View File

@ -1769,12 +1769,13 @@ public class WALSplitter {
int maxSize = 0; int maxSize = 0;
List<Pair<HRegionLocation, Entry>> maxQueue = null; List<Pair<HRegionLocation, Entry>> maxQueue = null;
synchronized (this.serverToBufferQueueMap) { synchronized (this.serverToBufferQueueMap) {
for (String key : this.serverToBufferQueueMap.keySet()) { for (Map.Entry<String, List<Pair<HRegionLocation, Entry>>> entry:
List<Pair<HRegionLocation, Entry>> curQueue = this.serverToBufferQueueMap.get(key); serverToBufferQueueMap.entrySet()) {
List<Pair<HRegionLocation, Entry>> curQueue = entry.getValue();
if (curQueue.size() > maxSize) { if (curQueue.size() > maxSize) {
maxSize = curQueue.size(); maxSize = curQueue.size();
maxQueue = curQueue; maxQueue = curQueue;
maxLocKey = key; maxLocKey = entry.getKey();
} }
} }
if (maxSize < minBatchSize if (maxSize < minBatchSize
@ -2065,8 +2066,10 @@ public class WALSplitter {
int curSize = 0; int curSize = 0;
List<Pair<HRegionLocation, Entry>> curQueue = null; List<Pair<HRegionLocation, Entry>> curQueue = null;
synchronized (this.serverToBufferQueueMap) { synchronized (this.serverToBufferQueueMap) {
for (String locationKey : this.serverToBufferQueueMap.keySet()) { for (Map.Entry<String, List<Pair<HRegionLocation, Entry>>> entry :
curQueue = this.serverToBufferQueueMap.get(locationKey); serverToBufferQueueMap.entrySet()) {
String locationKey = entry.getKey();
curQueue = entry.getValue();
if (!curQueue.isEmpty()) { if (!curQueue.isEmpty()) {
curSize = curQueue.size(); curSize = curQueue.size();
curLoc = locationKey; curLoc = locationKey;
@ -2144,8 +2147,9 @@ public class WALSplitter {
} }
} finally { } finally {
synchronized (writers) { synchronized (writers) {
for (String locationKey : writers.keySet()) { for (Map.Entry<String, RegionServerWriter> entry : writers.entrySet()) {
RegionServerWriter tmpW = writers.get(locationKey); String locationKey = entry.getKey();
RegionServerWriter tmpW = entry.getValue();
try { try {
tmpW.close(); tmpW.close();
} catch (IOException ioe) { } catch (IOException ioe) {
@ -2157,8 +2161,10 @@ public class WALSplitter {
// close connections // close connections
synchronized (this.tableNameToHConnectionMap) { synchronized (this.tableNameToHConnectionMap) {
for (TableName tableName : this.tableNameToHConnectionMap.keySet()) { for (Map.Entry<TableName, HConnection> entry :
HConnection hconn = this.tableNameToHConnectionMap.get(tableName); tableNameToHConnectionMap.entrySet()) {
TableName tableName = entry.getKey();
HConnection hconn = entry.getValue();
try { try {
hconn.clearRegionCache(); hconn.clearRegionCache();
hconn.close(); hconn.close();