You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by jo...@apache.org on 2008/10/06 12:42:17 UTC
svn commit: r702086 - in /hadoop/core/trunk: ./
src/core/org/apache/hadoop/conf/ src/core/org/apache/hadoop/fs/
src/core/org/apache/hadoop/record/compiler/
src/mapred/org/apache/hadoop/mapred/
Author: johan
Date: Mon Oct 6 03:42:16 2008
New Revision: 702086
URL: http://svn.apache.org/viewvc?rev=702086&view=rev
Log:
HADOOP-4253. Fix various warnings generated by findbugs.
Following deprecated methods in RawLocalFileSystem are removed:
public String getName()
public void lock(Path p, boolean shared)
public void release(Path p)
(Suresh Srinivas via johan)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/core/org/apache/hadoop/conf/Configuration.java
hadoop/core/trunk/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
hadoop/core/trunk/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CGenerator.java
hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CppGenerator.java
hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/JRecord.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Oct 6 03:42:16 2008
@@ -7,6 +7,13 @@
HADOOP-4210. Fix findbugs warnings for equals implementations of mapred ID
classes. Removed public, static ID::read and ID::forName; made ID an
abstract class. (Suresh Srinivas via cdouglas)
+
+ HADOOP-4253. Fix various warnings generated by findbugs.
+ Following deprecated methods in RawLocalFileSystem are removed:
+ public String getName()
+ public void lock(Path p, boolean shared)
+ public void release(Path p)
+ (Suresh Srinivas via johan)
NEW FEATURES
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/conf/Configuration.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/conf/Configuration.java Mon Oct 6 03:42:16 2008
@@ -192,11 +192,18 @@
LOG.debug(StringUtils.stringifyException
(new IOException("config(config)")));
}
- this.resources = (ArrayList)other.resources.clone();
- if (other.properties != null)
- this.properties = (Properties)other.properties.clone();
- if (other.overlay!=null)
- this.overlay = (Properties)other.overlay.clone();
+
+ this.resources = (ArrayList)other.resources.clone();
+ synchronized(other) {
+ if (other.properties != null) {
+ this.properties = (Properties)other.properties.clone();
+ }
+
+ if (other.overlay!=null) {
+ this.overlay = (Properties)other.overlay.clone();
+ }
+ }
+
this.finalParameters = new HashSet<String>(other.finalParameters);
}
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java Mon Oct 6 03:42:16 2008
@@ -484,10 +484,7 @@
throws IOException {
if (!fs.isDirectory(src)) { // source is a file
fs.copyToLocalFile(src, dst);
- FileSystem localFs = getLocal(getConf());
- if (localFs instanceof ChecksumFileSystem) {
- localFs = ((ChecksumFileSystem) localFs).getRawFileSystem();
- }
+ FileSystem localFs = getLocal(getConf()).getRawFileSystem();
if (localFs.isDirectory(dst)) {
dst = new Path(dst, src.getName());
}
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java Mon Oct 6 03:42:16 2008
@@ -37,11 +37,6 @@
public class RawLocalFileSystem extends FileSystem {
static final URI NAME = URI.create("file:///");
private Path workingDir;
- TreeMap<File, FileInputStream> sharedLockDataSet =
- new TreeMap<File, FileInputStream>();
- TreeMap<File, FileOutputStream> nonsharedLockDataSet =
- new TreeMap<File, FileOutputStream>();
- TreeMap<File, FileLock> lockObjSet = new TreeMap<File, FileLock>();
public RawLocalFileSystem() {
workingDir = new Path(System.getProperty("user.dir")).makeQualified(this);
@@ -56,9 +51,6 @@
return new File(path.toUri().getPath());
}
- /** @deprecated */
- public String getName() { return "local"; }
-
public URI getUri() { return NAME; }
public void initialize(URI uri, Configuration conf) {
@@ -336,58 +328,6 @@
return workingDir;
}
- /** @deprecated */ @Deprecated
- public void lock(Path p, boolean shared) throws IOException {
- File f = pathToFile(p);
- f.createNewFile();
-
- if (shared) {
- FileInputStream lockData = new FileInputStream(f);
- FileLock lockObj =
- lockData.getChannel().lock(0L, Long.MAX_VALUE, shared);
- synchronized (this) {
- sharedLockDataSet.put(f, lockData);
- lockObjSet.put(f, lockObj);
- }
- } else {
- FileOutputStream lockData = new FileOutputStream(f);
- FileLock lockObj = lockData.getChannel().lock(0L, Long.MAX_VALUE, shared);
- synchronized (this) {
- nonsharedLockDataSet.put(f, lockData);
- lockObjSet.put(f, lockObj);
- }
- }
- }
-
- /** @deprecated */ @Deprecated
- public void release(Path p) throws IOException {
- File f = pathToFile(p);
-
- FileLock lockObj;
- FileInputStream sharedLockData;
- FileOutputStream nonsharedLockData;
- synchronized (this) {
- lockObj = lockObjSet.remove(f);
- sharedLockData = sharedLockDataSet.remove(f);
- nonsharedLockData = nonsharedLockDataSet.remove(f);
- }
-
- if (lockObj == null) {
- throw new IOException("Given target not held as lock");
- }
- if (sharedLockData == null && nonsharedLockData == null) {
- throw new IOException("Given target not held as lock");
- }
-
- lockObj.release();
-
- if (sharedLockData != null) {
- sharedLockData.close();
- } else {
- nonsharedLockData.close();
- }
- }
-
// In the case of the local filesystem, we can just rename the file.
public void moveFromLocalFile(Path src, Path dst) throws IOException {
rename(src, dst);
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CGenerator.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CGenerator.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CGenerator.java Mon Oct 6 03:42:16 2008
@@ -42,26 +42,30 @@
throws IOException {
name = new File(destDir, (new File(name)).getName()).getAbsolutePath();
FileWriter cc = new FileWriter(name+".c");
- FileWriter hh = new FileWriter(name+".h");
-
- hh.write("#ifndef __"+name.toUpperCase().replace('.','_')+"__\n");
- hh.write("#define __"+name.toUpperCase().replace('.','_')+"__\n");
- hh.write("#include \"recordio.h\"\n");
- for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
- hh.write("#include \""+iter.next().getName()+".h\"\n");
- }
-
- cc.write("#include \""+name+".h\"\n");
-
- /*
- for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
- iter.next().genCppCode(hh, cc);
+ try {
+ FileWriter hh = new FileWriter(name+".h");
+ try {
+ hh.write("#ifndef __"+name.toUpperCase().replace('.','_')+"__\n");
+ hh.write("#define __"+name.toUpperCase().replace('.','_')+"__\n");
+ hh.write("#include \"recordio.h\"\n");
+ for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
+ hh.write("#include \""+iter.next().getName()+".h\"\n");
+ }
+
+ cc.write("#include \""+name+".h\"\n");
+
+ /*
+ for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
+ iter.next().genCppCode(hh, cc);
+ }
+ */
+
+ hh.write("#endif //"+name.toUpperCase().replace('.','_')+"__\n");
+ } finally {
+ hh.close();
}
- */
-
- hh.write("#endif //"+name.toUpperCase().replace('.','_')+"__\n");
-
- hh.close();
- cc.close();
+ } finally {
+ cc.close();
+ }
}
}
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CppGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CppGenerator.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CppGenerator.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/CppGenerator.java Mon Oct 6 03:42:16 2008
@@ -41,28 +41,34 @@
ArrayList<JRecord> rlist, String destDir, ArrayList<String> options)
throws IOException {
name = new File(destDir, (new File(name)).getName()).getAbsolutePath();
+
FileWriter cc = new FileWriter(name+".cc");
- FileWriter hh = new FileWriter(name+".hh");
-
- String fileName = (new File(name)).getName();
- hh.write("#ifndef __"+fileName.toUpperCase().replace('.','_')+"__\n");
- hh.write("#define __"+fileName.toUpperCase().replace('.','_')+"__\n");
- hh.write("#include \"recordio.hh\"\n");
- hh.write("#include \"recordTypeInfo.hh\"\n");
- for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
- hh.write("#include \""+iter.next().getName()+".hh\"\n");
+ try {
+ FileWriter hh = new FileWriter(name+".hh");
+
+ try {
+ String fileName = (new File(name)).getName();
+ hh.write("#ifndef __"+fileName.toUpperCase().replace('.','_')+"__\n");
+ hh.write("#define __"+fileName.toUpperCase().replace('.','_')+"__\n");
+ hh.write("#include \"recordio.hh\"\n");
+ hh.write("#include \"recordTypeInfo.hh\"\n");
+ for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
+ hh.write("#include \""+iter.next().getName()+".hh\"\n");
+ }
+
+ cc.write("#include \""+fileName+".hh\"\n");
+ cc.write("#include \"utils.hh\"\n");
+
+ for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
+ iter.next().genCppCode(hh, cc, options);
+ }
+
+ hh.write("#endif //"+fileName.toUpperCase().replace('.','_')+"__\n");
+ } finally {
+ hh.close();
+ }
+ } finally {
+ cc.close();
}
-
- cc.write("#include \""+fileName+".hh\"\n");
- cc.write("#include \"utils.hh\"\n");
-
- for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
- iter.next().genCppCode(hh, cc, options);
- }
-
- hh.write("#endif //"+fileName.toUpperCase().replace('.','_')+"__\n");
-
- hh.close();
- cc.close();
}
}
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/JRecord.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/JRecord.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/JRecord.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/compiler/JRecord.java Mon Oct 6 03:42:16 2008
@@ -155,6 +155,8 @@
String pkg = module;
String pkgpath = pkg.replaceAll("\\.", "/");
File pkgdir = new File(destDir, pkgpath);
+
+ final File jfile = new File(pkgdir, name+".java");
if (!pkgdir.exists()) {
// create the pkg directory
boolean ret = pkgdir.mkdirs();
@@ -165,9 +167,7 @@
// not a directory
throw new IOException(pkgpath+" is not a directory.");
}
- File jfile = new File(pkgdir, name+".java");
- FileWriter jj = new FileWriter(jfile);
-
+
CodeBuffer cb = new CodeBuffer();
cb.append("// File generated by hadoop record compiler. Do not edit.\n");
cb.append("package "+module+";\n\n");
@@ -456,8 +456,12 @@
cb.append("}\n");
cb.append("}\n");
- jj.write(cb.toString());
- jj.close();
+ FileWriter jj = new FileWriter(jfile);
+ try {
+ jj.write(cb.toString());
+ } finally {
+ jj.close();
+ }
}
}
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java?rev=702086&r1=702085&r2=702086&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java Mon Oct 6 03:42:16 2008
@@ -551,7 +551,7 @@
@Override
public void run() {
- LOG.info("Starting thread: " + getName());
+ LOG.info("Starting thread: " + this.getName());
while (true) {
try {
@@ -561,7 +561,7 @@
try {
runningJobs.wait();
} catch (InterruptedException e) {
- LOG.info("Shutting down: " + getName());
+ LOG.info("Shutting down: " + this.getName());
return;
}
}
@@ -592,7 +592,7 @@
waitingOn.wait(heartbeatInterval);
}
} catch (InterruptedException ie) {
- LOG.info("Shutting down: " + getName());
+ LOG.info("Shutting down: " + this.getName());
return;
}
}