Author: atm
Date: Fri Mar 2 01:32:49 2012
New Revision: 1296017
URL: http://svn.apache.org/viewvc?rev=1296017&view=rev
Log:
HDFS-3039. Address findbugs and javadoc warnings on branch. Contributed by Todd
Lipcon.
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
Fri Mar 2 01:32:49 2012
@@ -248,3 +248,5 @@ HDFS-3023. Optimize entries in edits log
HDFS-2979. Balancer should use logical uri for creating failover proxy with HA
enabled. (atm)
HDFS-3035. Fix failure of TestFileAppendRestart due to OP_UPDATE_BLOCKS (todd)
+
+HDFS-3039. Address findbugs and javadoc warnings on branch. (todd via atm)
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml
Fri Mar 2 01:32:49 2012
@@ -247,4 +247,12 @@
<Method name="save" />
<Bug pattern="OS_OPEN_STREAM" />
</Match>
+ <!--
+ This method isn't performance-critical and is much clearer to write as
it's written.
+ -->
+ <Match>
+ <Class name="org.apache.hadoop.hdfs.server.datanode.BlockPoolManager" />
+ <Method name="doRefreshNamenodes" />
+ <Bug category="PERFORMANCE" />
+ </Match>
</FindBugsFilter>
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
Fri Mar 2 01:32:49 2012
@@ -99,7 +99,8 @@ public class HAUtil {
nsId, null, DFSUtil.LOCAL_ADDRESS_MATCHER);
if (suffixes == null) {
String msg = "Configuration " + DFS_NAMENODE_RPC_ADDRESS_KEY +
- " must be suffixed with" + namenodeId + " for HA configuration.";
+ " must be suffixed with nameservice and namenode ID for HA " +
+ "configuration.";
throw new HadoopIllegalArgumentException(msg);
}
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java
Fri Mar 2 01:32:49 2012
@@ -63,7 +63,8 @@ public class NameNodeProxies {
/**
* Wrapper for a client proxy as well as its associated service ID.
* This is simply used as a tuple-like return type for
- * {@link createProxy} and {@link createNonHaProxy}.
+ * {@link NameNodeProxies#createProxy} and
+ * {@link NameNodeProxies#createNonHAProxy}.
*/
public static class ProxyAndInfo<PROXYTYPE> {
private final PROXYTYPE proxy;
@@ -125,7 +126,7 @@ public class NameNodeProxies {
/**
* Creates an explicitly non-HA-enabled proxy object. Most of the time you
- * don't want to use this, and should instead use {@link createProxy}.
+ * don't want to use this, and should instead use {@link
NameNodeProxies#createProxy}.
*
* @param conf the configuration object
* @param nnAddr address of the remote NN to connect to
@@ -160,8 +161,8 @@ public class NameNodeProxies {
conf, ugi);
} else {
String message = "Upsupported protocol found when creating the proxy " +
- "conection to NameNode: " +
- ((xface != null) ? xface.getClass().getName() : xface);
+ "connection to NameNode: " +
+ ((xface != null) ? xface.getClass().getName() : "null");
LOG.error(message);
throw new IllegalStateException(message);
}
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
Fri Mar 2 01:32:49 2012
@@ -1918,7 +1918,7 @@ assert storedBlock.findDatanode(dn) < 0
int numCurrentReplica = countLiveNodes(storedBlock);
if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED
&& numCurrentReplica >= minReplication) {
- storedBlock = completeBlock(storedBlock.getINode(), storedBlock, false);
+ completeBlock(storedBlock.getINode(), storedBlock, false);
} else if (storedBlock.isComplete()) {
// check whether safe replication is reached for the block
// only complete blocks are counted towards that.
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
Fri Mar 2 01:32:49 2012
@@ -173,7 +173,7 @@ class BPOfferService {
}
}
- NamespaceInfo getNamespaceInfo() {
+ synchronized NamespaceInfo getNamespaceInfo() {
return bpNSInfo;
}
@@ -366,7 +366,7 @@ class BPOfferService {
}
}
- DatanodeRegistration createRegistration() {
+ synchronized DatanodeRegistration createRegistration() {
Preconditions.checkState(bpNSInfo != null,
"getRegistration() can only be called after initial handshake");
return dn.createBPRegistration(bpNSInfo);
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
Fri Mar 2 01:32:49 2012
@@ -188,7 +188,7 @@ public class FSEditLog {
this.sharedEditsDirs = FSNamesystem.getSharedEditsDirs(conf);
}
- public void initJournalsForWrite() {
+ public synchronized void initJournalsForWrite() {
Preconditions.checkState(state == State.UNINITIALIZED ||
state == State.CLOSED, "Unexpected state: %s", state);
@@ -196,7 +196,7 @@ public class FSEditLog {
state = State.BETWEEN_LOG_SEGMENTS;
}
- public void initSharedJournalsForRead() {
+ public synchronized void initSharedJournalsForRead() {
if (state == State.OPEN_FOR_READING) {
LOG.warn("Initializing shared journals for READ, already open for READ",
new Exception());
@@ -209,7 +209,7 @@ public class FSEditLog {
state = State.OPEN_FOR_READING;
}
- private void initJournals(List<URI> dirs) {
+ private synchronized void initJournals(List<URI> dirs) {
int minimumRedundantJournals = conf.getInt(
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_MINIMUM_KEY,
DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_MINIMUM_DEFAULT);
@@ -808,7 +808,7 @@ public class FSEditLog {
* Used only by unit tests.
*/
@VisibleForTesting
- List<JournalAndStream> getJournals() {
+ synchronized List<JournalAndStream> getJournals() {
return journalSet.getAllJournalStreams();
}
@@ -816,7 +816,7 @@ public class FSEditLog {
* Used only by tests.
*/
@VisibleForTesting
- public JournalSet getJournalSet() {
+ synchronized public JournalSet getJournalSet() {
return journalSet;
}
@@ -950,17 +950,14 @@ public class FSEditLog {
/**
* Archive any log files that are older than the given txid.
*/
- public void purgeLogsOlderThan(final long minTxIdToKeep) {
- synchronized (this) {
- // synchronized to prevent findbugs warning about inconsistent
- // synchronization. This will be JIT-ed out if asserts are
- // off.
- assert curSegmentTxId == HdfsConstants.INVALID_TXID || // on format this
is no-op
- minTxIdToKeep <= curSegmentTxId :
- "cannot purge logs older than txid " + minTxIdToKeep +
- " when current segment starts at " + curSegmentTxId;
- }
+ public synchronized void purgeLogsOlderThan(final long minTxIdToKeep) {
+ assert curSegmentTxId == HdfsConstants.INVALID_TXID || // on format this
is no-op
+ minTxIdToKeep <= curSegmentTxId :
+ "cannot purge logs older than txid " + minTxIdToKeep +
+ " when current segment starts at " + curSegmentTxId;
+ // This could be improved to not need synchronization. But currently,
+ // journalSet is not threadsafe, so we need to synchronize this method.
try {
journalSet.purgeLogsOlderThan(minTxIdToKeep);
} catch (IOException ex) {
@@ -992,8 +989,8 @@ public class FSEditLog {
// sets the initial capacity of the flush buffer.
- public void setOutputBufferCapacity(int size) {
- journalSet.setOutputBufferCapacity(size);
+ synchronized void setOutputBufferCapacity(int size) {
+ journalSet.setOutputBufferCapacity(size);
}
/**
@@ -1069,7 +1066,7 @@ public class FSEditLog {
/**
* Run recovery on all journals to recover any unclosed segments
*/
- void recoverUnclosedStreams() {
+ synchronized void recoverUnclosedStreams() {
Preconditions.checkState(
state == State.BETWEEN_LOG_SEGMENTS,
"May not recover segments - wrong state: %s", state);
@@ -1092,7 +1089,7 @@ public class FSEditLog {
* @param toAtLeast the selected streams must contain this transaction
* @param inProgessOk set to true if in-progress streams are OK
*/
- public Collection<EditLogInputStream> selectInputStreams(long fromTxId,
+ public synchronized Collection<EditLogInputStream> selectInputStreams(long
fromTxId,
long toAtLeastTxId, boolean inProgressOk) throws IOException {
List<EditLogInputStream> streams = new ArrayList<EditLogInputStream>();
EditLogInputStream stream = journalSet.getInputStream(fromTxId,
inProgressOk);
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Fri Mar 2 01:32:49 2012
@@ -494,7 +494,7 @@ public class FSNamesystem implements Nam
nnResourceChecker = new NameNodeResourceChecker(conf);
checkAvailableResources();
assert safeMode != null &&
- !safeMode.initializedReplQueues;
+ !safeMode.isPopulatingReplQueues();
setBlockTotal();
blockManager.activate(conf);
this.nnrmthread = new Daemon(new NameNodeResourceMonitor());
@@ -3801,7 +3801,7 @@ public class FSNamesystem implements Nam
}
}
- private void adjustBlockTotals(int deltaSafe, int deltaTotal) {
+ private synchronized void adjustBlockTotals(int deltaSafe, int deltaTotal)
{
if (!shouldIncrementallyTrackBlocks) {
return;
}
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
Fri Mar 2 01:32:49 2012
@@ -310,7 +310,9 @@ class FileJournalManager implements Jour
// file, but before writing anything to it. Safe to delete it.
if (elf.getFile().length() == 0) {
LOG.info("Deleting zero-length edit log file " + elf);
- elf.getFile().delete();
+ if (!elf.getFile().delete()) {
+ throw new IOException("Unable to delete file " + elf.getFile());
+ }
continue;
}
@@ -328,7 +330,9 @@ class FileJournalManager implements Jour
// delete the file.
if (elf.getNumTransactions() == 0) {
LOG.info("Deleting edit log file with zero transactions " + elf);
- elf.getFile().delete();
+ if (!elf.getFile().delete()) {
+ throw new IOException("Unable to delete " + elf.getFile());
+ }
continue;
}
Modified:
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java?rev=1296017&r1=1296016&r2=1296017&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
(original)
+++
hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java
Fri Mar 2 01:32:49 2012
@@ -315,10 +315,10 @@ class NamenodeJspHelper {
// since the standby namenode doesn't compute replication queues
String underReplicatedBlocks = "";
if (nn.getServiceState() == HAServiceState.ACTIVE) {
- underReplicatedBlocks = new String(rowTxt()
+ underReplicatedBlocks = rowTxt()
+ colTxt("Excludes missing blocks.")
+ "Number of Under-Replicated Blocks" + colTxt() + ":" + colTxt()
- + fsn.getBlockManager().getUnderReplicatedNotMissingBlocks());
+ + fsn.getBlockManager().getUnderReplicatedNotMissingBlocks();
}
out.print("<div id=\"dfstable\"> <table>\n" + rowTxt() + colTxt()
+ "Configured Capacity" + colTxt() + ":" + colTxt()