浏览代码

HADOOP-4951. Lease monitor should acquire the LeaseManager lock but not the Monitor lock. (szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@730035 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 16 年之前
父节点
当前提交
e1fb3387d0
共有 2 个文件被更改,包括 26 次插入25 次删除
  1. 3 0
      CHANGES.txt
  2. 23 25
      src/hdfs/org/apache/hadoop/dfs/LeaseManager.java

+ 3 - 0
CHANGES.txt

@@ -118,6 +118,9 @@ Release 0.18.3 - Unreleased
     HADOOP-1980. 'dfsadmin -safemode enter' should prevent the namenode from
     leaving safemode automatically. (shv)
 
+    HADOOP-4951. Lease monitor should acquire the LeaseManager lock but not the
+    Monitor lock. (szetszwo)
+
 Release 0.18.2 - 2008-11-03
 
   BUG FIXES

+ 23 - 25
src/hdfs/org/apache/hadoop/dfs/LeaseManager.java

@@ -355,42 +355,40 @@ class LeaseManager {
         }
       }
     }
+  }
 
-    /** Check the leases beginning from the oldest. */
-    private synchronized void checkLeases() {
-      for(; sortedLeases.size() > 0; ) {
-        final Lease oldest = sortedLeases.first();
-        if (!oldest.expiredHardLimit()) {
-          return;
-        }
+  /** Check the leases beginning from the oldest. */
+  private synchronized void checkLeases() {
+    for(; sortedLeases.size() > 0; ) {
+      final Lease oldest = sortedLeases.first();
+      if (!oldest.expiredHardLimit()) {
+        return;
+      }
 
-        LOG.info(name + ": Lease " + oldest + " has expired hard limit");
+      LOG.info("Lease " + oldest + " has expired hard limit");
 
-        final List<StringBytesWritable> removing = new ArrayList<StringBytesWritable>();
-        for(StringBytesWritable p : oldest.getPaths()) {
-          try {
-            fsnamesystem.internalReleaseLease(oldest, p.getString());
-          } catch (IOException e) {
-            LOG.error("In " + name + ", cannot release the path " + p
-                + " in the lease " + oldest, e);
-            removing.add(p);
-          }
+      final List<StringBytesWritable> removing = new ArrayList<StringBytesWritable>();
+      for(StringBytesWritable p : oldest.getPaths()) {
+        try {
+          fsnamesystem.internalReleaseLease(oldest, p.getString());
+        } catch (IOException e) {
+          LOG.error("Cannot release the path "+p+" in the lease "+oldest, e);
+          removing.add(p);
         }
+      }
 
-        for(StringBytesWritable p : removing) {
-          try {
-            removeLease(oldest, p.getString());
-          } catch (IOException e) {
-            LOG.error("In " + name + ", cannot removeLease: oldest="
-                + oldest + ", p=" + p, e);
-          }
+      for(StringBytesWritable p : removing) {
+        try {
+          removeLease(oldest, p.getString());
+        } catch (IOException e) {
+          LOG.error("Cannot removeLease: oldest=" + oldest + ", p=" + p, e);
         }
       }
     }
   }
 
   /** {@inheritDoc} */
-  public String toString() {
+  public synchronized String toString() {
     return getClass().getSimpleName() + "= {"
         + "\n leases=" + leases
         + "\n sortedLeases=" + sortedLeases