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 br...@apache.org on 2014/02/20 23:53:33 UTC
svn commit: r1570382 - in /hadoop/common/branches/branch-1: CHANGES.txt
src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java
Author: brandonli
Date: Thu Feb 20 22:53:32 2014
New Revision: 1570382
URL: http://svn.apache.org/r1570382
Log:
HDFS-5944. LeaseManager:findLeaseWithPrefixPath can't handle path like /a/b/ and cause SecondaryNameNode failed do checkpoint. Contributed by Yonjiong Zhao
Modified:
hadoop/common/branches/branch-1/CHANGES.txt
hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java
Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1570382&r1=1570381&r2=1570382&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Thu Feb 20 22:53:32 2014
@@ -196,6 +196,9 @@ Release 1.3.0 - unreleased
HDFS-2264. NamenodeProtocol has the wrong value for clientPrincipal in
KerberosInfo annotation. (Aaron T. Myers, backported by jing9)
+ HDFS-5944. LeaseManager:findLeaseWithPrefixPath can't handle path like /a/b/
+ and cause SecondaryNameNode failed do checkpoint (Yunjiong Zhao via brandonli)
+
Release 1.2.2 - unreleased
INCOMPATIBLE CHANGES
Modified: hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java?rev=1570382&r1=1570381&r2=1570382&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java (original)
+++ hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java Thu Feb 20 22:53:32 2014
@@ -331,7 +331,12 @@ public class LeaseManager {
}
List<Map.Entry<String, Lease>> entries = new ArrayList<Map.Entry<String, Lease>>();
- final int srclen = prefix.length();
+ int srclen = prefix.length();
+
+ // prefix may ended with '/'
+ if (prefix.charAt(srclen -1) == Path.SEPARATOR_CHAR) {
+ srclen -= 1;
+ }
for(Map.Entry<String, Lease> entry : path2lease.tailMap(prefix).entrySet()) {
final String p = entry.getKey();
Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java?rev=1570382&r1=1570381&r2=1570382&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java (original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java Thu Feb 20 22:53:32 2014
@@ -46,6 +46,7 @@ public class TestLeaseManager extends Te
throws IOException, InterruptedException {
Configuration conf = new Configuration();
MiniDFSCluster cluster = new MiniDFSCluster(conf, 3, true, null);
+ cluster.waitActive();
NameNode namenode = cluster.getNameNode();
FSNamesystem spyNamesystem = spy(namenode.getNamesystem());
LeaseManager leaseManager = new LeaseManager(spyNamesystem);
@@ -77,6 +78,37 @@ public class TestLeaseManager extends Te
assertTrue("internalReleaseOne not called", internalReleaseOneCalled.isCalled());
assertFalse("internalRelease called", internalReleaseCalled.isCalled());
+ cluster.shutdown();
+ }
+
+ public void testRemoveLeaseWithPrefixPath() throws IOException {
+ Configuration conf = new Configuration();
+ MiniDFSCluster cluster = new MiniDFSCluster(conf, 3, true, null);
+ cluster.waitActive();
+
+ NameNode namenode = cluster.getNameNode();
+ FSNamesystem spyNamesystem = spy(namenode.getNamesystem());
+ LeaseManager leaseManager = new LeaseManager(spyNamesystem);
+
+ leaseManager.addLease("holder1", "/a/b");
+ leaseManager.addLease("holder1", "/a/c");
+ assertNotNull(leaseManager.getLeaseByPath("/a/b"));
+ assertNotNull(leaseManager.getLeaseByPath("/a/c"));
+
+ leaseManager.removeLeaseWithPrefixPath("/a");
+
+ assertNull(leaseManager.getLeaseByPath("/a/b"));
+ assertNull(leaseManager.getLeaseByPath("/a/c"));
+
+ leaseManager.addLease("holder1", "/a/b");
+ leaseManager.addLease("holder1", "/a/c");
+
+ leaseManager.removeLeaseWithPrefixPath("/a/");
+
+ assertNull(leaseManager.getLeaseByPath("/a/b"));
+ assertNull(leaseManager.getLeaseByPath("/a/c"));
+
+ cluster.shutdown();
}
private static class CalledAnswer<T> implements Answer<T>{