HBASE-8478 HBASE-2231 breaks TestHRegion#testRecoveredEditsReplayCompaction under hadoop2 profile

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1479716 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Enis Soztutar 2013-05-06 23:12:55 +00:00
parent e5becce33e
commit c68cea5b45
2 changed files with 13 additions and 5 deletions

View File

@ -1398,7 +1398,9 @@ public abstract class FSUtils {
/** /**
* Calls fs.listStatus() and treats FileNotFoundException as non-fatal * Calls fs.listStatus() and treats FileNotFoundException as non-fatal
* This accommodates differences between hadoop versions * This accommodates differences between hadoop versions, where hadoop 1
* does not throw a FileNotFoundException, and return an empty FileStatus[]
* while Hadoop 2 will throw FileNotFoundException.
* *
* @param fs file system * @param fs file system
* @param dir directory * @param dir directory

View File

@ -95,6 +95,7 @@ import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.test.MetricsAssertHelper; import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper; import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge; import org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.PairOfSameType; import org.apache.hadoop.hbase.util.PairOfSameType;
@ -422,8 +423,11 @@ public class TestHRegion extends HBaseTestCase {
//now find the compacted file, and manually add it to the recovered edits //now find the compacted file, and manually add it to the recovered edits
Path tmpDir = region.getRegionFileSystem().getTempDir(); Path tmpDir = region.getRegionFileSystem().getTempDir();
FileStatus[] files = region.getRegionFileSystem().getFileSystem().listStatus(tmpDir); FileStatus[] files = FSUtils.listStatus(fs, tmpDir);
assertEquals(1, files.length); String errorMsg = "Expected to find 1 file in the region temp directory " +
"from the compaction, could not find any";
assertNotNull(errorMsg, files);
assertEquals(errorMsg, 1, files.length);
//move the file inside region dir //move the file inside region dir
Path newFile = region.getRegionFileSystem().commitStoreFile(Bytes.toString(family), files[0].getPath()); Path newFile = region.getRegionFileSystem().commitStoreFile(Bytes.toString(family), files[0].getPath());
@ -459,8 +463,9 @@ public class TestHRegion extends HBaseTestCase {
LOG.info(sf.getPath()); LOG.info(sf.getPath());
} }
assertEquals(1, region.getStore(family).getStorefilesCount()); assertEquals(1, region.getStore(family).getStorefilesCount());
files = region.getRegionFileSystem().getFileSystem().listStatus(tmpDir); files = FSUtils.listStatus(fs, tmpDir);
assertEquals(0, files.length); assertTrue("Expected to find 0 files inside " + tmpDir,
files == null || files.length == 0);
for (long i = minSeqId; i < maxSeqId; i++) { for (long i = minSeqId; i < maxSeqId; i++) {
Get get = new Get(Bytes.toBytes(i)); Get get = new Get(Bytes.toBytes(i));
@ -3176,6 +3181,7 @@ public class TestHRegion extends HBaseTestCase {
ctx.addThread(new RepeatingTestThread(ctx) { ctx.addThread(new RepeatingTestThread(ctx) {
private int flushesSinceCompact = 0; private int flushesSinceCompact = 0;
private final int maxFlushesSinceCompact = 20; private final int maxFlushesSinceCompact = 20;
@Override
public void doAnAction() throws Exception { public void doAnAction() throws Exception {
if (region.flushcache()) { if (region.flushcache()) {
++flushesSinceCompact; ++flushesSinceCompact;