com.continuent.tungsten.replicator.thl
Class CommitSeqnoTable

java.lang.Object
  extended by com.continuent.tungsten.replicator.thl.CommitSeqnoTable

public class CommitSeqnoTable
extends java.lang.Object

Encapsulates definition and management of the trep_commit_seqno table, which is used to ensure consistency between the current contents of the history table and the actual database. Here are the rules for master and slave:

Version:
1.0
Author:
Robert Hodges

Field Summary
static java.lang.String TABLE_NAME
           
 
Constructor Summary
CommitSeqnoTable(Database database, java.lang.String schema, java.lang.String tableType, boolean syncNativeSlaveRequired)
          Creates a new instance valid for life of the provided database connection.
 
Method Summary
 int count()
          Returns the count of rows in the trep_commit_seqno table.
 void expandTasks(int channels)
          Copies the single task 0 row left by a clean offline operation to add rows for each task in multi-channel operation.
 void initializeTable(int channels)
          Create the trep_commit_seqno table, if necessary, and ensure the number of channels matches the number of channels.
 ReplDBMSHeader lastCommitSeqno(int taskId)
          Fetches header data for last committed transaction or null if none such can be found.
 ReplDBMSHeader minCommitSeqno()
          Returns the header for the lowest committed sequence number or null if none such can be found.
 void prepare(int taskId)
          Prepares the instance for use.
 boolean reduceTasks(Database conn, int channels)
          Reduces the trep_commit_seqno table to task 0 entry *provided* there is a task 0 row and provide all rows are at the same sequence number.
 void release()
          Releases the instance.
 void updateLastCommitSeqno(int taskId, ReplDBMSHeader header, long appliedLatency)
          Updates the last commit seqno value.
 void validate(int channels)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME

public static final java.lang.String TABLE_NAME
See Also:
Constant Field Values
Constructor Detail

CommitSeqnoTable

public CommitSeqnoTable(Database database,
                        java.lang.String schema,
                        java.lang.String tableType,
                        boolean syncNativeSlaveRequired)
                 throws java.sql.SQLException
Creates a new instance valid for life of the provided database connection.

Throws:
java.sql.SQLException
Method Detail

initializeTable

public void initializeTable(int channels)
                     throws java.sql.SQLException,
                            ReplicatorException
Create the trep_commit_seqno table, if necessary, and ensure the number of channels matches the number of channels.

Parameters:
channels - Number of channels in the pipeline
Throws:
java.sql.SQLException
ReplicatorException

prepare

public void prepare(int taskId)
             throws java.sql.SQLException,
                    ReplicatorException
Prepares the instance for use. This must occur before use.

Throws:
ReplicatorException - Thrown if we don't have a row for this entry
java.sql.SQLException

release

public void release()
Releases the instance. This must occur after last use.


lastCommitSeqno

public ReplDBMSHeader lastCommitSeqno(int taskId)
                               throws java.sql.SQLException
Fetches header data for last committed transaction or null if none such can be found.

Throws:
java.sql.SQLException

minCommitSeqno

public ReplDBMSHeader minCommitSeqno()
                              throws java.sql.SQLException
Returns the header for the lowest committed sequence number or null if none such can be found.

Throws:
java.sql.SQLException

expandTasks

public void expandTasks(int channels)
                 throws java.sql.SQLException,
                        ReplicatorException
Copies the single task 0 row left by a clean offline operation to add rows for each task in multi-channel operation. This fails if task 0 does not exist.

Throws:
ReplicatorException - Thrown if the task ID 0 does not exist
java.sql.SQLException

reduceTasks

public boolean reduceTasks(Database conn,
                           int channels)
                    throws java.sql.SQLException
Reduces the trep_commit_seqno table to task 0 entry *provided* there is a task 0 row and provide all rows are at the same sequence number. This operation allows the table to convert to a different number of apply threads.

Throws:
java.sql.SQLException

updateLastCommitSeqno

public void updateLastCommitSeqno(int taskId,
                                  ReplDBMSHeader header,
                                  long appliedLatency)
                           throws java.sql.SQLException
Updates the last commit seqno value.

Throws:
java.sql.SQLException

count

public int count()
          throws java.sql.SQLException
Returns the count of rows in the trep_commit_seqno table.

Throws:
java.sql.SQLException

validate

public void validate(int channels)
              throws java.sql.SQLException,
                     ReplicatorException
Throws:
java.sql.SQLException
ReplicatorException