hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1151668 - in /hadoop/common/branches/branch-0.22/hdfs: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
Date Wed, 27 Jul 2011 23:32:03 GMT
Author: shv
Date: Wed Jul 27 23:32:02 2011
New Revision: 1151668

URL: http://svn.apache.org/viewvc?rev=1151668&view=rev
Log:
HDFS-1981. svn merge -c 1151666 from trunk to branch-0.22.

Added:
    hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
  (with props)
Modified:
    hadoop/common/branches/branch-0.22/hdfs/CHANGES.txt
    hadoop/common/branches/branch-0.22/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java

Modified: hadoop/common/branches/branch-0.22/hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/hdfs/CHANGES.txt?rev=1151668&r1=1151667&r2=1151668&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.22/hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.22/hdfs/CHANGES.txt Wed Jul 27 23:32:02 2011
@@ -597,6 +597,9 @@ Release 0.22.0 - Unreleased
     HDFS-2189. Add guava-r09 dependency to ivy/hadoop-hdfs-template.xml
     (Plamen Jeliazkov via shv)
 
+    HDFS-1981. NameNode does not saveNamespace() when editsNew is empty.
+    (Uma Maheswara Rao G via shv)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/common/branches/branch-0.22/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java?rev=1151668&r1=1151667&r2=1151668&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.22/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
(original)
+++ hadoop/common/branches/branch-0.22/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
Wed Jul 27 23:32:02 2011
@@ -1110,7 +1110,9 @@ public class FSImage extends Storage {
       numEdits += loader.loadFSEdits(edits);
       edits.close();
     }
-    
+    if (numEdits == 0 && editsNew.exists()) {
+      numEdits++;
+    }
     // update the counts.
     getFSNamesystem().dir.updateCountForINodeWithQuota();    
     

Added: hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java?rev=1151668&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
(added)
+++ hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
Wed Jul 27 23:32:02 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.assertEquals;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFSImage {
+
+  private static final String OUT_DIR = System.getProperty("test.build.data",
+      "build/test/fsimage");
+
+  private MiniDFSCluster miniDFSCluster = null;
+
+  private static Configuration nnConf = new Configuration();
+
+  private File current = new File(OUT_DIR);
+
+  @Before
+  public void setUpCluster() throws Exception {
+    clearDirs();
+  }
+
+  @After
+  public void clusterShutdown() throws Exception {
+    if (null != miniDFSCluster) {
+      miniDFSCluster.shutdown();
+    }
+  }
+
+  @Test
+  public void testLoadFsEditsShouldReturnTrueWhenEditsNewExists()
+      throws Exception {
+    nnConf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, OUT_DIR + "/BNN1");
+    NameNode.format(nnConf);
+    miniDFSCluster = new MiniDFSCluster.Builder(nnConf).numDataNodes(1).build();
+    FSImage image = miniDFSCluster.getNameNode().getFSImage();
+    URI next = miniDFSCluster.getNameDirs().iterator().next();
+    File editsNew = new File(next.getRawPath(), "/current/edits.new");
+    createEditsNew(editsNew, image);
+    int loadFSEdits = image.loadFSEdits(image.getStorageDir(0));
+    assertEquals("The numEdits should not be zero.", 1, loadFSEdits);
+  }
+
+  private void createEditsNew(File editsNew, FSImage image) throws Exception {
+    FileOutputStream fileOutputStream = null;
+    if (!editsNew.exists()) {
+      try {
+        editsNew.createNewFile();
+        image.editLog.createEditLogFile(editsNew);
+      } finally {
+        IOUtils.closeStream(fileOutputStream);
+      }
+    }
+  }
+
+  private void clearDirs() throws IOException {
+    if (current.exists()) {
+      FileUtil.fullyDelete(current);
+    }
+  }
+}

Propchange: hadoop/common/branches/branch-0.22/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message