org.apache.solr.update

## Class CdcrUpdateLog.CdcrLogReader

- java.lang.Object
- - org.apache.solr.update.CdcrUpdateLog.CdcrLogReader

- Enclosing class:
    CdcrUpdateLog

      public class CdcrUpdateLog.CdcrLogReader
      extends Object

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes streams and remove the associated `CdcrUpdateLog.CdcrLogPointer` from the parent `CdcrUpdateLog`.
    `void` | `forwardSeek(CdcrUpdateLog.CdcrLogReader subReader)` Expert: Fast forward this log reader with a log subreader.
    `long` | `getLastVersion()` Returns the absolute form of the version number of the last entry read.
    `long` | `getNumberOfRemainingRecords()` Returns the number of remaining records (including commit but excluding header) to be read in the logs.
    `CdcrUpdateLog.CdcrLogReader` | `getSubReader()` Expert: Instantiate a sub-reader.
    `Object` | `next()` Advances to the next log entry in the updates log and returns the log entry itself.
    `void` | `resetToLastPosition()` If called after `next()`, it resets the reader to its last position.
    `boolean` | `seek(long targetVersion)` Advances to the first beyond the current whose version number is greater than or equal to targetVersion. Returns true if the reader has been advanced.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getSubReader

          public CdcrUpdateLog.CdcrLogReader getSubReader()

      Expert: Instantiate a sub-reader. A sub-reader is used for batch updates. It allows to iterates over the update logs entries without modifying the state of the parent log reader. If the batch update fails, the state of the sub-reader is discarded and the state of the parent reader is not modified. If the batch update is successful, the sub-reader is used to fast forward the parent reader with the method `forwardSeek(org.apache.solr.update.CdcrUpdateLog.CdcrLogReader)`.

    - #### forwardSeek

          public void forwardSeek(CdcrUpdateLog.CdcrLogReader subReader)

      Expert: Fast forward this log reader with a log subreader. The subreader will be closed after calling this method. In order to avoid unexpected results, the log subreader must be created from this reader with the method `getSubReader()`.

    - #### next

          public Object next()
                      throws IOException,
                             InterruptedException

      Advances to the next log entry in the updates log and returns the log entry itself. Returns null if there are no more log entries in the updates log.

      NOTE: after the reader has exhausted, you can call again this method since the updates log might have been updated with new entries.

      Throws:
        `IOException`
        `InterruptedException`

    - #### seek

          public boolean seek(long targetVersion)
                       throws IOException,
                              InterruptedException

      Advances to the first beyond the current whose version number is greater than or equal to targetVersion.
      Returns true if the reader has been advanced. If targetVersion is greater than the highest version number in the updates log, the reader has been advanced to the end of the current tlog, and a call to `next()` will probably return null.
      Returns false if targetVersion is lower than the oldest known entry. In this scenario, it probably means that there is a gap in the updates log.

      NOTE: This method must be called before the first call to `next()`.

      Throws:
        `IOException`
        `InterruptedException`

    - #### resetToLastPosition

          public void resetToLastPosition()

      If called after `next()`, it resets the reader to its last position.

    - #### getNumberOfRemainingRecords

          public long getNumberOfRemainingRecords()

      Returns the number of remaining records (including commit but excluding header) to be read in the logs.

    - #### close

          public void close()

      Closes streams and remove the associated `CdcrUpdateLog.CdcrLogPointer` from the parent `CdcrUpdateLog`.

    - #### getLastVersion

          public long getLastVersion()

      Returns the absolute form of the version number of the last entry read. If the current version is equal to 0 (because of a commit), it will return the next to last version number.

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.