hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r398674 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/FSDirectory.java
Date Mon, 01 May 2006 20:00:58 GMT
Author: cutting
Date: Mon May  1 13:00:57 2006
New Revision: 398674

URL: http://svn.apache.org/viewcvs?rev=398674&view=rev
Log:
HADOOP-183.  If the namendode is restarted with different minimum or maximum replication counts,
existing files' replication counts are now automatically adjusted to be within the newly configured
bounds.  Contributed by Hairong Kuang.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/CHANGES.txt?rev=398674&r1=398673&r2=398674&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Mon May  1 13:00:57 2006
@@ -138,6 +138,10 @@
     to namenode.  This fixes a problem where restarting the namenode
     triggered a lot of uneeded replication. (Hairong Kuang via cutting)
 
+37. HADOOP-183.  If the DFS namenode is restarted with different
+    minimum and/or maximum replication counts, existing files'
+    replication counts are now automatically adjusted to be within the
+    newly configured bounds. (Hairong Kuang via cutting)
 
 Release 0.1.1 - 2006-04-08
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java?rev=398674&r1=398673&r2=398674&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java Mon May  1 13:00:57
2006
@@ -403,8 +403,10 @@
                     UTF8 name = new UTF8();
                     name.readFields(in);
                     // version 0 does not support per file replication
-                    if( !(imgVersion >= 0) )
+                    if( !(imgVersion >= 0) ) {
                       replication = in.readShort(); // other versions do
+                      replication = adjustReplication( replication, conf );
+                    }
                     int numBlocks = in.readInt();
                     Block blocks[] = null;
                     if (numBlocks > 0) {
@@ -484,6 +486,7 @@
                           name = (UTF8) writables[0];
                           replication = Short.parseShort(
                                               ((UTF8)writables[1]).toString());
+                          replication = adjustReplication( replication, conf );
                         }
                         // get blocks
                         aw = new ArrayWritable(Block.class);
@@ -501,8 +504,11 @@
                         UTF8 repl = new UTF8();
                         src.readFields(in);
                         repl.readFields(in);
+                        replication=adjustReplication(
+                                fromLogReplication(repl),
+                                conf);
                         unprotectedSetReplication(src.toString(), 
-                                                  fromLogReplication(repl),
+                                                  replication,
                                                   null);
                         break;
                     } 
@@ -541,6 +547,17 @@
         return numEdits;
     }
 
+    private static short adjustReplication( short replication, Configuration conf) {
+        short minReplication = (short)conf.getInt("dfs.replication.min", 1);
+        if( replication<minReplication ) {
+            replication = minReplication;
+        }
+        short maxReplication = (short)conf.getInt("dfs.replication.max", 512);
+        if( replication>maxReplication ) {
+            replication = maxReplication;
+        }
+        return replication;
+    }
     /**
      * Save the contents of the FS image
      */



Mime
View raw message