CommitLog (apache-cassandra API)
Date: 2014-10-21

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `CommitLogSegmentManager` | `allocator`
    `CommitLogArchiver` | `archiver`
    `static CommitLog` | `instance`

  - ### Method Summary

    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
    `java.util.List<java.lang.String>` | `getActiveSegmentNames()`
    `java.util.List<java.lang.String>` | `getArchivingSegmentNames()`
    `long` | `getCompletedTasks()` Get the number of completed tasks
    `ReplayPosition` | `getContext()`
    `long` | `getPendingTasks()` Get the number of tasks waiting to be executed
    `long` | `getTotalCommitlogSize()` Get the current size used by all the commitlog segments.
    `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` | `resetUnsafe()` FOR TESTING PURPOSES.
    `void` | `shutdownBlocking()` Shuts down the threads used by the commit log, blocking until completion.
    `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

  - ### 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 Future representing a ReplayPosition such that when it is ready, all Allocations created prior to the getContext call will be written to the log

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

    - #### getCompletedTasks

          public long getCompletedTasks()

      Description copied from interface: `CommitLogMBean`
      Get the number of completed tasks
      Specified by:
        `getCompletedTasks` in interface `CommitLogMBean`
      See Also:
        `CommitLogMetrics.completedTasks`

    - #### getPendingTasks

          public long getPendingTasks()

      Description copied from interface: `CommitLogMBean`
      Get the number of tasks waiting to be executed
      Specified by:
        `getPendingTasks` in interface `CommitLogMBean`
      See Also:
        `CommitLogMetrics.pendingTasks`

    - #### getTotalCommitlogSize

          public long getTotalCommitlogSize()

      Description copied from interface: `CommitLogMBean`
      Get the current size used by all the commitlog segments.
      Specified by:
        `getTotalCommitlogSize` in interface `CommitLogMBean`
      Returns:
        the total size occupied by commitlog segments expressed in bytes. (used by MBean)
      See Also:
        `CommitLogMetrics.totalCommitLogSize`

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

    - #### 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 void resetUnsafe()

      FOR TESTING PURPOSES. See CommitLogAllocator.

    - #### activeSegments

          public int activeSegments()

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

Copyright © 2014 The Apache Software Foundation