Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 07D3710FDF for ; Thu, 20 Feb 2014 22:27:59 +0000 (UTC) Received: (qmail 18423 invoked by uid 500); 20 Feb 2014 22:27:40 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 18383 invoked by uid 500); 20 Feb 2014 22:27:39 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 18369 invoked by uid 99); 20 Feb 2014 22:27:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Feb 2014 22:27:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Feb 2014 22:27:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DAD9F238897A; Thu, 20 Feb 2014 22:27:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1570366 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java Date: Thu, 20 Feb 2014 22:27:13 -0000 To: hdfs-commits@hadoop.apache.org From: brandonli@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140220222713.DAD9F238897A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: brandonli Date: Thu Feb 20 22:27:13 2014 New Revision: 1570366 URL: http://svn.apache.org/r1570366 Log: HDFS-5944. LeaseManager:findLeaseWithPrefixPath can't handle path like /a/b/ and cause SecondaryNameNode failed do checkpoint. Contributed by Yunjiong Zhao Added: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1570366&r1=1570365&r2=1570366&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu Feb 20 22:27:13 2014 @@ -540,6 +540,9 @@ Release 2.4.0 - UNRELEASED HDFS-5962. Mtime and atime are not persisted for symbolic links. (Akira 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 HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9) Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java?rev=1570366&r1=1570365&r2=1570366&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java Thu Feb 20 22:27:13 2014 @@ -339,7 +339,12 @@ public class LeaseManager { } final Map entries = new HashMap(); - 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 entry : path2lease.tailMap(prefix).entrySet()) { final String p = entry.getKey(); Added: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java?rev=1570366&view=auto ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java (added) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestLeaseManager.java Thu Feb 20 22:27:13 2014 @@ -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")); + } +}