CommitLog (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.db.commitlog

## Class CommitLog

- java.lang.Object
- - org.apache.cassandra.db.commitlog.CommitLog

- All Implemented Interfaces:
    CommitLogMBean

      public class CommitLog
      extends java.lang.Object
      implements CommitLogMBean

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CommitLog.Configuration`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `CommitLogSegmentManager` | `allocator`
    `CommitLogArchiver` | `archiver`
    `static CommitLog` | `instance`
    `java.lang.String` | `location`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `activeSegments()` Used by tests.
    `ReplayPosition` | `add(Mutation mutation)` Add a Mutation to the commit log.
    `void` | `discardCompletedSegments(java.util.UUID cfId, ReplayPosition context)` Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given.
    `void` | `forceRecycleAllSegments()` Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining
    `void` | `forceRecycleAllSegments(java.lang.Iterable<java.util.UUID> droppedCfs)` Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining
    `long` | `getActiveContentSize()`
    `long` | `getActiveOnDiskSize()`
    `java.util.Map<java.lang.String,java.lang.Double>` | `getActiveSegmentCompressionRatios()`
    `java.util.List<java.lang.String>` | `getActiveSegmentNames()`
    `java.lang.String` | `getArchiveCommand()` Command to execute to archive a commitlog segment.
    `java.util.List<java.lang.String>` | `getArchivingSegmentNames()`
    `ReplayPosition` | `getContext()`
    `java.lang.String` | `getRestoreCommand()` Command to execute to make an archived commitlog live again
    `java.lang.String` | `getRestoreDirectories()` Directory to scan the recovery files in
    `long` | `getRestorePointInTime()` Restore mutations created up to and including this timestamp in GMT Format: yyyy:MM:dd HH:mm:ss (2012:04:31 20:43:12) Recovery will continue through the segment when the first client-supplied timestamp greater than this time is encountered, but only mutations less than or equal to this timestamp will be applied.
    `java.lang.String` | `getRestorePrecision()` get precision of the timestamp used in the restore (MILLISECONDS, MICROSECONDS, ...) to determine if passed the restore point in time.
    `static boolean` | `handleCommitError(java.lang.String message, java.lang.Throwable t)`
    `int` | `recover()` Perform recovery on commit logs located in the directory specified by the config file.
    `int` | `recover(java.io.File... clogs)` Perform recovery on a list of commit log files.
    `void` | `recover(java.lang.String path)` Perform recovery on a single commit log.
    `void` | `requestExtraSync()` Preempts the CLExecutor, telling to to sync immediately
    `void` | `resetConfiguration()` FOR TESTING PURPOSES.
    `int` | `resetUnsafe(boolean deleteSegments)` FOR TESTING PURPOSES.
    `int` | `restartUnsafe()` FOR TESTING PURPOSES.
    `void` | `shutdownBlocking()` Shuts down the threads used by the commit log, blocking until completion.
    `void` | `stopUnsafe(boolean deleteSegments)` FOR TESTING PURPOSES.
    `void` | `sync(boolean syncAllSegments)` Forces a disk flush on the commit log files that need it.

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

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

- - ### Field Detail

    - #### instance

          public static final CommitLog instance

    - #### allocator

          public final CommitLogSegmentManager allocator

    - #### archiver

          public final CommitLogArchiver archiver

    - #### location

          public final java.lang.String location

  - ### Method Detail

    - #### recover

          public int recover()
                      throws java.io.IOException

      Perform recovery on commit logs located in the directory specified by the config file.
      Returns:
        the number of mutations replayed
      Throws:
        `java.io.IOException`

    - #### recover

          public int recover(java.io.File... clogs)
                      throws java.io.IOException

      Perform recovery on a list of commit log files.
      Parameters:
        `clogs` - the list of commit log files to replay
      Returns:
        the number of mutations replayed
      Throws:
        `java.io.IOException`

    - #### recover

          public void recover(java.lang.String path)
                       throws java.io.IOException

      Perform recovery on a single commit log.
      Specified by:
        `recover` in interface `CommitLogMBean`
      Throws:
        `java.io.IOException`

    - #### getContext

          public ReplayPosition getContext()

      Returns:
        a ReplayPosition which, if >= one returned from add(), implies add() was started (but not necessarily finished) prior to this call

    - #### forceRecycleAllSegments

          public void forceRecycleAllSegments(java.lang.Iterable<java.util.UUID> droppedCfs)

      Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining

    - #### forceRecycleAllSegments

          public void forceRecycleAllSegments()

      Flushes all dirty CFs, waiting for them to free and recycle any segments they were retaining

    - #### sync

          public void sync(boolean syncAllSegments)

      Forces a disk flush on the commit log files that need it. Blocking.

    - #### requestExtraSync

          public void requestExtraSync()

      Preempts the CLExecutor, telling to to sync immediately

    - #### add

          public ReplayPosition add(Mutation mutation)

      Add a Mutation to the commit log.
      Parameters:
        `mutation` - the Mutation to add to the log

    - #### discardCompletedSegments

          public void discardCompletedSegments(java.util.UUID cfId,
                                               ReplayPosition context)

      Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given. Discards any commit log segments that are no longer used.
      Parameters:
        `cfId` - the column family ID that was flushed
        `context` - the replay position of the flush

    - #### getArchiveCommand

          public java.lang.String getArchiveCommand()

      Description copied from interface: `CommitLogMBean`
      Command to execute to archive a commitlog segment. Blank to disabled.
      Specified by:
        `getArchiveCommand` in interface `CommitLogMBean`

    - #### getRestoreCommand

          public java.lang.String getRestoreCommand()

      Description copied from interface: `CommitLogMBean`
      Command to execute to make an archived commitlog live again
      Specified by:
        `getRestoreCommand` in interface `CommitLogMBean`

    - #### getRestoreDirectories

          public java.lang.String getRestoreDirectories()

      Description copied from interface: `CommitLogMBean`
      Directory to scan the recovery files in
      Specified by:
        `getRestoreDirectories` in interface `CommitLogMBean`

    - #### getRestorePointInTime

          public long getRestorePointInTime()

      Description copied from interface: `CommitLogMBean`
      Restore mutations created up to and including this timestamp in GMT Format: yyyy:MM:dd HH:mm:ss (2012:04:31 20:43:12) Recovery will continue through the segment when the first client-supplied timestamp greater than this time is encountered, but only mutations less than or equal to this timestamp will be applied.
      Specified by:
        `getRestorePointInTime` in interface `CommitLogMBean`

    - #### getRestorePrecision

          public java.lang.String getRestorePrecision()

      Description copied from interface: `CommitLogMBean`
      get precision of the timestamp used in the restore (MILLISECONDS, MICROSECONDS, ...) to determine if passed the restore point in time.
      Specified by:
        `getRestorePrecision` in interface `CommitLogMBean`

    - #### getActiveSegmentNames

          public java.util.List<java.lang.String> getActiveSegmentNames()

      Specified by:
        `getActiveSegmentNames` in interface `CommitLogMBean`
      Returns:
        file names (not full paths) of active commit log segments (segments containing unflushed data)

    - #### getArchivingSegmentNames

          public java.util.List<java.lang.String> getArchivingSegmentNames()

      Specified by:
        `getArchivingSegmentNames` in interface `CommitLogMBean`
      Returns:
        Files which are pending for archival attempt. Does NOT include failed archive attempts.

    - #### getActiveContentSize

          public long getActiveContentSize()

      Specified by:
        `getActiveContentSize` in interface `CommitLogMBean`
      Returns:
        The size of the mutations in all active commit log segments (uncompressed).

    - #### getActiveOnDiskSize

          public long getActiveOnDiskSize()

      Specified by:
        `getActiveOnDiskSize` in interface `CommitLogMBean`
      Returns:
        The space taken on disk by the commit log (compressed).

    - #### getActiveSegmentCompressionRatios

          public java.util.Map<java.lang.String,java.lang.Double> getActiveSegmentCompressionRatios()

      Specified by:
        `getActiveSegmentCompressionRatios` in interface `CommitLogMBean`
      Returns:
        A map between active log segments and the compression ratio achieved for each.

    - #### shutdownBlocking

          public void shutdownBlocking()
                                throws java.lang.InterruptedException

      Shuts down the threads used by the commit log, blocking until completion.
      Throws:
        `java.lang.InterruptedException`

    - #### resetUnsafe

          public int resetUnsafe(boolean deleteSegments)
                          throws java.io.IOException

      FOR TESTING PURPOSES. See CommitLogAllocator.
      Returns:
        the number of files recovered
      Throws:
        `java.io.IOException`

    - #### stopUnsafe

          public void stopUnsafe(boolean deleteSegments)

      FOR TESTING PURPOSES. See CommitLogAllocator.

    - #### resetConfiguration

          public void resetConfiguration()

      FOR TESTING PURPOSES.

    - #### restartUnsafe

          public int restartUnsafe()
                            throws java.io.IOException

      FOR TESTING PURPOSES. See CommitLogAllocator
      Throws:
        `java.io.IOException`

    - #### activeSegments

          public int activeSegments()

      Used by tests.
      Returns:
        the number of active segments (segments with unflushed data in them)

    - #### handleCommitError

          public static boolean handleCommitError(java.lang.String message,
                                                  java.lang.Throwable t)

Copyright © 2018 The Apache Software Foundation