com.continuent.tungsten.replicator.thl
Class THLParallelQueueExtractor

java.lang.Object
  extended by com.continuent.tungsten.replicator.thl.THLParallelQueueExtractor
All Implemented Interfaces:
Extractor, ParallelExtractor, ReplicatorPlugin

public class THLParallelQueueExtractor
extends java.lang.Object
implements ParallelExtractor

Implements ParallelExtractor interface for a parallel queue.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
THLParallelQueueExtractor()
          Instantiate the adapter.
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 ReplEvent extract()
          Extract the next available event from the log.
 java.lang.String getCurrentResourceEventId()
          Returns the last event ID committed in a database from which we are extracting.
 java.lang.String getStoreName()
          Returns the store name on which this extractor operates.
 boolean hasMoreEvents()
          Returns true if the queue has more events.
 void prepare(PluginContext context)
          Connect to underlying queue.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setLastEvent(ReplDBMSHeader header)
          Store the header so that it can be propagated back through the pipeline for restart.
 void setLastEventId(java.lang.String eventId)
          Ignored for now as in-memory queues do not extract.
 void setStoreName(java.lang.String storeName)
           
 void setTaskId(int id)
          Sets the ID of the task using this extractor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

THLParallelQueueExtractor

public THLParallelQueueExtractor()
Instantiate the adapter.

Method Detail

getStoreName

public java.lang.String getStoreName()
Description copied from interface: ParallelExtractor
Returns the store name on which this extractor operates. This is used to implement orderly shutdown and synchronize waits.

Specified by:
getStoreName in interface ParallelExtractor

setStoreName

public void setStoreName(java.lang.String storeName)

extract

public ReplEvent extract()
                  throws ReplicatorException,
                         java.lang.InterruptedException
Extract the next available event from the log.

Specified by:
extract in interface Extractor
Returns:
next ReplDBMSEvent found in the logs or another ReplEvent subclass containing control data
Throws:
ReplicatorException
java.lang.InterruptedException
See Also:
Extractor.extract()

getCurrentResourceEventId

public java.lang.String getCurrentResourceEventId()
                                           throws ReplicatorException,
                                                  java.lang.InterruptedException
Returns the last event ID committed in a database from which we are extracting. It is used to help synchronize state between the database and the transaction history log. Values returned from this call must correspond with the last extracted DBMSEvent.eventId as follows:
  1. If the returned value is greater than DBMSEvent.eventId, the database has more recent updates
  2. If the returned value is equal to DBMSEvent.eventId, all events have been extracted
It should not be possible to receive a value that is less than the last extracted DBMSEvent.eventId as this implies that the extractor is somehow ahead of the state of the database, which would be inconsistent.

Specified by:
getCurrentResourceEventId in interface Extractor
Returns:
A current event ID that can be compared with event IDs in DBMSEvent or null if this type of extractor does not extract from a database
Throws:
ReplicatorException
java.lang.InterruptedException
See Also:
Extractor.getCurrentResourceEventId()

hasMoreEvents

public boolean hasMoreEvents()
Returns true if the queue has more events. Returns true if there are additional events that may be read as part of block commit processing.

Specified by:
hasMoreEvents in interface Extractor
See Also:
Extractor.hasMoreEvents()

configure

public void configure(PluginContext context)
               throws ReplicatorException
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
See Also:
ReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

prepare

public void prepare(PluginContext context)
             throws ReplicatorException
Connect to underlying queue. 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
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 - Thrown if resource deallocation fails
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)

setTaskId

public void setTaskId(int id)
Sets the ID of the task using this extractor. This method is called prior to invoking the configure() method.

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

setLastEvent

public void setLastEvent(ReplDBMSHeader header)
                  throws ReplicatorException
Store the header so that it can be propagated back through the pipeline for restart. Keep the sequence number locally so that we can throw away any extra events that are sent to us. Set the value of the last event called. The extractor is responsible for returning the next event in sequence after this one the next time extract() is called.

Specified by:
setLastEvent in interface Extractor
Parameters:
header - Last event we extracted
Throws:
ReplicatorException
See Also:
Extractor.setLastEvent(com.continuent.tungsten.replicator.event.ReplDBMSHeader)

setLastEventId

public void setLastEventId(java.lang.String eventId)
                    throws ReplicatorException
Ignored for now as in-memory queues do not extract. Provides a new native event ID that overrides the default value that the extractor would otherwise use. This call is used to position raw extractors at a specific native event ID in the DBMS log. It can be ignored by other extractors that do not read from a data source.

Specified by:
setLastEventId in interface Extractor
Parameters:
eventId - Event ID at which to begin extracting
Throws:
ReplicatorException
See Also:
Extractor.setLastEventId(java.lang.String)