com.continuent.tungsten.replicator.prefetch
Class PrefetchStore

java.lang.Object
  extended by com.continuent.tungsten.replicator.storage.InMemoryQueueStore
      extended by com.continuent.tungsten.replicator.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
 void configure(PluginContext context)
          Complete plug-in configuration.
 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 setAllowAll(boolean allowAll)
          Allow all events regardless of position of slave service we are tracking.
 void setCheckInterval(long timeInMillis)
          Sets the number of milliseconds between slave position checks.
 void setLastHeader(ReplDBMSHeader header)
          Sets the last header processed.
 void setMaxTimeAhead(int aheadMaxTime)
          Sets the maximum number of seconds that event should be from the last event applied by the slave.
 void setMinTimeAhead(int aheadMinTime)
          Sets the minimum number of seconds ahead of slave in order to accept an event for prefetch.
 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 number of milliseconds to sleep when we get too far ahead of the slave.
 void setUrl(java.lang.String url)
          Sets the JDBC URL to connect to the slave server.
 void setUser(java.lang.String user)
           
 TungstenProperties status()
          Returns status information as a set of named properties.
 
Methods inherited from class com.continuent.tungsten.replicator.storage.InMemoryQueueStore
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 -

setMinTimeAhead

public void setMinTimeAhead(int aheadMinTime)
Sets the minimum number of seconds ahead of slave in order to accept an event for prefetch. If an event is under this number we discard it.

Parameters:
aheadMinTime - Minimum lead time in seconds

setMaxTimeAhead

public void setMaxTimeAhead(int aheadMaxTime)
Sets the maximum number of seconds that event should be from the last event applied by the slave. If we exceed this we sleep to let the slave catch up.

Parameters:
aheadMaxTime - Maximum lead time in seconds

setSleepTime

public void setSleepTime(int sleepTime)
Sets the number of milliseconds to sleep when we get too far ahead of the slave.

Parameters:
sleepTime - The sleepTime to set.

setAllowAll

public void setAllowAll(boolean allowAll)
Allow all events regardless of position of slave service we are tracking. Used for debugging and to exercise prefetch applier code easily.


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

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
Overrides:
configure in class InMemoryQueueStore
Throws:
ReplicatorException - Thrown if configuration is incomplete or fails
See Also:
InMemoryQueueStore.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

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