hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r405890 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/Block.java src/java/org/apache/hadoop/dfs/FSNamesystem.java
Date Fri, 12 May 2006 21:41:39 GMT
Author: cutting
Date: Fri May 12 14:41:38 2006
New Revision: 405890

URL: http://svn.apache.org/viewcvs?rev=405890&view=rev
Log:
HADOOP-146.  Fix DFS to check that newly allocated block id's are not already used.  Contributed
by Konstantin.

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

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/CHANGES.txt?rev=405890&r1=405889&r2=405890&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri May 12 14:41:38 2006
@@ -12,6 +12,10 @@
     copy files within or between file systems in parallel.
     (Milind Bhandarkar via cutting)
 
+ 4. HADOOP-146.  Fix DFS to check when randomly generating a new block
+    id that no existing blocks already have that id.
+    (Konstantin Shvachko via cutting)
+
 
 Release 0.2.1 - 2006-05-12
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Block.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Block.java?rev=405890&r1=405889&r2=405890&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Block.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Block.java Fri May 12 14:41:38 2006
@@ -35,8 +35,6 @@
          });
     }
 
-    static Random r = new Random();
-
     /**
      */
     public static boolean isBlockFilename(File f) {
@@ -53,7 +51,7 @@
     /**
      */
     public Block() {
-        this.blkid = r.nextLong();
+        this.blkid = 0;
         this.len = 0;
     }
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?rev=405890&r1=405889&r2=405890&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Fri May 12 14:41:38
2006
@@ -585,11 +585,16 @@
         return COMPLETE_SUCCESS;
     }
 
+    static Random randBlockId = new Random();
+    
     /**
      * Allocate a block at the given pending filename
      */
     synchronized Block allocateBlock(UTF8 src) {
-        Block b = new Block();
+        Block b = null;
+        do {
+            b = new Block(FSNamesystem.randBlockId.nextLong(), 0);
+        } while (dir.isValidBlock(b));
         FileUnderConstruction v = 
           (FileUnderConstruction) pendingCreates.get(src);
         v.getBlocks().add(b);



Mime
View raw message