You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ns...@apache.org on 2011/10/11 04:09:25 UTC

svn commit: r1181450 - /hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java

Author: nspiegelberg
Date: Tue Oct 11 02:09:25 2011
New Revision: 1181450

URL: http://svn.apache.org/viewvc?rev=1181450&view=rev
Log:
HBASE-2884: Fix TestHFileOutputFormat intermittent failure

Modified:
    hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java

Modified: hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java?rev=1181450&r1=1181449&r2=1181450&view=diff
==============================================================================
--- hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java (original)
+++ hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java Tue Oct 11 02:09:25 2011
@@ -106,10 +106,15 @@ public class TestHFileOutputFormat  {
       byte keyBytes[] = new byte[keyLength];
       byte valBytes[] = new byte[valLength];
 
-      Random random = new Random(System.currentTimeMillis());
+      int taskId = context.getTaskAttemptID().getTaskID().getId();
+      assert taskId < Byte.MAX_VALUE : "Unit tests dont support > 127 tasks!";
+
+      Random random = new Random();
       for (int i = 0; i < ROWSPERSPLIT; i++) {
 
         random.nextBytes(keyBytes);
+        // Ensure that unique tasks generate unique keys
+        keyBytes[keyLength - 1] = (byte)(taskId & 0xFF);
         random.nextBytes(valBytes);
         ImmutableBytesWritable key = new ImmutableBytesWritable(keyBytes);