Class CommitScn

java.lang.Object
io.debezium.connector.oracle.CommitScn
All Implemented Interfaces:
Comparable<Scn>

public class CommitScn extends Object implements Comparable<Scn>
Represents either a single or a collection of commit Scn positions that collectively represents the high-watermark point for streaming changes. In a standalone Oracle environment, a commit Scn would normally represent a single position or system change number in the logs as there is only ever a single redo thread. However, in an Oracle RAC environment where each node maintains its own redo, there are multiple redo threads which maintain their own "commit" point in the logs that may differ. This class is meant to encapsulate the Oracle RAC environment by exposing a "commit scn" as a single representation that spans all nodes within the cluster as one logical unit, much like what we expect when integrating with a standalone Oracle database.
Author:
Chris Cranford
  • Field Details

  • Constructor Details

  • Method Details

    • getMaxCommittedScn

      public Scn getMaxCommittedScn()
      Examines all redo threads and returns the maximum committed scn.
      Returns:
      the maximum recorded commit across all redo threads
    • getCommitScnForAllRedoThreads

      public Map<Integer,Scn> getCommitScnForAllRedoThreads()
      Get the commit scns associated with all redo threads.
      Returns:
      a map by redo thread with each commit system change number.
    • getCommitScnForRedoThread

      public Scn getCommitScnForRedoThread(int thread)
      Get the commit scn associated with a specific redo thread.
      Parameters:
      thread - the redo thread
      Returns:
      the commit scn associated with redo thread
    • hasCommitAlreadyBeenHandled

      public boolean hasCommitAlreadyBeenHandled(LogMinerEventRow row)
      Checks whether the transaction associated with the commit event has been handled.
      Parameters:
      row - the transaction commit event, should never be null
      Returns:
      true if the commit has been handled, false if it has not
    • getRedoThreadCommitScn

      @VisibleForTesting public CommitScn.RedoThreadCommitScn getRedoThreadCommitScn(int thread)
    • recordCommit

      public void recordCommit(LogMinerEventRow row)
      Records the specified commit in the commit scn
      Parameters:
      row - the commit event, should never be null
    • setCommitScnOnAllThreads

      public void setCommitScnOnAllThreads(Scn commitScn)
      Set the commit scn across all redo threads.
      Parameters:
      commitScn - the commit scn to be set, should not be null
    • compareTo

      public int compareTo(Scn scn)
      Specified by:
      compareTo in interface Comparable<Scn>
    • store

      public Map<String,Object> store(Map<String,Object> offset)
      Store the contents of the CommitScn in the connector offsets.
      Parameters:
      offset - the offsets, should not be null
      Returns:
      the adjusted offsets
    • store

      public org.apache.kafka.connect.data.Struct store(SourceInfo sourceInfo, org.apache.kafka.connect.data.Struct sourceInfoStruct)
      Store the contents of the CommitScn in the source info struct.
      Parameters:
      sourceInfo - the connector's source info data
      sourceInfoStruct - the source info struct
      Returns:
      the adjusted source info struct
    • toLoggableFormat

      public String toLoggableFormat()
      Returns a loggable string representing the commit scn
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueOf

      public static CommitScn valueOf(String value)
      Parses a string-based representation of commit scn entries as a CommitScn instance.
      Parameters:
      value - the commit scn entries, comma-separated
      Returns:
      the commit scn instance, never null
    • valueOf

      public static CommitScn valueOf(Long value)
      Parses a long-based representation of commit scn entries as a CommitScn instance.
      Parameters:
      value - the commit scn long value, should never be null
      Returns:
      the commit scn instance, never null
    • load

      public static CommitScn load(Map<String,?> offset)
      Load the CommitScn values from the offsets.
      Parameters:
      offset - the connector offsets, should not be null
      Returns:
      the commit scn instance, never null
    • schemaBuilder

      public static org.apache.kafka.connect.data.SchemaBuilder schemaBuilder(org.apache.kafka.connect.data.SchemaBuilder schemaBuilder)
    • toCommaSeparatedValue

      private String toCommaSeparatedValue()
      Returns the commit scn as a comma-separated list of string values.