From: <tho...@us...> - 2013-10-29 12:07:14
|
Revision: 7489 http://bigdata.svn.sourceforge.net/bigdata/?rev=7489&view=rev Author: thompsonbry Date: 2013-10-29 12:07:08 +0000 (Tue, 29 Oct 2013) Log Message: ----------- changed "journal" to "HALog" in error messages for MAGIC and VERSION. 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-28 19:16:50 UTC (rev 7488) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java 2013-10-29 12:07:08 UTC (rev 7489) @@ -126,11 +126,11 @@ ex); } if (magic != HALogWriter.MAGIC) - throw new RuntimeException("Bad journal magic: expected=" + throw new RuntimeException("Bad HALog magic: expected=" + HALogWriter.MAGIC + ", actual=" + magic); version = m_raf.readInt(); if (version != HALogWriter.VERSION1) - throw new RuntimeException("Bad journal version: expected=" + throw new RuntimeException("Bad HALog version: expected=" + HALogWriter.VERSION1 + ", actual=" + version); final RootBlockUtility tmp = new RootBlockUtility(reopener, file, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-10-29 12:09:56
|
Revision: 7490 http://bigdata.svn.sourceforge.net/bigdata/?rev=7490&view=rev Author: thompsonbry Date: 2013-10-29 12:09:49 +0000 (Tue, 29 Oct 2013) Log Message: ----------- added the file name into the error messages. javadoc update on class. 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:07:08 UTC (rev 7489) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java 2013-10-29 12:09:49 UTC (rev 7490) @@ -37,6 +37,7 @@ import org.apache.log4j.Logger; +import com.bigdata.ha.msg.IHAMessage; import com.bigdata.ha.msg.IHAWriteMessage; import com.bigdata.io.DirectBufferPool; import com.bigdata.io.FileChannelUtility; @@ -50,17 +51,13 @@ /** * Given an HALog file can be used to replay the file and can provide a readable - * dump of the content. + * dump of the content. When replaying, the current position is compared to the + * EOF to determine whether more data can be read. The called should call + * {@link IHALogReader#hasMoreBuffers()} and if so read the next associated + * buffer and process with the returned {@link IHAMessage}. If + * {@link IHALogReader#hasMoreBuffers()} is false, then the committing + * {@link IRootBlockView} should be used to commit the replayed transaction. * - * When replaying, the current position is compared to the EOF to determine - * whether more data can be read. - * - * The called should call hasMoreBuffers() and if so read the next associated - * buffer and process with the returned IHAMessage. - * - * If hasMoreBuffers() is false, then the committing rootBlock should be used to - * commit the replayed transaction. - * * @author Martyn Cutcher */ public class HALogReader implements IHALogReader { @@ -121,17 +118,19 @@ */ magic = m_raf.readInt(); } catch (IOException ex) { - throw new RuntimeException( - "Can not read magic. Is file locked by another process?", - ex); + throw new RuntimeException( + "Can not read magic. Is file locked by another process? file=" + + file, ex); } - if (magic != HALogWriter.MAGIC) - throw new RuntimeException("Bad HALog magic: expected=" - + HALogWriter.MAGIC + ", actual=" + magic); + if (magic != HALogWriter.MAGIC) + throw new RuntimeException("Bad HALog magic: file=" + file + + ", expected=" + HALogWriter.MAGIC + ", actual=" + + magic); version = m_raf.readInt(); if (version != HALogWriter.VERSION1) - throw new RuntimeException("Bad HALog version: expected=" - + HALogWriter.VERSION1 + ", actual=" + version); + throw new RuntimeException("Bad HALog version: file=" + file + + ", expected=" + HALogWriter.VERSION1 + ", actual=" + + version); final RootBlockUtility tmp = new RootBlockUtility(reopener, file, true/* validateChecksum */, false/* alternateRootBlock */, @@ -151,8 +150,9 @@ * Counters are inconsistent with either an empty log file or a * single transaction scope. */ - throw new IllegalStateException("Incompatible rootblocks: cc0=" - + cc0 + ", cc1=" + cc1); + throw new IllegalStateException( + "Incompatible rootblocks: file=" + file + ", cc0=" + + cc0 + ", cc1=" + cc1); } m_channel.position(HALogWriter.headerSize0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <tho...@us...> - 2013-10-29 12:19:45
|
Revision: 7492 http://bigdata.svn.sourceforge.net/bigdata/?rev=7492&view=rev Author: thompsonbry Date: 2013-10-29 12:19:39 +0000 (Tue, 29 Oct 2013) Log Message: ----------- Added sort for the top-level arguments as well to force lexical visitation order for HALog files. 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:18:26 UTC (rev 7491) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/ha/halog/HALogReader.java 2013-10-29 12:19:39 UTC (rev 7492) @@ -406,6 +406,17 @@ */ public static void main(final String[] args) throws InterruptedException { + /* + * Sort into lexical order to force visitation in lexical order. + * + * Note: This should work under any OS. Files will be either directory + * names (3 digits) or filenames (21 digits plus the file extension). + * Thus the comparison centers numerically on the digits that encode + * either part of a commit counter (subdirectory) or an entire commit + * counter (HALog file). + */ + Arrays.sort(args); + final IBufferAccess buf = DirectBufferPool.INSTANCE.acquire(); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |