com.continuent.tungsten.replicator.extractor.oracle
Class OracleCDCReaderExtractor

java.lang.Object
  extended by com.continuent.tungsten.replicator.extractor.oracle.OracleCDCReaderExtractor
All Implemented Interfaces:
RawExtractor, ReplicatorPlugin

public class OracleCDCReaderExtractor
extends java.lang.Object
implements RawExtractor

Version:
1.0
Author:
Stephane Giron

Constructor Summary
OracleCDCReaderExtractor()
           
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 DBMSEvent extract()
          Extract the next available DBMSEvent from the database log.
 DBMSEvent extract(java.lang.String eventId)
          Extract starting after the event ID provided as an argument.
 java.lang.String getCurrentResourceEventId()
          Returns the last event ID committed in the database from which we are extracting.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setLastEventId(java.lang.String eventId)
          Set the value of the last event ID we have processed.
 void setMaxRowsByBlock(int maxRowsByBlock)
          Sets the maxRowsByBlock value.
 void setMaxSleepTime(int maxSleepTime)
          Sets the maximum sleep time : maximum time the extracting thread will sleep between two calls.
 void setPassword(java.lang.String password)
           
 void setQueueSize(int queueSize)
          Sets the queueSize value.
 void setReconnectTimeout(long reconnectTimeout)
          Sets the reconnectTimeout value.
 void setServiceName(java.lang.String serviceName)
           
 void setTransactionFragSize(int transactionFragSize)
          Sets the transactionFragSize value.
 void setUrl(java.lang.String url)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleCDCReaderExtractor

public OracleCDCReaderExtractor()
Method Detail

setUrl

public void setUrl(java.lang.String url)

setUser

public void setUser(java.lang.String user)

setPassword

public void setPassword(java.lang.String password)

setMaxSleepTime

public void setMaxSleepTime(int maxSleepTime)
Sets the maximum sleep time : maximum time the extracting thread will sleep between two calls. The extracting thread goes to sleep when nothing was retrieved from the CDC window. It first goes to sleep for 1s, and then sleep time is doubled until reaching the maximum or new data arrives. In this last case, the sleep time is reset to 1s. If this is set to 1, then the extracting thread will sleep only 1s.

Parameters:
maxSleepTime - maximum sleep time in seconds

setTransactionFragSize

public void setTransactionFragSize(int transactionFragSize)
Sets the transactionFragSize value.

Parameters:
transactionFragSize - The transactionFragSize to set.

setQueueSize

public void setQueueSize(int queueSize)
Sets the queueSize value. This is the maximum number of blocks that can be handled within the queue. One block contains at most maxRowsByBlock rows.

Parameters:
queueSize - The queueSize to set.

setMaxRowsByBlock

public void setMaxRowsByBlock(int maxRowsByBlock)
Sets the maxRowsByBlock value. Fragmentation will happen if an event contains more than maxRowsByBlock rows within the same change table or for each change table which contains rows. The maximum fragment size will then be at most : transactionFragSize * maxRowsByBlock rows

Parameters:
maxRowsByBlock - The maxRowsByBlock to set.

setReconnectTimeout

public void setReconnectTimeout(long reconnectTimeout)
Sets the reconnectTimeout value. This is the time after which a connection has to be renewed (this happens once a CDC window was fully processed). If set to 0, there won't be any connection renewal.

Parameters:
reconnectTimeout - The time in seconds after which the connection has to be renewed.

setServiceName

public void setServiceName(java.lang.String serviceName)
Parameters:
serviceName - the serviceName to set

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)

setLastEventId

public void setLastEventId(java.lang.String eventId)
                    throws ReplicatorException
Set the value of the last event ID we have processed. The extractor is responsible for returning the next event ID in sequence after this one the next time extract() is called.

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

extract

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

Specified by:
extract in interface RawExtractor
Returns:
next DBMSEvent found in the logs
Throws:
ReplicatorException
java.lang.InterruptedException
See Also:
RawExtractor.extract()

extract

public DBMSEvent extract(java.lang.String eventId)
                  throws ReplicatorException,
                         java.lang.InterruptedException
Extract starting after the event ID provided as an argument. This is equivalent to invoking setLastEventId() followed by extract().

Specified by:
extract in interface RawExtractor
Parameters:
eventId - Event ID at which to begin extracting
Returns:
DBMSEvent corresponding to the id
Throws:
ReplicatorException - Thrown if extractor processing fails
java.lang.InterruptedException - Thrown if the applier is interrupted
See Also:
RawExtractor.extract(java.lang.String)

getCurrentResourceEventId

public java.lang.String getCurrentResourceEventId()
                                           throws ReplicatorException,
                                                  java.lang.InterruptedException
Returns the last event ID committed in the 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 RawExtractor
Returns:
A current event ID that can be compared with event IDs in DBMSEvent
Throws:
ReplicatorException
java.lang.InterruptedException
See Also:
RawExtractor.getCurrentResourceEventId()