From: <tho...@us...> - 2013-10-29 12:18:32
|
Revision: 7491 http://bigdata.svn.sourceforge.net/bigdata/?rev=7491&view=rev Author: thompsonbry Date: 2013-10-29 12:18:26 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Modified the main() routine for HALogReader to not halt if it encounters an HALog file that it can not read. It now reports the error and continues. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java 2013-10-29 12:09:49 UTC (rev 7490) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java 2013-10-29 12:18:26 UTC (rev 7491) @@ -48,6 +48,7 @@ import com.bigdata.journal.StoreTypeEnum; import com.bigdata.util.ChecksumError; import com.bigdata.util.ChecksumUtility; +import com.bigdata.util.InnerCause; /** * Given an HALog file can be used to replay the file and can provide a readable @@ -403,8 +404,7 @@ * @throws IOException * @throws InterruptedException */ - public static void main(final String[] args) throws IOException, - InterruptedException { + public static void main(final String[] args) throws InterruptedException { final IBufferAccess buf = DirectBufferPool.INSTANCE.acquire(); @@ -442,8 +442,7 @@ } - private static void doDirectory(final File dir, final IBufferAccess buf) - throws IOException { + private static void doDirectory(final File dir, final IBufferAccess buf) { final File[] files = dir.listFiles(new FilenameFilter() { @@ -489,48 +488,76 @@ } - private static void doFile(final File file, final IBufferAccess buf) - throws IOException { + private static void doFile(final File file, final IBufferAccess buf) { - final HALogReader r = new HALogReader(file); + try { + + doFile2(file,buf); + + } catch (Throwable e) { + + if(InnerCause.isInnerCause(e, InterruptedException.class)) { + + // Propagate interrupt. + Thread.currentThread().interrupt(); + + } - try { + final String msg = "ERROR: Could not read file: file=" + file + + ", cause=" + e; + + System.err.println(msg); + + log.error(msg, e); + + } + + } - final IRootBlockView openingRootBlock = r.getOpeningRootBlock(); + private static void doFile2(final File file, final IBufferAccess buf) + throws IOException { + + final HALogReader r = new HALogReader(file); - final IRootBlockView closingRootBlock = r.getClosingRootBlock(); + try { - final boolean isWORM = openingRootBlock.getStoreType() == StoreTypeEnum.WORM; + final IRootBlockView openingRootBlock = r.getOpeningRootBlock(); - if (openingRootBlock.getCommitCounter() == closingRootBlock - .getCommitCounter()) { + final IRootBlockView closingRootBlock = r.getClosingRootBlock(); - System.err.println("EMPTY LOG: " + file); + final boolean isWORM = openingRootBlock.getStoreType() == StoreTypeEnum.WORM; - } + System.out.println("----------begin----------"); + System.out.println("file=" + file); + System.out.println("openingRootBlock=" + openingRootBlock); + System.out.println("closingRootBlock=" + closingRootBlock); - System.out.println("----------begin----------"); - System.out.println("file=" + file); - System.out.println("openingRootBlock=" + openingRootBlock); - System.out.println("closingRootBlock=" + closingRootBlock); + if (openingRootBlock.getCommitCounter() == closingRootBlock + .getCommitCounter()) { - while (r.hasMoreBuffers()) { + System.err + .println("WARN : LOGICALLY EMPTY LOG (closing root block == opening root block): file=" + + file); - // don't pass buffer in if WORM, just validate the messages - final IHAWriteMessage msg = r.processNextBuffer(isWORM ? null - : buf.buffer()); + } + + while (r.hasMoreBuffers()) { - System.out.println(msg.toString()); + // don't pass buffer in if WORM, just validate the messages + final IHAWriteMessage msg = r.processNextBuffer(isWORM ? null + : buf.buffer()); - } - System.out.println("-----------end-----------"); + System.out.println(msg.toString()); - } finally { + } + System.out.println("-----------end-----------"); - r.close(); + } finally { - } + r.close(); + } + } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |