Author: szetszwo
Date: Mon Jan 12 13:18:08 2009
New Revision: 733898
URL: http://svn.apache.org/viewvc?rev=733898&view=rev
Log:
HADOOP-4985. Remove unnecessary "throw IOException" declarations in FSDirectory
related methods. (szetszwo)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=733898&r1=733897&r2=733898&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Jan 12 13:18:08 2009
@@ -26,6 +26,9 @@
HADOOP-4936. Improvements to TestSafeMode. (shv)
+ HADOOP-4985. Remove unnecessary "throw IOException" declarations in
+ FSDirectory related methods. (szetszwo)
+
OPTIMIZATIONS
BUG FIXES
Modified:
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=733898&r1=733897&r2=733898&view=diff
==============================================================================
---
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
(original)
+++
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
Mon Jan 12 13:18:08 2009
@@ -43,7 +43,7 @@
* and logged to disk.
*
*************************************************/
-class FSDirectory implements FSConstants, Closeable {
+class FSDirectory implements Closeable {
final FSNamesystem namesystem;
final INodeDirectoryWithQuota rootDir;
@@ -53,13 +53,13 @@
private MetricsRecord directoryMetrics = null;
/** Access an existing dfs name directory. */
- public FSDirectory(FSNamesystem ns, Configuration conf) throws IOException {
+ public FSDirectory(FSNamesystem ns, Configuration conf) {
this(new FSImage(), ns, conf);
fsImage.setCheckpointDirectories(FSImage.getCheckpointDirs(conf, null),
FSImage.getCheckpointEditsDirs(conf, null));
}
- public FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf)
throws IOException {
+ public FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) {
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
ns.createFsOwnerPermissions(new FsPermission((short)0755)),
Integer.MAX_VALUE, -1);
@@ -255,7 +255,8 @@
/**
* Add a block to the file. Returns a reference to the added block.
*/
- Block addBlock(String path, INode[] inodes, Block block) throws IOException {
+ Block addBlock(String path, INode[] inodes, Block block
+ ) throws QuotaExceededException {
waitForReady();
synchronized (rootDir) {
@@ -281,8 +282,7 @@
/**
* Persist the block list for the inode.
*/
- void persistBlocks(String path, INodeFileUnderConstruction file)
- throws IOException {
+ void persistBlocks(String path, INodeFileUnderConstruction file) {
waitForReady();
synchronized (rootDir) {
@@ -296,7 +296,7 @@
/**
* Close file.
*/
- void closeFile(String path, INodeFile file) throws IOException {
+ void closeFile(String path, INodeFile file) {
waitForReady();
synchronized (rootDir) {
// file is closed
@@ -449,12 +449,12 @@
* @param replication new replication
* @param oldReplication old replication - output parameter
* @return array of file blocks
- * @throws IOException
+ * @throws QuotaExceededException
*/
Block[] setReplication(String src,
short replication,
int[] oldReplication
- ) throws IOException {
+ ) throws QuotaExceededException {
waitForReady();
Block[] fileBlocks = unprotectedSetReplication(src, replication,
oldReplication);
if (fileBlocks != null) // log replication change
@@ -465,7 +465,7 @@
Block[] unprotectedSetReplication( String src,
short replication,
int[] oldReplication
- ) throws IOException {
+ ) throws QuotaExceededException {
if (oldReplication == null)
oldReplication = new int[1];
oldReplication[0] = -1;
@@ -501,7 +501,7 @@
synchronized (rootDir) {
INode fileNode = rootDir.getNode(filename);
if (fileNode == null) {
- throw new IOException("Unknown file: " + filename);
+ throw new FileNotFoundException("File does not exist: " + filename);
}
if (fileNode.isDirectory()) {
throw new IOException("Getting block size of a directory: " +
@@ -523,12 +523,13 @@
}
void setPermission(String src, FsPermission permission
- ) throws IOException {
+ ) throws FileNotFoundException {
unprotectedSetPermission(src, permission);
fsImage.getEditLog().logSetPermissions(src, permission);
}
- void unprotectedSetPermission(String src, FsPermission permissions) throws
FileNotFoundException {
+ void unprotectedSetPermission(String src, FsPermission permissions
+ ) throws FileNotFoundException {
synchronized(rootDir) {
INode inode = rootDir.getNode(src);
if(inode == null)
@@ -538,12 +539,13 @@
}
void setOwner(String src, String username, String groupname
- ) throws IOException {
+ ) throws FileNotFoundException {
unprotectedSetOwner(src, username, groupname);
fsImage.getEditLog().logSetOwner(src, username, groupname);
}
- void unprotectedSetOwner(String src, String username, String groupname)
throws FileNotFoundException {
+ void unprotectedSetOwner(String src, String username, String groupname
+ ) throws FileNotFoundException {
synchronized(rootDir) {
INode inode = rootDir.getNode(src);
if(inode == null)
@@ -629,7 +631,7 @@
+src+" is removed");
}
return targetNode;
- } catch (IOException e) {
+ } catch(QuotaExceededException e) {
NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedDelete: " +
"failed to remove " + src + " because " + e.getMessage());
return null;
@@ -1039,7 +1041,7 @@
return src;
}
- ContentSummary getContentSummary(String src) throws IOException {
+ ContentSummary getContentSummary(String src) throws FileNotFoundException {
String srcs = normalizePath(src);
synchronized (rootDir) {
INode targetNode = rootDir.getNode(srcs);
@@ -1208,21 +1210,19 @@
/**
* Sets the access time on the file. Logs it in the transaction log
*/
- void setTimes(String src, INodeFile inode, long mtime, long atime, boolean
force)
- throws IOException {
+ void setTimes(String src, INodeFile inode, long mtime, long atime, boolean
force) {
if (unprotectedSetTimes(src, inode, mtime, atime, force)) {
fsImage.getEditLog().logTimes(src, mtime, atime);
}
}
- boolean unprotectedSetTimes(String src, long mtime, long atime, boolean
force)
- throws IOException {
+ boolean unprotectedSetTimes(String src, long mtime, long atime, boolean
force) {
INodeFile inode = getFileINode(src);
return unprotectedSetTimes(src, inode, mtime, atime, force);
}
private boolean unprotectedSetTimes(String src, INodeFile inode, long mtime,
- long atime, boolean force) throws
IOException {
+ long atime, boolean force) {
boolean status = false;
if (mtime != -1) {
inode.setModificationTimeForce(mtime);
Modified:
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java?rev=733898&r1=733897&r2=733898&view=diff
==============================================================================
---
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
(original)
+++
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
Mon Jan 12 13:18:08 2009
@@ -366,7 +366,7 @@
/**
* Shutdown the file store.
*/
- public synchronized void close() throws IOException {
+ public synchronized void close() {
while (isSyncRunning) {
try {
wait(1000);
@@ -470,7 +470,7 @@
/**
* check if ANY edits.new log exists
*/
- boolean existsNew() throws IOException {
+ boolean existsNew() {
for (Iterator<StorageDirectory> it =
fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
if (getEditNewFile(it.next()).exists()) {
@@ -980,8 +980,7 @@
* Add open lease record to edit log.
* Records the block locations of the last block.
*/
- public void logOpenFile(String path, INodeFileUnderConstruction newNode)
- throws IOException {
+ public void logOpenFile(String path, INodeFileUnderConstruction newNode) {
UTF8 nameReplicationPair[] = new UTF8[] {
new UTF8(path),
@@ -1202,7 +1201,7 @@
/**
* Return the name of the edit file
*/
- synchronized File getFsEditName() throws IOException {
+ synchronized File getFsEditName() {
StorageDirectory sd = null;
for (Iterator<StorageDirectory> it =
fsimage.dirIterator(NameNodeDirType.EDITS); it.hasNext();)
Modified:
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java?rev=733898&r1=733897&r2=733898&view=diff
==============================================================================
---
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
(original)
+++
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImage.java
Mon Jan 12 13:18:08 2009
@@ -144,8 +144,7 @@
/**
*/
- FSImage(Collection<File> fsDirs, Collection<File> fsEditsDirs)
- throws IOException {
+ FSImage(Collection<File> fsDirs, Collection<File> fsEditsDirs) {
this();
setStorageDirectories(fsDirs, fsEditsDirs);
}
@@ -157,7 +156,7 @@
/**
* Represents an Image (image and edit file).
*/
- public FSImage(File imageDir) throws IOException {
+ FSImage(File imageDir) {
this();
ArrayList<File> dirs = new ArrayList<File>(1);
ArrayList<File> editsDirs = new ArrayList<File>(1);
@@ -167,8 +166,7 @@
}
void setStorageDirectories(Collection<File> fsNameDirs,
- Collection<File> fsEditsDirs
- ) throws IOException {
+ Collection<File> fsEditsDirs) {
this.storageDirs = new ArrayList<StorageDirectory>();
this.removedStorageDirs = new ArrayList<StorageDirectory>();
// Add all name dirs with appropriate NameNodeDirType
Modified:
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=733898&r1=733897&r2=733898&view=diff
==============================================================================
---
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++
hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Mon Jan 12 13:18:08 2009
@@ -748,8 +748,7 @@
long offset,
long length,
int nrBlocksToReturn,
- boolean doAccessTime)
- throws IOException {
+ boolean doAccessTime) {
if(inode == null) {
return null;
}
@@ -1647,7 +1646,7 @@
return dir.delete(src) != null;
}
- void removePathAndBlocks(String src, List<Block> blocks) throws IOException {
+ void removePathAndBlocks(String src, List<Block> blocks) {
leaseManager.removeLeaseWithPrefixPath(src);
for(Block b : blocks) {
blocksMap.removeINode(b);