Class CommitLogReadHandlerImpl

  • All Implemented Interfaces:
    org.apache.cassandra.db.commitlog.CommitLogReadHandler

    public class CommitLogReadHandlerImpl
    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.
    • 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:
        handleMutation in interface org.apache.cassandra.db.commitlog.CommitLogReadHandler
      • handleUnrecoverableError

        public void handleUnrecoverableError​(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception)
                                      throws IOException
        Specified by:
        handleUnrecoverableError in interface org.apache.cassandra.db.commitlog.CommitLogReadHandler
        Throws:
        IOException
      • shouldSkipSegmentOnError

        public boolean shouldSkipSegmentOnError​(org.apache.cassandra.db.commitlog.CommitLogReadHandler.CommitLogReadException exception)
                                         throws IOException
        Specified by:
        shouldSkipSegmentOnError in interface org.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 a Record and enqueued to the ChangeEventQueue.
      • 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 a Record object and queue the record to ChangeEventQueue. 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 from SchemaHolder (3) Populate the "after" field for this event a. populate partition columns b. populate regular columns with null values (4) Assemble a Record object 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 a Record object and queue the record to ChangeEventQueue. 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 from SchemaHolder (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 a Record object 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)
      • getPartitionKeys

        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.