com.continuent.tungsten.replicator.applier
Class ApplierWrapper

java.lang.Object
  extended by com.continuent.tungsten.replicator.applier.ApplierWrapper
All Implemented Interfaces:
Applier, ParallelApplier, ReplicatorPlugin

public class ApplierWrapper
extends java.lang.Object
implements ParallelApplier

This class wraps a basic Applier so that it handles ReplDBMSEvent values with assigned sequence numbers.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
ApplierWrapper(RawApplier applier)
          Create a new instance to wrap a raw applier.
 
Method Summary
 void apply(ReplDBMSEvent event, boolean doCommit, boolean doRollback, boolean syncTHL)
          Apply the DBMSEvent in the ReplDBMSEvent.
 void commit()
          Commits current open transaction to ensure data applied up to current point are durable.
 void configure(PluginContext context)
          Complete plug-in configuration.
 RawApplier getApplier()
          Return wrapped applier.
 ReplDBMSHeader getLastEvent()
          Return header information corresponding to last committed transaction.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void rollback()
          Rolls back any current work.
 void setTaskId(int id)
          Sets the ID of the task using this applier.
 void updatePosition(ReplDBMSHeader header, boolean doCommit, boolean syncTHL)
          Update current recovery position but do not apply an event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplierWrapper

public ApplierWrapper(RawApplier applier)
Create a new instance to wrap a raw applier.

Parameters:
applier - Extractor to be wrapped
Method Detail

getApplier

public RawApplier getApplier()
Return wrapped applier.


setTaskId

public void setTaskId(int id)
Sets the ID of the task using this applier.

Specified by:
setTaskId in interface ParallelApplier
Parameters:
id - Task ID
See Also:
ParallelApplier.setTaskId(int)

apply

public void apply(ReplDBMSEvent event,
                  boolean doCommit,
                  boolean doRollback,
                  boolean syncTHL)
           throws ReplicatorException,
                  ConsistencyException,
                  java.lang.InterruptedException
Apply the DBMSEvent in the ReplDBMSEvent. Apply the proffered event to the replication target.

Specified by:
apply in interface Applier
Parameters:
event - Event to be applied
doCommit - Boolean flag indicating whether this is the last part of multipart event
doRollback - Boolean flag indicating whether this transaction should rollback
syncTHL - Should this applier synchronize the trep_commit_seqno table? This should be false for slave.
Throws:
ReplicatorException - Thrown if applier processing fails
ConsistencyException - Thrown if the applier detects that a consistency check has failed
java.lang.InterruptedException - Thrown if the applier is interrupted
See Also:
Applier.apply(com.continuent.tungsten.replicator.event.ReplDBMSEvent, boolean, boolean, boolean)

updatePosition

public void updatePosition(ReplDBMSHeader header,
                           boolean doCommit,
                           boolean syncTHL)
                    throws ReplicatorException,
                           java.lang.InterruptedException
Update current recovery position but do not apply an event.

Specified by:
updatePosition in interface Applier
Parameters:
header - Header containing seqno, event ID, etc.
doCommit - Boolean flag indicating whether this is the last part of multipart event
syncTHL - Should this applier synchronize the trep_commit_seqno table? This should be false for slave.
Throws:
ReplicatorException - Thrown if applier processing fails
java.lang.InterruptedException - Thrown if the applier is interrupted
See Also:
Applier.updatePosition(com.continuent.tungsten.replicator.event.ReplDBMSHeader, boolean, boolean)

commit

public void commit()
            throws ReplicatorException,
                   java.lang.InterruptedException
Commits current open transaction to ensure data applied up to current point are durable.

Specified by:
commit in interface Applier
Throws:
ReplicatorException - Thrown if applier processing fails
java.lang.InterruptedException - Thrown if the applier is interrupted
See Also:
Applier.commit()

rollback

public void rollback()
              throws java.lang.InterruptedException
Rolls back any current work.

Specified by:
rollback in interface Applier
Throws:
java.lang.InterruptedException
See Also:
Applier.rollback()

getLastEvent

public ReplDBMSHeader getLastEvent()
                            throws ReplicatorException,
                                   java.lang.InterruptedException
Return header information corresponding to last committed transaction.

Specified by:
getLastEvent in interface Applier
Returns:
Header data for last committed transaction
Throws:
ReplicatorException - Thrown if getting sequence number fails
java.lang.InterruptedException - Thrown if the applier is interrupted
See Also:
Applier.getLastEvent()

configure

public void configure(PluginContext context)
               throws ReplicatorException,
                      java.lang.InterruptedException
Complete plug-in configuration. This is called after setters are invoked at the time that the replicator goes through configuration.

Specified by:
configure in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if configuration is incomplete or fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

prepare

public void prepare(PluginContext context)
             throws ReplicatorException,
                    java.lang.InterruptedException
Prepare plug-in for use. This method is assumed to allocate all required resources. It is called before the plug-in performs any operations.

Specified by:
prepare in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if resource allocation fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)

release

public void release(PluginContext context)
             throws ReplicatorException,
                    java.lang.InterruptedException
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if resource deallocation fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)