From hdfs-commits-return-1355-apmail-hadoop-hdfs-commits-archive=hadoop.apache.org@hadoop.apache.org Wed Apr 20 00:43:28 2011 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 8566811F3 for ; Wed, 20 Apr 2011 00:43:28 +0000 (UTC) Received: (qmail 55786 invoked by uid 500); 20 Apr 2011 00:43:28 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 55762 invoked by uid 500); 20 Apr 2011 00:43:28 -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 55753 invoked by uid 99); 20 Apr 2011 00:43:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Apr 2011 00:43:28 +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; Wed, 20 Apr 2011 00:43:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 26BBB2388901; Wed, 20 Apr 2011 00:43:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1095245 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/INode.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Date: Wed, 20 Apr 2011 00:43:04 -0000 To: hdfs-commits@hadoop.apache.org From: eli@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110420004304.26BBB2388901@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eli Date: Wed Apr 20 00:43:03 2011 New Revision: 1095245 URL: http://svn.apache.org/viewvc?rev=1095245&view=rev Log: HDFS-1845. Symlink comes up as directory after namenode restart. Contributed by John George Modified: hadoop/hdfs/trunk/CHANGES.txt hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INode.java hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Modified: hadoop/hdfs/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1095245&r1=1095244&r2=1095245&view=diff ============================================================================== --- hadoop/hdfs/trunk/CHANGES.txt (original) +++ hadoop/hdfs/trunk/CHANGES.txt Wed Apr 20 00:43:03 2011 @@ -657,6 +657,9 @@ Release 0.22.0 - Unreleased HDFS-1806. TestBlockReport.blockReport_08() and _09() are timing-dependent and likely to fail on fast servers. (Matt Foley via eli) + HDFS-1845. Symlink comes up as directory after namenode restart. + (John George via eli) + Release 0.21.1 - Unreleased IMPROVEMENTS Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INode.java URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INode.java?rev=1095245&r1=1095244&r2=1095245&view=diff ============================================================================== --- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INode.java (original) +++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/INode.java Wed Apr 20 00:43:03 2011 @@ -461,7 +461,9 @@ abstract class INode implements Comparab long nsQuota, long dsQuota, long preferredBlockSize) { - if (blocks == null) { + if (symlink.length() != 0) { // check if symbolic link + return new INodeSymlink(symlink, modificationTime, atime, permissions); + } else if (blocks == null) { //not sym link and blocks null? directory! if (nsQuota >= 0 || dsQuota >= 0) { return new INodeDirectoryWithQuota( permissions, modificationTime, nsQuota, dsQuota); @@ -469,10 +471,6 @@ abstract class INode implements Comparab // regular directory return new INodeDirectory(permissions, modificationTime); } - // check if symbolic link - if (symlink.length() != 0) { - return new INodeSymlink(symlink, modificationTime, atime, permissions); - } // file return new INodeFile(permissions, blocks, replication, modificationTime, atime, preferredBlockSize); Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java?rev=1095245&r1=1095244&r2=1095245&view=diff ============================================================================== --- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java (original) +++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Wed Apr 20 00:43:03 2011 @@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.tools.DFSA import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileUtil; +import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DFSConfigKeys; @@ -736,11 +737,13 @@ public class TestCheckpoint extends Test public void testSaveNamespace() throws IOException { MiniDFSCluster cluster = null; DistributedFileSystem fs = null; + FileContext fc; try { Configuration conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes).format(false).build(); cluster.waitActive(); fs = (DistributedFileSystem)(cluster.getFileSystem()); + fc = FileContext.getFileContext(cluster.getURI()); // Saving image without safe mode should fail DFSAdmin admin = new DFSAdmin(conf); @@ -756,6 +759,12 @@ public class TestCheckpoint extends Test Path file = new Path("namespace.dat"); writeFile(fs, file, replication); checkFile(fs, file, replication); + + // create new link + Path symlink = new Path("file.link"); + fc.createSymlink(file, symlink, false); + assertTrue(fc.getFileLinkStatus(symlink).isSymlink()); + // verify that the edits file is NOT empty Collection editsDirs = cluster.getNameEditsDirs(); for(URI uri : editsDirs) { @@ -784,6 +793,8 @@ public class TestCheckpoint extends Test cluster.waitActive(); fs = (DistributedFileSystem)(cluster.getFileSystem()); checkFile(fs, file, replication); + fc = FileContext.getFileContext(cluster.getURI()); + assertTrue(fc.getFileLinkStatus(symlink).isSymlink()); } finally { if(fs != null) fs.close(); if(cluster!= null) cluster.shutdown();