com.continuent.tungsten.replicator.thl
Class THL

java.lang.Object
  extended by com.continuent.tungsten.replicator.thl.THL
All Implemented Interfaces:
ReplicatorPlugin, Store

public class THL
extends java.lang.Object
implements Store

Implements a standard Store interface on the THL (transaction history log).

Version:
1.0
Author:
Robert Hodges

Field Summary
protected  int bufferSize
          I/O buffer size in bytes.
protected  PluginContext context
           
protected  java.lang.String eventSerializerClass
          Name of the class used to serialize events.
protected  int logConnectionTimeout
          Idle log Connection timeout in seconds.
protected  long logFileRetainMillis
          Log file retention in milliseconds.
protected  int logFileSize
          Log file maximum size in bytes.
protected static org.apache.log4j.Logger logger
           
static int MAJOR
           
static int MINOR
           
protected  java.lang.String password
           
static java.lang.String PLAINTEXT_URI_SCHEME
           
static java.lang.String SSL_URI_SCHEME
           
static java.lang.String SUFFIX
           
protected  java.lang.String url
           
protected  java.lang.String user
           
protected  java.lang.String vendor
           
 
Constructor Summary
THL()
          Creates a store instance.
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 LogConnection connect(boolean readonly)
          Connect to the log.
 void disconnect(LogConnection client)
          Disconnect from the log.
 java.util.LinkedList<ConnectorHandler> getClients()
          Returns list of currently connected clients.
 ReplDBMSHeader getLastAppliedEvent()
          Get the last applied event.
 ReplDBMSHeader getLastLoggedEvent()
          Get the last event applied to the replicator log or return null if there is no such event.
 long getMaxStoredSeqno()
          Return max stored sequence number.
 long getMinStoredSeqno()
          Return minimum stored sequence number.
 java.lang.String getName()
          Gets the storage name.
 java.lang.String getPassword()
           
 int getResetPeriod()
           
 boolean getStopOnDBError()
           
 java.lang.String getStorageListenerUri()
           
 java.lang.String getUrl()
           
 java.lang.String getUser()
           
 boolean isLogConsistencyCheck()
           
 boolean pollSeqno(long seqno)
          Returns true if the indicated sequence number is available.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setBufferSize(int bufferSize)
          Sets the log buffer size.
 void setDoChecksum(boolean doChecksum)
          Determines whether to checksum log records.
 void setEventSerializer(java.lang.String eventSerializer)
          Sets the event serializer name.
 void setFlushIntervalMillis(long flushIntervalMillis)
          Sets the interval between flush calls.
 void setFsyncOnFlush(boolean fsyncOnFlush)
          If set to true, perform an fsync with every flush.
 void setLogConnectionTimeout(int logConnectionTimeout)
          Sets the idle log connection timeout in seconds.
 void setLogConsistencyCheck(boolean checkRecoveredMasterLog)
           
 void setLogDir(java.lang.String logDir)
          Sets the logDir value.
 void setLogFileRetention(java.lang.String logFileRetention)
          Sets the log file retention interval.
 void setLogFileSize(int logFileSize)
          Sets the logFileSize value in bytes.
 void setName(java.lang.String name)
          Sets the storage name.
 void setPassword(java.lang.String password)
           
 void setReadOnly(java.lang.String ro)
           
 void setResetPeriod(int resetPeriod)
           
 void setStopOnDBError(boolean stopOnDBErr)
           
 void setStorageListenerUri(java.lang.String storageListenerUri)
           
 void setUrl(java.lang.String url)
           
 void setUser(java.lang.String user)
           
 void setVendor(java.lang.String vendor)
           
 TungstenProperties status()
          Returns status information as a set of named properties.
 void updateActiveSeqno(long activeSeqno)
          Updates the active sequence number on the log.
 void updateCommitSeqno(THLEvent thlEvent)
          Updates the sequence number stored in the catalog trep_commit_seqno.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

MAJOR

public static final int MAJOR
See Also:
Constant Field Values

MINOR

public static final int MINOR
See Also:
Constant Field Values

SUFFIX

public static final java.lang.String SUFFIX
See Also:
Constant Field Values

PLAINTEXT_URI_SCHEME

public static final java.lang.String PLAINTEXT_URI_SCHEME
See Also:
Constant Field Values

SSL_URI_SCHEME

public static final java.lang.String SSL_URI_SCHEME
See Also:
Constant Field Values

password

protected java.lang.String password

url

protected java.lang.String url

user

protected java.lang.String user

vendor

protected java.lang.String vendor

eventSerializerClass

protected java.lang.String eventSerializerClass
Name of the class used to serialize events.


logFileSize

protected int logFileSize
Log file maximum size in bytes.


logFileRetainMillis

protected long logFileRetainMillis
Log file retention in milliseconds. Defaults to 0 (= forever)


logConnectionTimeout

protected int logConnectionTimeout
Idle log Connection timeout in seconds.


bufferSize

protected int bufferSize
I/O buffer size in bytes.


context

protected PluginContext context
Constructor Detail

THL

public THL()
Creates a store instance.

Method Detail

getName

public java.lang.String getName()
Description copied from interface: Store
Gets the storage name.

Specified by:
getName in interface Store

setName

public void setName(java.lang.String name)
Description copied from interface: Store
Sets the storage name.

Specified by:
setName in interface Store

getStorageListenerUri

public java.lang.String getStorageListenerUri()

setStorageListenerUri

public void setStorageListenerUri(java.lang.String storageListenerUri)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

setVendor

public void setVendor(java.lang.String vendor)

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)

getResetPeriod

public int getResetPeriod()

setResetPeriod

public void setResetPeriod(int resetPeriod)

setLogDir

public void setLogDir(java.lang.String logDir)
Sets the logDir value.

Parameters:
logDir - The logDir to set.

setLogFileSize

public void setLogFileSize(int logFileSize)
Sets the logFileSize value in bytes.

Parameters:
logFileSize - The logFileSize to set.

setDoChecksum

public void setDoChecksum(boolean doChecksum)
Determines whether to checksum log records.

Parameters:
doChecksum - If true use checksums

setEventSerializer

public void setEventSerializer(java.lang.String eventSerializer)
Sets the event serializer name.


setLogFileRetention

public void setLogFileRetention(java.lang.String logFileRetention)
Sets the log file retention interval.


setLogConnectionTimeout

public void setLogConnectionTimeout(int logConnectionTimeout)
Sets the idle log connection timeout in seconds.


setBufferSize

public void setBufferSize(int bufferSize)
Sets the log buffer size.


setFlushIntervalMillis

public void setFlushIntervalMillis(long flushIntervalMillis)
Sets the interval between flush calls.


setFsyncOnFlush

public void setFsyncOnFlush(boolean fsyncOnFlush)
If set to true, perform an fsync with every flush. Warning: fsync is very slow, so you want a long flush interval in this case.


setReadOnly

public void setReadOnly(java.lang.String ro)

setStopOnDBError

public void setStopOnDBError(boolean stopOnDBErr)

getStopOnDBError

public boolean getStopOnDBError()

isLogConsistencyCheck

public boolean isLogConsistencyCheck()

setLogConsistencyCheck

public void setLogConsistencyCheck(boolean checkRecoveredMasterLog)

getMaxStoredSeqno

public long getMaxStoredSeqno()
Return max stored sequence number.

Specified by:
getMaxStoredSeqno in interface Store

getMinStoredSeqno

public long getMinStoredSeqno()
Return minimum stored sequence number.

Specified by:
getMinStoredSeqno in interface Store

updateActiveSeqno

public void updateActiveSeqno(long activeSeqno)
Updates the active sequence number on the log. Log files can only be deleted if their last sequence number is below this value.


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 java.lang.InterruptedException,
                    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
java.lang.InterruptedException
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)

connect

public LogConnection connect(boolean readonly)
                      throws ReplicatorException
Connect to the log. Adapters must call this to use the log.

Parameters:
readonly - If true, this is a readonly connection
Returns:
A disk log client
Throws:
ReplicatorException

disconnect

public void disconnect(LogConnection client)
                throws ReplicatorException
Disconnect from the log. Adapters must call this to free resources and avoid leaks.

Parameters:
client - a Disk log client to be disconnected
Throws:
ReplicatorException

updateCommitSeqno

public void updateCommitSeqno(THLEvent thlEvent)
                       throws ReplicatorException
Updates the sequence number stored in the catalog trep_commit_seqno. If the catalog is disabled we do nothing, which allows us to run unit tests easily without a DBMS present.

Throws:
ReplicatorException - Thrown if update is unsuccessful

pollSeqno

public boolean pollSeqno(long seqno)
Returns true if the indicated sequence number is available.


getLastAppliedEvent

public ReplDBMSHeader getLastAppliedEvent()
                                   throws ReplicatorException,
                                          java.lang.InterruptedException
Get the last applied event. We first try the disk log then if that is absent try the catalog. If there is nothing there we must be starting from scratch and return null.

Returns:
An event header or null if log is newly initialized
Throws:
java.lang.InterruptedException
ReplicatorException

getLastLoggedEvent

public ReplDBMSHeader getLastLoggedEvent()
                                  throws ReplicatorException,
                                         java.lang.InterruptedException
Get the last event applied to the replicator log or return null if there is no such event.

Returns:
An event header or null if log is newly initialized
Throws:
ReplicatorException
java.lang.InterruptedException

status

public TungstenProperties status()
Returns status information as a set of named properties.

Specified by:
status in interface Store
See Also:
Store.status()

getClients

public java.util.LinkedList<ConnectorHandler> getClients()
                                                  throws ReplicatorException
Returns list of currently connected clients.

Throws:
ReplicatorException - If there's no listener.