com.sleepycat.je.rep.stream
Class FeederReader
java.lang.Object
com.sleepycat.je.log.FileReader
com.sleepycat.je.rep.stream.VLSNReader
com.sleepycat.je.rep.stream.FeederReader
public class FeederReader
- extends VLSNReader
The FeederReader is a flavor of VLSNReader which supports replication
stream feeding. It assumes that reading will always go forward in the log.
Special features are:
- The reader can read either from a log buffer or from the file. Sometimes
log entries are logged but are not yet available on disk. In general, it's
better to read from the log buffers rather then the file.
- The reader can block for a given time period, waiting for the next vlsn to
appear
Nested Class Summary |
(package private) static class |
FeederReader.SwitchWindow
The SwitchWindow can fill itself from either the log file or the log
buffers. |
Fields inherited from class com.sleepycat.je.log.FileReader |
cksumValidator, currentEntryHeader, currentEntryOffset, currentEntryPrevOffset, envImpl, eof, fileManager, forward, logger, nextEntryOffset, startLsn, window |
Methods inherited from class com.sleepycat.je.log.FileReader |
entryIsReplicated, getAndResetNReads, getLastEntrySize, getLastLsn, getNRepeatIteratorReads, getNumRead, initStartingPosition, readNextEntry, readNextEntryAllowExceptions, resyncReader, setAlwaysValidateChecksum, setBackwardPosition, setForwardPosition, skipData, skipEntry |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FeederReader
public FeederReader(EnvironmentImpl envImpl,
VLSNIndex vlsnIndex,
long startLsn,
int readBufferSize,
NameIdPair nameIdPair)
FeederReader
FeederReader(EnvironmentImpl envImpl,
VLSNIndex vlsnIndex,
long startLsn,
int readBufferSize)
- For unit testing only!! Bypass the VLSNIndex cache, provide a node name.
makeWindow
protected FileReader.ReadWindow makeWindow(int readBufferSize)
- Use a ReadWindow which can read from LogBuffers as well as the physical
file.
- Overrides:
makeWindow
in class FileReader
- Throws:
DatabaseException
initScan
public void initScan(VLSN startVLSN)
throws IOException
- Set up the FeederReader to start scanning from this VLSN. If we find a
mapping for this VLSN, we'll start precisely at its LSN, else we'll have
to start from an earlier location. This initialization can't be done in
the constructor, because the Feeder is set up to require the
construction of the source before we know where to start.
- Throws:
IOException
scanForwards
public OutputWireRecord scanForwards(VLSN vlsn,
int waitTime)
throws InterruptedException
- Forward scanning for feeding the replica: get the log record for this
VLSN. If the log record hasn't been created yet, wait for a period
specified by "waitTime".
Where possible, the FeederReader fetches the log record from the cache
within the VLSNIndex. (See the VLSNIndex for a description of this two
level cache). If the requested VLSN is not available from the cache, the
reader fetches the item from the JE log -- either from the log buffers
or from disk.
The FeederReader is like a cursor on the log, and retains a position
in the log. When there are log item cache hits, the FeederReader's
position can fall behind, because it is being bypassed. It is possible
for log cleaning to take place between the point of the FeederReader's
stale position and the end of the log. If so, the FeederReader must
not attempt to scan from its current position, because it might
run afoul of gap created by the cleaned and delete log files. When
there have been log item cache hits, the FeederReader must jump its
position forward using the vlsnIndex mappings to safely skip over
any cleaned gaps in the log.
- Throws:
InterruptedException
isTargetEntry
protected boolean isTargetEntry()
- Return true if this entry is replicated and its VLSN is currentVLSN.
- Overrides:
isTargetEntry
in class FileReader
- Returns:
- true if this reader should process this entry, or just
skip over it.
dumpState
String dumpState()
Copyright (c) 2004-2012 Oracle. All rights reserved.