HDFS-5944. LeaseManager:findLeaseWithPrefixPath can't handle path like /a/b/ and cause SecondaryNameNode failed do checkpoint. Contributed by Yunjiong Zhao
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1570366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12a8aa1510
commit
7568e2f193
|
@ -540,6 +540,9 @@ Release 2.4.0 - UNRELEASED
|
||||||
HDFS-5962. Mtime and atime are not persisted for symbolic links. (Akira
|
HDFS-5962. Mtime and atime are not persisted for symbolic links. (Akira
|
||||||
Ajisaka via kihwal)
|
Ajisaka via kihwal)
|
||||||
|
|
||||||
|
HDFS-5944. LeaseManager:findLeaseWithPrefixPath can't handle path like /a/b/
|
||||||
|
and cause SecondaryNameNode failed do checkpoint (Yunjiong Zhao via brandonli)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-5698 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HDFS-5698 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9)
|
HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9)
|
||||||
|
|
|
@ -339,7 +339,12 @@ public class LeaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Lease> entries = new HashMap<String, Lease>();
|
final Map<String, Lease> entries = new HashMap<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()) {
|
for(Map.Entry<String, Lease> entry : path2lease.tailMap(prefix).entrySet()) {
|
||||||
final String p = entry.getKey();
|
final String p = entry.getKey();
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.hadoop.hdfs.server.namenode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||||
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestLeaseManager {
|
||||||
|
Configuration conf = new HdfsConfiguration();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveLeaseWithPrefixPath() throws Exception {
|
||||||
|
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
|
||||||
|
cluster.waitActive();
|
||||||
|
|
||||||
|
LeaseManager lm = NameNodeAdapter.getLeaseManager(cluster.getNamesystem());
|
||||||
|
lm.addLease("holder1", "/a/b");
|
||||||
|
lm.addLease("holder2", "/a/c");
|
||||||
|
assertNotNull(lm.getLeaseByPath("/a/b"));
|
||||||
|
assertNotNull(lm.getLeaseByPath("/a/c"));
|
||||||
|
|
||||||
|
lm.removeLeaseWithPrefixPath("/a");
|
||||||
|
|
||||||
|
assertNull(lm.getLeaseByPath("/a/b"));
|
||||||
|
assertNull(lm.getLeaseByPath("/a/c"));
|
||||||
|
|
||||||
|
lm.addLease("holder1", "/a/b");
|
||||||
|
lm.addLease("holder2", "/a/c");
|
||||||
|
|
||||||
|
lm.removeLeaseWithPrefixPath("/a/");
|
||||||
|
|
||||||
|
assertNull(lm.getLeaseByPath("/a/b"));
|
||||||
|
assertNull(lm.getLeaseByPath("/a/c"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue