Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  import static;
The FeederSyncupReader scans the log backwards for requested log entries. It uses the vlsnIndex to optimize its search, repositioning when a concrete vlsn->lsn mapping is available. The FeederSyncupReader is not thread safe, and can only be used serially. It will stop at the finishLsn, which should be set using the GlobalCBVLSN.
 public class FeederSyncupReader extends VLSNReader {
     /* The scanner is a cursor over the VLSNIndex. */
     private final BackwardVLSNScanner scanner;
     public FeederSyncupReader(EnvironmentImpl envImpl,
                               VLSNIndex vlsnIndex,
                               long endOfLogLsn,
                               int readBufferSize,
                               NameIdPair nameIdPair,
                               VLSN startVLSN,
                               long finishLsn)
         throws IOExceptionDatabaseException {
          * If we go backwards, endOfFileLsn and startLsn must not be null.
          * Make them the same, so we always start at the same very end.
               false,           // forward
          = new BackwardVLSNScanner(vlsnIndex);

Set up the FeederSyncupReader 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.

     private void initScan(VLSN startVLSN)
         throws DatabaseExceptionIOException {
         if (startVLSN.equals(.)) {
             throw EnvironmentFailureException.unexpectedState
                 ("FeederSyncupReader start can't be NULL_VLSN");
         VLSN startPoint = startVLSN;
          = .getStartingLsn(startPoint);
         assert  != ;
          * Flush the log so that syncup can assume that all log entries that
          * are represented in the VLSNIndex  are safely out of the log buffers
          * and on disk. Simplifies this reader, so it can use the regular
          * ReadWindow, which only works on a file.
          = .getEndOffset();
          = startVLSN;

Backward scanning for records for the feeder's part in syncup.

    public OutputWireRecord scanBackwards(VLSN vlsn)
        throws FileNotFoundExceptionChecksumException {
        VLSNRange range = .getRange();
        if (vlsn.compareTo(range.getFirst()) < 0) {
             * The requested VLSN is before the start of our range, we don't
             * have this record.
            return null;
         = vlsn;
         * If repositionLsn is not NULL_LSN, the reader will seek to that
         * position when calling readNextEntry instead of scanning.
         * setPosition() is a noop if repositionLsn is null.
        long repositionLsn = .getPreciseLsn(vlsn);
        if (readNextEntry()) {
            return ;
        return null;


an EnvironmentFailureException if we were scanning for a particular VLSN and we have passed it by.
    private void checkForPassingTarget(int compareResult) {
        if (compareResult < 0) {
            /* Hey, we passed the VLSN we wanted. */
            throw EnvironmentFailureException.unexpectedState
                ("want to read " +  + " but reader at " +
    protected boolean isTargetEntry()
        throws DatabaseException {
        /* Skip invisible entries. */
        if (.isInvisible()) {
            return false;
         * Return true if this entry is replicated and its VLSN is currentVLSN.
        if (entryIsReplicated()) {
            VLSN entryVLSN = .getVLSN();
            int compareResult = entryVLSN.compareTo();
            /* return true if this is the entry we want. */
            return (compareResult == 0);
        return false;

Instantiate a WireRecord to house this log entry.
    protected boolean processEntry(ByteBuffer entryBuffer) {
        ByteBuffer buffer = entryBuffer.slice();
            new OutputWireRecord(buffer);
        entryBuffer.position(entryBuffer.position() +
        return true;
New to GrepCode? Check out our FAQ X