org.apache.solr.update

## Class TransactionLog

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

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    CdcrTransactionLog, HdfsTransactionLog

      public class TransactionLog
      extends Object
      implements Closeable

  Log Format: List{Operation, Version, ...} ADD, VERSION, DOC DELETE, VERSION, ID_BYTES DELETE_BY_QUERY, VERSION, String TODO: keep two files, one for [operation, version, id] and the other for the actual document data. That way we could throw away document log files more readily while retaining the smaller operation log files longer (and we can retrieve the stored fields from the latest documents from the index). This would require keeping all source fields stored of course. This would also allow to not log document data for requests with commit=true in them (since we know that if the request succeeds, all docs will be committed)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `TransactionLog.FSReverseReader`
    `class` | `TransactionLog.LogCodec`
    `class` | `TransactionLog.LogReader`
    `class` | `TransactionLog.ReverseReader`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `deleteOnClose`
    `static String` | `END_MESSAGE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TransactionLog()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addGlobalStrings(Collection<String> strings)`
    `void` | `close()`
    `void` | `closeOutput()` Move to a read-only state, closing and releasing resources while keeping the log available for reads
    `void` | `decref()`
    `protected void` | `endRecord(long startRecordPosition)`
    `boolean` | `endsWithCommit()`
    `void` | `finish(UpdateLog.SyncLevel syncLevel)`
    `void` | `forceClose()`
    `long` | `getLogSize()`
    `TransactionLog.LogReader` | `getReader(long startingPos)` Returns a reader that can be used while a log is still in use.
    `TransactionLog.ReverseReader` | `getReverseReader()` Returns a single threaded reverse reader
    `void` | `incref()`
    `Object` | `lookup(long pos)`
    `int` | `numRecords()` Returns the number of records in the log (currently includes the header and an optional commit).
    `long` | `position()` returns the current position in the log file
    `void` | `rollback(long pos)`
    `long` | `snapshot()` takes a snapshot of the current position and number of records for later possible rollback, and returns the position
    `String` | `toString()`
    `boolean` | `try_incref()`
    `long` | `write(AddUpdateCommand cmd, int flags)`
    `long` | `writeCommit(CommitUpdateCommand cmd, int flags)`
    `long` | `writeData(Object o)`
    `long` | `writeDelete(DeleteUpdateCommand cmd, int flags)`
    `long` | `writeDeleteByQuery(DeleteUpdateCommand cmd, int flags)`
    `protected void` | `writeLogHeader(TransactionLog.LogCodec codec)`

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

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

- - ### Field Detail

    - #### END_MESSAGE

          public static final String END_MESSAGE

      See Also:
        Constant Field Values

    - #### deleteOnClose

          protected volatile boolean deleteOnClose

  - ### Constructor Detail

    - #### TransactionLog

          protected TransactionLog()

  - ### Method Detail

    - #### numRecords

          public int numRecords()

      Returns the number of records in the log (currently includes the header and an optional commit). Note: currently returns 0 for reopened existing log files.

    - #### endsWithCommit

          public boolean endsWithCommit()
                                 throws IOException

      Throws:
        `IOException`

    - #### snapshot

          public long snapshot()

      takes a snapshot of the current position and number of records for later possible rollback, and returns the position

    - #### rollback

          public void rollback(long pos)
                        throws IOException

      Throws:
        `IOException`

    - #### writeData

          public long writeData(Object o)

    - #### addGlobalStrings

          protected void addGlobalStrings(Collection<String> strings)

    - #### writeLogHeader

          protected void writeLogHeader(TransactionLog.LogCodec codec)
                                 throws IOException

      Throws:
        `IOException`

    - #### endRecord

          protected void endRecord(long startRecordPosition)
                            throws IOException

      Throws:
        `IOException`

    - #### write

          public long write(AddUpdateCommand cmd,
                            int flags)

    - #### writeDelete

          public long writeDelete(DeleteUpdateCommand cmd,
                                  int flags)

    - #### writeDeleteByQuery

          public long writeDeleteByQuery(DeleteUpdateCommand cmd,
                                         int flags)

    - #### writeCommit

          public long writeCommit(CommitUpdateCommand cmd,
                                  int flags)

    - #### lookup

          public Object lookup(long pos)

    - #### incref

          public void incref()

    - #### try_incref

          public boolean try_incref()

    - #### decref

          public void decref()

    - #### position

          public long position()

      returns the current position in the log file

    - #### closeOutput

          public void closeOutput()

      Move to a read-only state, closing and releasing resources while keeping the log available for reads

    - #### finish

          public void finish(UpdateLog.SyncLevel syncLevel)

    - #### close

          public void close()

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`

    - #### forceClose

          public void forceClose()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getLogSize

          public long getLogSize()

    - #### 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.

    - #### getReverseReader

          public TransactionLog.ReverseReader getReverseReader()
                                                        throws IOException

      Returns a single threaded reverse reader
      Throws:
        `IOException`

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