Package io.debezium.connector.cassandra
Class CommitLogReadHandlerImpl
- java.lang.Object
-
- io.debezium.connector.cassandra.CommitLogReadHandlerImpl
-
- All Implemented Interfaces:
org.apache.cassandra.db.commitlog.CommitLogReadHandler
public class CommitLogReadHandlerImpl extends Object implements org.apache.cassandra.db.commitlog.CommitLogReadHandler
Handler that implementsCommitLogReadHandlerinterface provided by Cassandra source code. This handler implementation processes eachMutationand invokes one of the registered partition handler for eachPartitionUpdatein theMutation(a mutation could have multiple partitions if it is a batch update), which in turn makes one or more record via theRecordMakerand enqueue the record into theChangeEventQueue.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classCommitLogReadHandlerImpl.PartitionTypeA PartitionType represents the type of a PartitionUpdate.(package private) static classCommitLogReadHandlerImpl.RowTypeA RowType represents different types ofRow-level modifications in a Cassandra table.
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGGERprivate static booleanMARK_OFFSETprivate CommitLogProcessorMetricsmetricsprivate OffsetWriteroffsetWriterprivate List<io.debezium.connector.base.ChangeEventQueue<Event>>queuesprivate RecordMakerrecordMakerprivate SchemaHolderschemaHolder
-
Constructor Summary
Constructors Constructor Description CommitLogReadHandlerImpl(SchemaHolder schemaHolder, List<io.debezium.connector.base.ChangeEventQueue<Event>> queues, OffsetWriter offsetWriter, RecordMaker recordMaker, CommitLogProcessorMetrics metrics)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static List<Object>getPartitionKeys(org.apache.cassandra.db.partitions.PartitionUpdate pu)Given a PartitionUpdate, deserialize the partition key byte buffer into a list of partition key values.voidhandleMutation(org.apache.cassandra.db.Mutation mutation, int size, int entryLocation, org.apache.cassandra.db.commitlog.CommitLogDescriptor descriptor)private voidhandlePartitionDeletion(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Handle a valid deletion event resulted from a partition-level deletion by converting Cassandra representation of this event into aRecordobject and queue the record toChangeEventQueue.private voidhandleRowModifications(org.apache.cassandra.db.rows.Row row, CommitLogReadHandlerImpl.RowType rowType, org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Handle a valid event resulted from a row-level modification by converting Cassandra representation of this event into aRecordobject and queue the record toChangeEventQueue.voidhandleUnrecoverableError(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception)private voidpopulateClusteringColumns(RowData after, org.apache.cassandra.db.rows.Row row, org.apache.cassandra.db.partitions.PartitionUpdate pu)private voidpopulatePartitionColumns(RowData after, org.apache.cassandra.db.partitions.PartitionUpdate pu)private voidpopulateRegularColumns(RowData after, org.apache.cassandra.db.rows.Row row, CommitLogReadHandlerImpl.RowType rowType, KeyValueSchema schema)private voidprocess(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Method which processes a partition update if it's valid (either a single-row partition-level deletion or a row-level modification) or throw an exception if it isn't.booleanshouldSkipSegmentOnError(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
MARK_OFFSET
private static final boolean MARK_OFFSET
- See Also:
- Constant Field Values
-
recordMaker
private final RecordMaker recordMaker
-
offsetWriter
private final OffsetWriter offsetWriter
-
schemaHolder
private final SchemaHolder schemaHolder
-
metrics
private final CommitLogProcessorMetrics metrics
-
-
Constructor Detail
-
CommitLogReadHandlerImpl
CommitLogReadHandlerImpl(SchemaHolder schemaHolder, List<io.debezium.connector.base.ChangeEventQueue<Event>> queues, OffsetWriter offsetWriter, RecordMaker recordMaker, CommitLogProcessorMetrics metrics)
-
-
Method Detail
-
handleMutation
public void handleMutation(org.apache.cassandra.db.Mutation mutation, int size, int entryLocation, org.apache.cassandra.db.commitlog.CommitLogDescriptor descriptor)- Specified by:
handleMutationin interfaceorg.apache.cassandra.db.commitlog.CommitLogReadHandler
-
handleUnrecoverableError
public void handleUnrecoverableError(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception) throws IOException- Specified by:
handleUnrecoverableErrorin interfaceorg.apache.cassandra.db.commitlog.CommitLogReadHandler- Throws:
IOException
-
shouldSkipSegmentOnError
public boolean shouldSkipSegmentOnError(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception) throws IOException- Specified by:
shouldSkipSegmentOnErrorin interfaceorg.apache.cassandra.db.commitlog.CommitLogReadHandler- Throws:
IOException
-
process
private void process(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Method which processes a partition update if it's valid (either a single-row partition-level deletion or a row-level modification) or throw an exception if it isn't. The valid partition update is then converted into aRecordand enqueued to theChangeEventQueue.
-
handlePartitionDeletion
private void handlePartitionDeletion(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Handle a valid deletion event resulted from a partition-level deletion by converting Cassandra representation of this event into aRecordobject and queue the record toChangeEventQueue. A valid deletion event means a partition only has a single row, this implies there are no clustering keys. The steps are: (1) Populate the "source" field for this event (2) Fetch the cached key/value schemas fromSchemaHolder(3) Populate the "after" field for this event a. populate partition columns b. populate regular columns with null values (4) Assemble aRecordobject from the populated data and queue the record
-
handleRowModifications
private void handleRowModifications(org.apache.cassandra.db.rows.Row row, CommitLogReadHandlerImpl.RowType rowType, org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable)Handle a valid event resulted from a row-level modification by converting Cassandra representation of this event into aRecordobject and queue the record toChangeEventQueue. A valid event implies this must be an insert, update, or delete. The steps are: (1) Populate the "source" field for this event (2) Fetch the cached key/value schemas fromSchemaHolder(3) Populate the "after" field for this event a. populate partition columns b. populate clustering columns c. populate regular columns d. for deletions, populate regular columns with null values (4) Assemble aRecordobject from the populated data and queue the record
-
populatePartitionColumns
private void populatePartitionColumns(RowData after, org.apache.cassandra.db.partitions.PartitionUpdate pu)
-
populateClusteringColumns
private void populateClusteringColumns(RowData after, org.apache.cassandra.db.rows.Row row, org.apache.cassandra.db.partitions.PartitionUpdate pu)
-
populateRegularColumns
private void populateRegularColumns(RowData after, org.apache.cassandra.db.rows.Row row, CommitLogReadHandlerImpl.RowType rowType, KeyValueSchema schema)
-
-