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 cu...@apache.org on 2007/03/30 19:20:10 UTC

svn commit: r524185 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/InMemoryFileSystem.java

Author: cutting
Date: Fri Mar 30 10:20:09 2007
New Revision: 524185

URL: http://svn.apache.org/viewvc?view=rev&rev=524185
Log:
HADOOP-1167.  Remove extra synchronization in InMemoryFileSystem.  Contributed by Owen.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=524185&r1=524184&r2=524185
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri Mar 30 10:20:09 2007
@@ -64,6 +64,9 @@
 19. HADOOP-1169.  Fix a cut/paste error in CopyFiles utility so that
     S3-based source files are correctly copied.  (Michael Stack via cutting)
 
+20. HADOOP-1167.  Remove extra synchronization in InMemoryFileSystem.
+    (omalley via cutting)
+
 
 Release 0.12.3 (not yet released)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java?view=diff&rev=524185&r1=524184&r2=524185
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/InMemoryFileSystem.java Fri Mar 30 10:20:09 2007
@@ -44,15 +44,13 @@
   private Path staticWorkingDir;
   
   //pathToFileAttribs is the final place where a file is put after it is closed
-  private Map <String, FileAttributes> pathToFileAttribs = 
-    Collections.synchronizedMap(new HashMap());
+  private Map <String, FileAttributes> pathToFileAttribs = new HashMap();
   
   //tempFileAttribs is a temp place which is updated while reserving memory for
   //files we are going to create. It is read in the createRaw method and the
   //temp key/value is discarded. If the file makes it to "close", then it
   //ends up being in the pathToFileAttribs map.
-  private Map <String, FileAttributes> tempFileAttribs = 
-    Collections.synchronizedMap(new HashMap());
+  private Map <String, FileAttributes> tempFileAttribs = new HashMap();
   
   public RawInMemoryFileSystem() {
     setConf(new Configuration());
@@ -193,10 +191,10 @@
   public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
       short replication, long blockSize, Progressable progress)
       throws IOException {
-    if (exists(f) && ! overwrite) {
-      throw new IOException("File already exists:"+f);
-    }
     synchronized (this) {
+      if (exists(f) && ! overwrite) {
+        throw new IOException("File already exists:"+f);
+      }
       FileAttributes fAttr =(FileAttributes) tempFileAttribs.remove(getPath(f));
       if (fAttr != null)
         return create(f, fAttr);