com.continuent.tungsten.replicator.pipeline
Class Stage

java.lang.Object
  extended by com.continuent.tungsten.replicator.pipeline.Stage
All Implemented Interfaces:
ReplicatorPlugin

public class Stage
extends java.lang.Object
implements ReplicatorPlugin

Stores the implementation of a single replicator processing stage, which consists of extract, filtering, and apply operations.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
Stage(Pipeline pipeline)
          Creates a new stage instance.
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
protected  void configurePlugin(ReplicatorPlugin plugin, PluginContext context)
          Call configure method on a plugin class.
 Applier getApplier0()
           
 PluginSpecification getApplierSpec()
           
 long getApplySkipCount()
           
 Interval getBlockCommitInterval()
          Return the minimum time interval to wait before committing when using block commit.
 int getBlockCommitRowCount()
          Returns the maximum number of transactions to apply before committing.
 Extractor getExtractor0()
           
 PluginSpecification getExtractorSpec()
           
 java.util.List<Filter> getFilters0()
           
 java.util.List<PluginSpecification> getFilterSpecs()
           
 java.lang.String getInitialEventId()
           
 java.lang.String getName()
           
 Pipeline getPipeline()
          Returns the pipeline value.
 PluginContext getPluginContext()
           
 StageProgressTracker getProgressTracker()
           
 java.util.List<ShardProgress> getShardProgress()
          Returns shard progress instances ordered by shard ID.
 int getTaskCount()
           
 StageTaskGroup getTaskGroup()
           
 java.util.List<TaskProgress> getTaskProgress()
          Returns task progress instances ordered by task ID.
 boolean isAutoSync()
           
 boolean isShutdown()
          Returns true if the stage has stopped.
 void prepare(PluginContext context)
          Prepare plug-in for use.
protected  void preparePlugin(ReplicatorPlugin plugin, PluginContext context)
          Call prepare method on a plugin class.
 void release(PluginContext context)
          Release all resources used by plug-in.
protected  void releasePlugin(ReplicatorPlugin plugin, PluginContext context)
          Call release method on a plugin class, warning on errors.
 void setApplierSpec(PluginSpecification applier)
           
 void setApplySkipCount(long applySkipCount)
           
 void setApplySkipEvents(java.util.SortedSet<java.lang.Long> seqnos)
           
 void setAutoSync(boolean autoSync)
           
 void setBlockCommitInterval(Interval blockCommitInterval)
           
 void setBlockCommitRowCount(int blockCommitRowCount)
           
 void setExtractorSpec(PluginSpecification extractor)
           
 void setFilterSpecs(java.util.List<PluginSpecification> filters)
           
 void setInitialEventId(java.lang.String initialEventId)
           
 void setLoggingInterval(long loggingInterval)
           
 void setName(java.lang.String name)
           
 void setTaskCount(int taskCount)
           
 void shutdown(boolean immediate)
          Shut down tasks threads that implement the stage.
 void start(com.continuent.tungsten.fsm.event.EventDispatcher dispatcher)
          Start task thread(s) that implement this stage.
 java.util.concurrent.Future<ReplDBMSHeader> watchForCommittedSequenceNumber(long seqno, boolean terminate)
          Sets a watch for a particular sequence number to be safely committed on all channels.
 java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedEventId(java.lang.String eventId, boolean terminate)
          Sets a watch for a particular event ID to be extracted.
 java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedHeartbeat(java.lang.String name, boolean terminate)
          Sets a watch for a heartbeat event to be extracted.
 java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedSequenceNumber(long seqno, boolean terminate)
          Sets a watch for a particular sequence number to be processed.
 java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedTimestamp(java.sql.Timestamp timestamp, boolean terminate)
          Sets a watch for a source timestamp to be extracted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stage

public Stage(Pipeline pipeline)
Creates a new stage instance.

Parameters:
pipeline - Pipeline to which this stage belongs.
Method Detail

getName

public java.lang.String getName()

getTaskCount

public int getTaskCount()

getExtractorSpec

public PluginSpecification getExtractorSpec()

getFilterSpecs

public java.util.List<PluginSpecification> getFilterSpecs()

getApplierSpec

public PluginSpecification getApplierSpec()

getProgressTracker

public StageProgressTracker getProgressTracker()

getTaskGroup

public StageTaskGroup getTaskGroup()

getPluginContext

public PluginContext getPluginContext()

getBlockCommitRowCount

public int getBlockCommitRowCount()
Returns the maximum number of transactions to apply before committing.


getBlockCommitInterval

public Interval getBlockCommitInterval()
Return the minimum time interval to wait before committing when using block commit. If set to zero has no effect.


setName

public void setName(java.lang.String name)

setTaskCount

public void setTaskCount(int taskCount)

setExtractorSpec

public void setExtractorSpec(PluginSpecification extractor)

setFilterSpecs

public void setFilterSpecs(java.util.List<PluginSpecification> filters)

setApplierSpec

public void setApplierSpec(PluginSpecification applier)

setBlockCommitRowCount

public void setBlockCommitRowCount(int blockCommitRowCount)

setBlockCommitInterval

public void setBlockCommitInterval(Interval blockCommitInterval)

setLoggingInterval

public void setLoggingInterval(long loggingInterval)

getInitialEventId

public java.lang.String getInitialEventId()

setInitialEventId

public void setInitialEventId(java.lang.String initialEventId)

getApplySkipCount

public long getApplySkipCount()

setApplySkipCount

public void setApplySkipCount(long applySkipCount)

isAutoSync

public boolean isAutoSync()

setAutoSync

public void setAutoSync(boolean autoSync)

getTaskProgress

public java.util.List<TaskProgress> getTaskProgress()
Returns task progress instances ordered by task ID.


getShardProgress

public java.util.List<ShardProgress> getShardProgress()
Returns shard progress instances ordered by shard ID.


getApplier0

public Applier getApplier0()

getFilters0

public java.util.List<Filter> getFilters0()

getExtractor0

public Extractor getExtractor0()

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
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface ReplicatorPlugin
Throws:
ReplicatorException
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)

start

public void start(com.continuent.tungsten.fsm.event.EventDispatcher dispatcher)
           throws ReplicatorException
Start task thread(s) that implement this stage.

Throws:
ReplicatorException

shutdown

public void shutdown(boolean immediate)
Shut down tasks threads that implement the stage.


isShutdown

public boolean isShutdown()
Returns true if the stage has stopped.


watchForCommittedSequenceNumber

public java.util.concurrent.Future<ReplDBMSHeader> watchForCommittedSequenceNumber(long seqno,
                                                                                   boolean terminate)
                                                                            throws java.lang.InterruptedException
Sets a watch for a particular sequence number to be safely committed on all channels.

Parameters:
seqno - Sequence number to watch for
terminate - If true, terminate task when watch is successful
Returns:
Returns a watch on matching event
Throws:
java.lang.InterruptedException

watchForProcessedSequenceNumber

public java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedSequenceNumber(long seqno,
                                                                                   boolean terminate)
                                                                            throws java.lang.InterruptedException
Sets a watch for a particular sequence number to be processed.

Parameters:
seqno - Sequence number to watch for
terminate - If true, terminate task when watch is successful
Returns:
Returns a watch on matching event
Throws:
java.lang.InterruptedException

watchForProcessedEventId

public java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedEventId(java.lang.String eventId,
                                                                            boolean terminate)
                                                                     throws java.lang.InterruptedException
Sets a watch for a particular event ID to be extracted.

Parameters:
eventId - Native event ID to watch for
terminate - If true, terminate task when watch is successful
Returns:
Returns a watch on matching event
Throws:
java.lang.InterruptedException

watchForProcessedHeartbeat

public java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedHeartbeat(java.lang.String name,
                                                                              boolean terminate)
                                                                       throws java.lang.InterruptedException
Sets a watch for a heartbeat event to be extracted.

Parameters:
terminate - If true, terminate task when watch is successful
Returns:
Returns a watch on matching event
Throws:
java.lang.InterruptedException

watchForProcessedTimestamp

public java.util.concurrent.Future<ReplDBMSHeader> watchForProcessedTimestamp(java.sql.Timestamp timestamp,
                                                                              boolean terminate)
                                                                       throws java.lang.InterruptedException
Sets a watch for a source timestamp to be extracted.

Parameters:
timestamp - Timestamp to watch for
terminate - If true, terminate task when watch is successful
Returns:
Returns a watch on matching event
Throws:
java.lang.InterruptedException

configurePlugin

protected void configurePlugin(ReplicatorPlugin plugin,
                               PluginContext context)
                        throws ReplicatorException
Call configure method on a plugin class.

Throws:
ReplicatorException

preparePlugin

protected void preparePlugin(ReplicatorPlugin plugin,
                             PluginContext context)
                      throws ReplicatorException
Call prepare method on a plugin class.

Throws:
ReplicatorException

releasePlugin

protected void releasePlugin(ReplicatorPlugin plugin,
                             PluginContext context)
Call release method on a plugin class, warning on errors.


getPipeline

public Pipeline getPipeline()
Returns the pipeline value.

Returns:
Returns the pipeline.

setApplySkipEvents

public void setApplySkipEvents(java.util.SortedSet<java.lang.Long> seqnos)