1 8 9 package com.sleepycat.je.log; 10 11 import java.io.IOException ; 12 import java.nio.ByteBuffer ; 13 14 import com.sleepycat.je.DatabaseException; 15 import com.sleepycat.je.dbi.EnvironmentImpl; 16 import com.sleepycat.je.log.entry.LogEntry; 17 18 21 public class PrintFileReader extends DumpFileReader { 22 23 26 public PrintFileReader(EnvironmentImpl env, 27 int readBufferSize, 28 long startLsn, 29 long finishLsn, 30 String entryTypes, 31 String txnIds, 32 boolean verbose) 33 throws IOException , DatabaseException { 34 35 super(env, 36 readBufferSize, 37 startLsn, 38 finishLsn, 39 entryTypes, 40 txnIds, 41 verbose); 42 } 43 44 47 protected boolean processEntry(ByteBuffer entryBuffer) 48 throws DatabaseException { 49 50 51 LogEntryType lastEntryType = 52 LogEntryType.findType(currentEntryTypeNum, 53 currentEntryTypeVersion); 54 55 56 StringBuffer sb = new StringBuffer (); 57 sb.append("<entry lsn=\"0x").append 58 (Long.toHexString(readBufferFileNum)); 59 sb.append("/0x").append 60 (Long.toHexString(currentEntryOffset)); 61 sb.append("\" type=\"").append(lastEntryType); 62 if (LogEntryType.isProvisional(currentEntryTypeVersion)) { 63 sb.append("\" isProvisional=\"true"); 64 } 65 sb.append("\" prev=\"0x"); 66 sb.append(Long.toHexString(currentEntryPrevOffset)); 67 if (verbose) { 68 sb.append("\" size=\"").append(currentEntrySize); 69 sb.append("\" cksum=\"").append(currentEntryChecksum); 70 } 71 sb.append("\">"); 72 73 74 LogEntry entry = lastEntryType.getSharedLogEntry(); 75 entry.readEntry(entryBuffer, currentEntrySize, 76 currentEntryTypeVersion, true); 77 boolean dumpIt = true; 78 if (targetTxnIds.size() > 0) { 79 if (entry.isTransactional()) { 80 if (!targetTxnIds.contains 81 (new Long (entry.getTransactionId()))) { 82 83 dumpIt = false; 84 } 85 } else { 86 87 dumpIt = false; 88 } 89 } 90 91 if (dumpIt) { 92 entry.dumpEntry(sb, verbose); 93 sb.append("</entry>"); 94 System.out.println(sb.toString()); 95 } 96 97 return true; 98 } 99 } 100 | Popular Tags |