From 76f6681f559bb386dfb34623cdbf65afe689d9eb Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Tue, 29 Jul 2014 10:18:20 -0500 Subject: [PATCH] HBASE-4744 enable test that log roll fails after split start. FSHLog changes: * make logging in replaceWriter handle null newPath * clean up javadoc for replaceWriter TestHLogSplit changes: * remove @Ignore, add debug messages about test progress * clean up check for proper failure from log roll --- .../hadoop/hbase/regionserver/wal/FSHLog.java | 28 +++++++++++++------- .../hbase/regionserver/wal/TestHLogSplit.java | 27 ++++++++++--------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index b816192..8d03347 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -823,14 +823,21 @@ class FSHLog implements HLog, Syncable { /** * Cleans up current writer closing it and then puts in place the passed in - * nextWriter - * - * @param oldPath - * @param newPath - * @param nextWriter - * @param nextHdfsOut - * @return newPath - * @throws IOException + * nextWriter. + * + * In the case of creating a new WAL, oldPath will be null. + * + * In the case of rolling over from one file to the next, none of the params will be null. + * + * In the case of closing out this FSHLog with no further use newPath, nextWriter, and + * nextHdfsOut will be null. + * + * @param oldPath may be null + * @param newPath may be null + * @param nextWriter may be null + * @param nextHdfsOut may be null + * @return the passed in newPath + * @throws IOException if there is a problem flushing or closing the underlying FS */ Path replaceWriter(final Path oldPath, final Path newPath, FSHLog.Writer nextWriter, final FSDataOutputStream nextHdfsOut) @@ -885,6 +892,7 @@ class FSHLog implements HLog, Syncable { this.hdfs_out = nextHdfsOut; int oldNumEntries = this.numEntries.get(); this.numEntries.set(0); + final String newPathString = (null == newPath ? null : FSUtils.getPath(newPath)); if (oldPath != null) { this.byWalRegionSequenceIds.put(oldPath, this.highestRegionSequenceIds); this.highestRegionSequenceIds = new HashMap(); @@ -892,9 +900,9 @@ class FSHLog implements HLog, Syncable { this.totalLogSize.addAndGet(oldFileLen); LOG.info("Rolled WAL " + FSUtils.getPath(oldPath) + " with entries=" + oldNumEntries + ", filesize=" + StringUtils.byteDesc(oldFileLen) + "; new WAL " + - FSUtils.getPath(newPath)); + newPathString); } else { - LOG.info("New WAL " + FSUtils.getPath(newPath)); + LOG.info("New WAL " + newPathString); } } catch (InterruptedException ie) { // Perpetuate the interrupt diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java index dc39415..bc22a9e 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java @@ -1072,12 +1072,14 @@ public class TestHLogSplit { assertEquals(regions.size(), outputCounts.size()); } - // HBASE-2312: tests the case where a RegionServer enters a GC pause, - // comes back online after the master declared it dead and started to split. - // Want log rolling after a master split to fail + /** + * Tests the case where a RegionServer enters a GC pause, + * comes back online after the master declared it dead and started to split. + * Want log rolling after a master split to fail. See HBASE-2312. + */ @Test (timeout=300000) - @Ignore("Need HADOOP-6886, HADOOP-6840, & HDFS-617 for this. HDFS 0.20.205.1+ should have this") public void testLogRollAfterSplitStart() throws IOException { + LOG.info("Verify wal roll after split starts will fail."); HLog log = null; String logName = "testLogRollAfterSplitStart"; Path thisTestsDir = new Path(HBASEDIR, logName); @@ -1103,24 +1105,25 @@ public class TestHLogSplit { log.sync(); ((FSHLog) log).replaceWriter(((FSHLog)log).getOldPath(), null, null, null); - /* code taken from ProcessServerShutdown.process() - * handles RS shutdowns (as observed by the Master) + /* code taken from MasterFileSystem.getLogDirs(), which is called from MasterFileSystem.splitLog() + * handles RS shutdowns (as observed by the splitting process) */ // rename the directory so a rogue RS doesn't create more HLogs - Path rsSplitDir = new Path(thisTestsDir.getParent(), - thisTestsDir.getName() + "-splitting"); - fs.rename(thisTestsDir, rsSplitDir); + Path rsSplitDir = thisTestsDir.suffix(HLog.SPLITTING_EXT); + if (!fs.rename(thisTestsDir, rsSplitDir)) { + throw new IOException("Failed fs.rename for log split: " + thisTestsDir); + } LOG.debug("Renamed region directory: " + rsSplitDir); - // Process the old log files + LOG.debug("Processing the old log files."); HLogSplitter.split(HBASEDIR, rsSplitDir, OLDLOGDIR, fs, conf); - // Now, try to roll the HLog and verify failure + LOG.debug("Trying to roll the HLog."); try { log.rollWriter(); Assert.fail("rollWriter() did not throw any exception."); } catch (IOException ioe) { - if (ioe.getCause().getMessage().contains("FileNotFound")) { + if (ioe.getCause() instanceof FileNotFoundException) { LOG.info("Got the expected exception: ", ioe.getCause()); } else { Assert.fail("Unexpected exception: " + ioe); -- 1.7.10.2 (Apple Git-33)