org.apache.cassandra.db.commitlog
Class CommitLog

java.lang.Object
  extended by org.apache.cassandra.db.commitlog.CommitLog
All Implemented Interfaces:
CommitLogMBean

public class CommitLog
extends java.lang.Object
implements CommitLogMBean


Field Summary
 CommitLogSegment activeSegment
           
 CommitLogAllocator allocator
           
static int END_OF_SEGMENT_MARKER
           
static int END_OF_SEGMENT_MARKER_SIZE
           
static CommitLog instance
           
static int SEGMENT_SIZE
          size of commitlog segments to allocate
 
Method Summary
 int activeSegments()
          Used by tests.
 void add(RowMutation rm)
          Add a RowMutation to the commit log.
 void discardCompletedSegments(java.lang.Integer cfId, ReplayPosition context)
          Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given.
 void forceNewSegment()
          Forces a new segment file to be allocated and activated.
 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 resetUnsafe()
          FOR TESTING PURPOSES.
 void shutdownBlocking()
          Shuts down the threads used by the commit log, blocking until completion.
 void sync()
          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 CommitLogAllocator allocator

END_OF_SEGMENT_MARKER

public static final int END_OF_SEGMENT_MARKER
See Also:
Constant Field Values

END_OF_SEGMENT_MARKER_SIZE

public static final int END_OF_SEGMENT_MARKER_SIZE
See Also:
Constant Field Values

SEGMENT_SIZE

public static final int SEGMENT_SIZE
size of commitlog segments to allocate

See Also:
Constant Field Values

activeSegment

public CommitLogSegment activeSegment
Method Detail

resetUnsafe

public void resetUnsafe()
                 throws java.io.IOException
FOR TESTING PURPOSES. See CommitLogAllocator.

Throws:
java.io.IOException

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

getContext

public ReplayPosition getContext()
Returns:
the current ReplayPosition of the current segment file

activeSegments

public int activeSegments()
Used by tests.

Returns:
the number of active segments (segments with unflushed data in them)

add

public void add(RowMutation rm)
         throws java.io.IOException
Add a RowMutation to the commit log.

Parameters:
rm - the RowMutation to add to the log
Throws:
java.io.IOException

discardCompletedSegments

public void discardCompletedSegments(java.lang.Integer cfId,
                                     ReplayPosition context)
                              throws java.io.IOException
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
Throws:
java.io.IOException

sync

public void sync()
          throws java.io.IOException
Forces a disk flush on the commit log files that need it.

Throws:
java.io.IOException

getCompletedTasks

public long getCompletedTasks()
Description copied from interface: CommitLogMBean
Get the number of completed tasks

Specified by:
getCompletedTasks in interface CommitLogMBean
Returns:
the number of tasks completed by the commit log executor

getPendingTasks

public long getPendingTasks()
Description copied from interface: CommitLogMBean
Get the number of tasks waiting to be executed

Specified by:
getPendingTasks in interface CommitLogMBean
Returns:
the depth of pending commit log executor queue

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 commitlo segments expressed in bytes. (used by MBean)

forceNewSegment

public void forceNewSegment()
                     throws java.util.concurrent.ExecutionException,
                            java.lang.InterruptedException
Forces a new segment file to be allocated and activated. Used mainly by truncate.

Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException

shutdownBlocking

public void shutdownBlocking()
                      throws java.lang.InterruptedException
Shuts down the threads used by the commit log, blocking until completion.

Throws:
java.lang.InterruptedException


Copyright © 2012 The Apache Software Foundation