Package io.debezium.connector.cassandra
Class Cassandra4CommitLogReadHandlerImpl
java.lang.Object
io.debezium.connector.cassandra.Cassandra4CommitLogReadHandlerImpl
- All Implemented Interfaces:
org.apache.cassandra.db.commitlog.CommitLogReadHandler
public class Cassandra4CommitLogReadHandlerImpl
extends Object
implements org.apache.cassandra.db.commitlog.CommitLogReadHandler
Handler that implements
CommitLogReadHandler interface provided by Cassandra source code.
This handler implementation processes each Mutation and invokes one of the registered partition handler
for each PartitionUpdate in the Mutation (a mutation could have multiple partitions if it is a batch update),
which in turn makes one or more record via the RecordMaker and enqueue the record into the ChangeEventQueue.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumA PartitionType represents the type of PartitionUpdate.(package private) static enumA RowType represents different types ofRow-level modifications in a Cassandra table.Nested classes/interfaces inherited from interface org.apache.cassandra.db.commitlog.CommitLogReadHandler
org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadErrorReason, org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final booleanprivate final CommitLogProcessorMetricsprivate final OffsetWriterprivate final RangeTombstoneContext<org.apache.cassandra.schema.TableMetadata>private final RecordMakerprivate final CassandraSchemaFactoryprivate final SchemaHolder -
Constructor Summary
ConstructorsConstructorDescriptionCassandra4CommitLogReadHandlerImpl(CassandraConnectorContext context, CommitLogProcessorMetrics metrics) -
Method Summary
Modifier and TypeMethodDescriptionprivate List<ByteBuffer>getComplexColumnDataByteBufferList(org.apache.cassandra.db.marshal.AbstractType<?> abstractType, org.apache.cassandra.db.rows.ComplexColumnData ccd) 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 voidhandleRangeTombstoneBoundMarker(org.apache.cassandra.db.rows.RangeTombstoneBoundMarker rangeTombstoneMarker, Cassandra4CommitLogReadHandlerImpl.RowType rowType, org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable) private voidhandleRowIterator(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable) private voidhandleRowModifications(org.apache.cassandra.db.rows.Row row, Cassandra4CommitLogReadHandlerImpl.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(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.rows.Row row, org.apache.cassandra.db.partitions.PartitionUpdate pu) private voidpopulatePartitionColumns(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.partitions.PartitionUpdate pu) private CassandraSchemaFactory.RangeDatapopulateRangeData(org.apache.cassandra.db.ClusteringBound<?> cb, String name, org.apache.cassandra.schema.TableMetadata metaData) private voidpopulateRegularColumns(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.rows.Row row, Cassandra4CommitLogReadHandlerImpl.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 Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
MARK_OFFSET
private static final boolean MARK_OFFSET- See Also:
-
queues
-
recordMaker
-
offsetWriter
-
schemaHolder
-
metrics
-
rangeTombstoneContext
private final RangeTombstoneContext<org.apache.cassandra.schema.TableMetadata> rangeTombstoneContext -
schemaFactory
-
-
Constructor Details
-
Cassandra4CommitLogReadHandlerImpl
Cassandra4CommitLogReadHandlerImpl(CassandraConnectorContext context, CommitLogProcessorMetrics metrics)
-
-
Method Details
-
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) - Specified by:
handleUnrecoverableErrorin interfaceorg.apache.cassandra.db.commitlog.CommitLogReadHandler
-
shouldSkipSegmentOnError
public boolean shouldSkipSegmentOnError(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception) - Specified by:
shouldSkipSegmentOnErrorin interfaceorg.apache.cassandra.db.commitlog.CommitLogReadHandler
-
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. -
handleRowIterator
private void handleRowIterator(org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable) -
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 clustering columns if any 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, Cassandra4CommitLogReadHandlerImpl.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 -
handleRangeTombstoneBoundMarker
private void handleRangeTombstoneBoundMarker(org.apache.cassandra.db.rows.RangeTombstoneBoundMarker rangeTombstoneMarker, Cassandra4CommitLogReadHandlerImpl.RowType rowType, org.apache.cassandra.db.partitions.PartitionUpdate pu, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable) -
populateRangeData
private CassandraSchemaFactory.RangeData populateRangeData(org.apache.cassandra.db.ClusteringBound<?> cb, String name, org.apache.cassandra.schema.TableMetadata metaData) -
populatePartitionColumns
private void populatePartitionColumns(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.partitions.PartitionUpdate pu) -
populateClusteringColumns
private void populateClusteringColumns(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.rows.Row row, org.apache.cassandra.db.partitions.PartitionUpdate pu) -
populateRegularColumns
private void populateRegularColumns(CassandraSchemaFactory.RowData after, org.apache.cassandra.db.rows.Row row, Cassandra4CommitLogReadHandlerImpl.RowType rowType, KeyValueSchema schema) -
getComplexColumnDataByteBufferList
private List<ByteBuffer> getComplexColumnDataByteBufferList(org.apache.cassandra.db.marshal.AbstractType<?> abstractType, org.apache.cassandra.db.rows.ComplexColumnData ccd) -
getPartitionKeys
Given a PartitionUpdate, deserialize the partition key byte buffer into a list of partition key values.
-