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

java.lang.Object
  extended by com.continuent.tungsten.replicator.extractor.mysql.RelayLogClient

public class RelayLogClient
extends java.lang.Object

Defines a client to extract binlog events and store them in local relay files in a fashion similar to MySQL.

Public methods are synchronized to ensure a consistent view of client data across threads.

Author:
Robert Hodges

Constructor Summary
RelayLogClient()
          Create new relay log client instance.
 
Method Summary
 void connect()
          Connect to database and set up relay log transfer.
 void disconnect()
          Clean up after termination.
 java.lang.String getBinlog()
           
 java.lang.String getBinlogDir()
           
 java.lang.String getBinlogPrefix()
           
 java.lang.String getLogin()
           
 java.util.concurrent.LinkedBlockingQueue<java.io.File> getLogQueue()
           
 long getOffset()
           
 java.lang.String getPassword()
           
 RelayLogPosition getPosition()
          Returns the current relay log position.
 long getReadTimeout()
          Returns the network read delay timeout.
 java.lang.String getUrl()
           
 boolean isAutoClean()
           
static void main(java.lang.String[] args)
          Connect to MySQL and start pulling down data.
 boolean processEvent()
          Process next event packet from MySQL.
 void setAutoClean(boolean autoClean)
           
 void setBinlog(java.lang.String binlog)
           
 void setBinlogDir(java.lang.String out)
           
 void setBinlogPrefix(java.lang.String binlogPrefix)
           
 void setLogin(java.lang.String login)
           
 void setLogQueue(java.util.concurrent.LinkedBlockingQueue<java.io.File> logQueue)
           
 void setOffset(int offset)
           
 void setPassword(java.lang.String password)
           
 void setReadTimeout(long readTimeout)
          Set the number of seconds delay we permit before giving up on partial reads from the network.
 void setServerId(int serverId)
           
 void setUrl(java.lang.String url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelayLogClient

public RelayLogClient()
Create new relay log client instance.

Method Detail

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getLogin

public java.lang.String getLogin()

setLogin

public void setLogin(java.lang.String login)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getBinlog

public java.lang.String getBinlog()

setBinlog

public void setBinlog(java.lang.String binlog)

getBinlogPrefix

public java.lang.String getBinlogPrefix()

setBinlogPrefix

public void setBinlogPrefix(java.lang.String binlogPrefix)

getOffset

public long getOffset()

setOffset

public void setOffset(int offset)

getBinlogDir

public java.lang.String getBinlogDir()

setBinlogDir

public void setBinlogDir(java.lang.String out)

isAutoClean

public boolean isAutoClean()

setAutoClean

public void setAutoClean(boolean autoClean)

setServerId

public void setServerId(int serverId)

getLogQueue

public java.util.concurrent.LinkedBlockingQueue<java.io.File> getLogQueue()

setLogQueue

public void setLogQueue(java.util.concurrent.LinkedBlockingQueue<java.io.File> logQueue)

getReadTimeout

public long getReadTimeout()
Returns the network read delay timeout.


setReadTimeout

public void setReadTimeout(long readTimeout)
Set the number of seconds delay we permit before giving up on partial reads from the network.


main

public static void main(java.lang.String[] args)
Connect to MySQL and start pulling down data.


connect

public void connect()
             throws ReplicatorException
Connect to database and set up relay log transfer. If successful we are ready to transfer binlogs.

Throws:
ReplicatorException

processEvent

public boolean processEvent()
                     throws ReplicatorException,
                            java.lang.InterruptedException
Process next event packet from MySQL.

Returns:
True if a packet was processed, otherwise false. Latter case may indicate that the connection has been terminated.
Throws:
ReplicatorException
java.lang.InterruptedException

disconnect

public void disconnect()
Clean up after termination.


getPosition

public RelayLogPosition getPosition()
Returns the current relay log position.