Interface StatePersister


  • public interface StatePersister
    Interface for persisting CDC state object and loading on start-up.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default org.apache.cassandra.cdc.state.CdcState loadCanonicalState​(java.lang.String jobId, int partitionId, org.apache.cassandra.bridge.TokenRange tokenRange)
      Load last CDC state from persistant storage after a bounce, restart or configuration change and merge into single canonical state object.
      java.util.List<org.apache.cassandra.cdc.state.CdcState> loadState​(java.lang.String jobId, int partitionId, org.apache.cassandra.bridge.TokenRange tokenRange)
      Load last CDC state from persistant storage after a bounce, restart or configuration change.
      void persist​(java.lang.String jobId, int partitionId, org.apache.cassandra.bridge.TokenRange tokenRange, java.nio.ByteBuffer buf)
      Optionally persist state between micro-batches, state should be stored namespaced by the jobId, partitionId and start/end tokens if RangeFilter is non-null.
    • Method Detail

      • persist

        void persist​(java.lang.String jobId,
                     int partitionId,
                     @Nullable
                     org.apache.cassandra.bridge.TokenRange tokenRange,
                     @NotNull
                     java.nio.ByteBuffer buf)
        Optionally persist state between micro-batches, state should be stored namespaced by the jobId, partitionId and start/end tokens if RangeFilter is non-null.
        Parameters:
        jobId - unique identifier for CDC streaming job.
        partitionId - unique identifier for this partition of the streaming job.
        tokenRange - TokenRange that provides the start-end token range for this state.
        buf - ByteBuffer with the serialized Iterator state.
      • loadCanonicalState

        @NotNull
        default org.apache.cassandra.cdc.state.CdcState loadCanonicalState​(java.lang.String jobId,
                                                                           int partitionId,
                                                                           @Nullable
                                                                           org.apache.cassandra.bridge.TokenRange tokenRange)
        Load last CDC state from persistant storage after a bounce, restart or configuration change and merge into single canonical state object.
        Parameters:
        jobId - unique identifier for CDC streaming job.
        partitionId - unique identifier for this partition of the streaming job.
        tokenRange - TokenRange that provides the start-end token range for this Spark partition.
        Returns:
        canonical view of the CDC state by merging one or more CDC state objects to give canonical view.
      • loadState

        @NotNull
        java.util.List<org.apache.cassandra.cdc.state.CdcState> loadState​(java.lang.String jobId,
                                                                          int partitionId,
                                                                          @Nullable
                                                                          org.apache.cassandra.bridge.TokenRange tokenRange)
        Load last CDC state from persistant storage after a bounce, restart or configuration change.

        NOTE: this method may return 1 or more CDC state objects which may occur if there is a cluster topology change (expansion, shrink etc.) or the CDC partition begins from a new token range so it is necessary to load CDC state for all overlaping token ranges.

        NOTE: it is safe to return a CDC state object even if it partially overlaps with `tokenRange`.

        Parameters:
        jobId - unique identifier for CDC streaming job.
        partitionId - unique identifier for this partition of the streaming job.
        tokenRange - TokenRange that provides the start-end token range for this Spark partition.
        Returns:
        list of previous CDC state objects overlapping with the tokenRange.