diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java index b1c7676..7bf80f7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java @@ -160,7 +160,7 @@ public class TestHLogSplit { * @throws IOException * @see https://issues.apache.org/jira/browse/HBASE-3020 */ - @Test + @Test public void testRecoveredEditsPathForMeta() throws IOException { FileSystem fs = FileSystem.get(TEST_UTIL.getConfiguration()); byte [] encoded = HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(); @@ -182,7 +182,7 @@ public class TestHLogSplit { * Test old recovered edits file doesn't break HLogSplitter. * This is useful in upgrading old instances. */ - @Test + @Test public void testOldRecoveredEditsFileSidelined() throws IOException { FileSystem fs = FileSystem.get(TEST_UTIL.getConfiguration()); byte [] encoded = HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(); @@ -197,7 +197,7 @@ public class TestHLogSplit { new WALEdit()); Path parent = HLogUtil.getRegionDirRecoveredEditsDir(regiondir); assertEquals(parent.getName(), HLog.RECOVERED_EDITS_DIR); - fs.createNewFile(parent); // create a recovered.edits file + fs.createNewFile(parent); // create a recovered.edits file Path p = HLogSplitter.getRegionSplitEditsPath(fs, entry, hbaseDir, true); String parentOfParent = p.getParent().getParent().getName(); @@ -478,12 +478,12 @@ public class TestHLogSplit { hbaseDir, hlogDir, oldLogDir, fs); logSplitter.splitLog(); - Path originalLog = (fs.listStatus(oldLogDir))[0].getPath(); Path splitLog = getLogForRegion(hbaseDir, TABLE_NAME, REGION); int actualCount = 0; HLog.Reader in = HLogFactory.createReader(fs, splitLog, conf); - HLog.Entry entry; + @SuppressWarnings("unused") + HLog.Entry entry; while ((entry = in.next()) != null) ++actualCount; assertEquals(entryCount-1, actualCount); @@ -542,36 +542,31 @@ public class TestHLogSplit { // hadoop 0.21 throws FNFE whereas hadoop 0.20 returns null } } -/* DISABLED for now. TODO: HBASE-2645 + @Test public void testLogCannotBeWrittenOnceParsed() throws IOException { AtomicLong counter = new AtomicLong(0); AtomicBoolean stop = new AtomicBoolean(false); generateHLogs(9); fs.initialize(fs.getUri(), conf); - Thread zombie = new ZombieLastLogWriterRegionServer(writer[9], counter, stop); - - - try { zombie.start(); - - HLog.splitLog(hbaseDir, hlogDir, oldLogDir, fs, conf); - - Path logfile = getLogForRegion(hbaseDir, TABLE_NAME, "juliet"); + HLogSplitter logSplitter = HLogSplitter.createLogSplitter(conf, hbaseDir, hlogDir, oldLogDir, fs); + logSplitter.splitLog(); + Path logfile = getLogForRegion(hbaseDir, TABLE_NAME, this.regions[0]); // It's possible that the writer got an error while appending and didn't count it // however the entry will in fact be written to file and split with the rest long numberOfEditsInRegion = countHLog(logfile, fs, conf); assertTrue("The log file could have at most 1 extra log entry, but " + - "can't have less. Zombie could write "+counter.get() +" and logfile had only"+ numberOfEditsInRegion+" " + logfile, counter.get() == numberOfEditsInRegion || - counter.get() + 1 == numberOfEditsInRegion); + "can't have less. Zombie could write " + counter.get() + " and logfile had only" + numberOfEditsInRegion+ + " " + logfile, counter.get() == numberOfEditsInRegion || + counter.get() + 1 == numberOfEditsInRegion); } finally { stop.set(true); } } -*/ @Test public void testSplitWillNotTouchLogsIfNewHLogGetsCreatedAfterSplitStarted() @@ -876,7 +871,7 @@ public class TestHLogSplit { HRegionInfo regioninfo = new HRegionInfo(tableName, HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW); log = HLogFactory.createHLog(fs, hbaseDir, logName, conf); - + final int total = 20; for (int i = 0; i < total; i++) { WALEdit kvs = new WALEdit(); @@ -1007,7 +1002,7 @@ public class TestHLogSplit { flushToConsole("Juliet: split not started, sleeping a bit..."); Threads.sleep(10); } - + fs.mkdirs(new Path(tableDir, region)); HLog.Writer writer = HLogFactory.createWriter(fs, julietLog, conf); @@ -1054,7 +1049,7 @@ public class TestHLogSplit { assertEquals(true, logsAreEqual(originalLog, splitLog)); } - + @Test public void testSplitLogFileDeletedRegionDir() throws IOException { @@ -1067,21 +1062,21 @@ public class TestHLogSplit { generateHLogs(1, 10, -1); FileStatus logfile = fs.listStatus(hlogDir)[0]; fs.initialize(fs.getUri(), conf); - + Path regiondir = new Path(tabledir, REGION); LOG.info("Region directory is" + regiondir); fs.delete(regiondir, true); - + HLogSplitter.splitLogFile(hbaseDir, logfile, fs, conf, reporter); HLogSplitter.finishSplitLogFile(hbaseDir, oldLogDir, logfile.getPath() .toString(), conf); - + assertTrue(!fs.exists(regiondir)); assertTrue(true); } - - + + @Test public void testSplitLogFileEmpty() throws IOException { LOG.info("testSplitLogFileEmpty"); @@ -1149,7 +1144,7 @@ public class TestHLogSplit { regions.add(regionName); generateHLogs(-1); - final HLog log = HLogFactory.createHLog(fs, regiondir, + final HLog log = HLogFactory.createHLog(fs, regiondir, regionName, conf); HLogSplitter logSplitter = new HLogSplitter( @@ -1210,14 +1205,12 @@ public class TestHLogSplit { makeRegionDirs(fs, regions); fs.mkdirs(hlogDir); for (int i = 0; i < writers; i++) { - writer[i] = HLogFactory.createWriter(fs, new Path(hlogDir, HLOG_FILE_PREFIX + i), - conf); + writer[i] = HLogFactory.createWriter(fs, new Path(hlogDir, HLOG_FILE_PREFIX + i), conf); for (int j = 0; j < entries; j++) { int prefix = 0; for (String region : regions) { String row_key = region + prefix++ + i + j; - appendEntry(writer[i], TABLE_NAME, region.getBytes(), - row_key.getBytes(), FAMILY, QUALIFIER, VALUE, seq); + appendEntry(writer[i], TABLE_NAME, region.getBytes(), row_key.getBytes(), FAMILY, QUALIFIER, VALUE, seq); } } if (i != leaveOpen) { @@ -1354,7 +1347,7 @@ public class TestHLogSplit { private void injectEmptyFile(String suffix, boolean closeFile) throws IOException { - HLog.Writer writer = HLogFactory.createWriter( + HLog.Writer writer = HLogFactory.createWriter( fs, new Path(hlogDir, HLOG_FILE_PREFIX + suffix), conf); if (closeFile) writer.close(); }