|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.thl.THLParallelQueue
public class THLParallelQueue
Implements a parallel event store based on on-disk queues. On-disk queues work by managing a set of threads that read from the THL in parallel on behalf of the next stage and populate queues for each applier task. This class is responsible for setting up the task threads as well as the queues they feed, ensuring that queues do not get too far apart when executing, and to handle control events including getting apply tasks to commit their restart position both at regular intervals as well as prior to clean shutdown.
Applier tasks are known as "channels" in replicator end-user documentation. This class makes a very strong assumption that shard IDs are correctly assigned in prior stages. If not, parallelization may fail due to conflicts when transactions are assigned to incorrect channels. This in turn can lead to apply failing on slaves in such a way that the slave must be resynchronized with its master to continue.
| Constructor Summary | |
|---|---|
THLParallelQueue()
|
|
| Method Summary | |
|---|---|
void |
configure(PluginContext context)
Complete plug-in configuration. |
ReplEvent |
get(int taskId)
Removes and returns next event from the queue, blocking if empty. |
long |
getHeadSeqno()
Returns the current head seqno to which read tasks may advance. |
AtomicIntervalGuard<?> |
getIntervalGuard()
Returns the interval guard structure that tracks positions of channels. |
int |
getMaxDelayInterval()
|
int |
getMaxOfflineInterval()
Returns the maximum number of seconds to do a clean shutdown. |
int |
getMaxSize()
Maximum size of individual queues. |
long |
getMaxStoredSeqno()
Returns the maximum persistently stored sequence number. |
ReplDBMSHeader |
getMinLastHeader()
Returns the minimum last header processed in order to handle restart correctly. |
long |
getMinStoredSeqno()
Returns the minimum persistently stored sequence number. |
java.lang.String |
getName()
Gets the storage name. |
Partitioner |
getPartitioner()
|
java.lang.String |
getPartitionerClass()
Returns the class used for partitioning transactions across queues. |
int |
getPartitions()
Returns the number of partitions for events. |
int |
getSyncInterval()
Returns the number of events between sync intervals. |
void |
insertStopEvent()
Inserts stop control event after next complete transaction. |
void |
insertWatchSyncEvent(WatchPredicate<ReplDBMSHeader> predicate)
Inserts watch synchronization event after next complete transaction that matches the provided predicate. |
ReplEvent |
peek(int taskId)
Returns next event from the queue without removing it, returning null if queue is empty. |
void |
prepare(PluginContext context)
Prepare plug-in for use. |
void |
put(int taskId,
ReplDBMSEvent event)
Puts an event in the queue, blocking if it is full. |
void |
release(PluginContext context)
Release queue. |
void |
setLastHeader(int taskId,
ReplDBMSHeader header)
Sets the last header processed. |
void |
setMaxDelayInterval(int maxDelayInterval)
Sets the maximum number of seconds to delay before allowing transactions to continue even when they would cause maxOfflineInterval to be exceeded. |
void |
setMaxOfflineInterval(int maxOfflineInterval)
Sets the maximum number of seconds for a clean shutdown. |
void |
setMaxSize(int size)
Returns the maximum size of individual queues. |
void |
setName(java.lang.String name)
Sets the storage name. |
void |
setPartitioner(Partitioner partitioner)
Sets the instance used to assign events to partitions (channels). |
void |
setPartitionerClass(java.lang.String partitionerClass)
Sets the name of the class used to assign events to partitions (channels). |
void |
setPartitions(int partitions)
Sets the number of queue partitions. |
void |
setSyncInterval(int syncInterval)
Sets the number of events to process before generating an automatic control event if sync is enabled. |
int |
size(int taskId)
Returns the current queue size. |
void |
start(int taskId)
Start the reader for a particular task. |
TungstenProperties |
status()
Returns status information as a set of named properties. |
void |
stop(int taskId)
Stop the reader for a particular task. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public THLParallelQueue()
| Method Detail |
|---|
public java.lang.String getName()
Store
getName in interface Storepublic void setName(java.lang.String name)
Store
setName in interface Storepublic int getMaxSize()
public void setMaxSize(int size)
ParallelStore
setMaxSize in interface ParallelStorepublic void setPartitions(int partitions)
setPartitions in interface ParallelStorepublic int getPartitions()
getPartitions in interface ParallelStorepublic Partitioner getPartitioner()
public void setPartitioner(Partitioner partitioner)
public java.lang.String getPartitionerClass()
ParallelStore
getPartitionerClass in interface ParallelStorepublic void setPartitionerClass(java.lang.String partitionerClass)
setPartitionerClass in interface ParallelStorepublic int getSyncInterval()
getSyncInterval in interface ParallelStorepublic void setSyncInterval(int syncInterval)
setSyncInterval in interface ParallelStorepublic int getMaxOfflineInterval()
getMaxOfflineInterval in interface ParallelStorepublic void setMaxOfflineInterval(int maxOfflineInterval)
setMaxOfflineInterval in interface ParallelStorepublic int getMaxDelayInterval()
public void setMaxDelayInterval(int maxDelayInterval)
public long getHeadSeqno()
public AtomicIntervalGuard<?> getIntervalGuard()
public void setLastHeader(int taskId,
ReplDBMSHeader header)
throws ReplicatorException
ReplicatorException
public ReplDBMSHeader getMinLastHeader()
throws ReplicatorException
ReplicatorExceptionpublic long getMaxStoredSeqno()
getMaxStoredSeqno in interface StoreStore.getMaxStoredSeqno()public long getMinStoredSeqno()
getMinStoredSeqno in interface StoreStore.getMinStoredSeqno()
public void put(int taskId,
ReplDBMSEvent event)
throws java.lang.InterruptedException,
ReplicatorException
java.lang.InterruptedException
ReplicatorException
public ReplEvent get(int taskId)
throws java.lang.InterruptedException,
ReplicatorException
java.lang.InterruptedException
ReplicatorException
public ReplEvent peek(int taskId)
throws java.lang.InterruptedException,
ReplicatorException
java.lang.InterruptedException
ReplicatorExceptionpublic int size(int taskId)
public void configure(PluginContext context)
throws ReplicatorException
configure in interface ReplicatorPluginReplicatorException - Thrown if configuration is incomplete or
failsReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)
public void prepare(PluginContext context)
throws ReplicatorException,
java.lang.InterruptedException
prepare in interface ReplicatorPluginReplicatorException - Thrown if resource allocation fails
java.lang.InterruptedExceptionReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)
public void release(PluginContext context)
throws ReplicatorException
release in interface ReplicatorPluginReplicatorException - Thrown if resource deallocation failsReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)public void start(int taskId)
public void stop(int taskId)
public void insertStopEvent()
throws java.lang.InterruptedException
insertStopEvent in interface ParallelStorejava.lang.InterruptedExceptionParallelStore.insertStopEvent()
public void insertWatchSyncEvent(WatchPredicate<ReplDBMSHeader> predicate)
throws java.lang.InterruptedException
insertWatchSyncEvent in interface ParallelStorejava.lang.InterruptedExceptionParallelStore.insertWatchSyncEvent(com.continuent.tungsten.replicator.util.WatchPredicate)public TungstenProperties status()
status in interface StoreStore.status()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||