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

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

public class OracleExtractor
extends java.lang.Object
implements RawExtractor

Defines a replication event extractor, which reads events from Oracle via a scoket connection to the actual C based Oracle extractor.

Author:
Scott Martin, Stephane Giron

Field Summary
protected  java.lang.String host
           
protected  java.lang.String instance
           
protected  java.lang.String password
           
protected  java.lang.String port
           
protected  java.lang.String startingSCN
           
protected  java.lang.String url
           
protected  java.lang.String user
           
 
Constructor Summary
OracleExtractor()
           
 
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 id)
          Extract starting after the event ID provided as an argument.
protected  DBMSEvent extractEventRowLevel(java.lang.String firstData)
          Return the next row level event from received from dslisten.
protected  DBMSEvent extractEventStatementLevel(java.lang.String firstData)
          Return the next statement extracted from dslisten
 java.lang.String getCurrentResourceEventId()
          Returns the last event ID committed in the database from which we are extracting.
 int getDsport()
          Get the port we attach to dslisten with.
 java.lang.String getHost()
          Return the name of the host associated with the extractor
 java.lang.String getInstance()
          Get the Oracle sid of the extractor
protected  java.lang.String getLogPosition()
          Return the last event id retrieved from dslisten.
 java.lang.String getMapping()
          Return the current schemaName.tableName mapping string.
 java.lang.String getPassword()
          Get the Oracle password.
 java.lang.String getPort()
          Get the port we attached to Oracle with.
 boolean getRowlevel()
          Return TRUE IFF we are performing row level extraction..
 java.lang.String getStartingSCN()
          Get starting system commit number.
 java.lang.String getUser()
          get the current Oracle user name associated with the extractor.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setDsport(java.lang.String portAsString)
          Set the port value used to communicate with dslisten.
 void setHost(java.lang.String host)
          Set the host name associated with the extractor
 void setInstance(java.lang.String instance)
          Set the Oracle sid associated with the extractor.
 void setLastEventId(java.lang.String eventId)
          Set the value of the last event ID we have processed.
 void setMapping(java.lang.String mapping)
          Set the current schemaName.tableName mapping string
 void setPassword(java.lang.String password)
          Set the Oracle password.
 void setPort(java.lang.String port)
          Set the port we attach to Oracle with.
 void setRowlevel(boolean rowLevel)
          Set boolean that controls row level extraction..
 void setStartingSCN(java.lang.String startingSCN)
          Set the starting system commit number.
 void setUser(java.lang.String user)
          Set the current Oracle user name associated with the extractor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected java.lang.String host

instance

protected java.lang.String instance

user

protected java.lang.String user

password

protected java.lang.String password

port

protected java.lang.String port

url

protected java.lang.String url

startingSCN

protected java.lang.String startingSCN
Constructor Detail

OracleExtractor

public OracleExtractor()
Method Detail

getHost

public java.lang.String getHost()
Return the name of the host associated with the extractor

Returns:
the host

setHost

public void setHost(java.lang.String host)
Set the host name associated with the extractor

Parameters:
host - new host name

getMapping

public java.lang.String getMapping()
Return the current schemaName.tableName mapping string.

Returns:
the mapping

setMapping

public void setMapping(java.lang.String mapping)
Set the current schemaName.tableName mapping string

Parameters:
mapping - New mapping

getUser

public java.lang.String getUser()
get the current Oracle user name associated with the extractor.

Returns:
the user

setUser

public void setUser(java.lang.String user)
Set the current Oracle user name associated with the extractor

Parameters:
user - new user name

getInstance

public java.lang.String getInstance()
Get the Oracle sid of the extractor

Returns:
the instance

setInstance

public void setInstance(java.lang.String instance)
Set the Oracle sid associated with the extractor.

Parameters:
instance - new sid

getPassword

public java.lang.String getPassword()
Get the Oracle password.

Returns:
the password

setPassword

public void setPassword(java.lang.String password)
Set the Oracle password.

Parameters:
password - New password

getStartingSCN

public java.lang.String getStartingSCN()
Get starting system commit number.

Returns:
the startingSCN

setStartingSCN

public void setStartingSCN(java.lang.String startingSCN)
Set the starting system commit number.

Parameters:
startingSCN - new starting system commit number.

getPort

public java.lang.String getPort()
Get the port we attached to Oracle with.

Returns:
the port

setPort

public void setPort(java.lang.String port)
Set the port we attach to Oracle with.

Parameters:
port - new port

getDsport

public int getDsport()
Get the port we attach to dslisten with.

Returns:
the DS port

getRowlevel

public boolean getRowlevel()
Return TRUE IFF we are performing row level extraction..

Returns:
the row level

setRowlevel

public void setRowlevel(boolean rowLevel)
Set boolean that controls row level extraction..

Parameters:
rowLevel - new value for row level.

setDsport

public void setDsport(java.lang.String portAsString)
Set the port value used to communicate with dslisten.

Parameters:
portAsString - new port value.

getLogPosition

protected java.lang.String getLogPosition()
Return the last event id retrieved from dslisten.

Returns:
the log position

extractEventRowLevel

protected DBMSEvent extractEventRowLevel(java.lang.String firstData)
                                  throws java.lang.InterruptedException,
                                         ExtractorException
Return the next row level event from received from dslisten.

Returns:
next DBMSEvent found in the logs
Throws:
ExtractorException
java.lang.InterruptedException

extractEventStatementLevel

protected DBMSEvent extractEventStatementLevel(java.lang.String firstData)
                                        throws java.lang.InterruptedException,
                                               ExtractorException
Return the next statement extracted from dslisten

Returns:
next DBMSEvent found in the logs
Throws:
ExtractorException
java.lang.InterruptedException

extract

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

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

extract

public DBMSEvent extract(java.lang.String id)
                  throws java.lang.InterruptedException,
                         ExtractorException
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:
id - Event ID at which to begin extracting
Returns:
DBMSEvent corresponding to the id
Throws:
java.lang.InterruptedException - Thrown if the applier is interrupted
ExtractorException
See Also:
RawExtractor.extract(java.lang.String)

setLastEventId

public void setLastEventId(java.lang.String eventId)
                    throws ExtractorException
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:
ExtractorException
See Also:
RawExtractor.setLastEventId(java.lang.String)

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
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(PluginContext context)

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(PluginContext context)

getCurrentResourceEventId

public java.lang.String getCurrentResourceEventId()
                                           throws ExtractorException,
                                                  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:
java.lang.InterruptedException
ExtractorException
See Also:
RawExtractor.getCurrentResourceEventId()