You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by sh...@apache.org on 2010/12/07 08:43:39 UTC

svn commit: r1042925 - in /hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode: FSImage.java FSImageCompression.java FSImageFormat.java FSImageSerialization.java

Author: shv
Date: Tue Dec  7 07:43:39 2010
New Revision: 1042925

URL: http://svn.apache.org/viewvc?rev=1042925&view=rev
Log:
Eliminate public and abstract qualifiers for HDFS-1473.

Modified:
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageCompression.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java?rev=1042925&r1=1042924&r2=1042925&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java Tue Dec  7 07:43:39 2010
@@ -1107,10 +1107,10 @@ public class FSImage extends Storage {
    * Save the contents of the FS image to the file.
    */
   void saveFSImage(File newFile) throws IOException {
-    FSImageFormat.Writer writer = new FSImageFormat.Writer();
+    FSImageFormat.Saver saver = new FSImageFormat.Saver();
     FSImageCompression compression = FSImageCompression.createCompression(conf);
-    writer.write(newFile, getFSNamesystem(), compression);
-    setImageDigest(writer.getWrittenDigest());
+    saver.save(newFile, getFSNamesystem(), compression);
+    setImageDigest(saver.getSavedDigest());
   }
 
   public void setImageDigest(MD5Hash digest) {

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageCompression.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageCompression.java?rev=1042925&r1=1042924&r2=1042925&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageCompression.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageCompression.java Tue Dec  7 07:43:39 2010
@@ -60,7 +60,7 @@ class FSImageCompression {
   /**
    * Create a "noop" compression - i.e. uncompressed
    */
-  public static FSImageCompression createNoopCompression() {
+  static FSImageCompression createNoopCompression() {
     return new FSImageCompression();
   }
 
@@ -69,7 +69,7 @@ class FSImageCompression {
    * Configuration object.
    * @throws IOException if the specified codec is not available.
    */
-  public static FSImageCompression createCompression(Configuration conf)
+  static FSImageCompression createCompression(Configuration conf)
     throws IOException {
     boolean compressImage = conf.getBoolean(
       DFSConfigKeys.DFS_IMAGE_COMPRESS_KEY,
@@ -107,7 +107,7 @@ class FSImageCompression {
    * @throws IOException if the specified codec is not available or the
    * underlying IO fails.
    */
-  public static FSImageCompression readCompressionHeader(
+  static FSImageCompression readCompressionHeader(
     Configuration conf,
     DataInputStream dis) throws IOException
   {
@@ -129,7 +129,7 @@ class FSImageCompression {
    * @throws IOException If the decompressor cannot be instantiated or an IO
    * error occurs.
    */
-  public DataInputStream unwrapInputStream(InputStream is) throws IOException {
+  DataInputStream unwrapInputStream(InputStream is) throws IOException {
     if (imageCodec != null) {
       return new DataInputStream(imageCodec.createInputStream(is));
     } else {
@@ -150,7 +150,7 @@ class FSImageCompression {
    * @throws IOException if an IO error occurs or the compressor cannot be
    * instantiated
    */
-  public DataOutputStream writeHeaderAndWrapStream(OutputStream os)
+  DataOutputStream writeHeaderAndWrapStream(OutputStream os)
   throws IOException {
     DataOutputStream dos = new DataOutputStream(os);
 

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java?rev=1042925&r1=1042924&r2=1042925&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java Tue Dec  7 07:43:39 2010
@@ -32,6 +32,8 @@ import java.security.MessageDigest;
 import java.util.Arrays;
 
 import org.apache.commons.logging.Log;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.PermissionStatus;
@@ -42,17 +44,22 @@ import org.apache.hadoop.io.MD5Hash;
 import org.apache.hadoop.io.Text;
 
 /**
- * Contains inner classes for reading or writing the on-disk format for FSImages
+ * Contains inner classes for reading or writing the on-disk format for FSImages.
  */
-public abstract class FSImageFormat {
+@InterfaceAudience.Private
+@InterfaceStability.Evolving
+class FSImageFormat {
   private static final Log LOG = FSImage.LOG;
   
+  // Static-only class
+  private FSImageFormat() {}
+  
   /**
    * A one-shot class responsible for loading an image. The load() function
    * should be called once, after which the getter methods may be used to retrieve
    * information about the image that was loaded, if loading was successful.
    */
-  public static class Loader {
+  static class Loader {
     private final Configuration conf;
     /** which namesystem this loader is working for */
     private final FSNamesystem namesystem;
@@ -67,7 +74,7 @@ public abstract class FSImageFormat {
     /** The MD5 sum of the loaded file */
     private MD5Hash imgDigest;
 
-    public Loader(Configuration conf, FSNamesystem namesystem) {
+    Loader(Configuration conf, FSNamesystem namesystem) {
       this.conf = conf;
       this.namesystem = namesystem;
     }
@@ -417,42 +424,42 @@ public abstract class FSImageFormat {
    * The write() function should be called once, after which the getter
    * functions may be used to retrieve information about the file that was written.
    */
-  static class Writer {
+  static class Saver {
     /** Set to true once an image has been written */
-    private boolean written = false;
+    private boolean saved = false;
     
     /** The MD5 checksum of the file that was written */
-    private MD5Hash writtenDigest;
+    private MD5Hash savedDigest;
 
     static private final byte[] PATH_SEPARATOR = DFSUtil.string2Bytes(Path.SEPARATOR);
 
-    /** @throws IllegalStateException if the instance has not yet written an image */
-    private void checkWritten() {
-      if (!written) {
-        throw new IllegalStateException("FSImageWriter has not written an image");
+    /** @throws IllegalStateException if the instance has not yet saved an image */
+    private void checkSaved() {
+      if (!saved) {
+        throw new IllegalStateException("FSImageSaver has not saved an image");
       }
     }
     
-    /** @throws IllegalStateException if the instance has already written an image */
-    private void checkNotWritten() {
-      if (written) {
-        throw new IllegalStateException("FSImageWriter has already written an image");
+    /** @throws IllegalStateException if the instance has already saved an image */
+    private void checkNotSaved() {
+      if (saved) {
+        throw new IllegalStateException("FSImageSaver has already saved an image");
       }
     }
 
     /**
      * Return the MD5 checksum of the image file that was saved.
      */
-    MD5Hash getWrittenDigest() {
-      checkWritten();
-      return writtenDigest;
+    MD5Hash getSavedDigest() {
+      checkSaved();
+      return savedDigest;
     }
 
-    void write(File newFile,
-               FSNamesystem sourceNamesystem,
-               FSImageCompression compression)
+    void save(File newFile,
+              FSNamesystem sourceNamesystem,
+              FSImageCompression compression)
       throws IOException {
-      checkNotWritten();
+      checkNotSaved();
 
       FSDirectory fsDir = sourceNamesystem.dir;
       long startTime = now();
@@ -491,9 +498,9 @@ public abstract class FSImageFormat {
         out.close();
       }
 
-      written = true;
+      saved = true;
       // set md5 of the saved image
-      writtenDigest = new MD5Hash(digester.digest());
+      savedDigest = new MD5Hash(digester.digest());
 
       LOG.info("Image file of size " + newFile.length() + " saved in " 
           + (now() - startTime)/1000 + " seconds.");

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java?rev=1042925&r1=1042924&r2=1042925&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java Tue Dec  7 07:43:39 2010
@@ -40,11 +40,18 @@ import org.apache.hadoop.io.Writable;
 /**
  * Static utility functions for serializing various pieces of data in the correct
  * format for the FSImage file.
+ *
+ * Some members are currently public for the benefit of the Offline Image Viewer
+ * which is located outside of this package. These members should be made
+ * package-protected when the OIV is refactored.
  */
 @InterfaceAudience.Private
 @InterfaceStability.Evolving
-public abstract class FSImageSerialization {
+public class FSImageSerialization {
 
+  // Static-only class
+  private FSImageSerialization() {}
+  
   /**
    * In order to reduce allocation, we reuse some static objects. However, the methods
    * in this class should be thread-safe since image-saving is multithreaded, so