## org.apache.cassandra.db.commitlog
Class CommitLogSegment

    java.lang.Object
      org.apache.cassandra.db.commitlog.CommitLogSegment

    public class CommitLogSegment

extends java.lang.Object

Field Summary
`long` `id`

Method Summary
`void` `close()` Close the segment file.
`boolean` `contains(ReplayPosition context)` Check to see if a certain ReplayPosition is contained by this segment file.
`java.lang.String` `dirtyString()`
`void` `discard(boolean deleteFile)` Completely discards a segment file by deleting it.
`static CommitLogSegment` `freshSegment()`
`ReplayPosition` `getContext()`
`java.util.Collection<java.lang.Integer>` `getDirtyCFIDs()`
`java.lang.String` `getName()`
`static long` `getNextId()`
`java.lang.String` `getPath()`
`boolean` `hasCapacityFor(RowMutation mutation)`
`static long` `idFromFilename(java.lang.String filename)` Extracts the commit log ID from filename
`boolean` `isUnused()`
`void` `markClean(java.lang.Integer cfId, ReplayPosition context)` Marks the ColumnFamily specified by cfId as clean for this log segment.
`int` `position()`
`static boolean` `possibleCommitLogFile(java.lang.String filename)`
`CommitLogSegment` `recycle()` Recycle processes an unneeded segment file for reuse.
`void` `sync()` Forces a disk flush for this segment file.
`java.lang.String` `toString()`
`ReplayPosition` `write(RowMutation rowMutation)` Appends a row mutation onto the commit log.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### id

    public final long id

Method Detail

### freshSegment

    public static CommitLogSegment freshSegment()

  Returns:
    a newly minted segment file

### getNextId

    public static long getNextId()

### idFromFilename

    public static long idFromFilename(java.lang.String filename)

  Extracts the commit log ID from filename

  Parameters:
    `filename` - the filename of the commit log file
  Returns:
    the extracted commit log ID

### possibleCommitLogFile

    public static boolean possibleCommitLogFile(java.lang.String filename)

  Parameters:
    `filename` - the filename to check
  Returns:
    true if filename could be a commit log based on it's filename

### discard

    public void discard(boolean deleteFile)

  Completely discards a segment file by deleting it. (Potentially blocking operation)

### recycle

    public CommitLogSegment recycle()

  Recycle processes an unneeded segment file for reuse.

  Returns:
    a new CommitLogSegment representing the newly reusable segment.

### hasCapacityFor

    public boolean hasCapacityFor(RowMutation mutation)

  Returns:
    true if there is room to write() @param mutation to this segment

### write

    public ReplayPosition write(RowMutation rowMutation)
                         throws java.io.IOException

  Appends a row mutation onto the commit log. Requres that hasCapacityFor has already been checked.

  Parameters:
    `rowMutation` - the mutation to append to the commit log.
  Returns:
    the position of the appended mutation
  Throws:
    `java.io.IOException`

### sync

    public void sync()
              throws java.io.IOException

  Forces a disk flush for this segment file.

  Throws:
    `java.io.IOException`

### getContext

    public ReplayPosition getContext()

  Returns:
    the current ReplayPosition for this log segment

### getPath

    public java.lang.String getPath()

  Returns:
    the file path to this segment

### getName

    public java.lang.String getName()

  Returns:
    the file name of this segment

### close

    public void close()

  Close the segment file.

### markClean

    public void markClean(java.lang.Integer cfId,
                          ReplayPosition context)

  Marks the ColumnFamily specified by cfId as clean for this log segment. If the given context argument is contained in this file, it will only mark the CF as clean if no newer writes have taken place.

  Parameters:
    `cfId` - the column family ID that is now clean
    `context` - the optional clean offset

### getDirtyCFIDs

    public java.util.Collection<java.lang.Integer> getDirtyCFIDs()

  Returns:
    a collection of dirty CFIDs for this segment file.

### isUnused

    public boolean isUnused()

  Returns:
    true if this segment is unused and safe to recycle or delete

### contains

    public boolean contains(ReplayPosition context)

  Check to see if a certain ReplayPosition is contained by this segment file.

  Parameters:
    `context` - the replay position to be checked
  Returns:
    true if the replay position is contained by this segment file.

### dirtyString

    public java.lang.String dirtyString()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### position

    public int position()

Copyright © 2013 The Apache Software Foundation