com.continuent.tungsten.replicator.storage.prefetch
Class PrefetchStore

java.lang.Object
  extended by com.continuent.tungsten.replicator.storage.InMemoryQueueStore
      extended by com.continuent.tungsten.replicator.storage.prefetch.PrefetchStore
All Implemented Interfaces:
ReplicatorPlugin, Store

public class PrefetchStore
extends InMemoryQueueStore

Implements a specialized store for handling slave prefetch from another replicator. This store coordinates restart at the current slave position and implements logic to drop events that are not far enough ahead of the slave position or have already been executed.


Field Summary
 
Fields inherited from class com.continuent.tungsten.replicator.storage.InMemoryQueueStore
lastHeader, maxSize, name, partitions, queue, transactionCount
 
Constructor Summary
PrefetchStore()
           
 
Method Summary
 ReplDBMSEvent filter(ReplDBMSEvent event)
          Filter the event if it has already been executed.
 ReplDBMSHeader getLastHeader()
          Returns the position of the slave on which we are handling prefetch.
 void prepare(PluginContext context)
          Prepare prefetch store.
 void put(ReplDBMSEvent event)
          Puts an event in the queue, blocking if it is full.
 void release(PluginContext context)
          Release queue.
 void setAheadMaxTime(int aheadMaxTime)
          Sets the aheadMaxTime value.
 void setCheckInterval(long timeInMillis)
          Sets the number of milliseconds between slave position checks.
 void setLastHeader(ReplDBMSHeader header)
          Sets the last header processed.
 void setPassword(java.lang.String password)
          Sets the password of the database login to check slave position.
 void setSlaveCatalogSchema(java.lang.String slaveCatalogSchema)
          Sets the catalog schema name of the slave for which we are prefetching.
 void setSleepTime(int sleepTime)
          Sets the sleepTime value.
 void setUrl(java.lang.String url)
          Sets the JDBC URL to connect to the slave server.
 void setUser(java.lang.String user)
           
 void setWarmUpEventCount(int warmUpEventCount)
          Sets the warmUpEventCount value.
 TungstenProperties status()
          Returns status information as a set of named properties.
 
Methods inherited from class com.continuent.tungsten.replicator.storage.InMemoryQueueStore
configure, get, getMaxSize, getMaxStoredSeqno, getMinStoredSeqno, getName, peek, poll, setMaxOfflineInterval, setMaxSize, setName, setPartitionerClass, setPartitions, setSyncInterval, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrefetchStore

public PrefetchStore()
Method Detail

setUrl

public void setUrl(java.lang.String url)
Sets the JDBC URL to connect to the slave server.


setUser

public void setUser(java.lang.String user)

setPassword

public void setPassword(java.lang.String password)
Sets the password of the database login to check slave position.


setSlaveCatalogSchema

public void setSlaveCatalogSchema(java.lang.String slaveCatalogSchema)
Sets the catalog schema name of the slave for which we are prefetching.


setCheckInterval

public void setCheckInterval(long timeInMillis)
Sets the number of milliseconds between slave position checks.

Parameters:
timeInMillis -

setAheadMaxTime

public void setAheadMaxTime(int aheadMaxTime)
Sets the aheadMaxTime value. This is the maximum number of seconds that event should be from the last applied event (based on master times).

Parameters:
aheadMaxTime - Time in seconds

setSleepTime

public void setSleepTime(int sleepTime)
Sets the sleepTime value.

Parameters:
sleepTime - The sleepTime to set.

setWarmUpEventCount

public void setWarmUpEventCount(int warmUpEventCount)
Sets the warmUpEventCount value.

Parameters:
warmUpEventCount - The warmUpEventCount to set.

setLastHeader

public void setLastHeader(ReplDBMSHeader header)
Sets the last header processed. This is required for restart.

Overrides:
setLastHeader in class InMemoryQueueStore

getLastHeader

public ReplDBMSHeader getLastHeader()
Returns the position of the slave on which we are handling prefetch.

Overrides:
getLastHeader in class InMemoryQueueStore

put

public void put(ReplDBMSEvent event)
         throws java.lang.InterruptedException,
                ReplicatorException
Puts an event in the queue, blocking if it is full.

Overrides:
put in class InMemoryQueueStore
Throws:
ReplicatorException
java.lang.InterruptedException

prepare

public void prepare(PluginContext context)
             throws ReplicatorException
Prepare prefetch store. Allocate an in-memory queue. 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
Overrides:
prepare in class InMemoryQueueStore
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 queue. Release queue. Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface ReplicatorPlugin
Overrides:
release in class InMemoryQueueStore
Throws:
ReplicatorException - Thrown if resource deallocation fails
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)

status

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

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

filter

public ReplDBMSEvent filter(ReplDBMSEvent event)
                     throws ReplicatorException,
                            java.lang.InterruptedException
Filter the event if it has already been executed.

Throws:
ReplicatorException
java.lang.InterruptedException