You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/10/10 21:34:22 UTC
svn commit: r823925 -
/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java
Author: stack
Date: Sat Oct 10 19:34:22 2009
New Revision: 823925
URL: http://svn.apache.org/viewvc?rev=823925&view=rev
Log:
HBASE-1887 Update hbase trunk to latests on hadoop 0.21 branch so we can all test sync/append; add more to testsync test -- make sure does right thing if file spans multiple blocks
Modified:
hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java?rev=823925&r1=823924&r2=823925&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java Sat Oct 10 19:34:22 2009
@@ -44,6 +44,8 @@
public void setUp() throws Exception {
// Enable append for these tests.
this.conf.setBoolean("dfs.support.append", true);
+ // Make block sizes small.
+ this.conf.setInt("dfs.blocksize", 1024 * 1024);
cluster = new MiniDFSCluster(conf, 3, true, (String[])null);
// Set the hbase.rootdir to be the home directory in mini dfs.
this.conf.set(HConstants.HBASE_DIR,
@@ -160,6 +162,28 @@
count = 0;
while(reader.next(key)) count++;
assertEquals(total * 2, count);
+ // Now do a test that ensures stuff works when we go over block boundary,
+ // especially that we return good length on file.
+ final byte [] value = new byte[1025 * 1024]; // Make a 1M value.
+ for (int i = 0; i < total; i++) {
+ List<KeyValue> kvs = new ArrayList<KeyValue>();
+ kvs.add(new KeyValue(Bytes.toBytes(i), bytes, value));
+ wal.append(bytes, bytes, kvs, false, System.currentTimeMillis());
+ }
+ // Now I should have written out lots of blocks. Sync then read.
+ wal.sync();
+ reader = HLog.getReader(this.fs, walPath, this.conf);
+ count = 0;
+ while(reader.next(key)) count++;
+ assertEquals(total * 3, count);
+ reader.close();
+ // Close it and ensure that closed, Reader gets right length also.
+ wal.close();
+ reader = HLog.getReader(this.fs, walPath, this.conf);
+ count = 0;
+ while(reader.next(key)) count++;
+ assertEquals(total * 3, count);
+ reader.close();
}
private void verifySplits(List<Path> splits, final int howmany)