org.apache.solr.update

## Class CdcrTransactionLog

- java.lang.Object
- - org.apache.solr.update.TransactionLog
  - - org.apache.solr.update.CdcrTransactionLog

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class CdcrTransactionLog
      extends TransactionLog

  Extends `TransactionLog` to:
  - reopen automatically the output stream if its reference count reached 0. This is achieved by extending methods `incref()`, `close()` and `reopenOutputStream()`.
  - encode the number of records in the tlog file in the last commit record. The number of records will be decoded and reuse if the tlog file is reopened. This is achieved by extending the constructor, and the methods `writeCommit(CommitUpdateCommand, int)` and `getReader(long)`.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `CdcrTransactionLog.CdcrLogReader`

    - ### Nested classes/interfaces inherited from class org.apache.solr.update.TransactionLog

      `TransactionLog.FSReverseReader, TransactionLog.LogCodec, TransactionLog.LogReader, TransactionLog.ReverseReader`

  - ### Field Summary

    - ### Fields inherited from class org.apache.solr.update.TransactionLog

      `deleteOnClose, END_MESSAGE`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `TransactionLog.LogReader` | `getReader(long startingPos)` Returns a reader that can be used while a log is still in use.
    `void` | `incref()`
    `int` | `numRecords()` Returns the number of records in the log (currently includes the header and an optional commit).
    `boolean` | `try_incref()` Modified to act like `incref()` in order to be compatible with `UpdateLog.recoverFromLog()`.
    `long` | `writeCommit(CommitUpdateCommand cmd, int flags)`

    - ### Methods inherited from class org.apache.solr.update.TransactionLog

      `addGlobalStrings, closeOutput, decref, endRecord, endsWithCommit, finish, forceClose, getLogSize, getReverseReader, lookup, position, rollback, snapshot, toString, write, writeData, writeDelete, writeDeleteByQuery, writeLogHeader`

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

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

- - ### Method Detail

    - #### numRecords

          public int numRecords()

      Returns the number of records in the log (currently includes the header and an optional commit).
      Overrides:
        `numRecords` in class `TransactionLog`

    - #### writeCommit

          public long writeCommit(CommitUpdateCommand cmd,
                                  int flags)

      Overrides:
        `writeCommit` in class `TransactionLog`

    - #### getReader

          public TransactionLog.LogReader getReader(long startingPos)

      Returns a reader that can be used while a log is still in use. Currently only *one* LogReader may be outstanding, and that log may only be used from a single thread.
      Overrides:
        `getReader` in class `TransactionLog`

    - #### incref

          public void incref()

      Overrides:
        `incref` in class `TransactionLog`

    - #### try_incref

          public boolean try_incref()

      Modified to act like `incref()` in order to be compatible with `UpdateLog.recoverFromLog()`. Otherwise, we would have to duplicate the method `UpdateLog.recoverFromLog()` in `CdcrUpdateLog` and change the call `if (!ll.try_incref()) continue;` to `incref();` .
      Overrides:
        `try_incref` in class `TransactionLog`

    - #### close

          public void close()

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `TransactionLog`

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