1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2002,2010 Oracle. All rights reserved.
*
* $Id: TestUtilLogReader.java,v 1.11.2.3 2010/01/04 15:30:44 cwl Exp $
*/
package com.sleepycat.je.log;
import java.io.IOException;
import java.nio.ByteBuffer;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.dbi.EnvironmentImpl;
import com.sleepycat.je.log.entry.LogEntry;
import com.sleepycat.je.utilint.DbLsn;
/**
* Instantiates all log entries using the shared log entry instances.
*/
public class TestUtilLogReader extends FileReader {
private LogEntryType entryType;
private LogEntry entry;
private boolean readFullItem;
public TestUtilLogReader(EnvironmentImpl env, boolean readFullItem)
throws IOException, DatabaseException {
super(env,
4096,
true,
DbLsn.NULL_LSN,
null,
DbLsn.NULL_LSN,
DbLsn.NULL_LSN);
this.readFullItem = readFullItem;
}
public TestUtilLogReader(EnvironmentImpl env,
int readBufferSize,
boolean forward,
long startLsn,
Long singleFileNumber,
long endOfFileLsn,
long finishLsn)
throws IOException, DatabaseException {
super(env,
readBufferSize,
forward,
startLsn,
singleFileNumber,
endOfFileLsn,
finishLsn);
}
public LogEntryType getEntryType() {
return entryType;
}
public int getEntryVersion() {
return currentEntryHeader.getVersion();
}
public LogEntry getEntry() {
return entry;
}
protected boolean isTargetEntry() {
return true;
}
protected boolean processEntry(ByteBuffer entryBuffer)
throws DatabaseException {
entryType = LogEntryType.findType(currentEntryHeader.getType());
entry = entryType.getSharedLogEntry();
entry.readEntry(currentEntryHeader,
entryBuffer,
readFullItem);
return true;
}
}
|