hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r547793 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/filecache/DistributedCache.java
Date Fri, 15 Jun 2007 21:34:24 GMT
Author: cutting
Date: Fri Jun 15 14:34:23 2007
New Revision: 547793

URL: http://svn.apache.org/viewvc?view=rev&rev=547793
Log:
HADOOP-1234.  Fix a race condition in the file cache that caused tasktracker to not be able
to find cached files.  Contributed by Arun.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/filecache/DistributedCache.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=547793&r1=547792&r2=547793
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri Jun 15 14:34:23 2007
@@ -133,6 +133,10 @@
  42. HADOOP-1472.  Fix so that timed-out tasks are counted as failures
      rather than as killed.  (Arun C Murthy via cutting)
 
+ 43. HADOOP-1234.  Fix a race condition in file cache that caused
+     tasktracker to not be able to find cached files.
+     (Arun C Murthy via cutting)
+
 
 Release 0.13.0 - 2007-06-08
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/filecache/DistributedCache.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/filecache/DistributedCache.java?view=diff&rev=547793&r1=547792&r2=547793
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/filecache/DistributedCache.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/filecache/DistributedCache.java Fri Jun
15 14:34:23 2007
@@ -68,23 +68,23 @@
     CacheStatus lcacheStatus;
     Path localizedPath;
     synchronized (cachedArchives) {
-      if (!cachedArchives.containsKey(cacheId)) {
+      lcacheStatus = cachedArchives.get(cacheId);
+      if (lcacheStatus == null) {
         // was never localized
         lcacheStatus = new CacheStatus();
         lcacheStatus.currentStatus = false;
-        lcacheStatus.refcount = 1;
+        lcacheStatus.refcount = 0;
         lcacheStatus.localLoadPath = new Path(baseDir, new Path(cacheId));
         cachedArchives.put(cacheId, lcacheStatus);
-      } else {
-        lcacheStatus = (CacheStatus) cachedArchives.get(cacheId);
-        synchronized (lcacheStatus) {
-          lcacheStatus.refcount++;
-        }
+      }
+      
+      synchronized (lcacheStatus) {
+        localizedPath = localizeCache(cache, lcacheStatus, conf, isArchive, 
+                                      md5, currentWorkDir);
+        lcacheStatus.refcount++;
       }
     }
-    synchronized (lcacheStatus) {
-      localizedPath = localizeCache(cache, lcacheStatus, conf, isArchive, md5, currentWorkDir);
-    }
+
     // try deleting stuff if you can
     long size = FileUtil.getDU(new File(baseDir.toString()));
     // setting the cache size to a default of 1MB
@@ -125,10 +125,12 @@
       for (Iterator it = cachedArchives.keySet().iterator(); it.hasNext();) {
         String cacheId = (String) it.next();
         CacheStatus lcacheStatus = (CacheStatus) cachedArchives.get(cacheId);
-        if (lcacheStatus.refcount == 0) {
-          // delete this cache entry
-          FileSystem.getLocal(conf).delete(lcacheStatus.localLoadPath);
-          it.remove();
+        synchronized (lcacheStatus) {
+          if (lcacheStatus.refcount == 0) {
+            // delete this cache entry
+            FileSystem.getLocal(conf).delete(lcacheStatus.localLoadPath);
+            it.remove();
+          }
         }
       }
     }



Mime
View raw message