TxnLog (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server.persistence

## Interface TxnLog

- All Superinterfaces:
    AutoCloseable, Closeable
  All Known Implementing Classes:
    FileTxnLog

      public interface TxnLog
      extends Closeable

  Interface for reading transaction logs.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `TxnLog.TxnIterator` an iterating interface for reading transaction logs.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `append(TxnHeader hdr, Record r)` Append a request to the transaction log
    `boolean` | `append(TxnHeader hdr, Record r, TxnDigest digest)` Append a request to the transaction log with a digset
    `void` | `close()` close the transactions logs
    `void` | `commit()` commit the transaction and make sure they are persisted
    `long` | `getDbId()` the dbid for this transaction log.
    `long` | `getLastLoggedZxid()` the last zxid of the logged transactions.
    `long` | `getTotalLogSize()` Gets the total size of all log files
    `long` | `getTxnLogSyncElapsedTime()`
    `TxnLog.TxnIterator` | `read(long zxid)` Start reading the transaction logs from a given zxid
    `void` | `rollLog()` roll the current log being appended to
    `void` | `setServerStats(ServerStats serverStats)` Setter for ServerStats to monitor fsync threshold exceed
    `void` | `setTotalLogSize(long size)` Sets the total size of all log files
    `boolean` | `truncate(long zxid)` truncate the log to get in sync with the leader.

- - ### Method Detail

    - #### setServerStats

          void setServerStats(ServerStats serverStats)

      Setter for ServerStats to monitor fsync threshold exceed
      Parameters:
        `serverStats` - used to update fsyncThresholdExceedCount

    - #### rollLog

          void rollLog()
                throws IOException

      roll the current log being appended to
      Throws:
        `IOException`

    - #### append

          boolean append(TxnHeader hdr,
                         Record r)
                  throws IOException

      Append a request to the transaction log
      Parameters:
        `hdr` - the transaction header
        `r` - the transaction itself
      Returns:
        true iff something appended, otw false
      Throws:
        `IOException`

    - #### append

          boolean append(TxnHeader hdr,
                         Record r,
                         TxnDigest digest)
                  throws IOException

      Append a request to the transaction log with a digset
      Parameters:
        `hdr` - the transaction header
        `r` - the transaction itself
        `digest` - transaction digest returns true iff something appended, otw false
      Throws:
        `IOException`

    - #### read

          TxnLog.TxnIterator read(long zxid)
                           throws IOException

      Start reading the transaction logs from a given zxid
      Parameters:
        `zxid` -
      Returns:
        returns an iterator to read the next transaction in the logs.
      Throws:
        `IOException`

    - #### getLastLoggedZxid

          long getLastLoggedZxid()
                          throws IOException

      the last zxid of the logged transactions.
      Returns:
        the last zxid of the logged transactions.
      Throws:
        `IOException`

    - #### truncate

          boolean truncate(long zxid)
                    throws IOException

      truncate the log to get in sync with the leader.
      Parameters:
        `zxid` - the zxid to truncate at.
      Throws:
        `IOException`

    - #### getDbId

          long getDbId()
                throws IOException

      the dbid for this transaction log.
      Returns:
        the dbid for this transaction log.
      Throws:
        `IOException`

    - #### commit

          void commit()
               throws IOException

      commit the transaction and make sure they are persisted
      Throws:
        `IOException`

    - #### getTxnLogSyncElapsedTime

          long getTxnLogSyncElapsedTime()

      Returns:
        transaction log's elapsed sync time in milliseconds

    - #### close

          void close()
              throws IOException

      close the transactions logs
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`
      Throws:
        `IOException`

    - #### setTotalLogSize

          void setTotalLogSize(long size)

      Sets the total size of all log files

    - #### getTotalLogSize

          long getTotalLogSize()

      Gets the total size of all log files

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.