com.continuent.tungsten.replicator.extractor.mysql
Class MySQLExtractor

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

public class MySQLExtractor
extends java.lang.Object
implements RawExtractor

This class defines a MySQLExtractor

Version:
1.0
Author:
Seppo Jaakola

Constructor Summary
MySQLExtractor()
           
 
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.
 java.lang.String getBinlogDir()
           
 java.lang.String getBinlogFilePattern()
           
 java.lang.String getBinlogMode()
           
 java.lang.String getCurrentResourceEventId()
          Returns the last event ID committed in the database from which we are extracting.
 java.lang.String getHost()
           
 java.lang.String getJdbcHeader()
           
 java.lang.String getPassword()
           
 int getPort()
           
 java.lang.String getRelayLogDir()
           
 long getRelayLogReadTimeout()
           
 int getRelayLogRetention()
           
 long getRelayLogWaitTimeout()
           
 int getServerId()
           
 int getTransactionFragSize()
           
 java.lang.String getUser()
           
 boolean isParseStatements()
           
 boolean isStrictVersionChecking()
           
 boolean isUseRelayLogs()
           
 boolean isUsingBytesForString()
           
 void prepare(PluginContext context)
          If strictVersionChecking is enabled we ensure this database is a supported version.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setBinlogDir(java.lang.String binlogDir)
           
 void setBinlogFilePattern(java.lang.String binlogFilePattern)
           
 void setBinlogMode(java.lang.String binlogMode)
           
 void setBufferSize(int size)
           
 void setHost(java.lang.String host)
           
 void setJdbcHeader(java.lang.String jdbcHeader)
           
 void setLastEventId(java.lang.String eventId)
          Set the value of the last event ID we have processed.
 void setParseStatements(boolean parseStatements)
           
 void setPassword(java.lang.String password)
           
 void setPort(int port)
           
 void setPrefetchSchemaNameLDI(boolean prefetchSchemaNameLDI)
           
 void setRelayLogDir(java.lang.String relayLogDir)
           
 void setRelayLogReadTimeout(long relayLogReadTimeout)
           
 void setRelayLogRetention(int relayLogRetention)
           
 void setRelayLogWaitTimeout(long relayLogWaitTimeout)
           
 void setServerId(int serverId)
           
 void setStrictVersionChecking(boolean strictVersionChecking)
           
 void setTransactionFragSize(int transactionFragSize)
           
 void setUser(java.lang.String user)
           
 void setUseRelayLogs(boolean useRelayDir)
           
 void setUsingBytesForString(boolean useBytes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLExtractor

public MySQLExtractor()
Method Detail

getHost

public java.lang.String getHost()

setHost

public void setHost(java.lang.String host)

getPort

public int getPort()

setPort

public void setPort(int port)

getUser

public java.lang.String getUser()

setUser

public void setUser(java.lang.String user)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getBinlogFilePattern

public java.lang.String getBinlogFilePattern()

setBinlogFilePattern

public void setBinlogFilePattern(java.lang.String binlogFilePattern)

getBinlogDir

public java.lang.String getBinlogDir()

setBinlogDir

public void setBinlogDir(java.lang.String binlogDir)

isStrictVersionChecking

public boolean isStrictVersionChecking()

setStrictVersionChecking

public void setStrictVersionChecking(boolean strictVersionChecking)

isParseStatements

public boolean isParseStatements()

setParseStatements

public void setParseStatements(boolean parseStatements)

isUsingBytesForString

public boolean isUsingBytesForString()

setUsingBytesForString

public void setUsingBytesForString(boolean useBytes)

isUseRelayLogs

public boolean isUseRelayLogs()

setUseRelayLogs

public void setUseRelayLogs(boolean useRelayDir)

getRelayLogWaitTimeout

public long getRelayLogWaitTimeout()

setRelayLogWaitTimeout

public void setRelayLogWaitTimeout(long relayLogWaitTimeout)

getRelayLogReadTimeout

public long getRelayLogReadTimeout()

setRelayLogReadTimeout

public void setRelayLogReadTimeout(long relayLogReadTimeout)

getRelayLogRetention

public int getRelayLogRetention()

setRelayLogRetention

public void setRelayLogRetention(int relayLogRetention)

getRelayLogDir

public java.lang.String getRelayLogDir()

setRelayLogDir

public void setRelayLogDir(java.lang.String relayLogDir)

getServerId

public int getServerId()

setServerId

public void setServerId(int serverId)

getTransactionFragSize

public int getTransactionFragSize()

setTransactionFragSize

public void setTransactionFragSize(int transactionFragSize)

getJdbcHeader

public java.lang.String getJdbcHeader()

setJdbcHeader

public void setJdbcHeader(java.lang.String jdbcHeader)

getBinlogMode

public java.lang.String getBinlogMode()

setBinlogMode

public void setBinlogMode(java.lang.String binlogMode)

setBufferSize

public void setBufferSize(int size)

extract

public DBMSEvent extract()
                  throws java.lang.InterruptedException,
                         ReplicatorException
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
ReplicatorException
See Also:
RawExtractor.extract()

extract

public DBMSEvent extract(java.lang.String id)
                  throws java.lang.InterruptedException,
                         ReplicatorException
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
ReplicatorException - Thrown if extractor processing fails
See Also:
RawExtractor.extract(java.lang.String)

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:
java.lang.InterruptedException
ReplicatorException
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
If strictVersionChecking is enabled we ensure this database is a supported version. 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)

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

setPrefetchSchemaNameLDI

public void setPrefetchSchemaNameLDI(boolean prefetchSchemaNameLDI)