Class CommitLogSegment
java.lang.Object
org.apache.cassandra.db.commitlog.CommitLogSegment
- Direct Known Subclasses:
DirectIOSegment,FileDirectSegment,MemoryMappedSegment
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA simple class for tracking information about the portion of a segment that has been allocated to a log write.protected static classstatic enumstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CommitLogDescriptorstatic final intfinal longprotected final AbstractCommitLogSegmentManager -
Method Summary
Modifier and TypeMethodDescriptionProvide any additional header data that should be stored in theCommitLogDescriptor.booleancontains(CommitLogPosition context) Check to see if a certain CommitLogPosition is contained by this segment file.longstatic <K> voidcoverInMap(ConcurrentMap<K, IntegerInterval> map, K key, int value) protected ByteBuffergetName()getPath()protected voidClose the segment file.booleanbooleanisUnused()voidmarkClean(TableId tableId, CommitLogPosition startPosition, CommitLogPosition endPosition) Marks the ColumnFamily specified by id as clean for this log segment.abstract longstatic voidFOR TESTING PURPOSES.setCDCState(CommitLogSegment.CDCState newState) Change the current cdcState on this CommitLogSegment.toString()static voidwriteCDCIndexFile(CommitLogDescriptor desc, int offset, boolean complete) We persist the offset of the last data synced to disk so clients can parse only durable data if they choose.protected static voidwriteSyncMarker(long id, ByteBuffer buffer, int offset, int filePos, int nextMarker) Create a sync marker to delineate sections of the commit log, typically created on each sync of the file.
-
Field Details
-
ENTRY_OVERHEAD_SIZE
public static final int ENTRY_OVERHEAD_SIZE- See Also:
-
id
public final long id -
manager
-
descriptor
-
-
Method Details
-
additionalHeaderParameters
Provide any additional header data that should be stored in theCommitLogDescriptor. -
createBuffer
-
resetReplayLimit
public static void resetReplayLimit()FOR TESTING PURPOSES. -
writeCDCIndexFile
We persist the offset of the last data synced to disk so clients can parse only durable data if they choose. Data in shared / memory-mapped buffers reflects un-synced data so we need an external sentinel for clients to read to determine actual durable data persisted. -
writeSyncMarker
protected static void writeSyncMarker(long id, ByteBuffer buffer, int offset, int filePos, int nextMarker) Create a sync marker to delineate sections of the commit log, typically created on each sync of the file. The sync marker consists of a file pointer to where the next sync marker should be (effectively declaring the length of this section), as well as a CRC value.- Parameters:
buffer- buffer in which to write out the sync marker.offset- Offset into thebufferat which to write the sync marker.filePos- The current position in the target file where the sync marker will be written (most likely different from the buffer position).nextMarker- The file position of where the next sync marker should be.
-
isStillAllocating
public boolean isStillAllocating() -
getCurrentCommitLogPosition
- Returns:
- the current CommitLogPosition for this log segment
-
getPath
- Returns:
- the file path to this segment
-
getName
- Returns:
- the file name of this segment
-
getCDCFile
- Returns:
- a File object representing the CDC directory and this file name for hard-linking
-
getCDCIndexFile
- Returns:
- a File object representing the CDC Index file holding the offset and completion status of this segment
-
internalClose
protected void internalClose()Close the segment file. Do not call from outside this class, use syncAndClose() instead. -
coverInMap
-
markClean
public void markClean(TableId tableId, CommitLogPosition startPosition, CommitLogPosition endPosition) Marks the ColumnFamily specified by id 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:
tableId- the table that is now cleanstartPosition- the start of the range that is cleanendPosition- the end of the range that is clean
-
getDirtyTableIds
- 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
Check to see if a certain CommitLogPosition is contained by this segment file.- Parameters:
context- the commit log segment position to be checked- Returns:
- true if the commit log segment position is contained by this segment file.
-
dirtyString
-
onDiskSize
public abstract long onDiskSize() -
contentSize
public long contentSize() -
toString
-
getCDCState
-
setCDCState
Change the current cdcState on this CommitLogSegment. There are some restrictions on state transitions and this method is idempotent.- Returns:
- the old cdc state
-