com.continuent.tungsten.replicator.storage.parallel
Class ShardListPartitioner

java.lang.Object
  extended by com.continuent.tungsten.replicator.storage.parallel.ShardListPartitioner
All Implemented Interfaces:
Partitioner

public class ShardListPartitioner
extends java.lang.Object
implements Partitioner

Partitions events using a map that directs shard assignment to partition numbers. The default shard map location is by convention tungsten-replicator/conf/shard.list. The shard map structure follows the example shown here.

 # Shard map file. 
 # Explicit database name match. 
 common1=0
 common2=0
 db1=1
 db2=2
 db3=3
 
 # Default partition for shards that do not match explicit name. 
 # Permissible values are either a partition number or -1 in 
 # which case values are hashed across available partitions. 
 (*)=4
 
 # Comma-separated list of shards that require critical section to run. 
 (critical)=common1,common2
 
 # Method for channel hash assignments.  Allowed values are round-robin and 
 # string-hash. 
 (hash-method)=string-hash
 

Version:
1.0
Author:
Robert Hodges

Constructor Summary
ShardListPartitioner()
          Create new instance of partitioner.
 
Method Summary
 PartitionerResponse partition(ReplDBMSHeader event, int taskId)
          Assign an event to a particular partition.
 void setContext(PluginContext context)
          Assigns the current runtime context in case the partitioner needs to refer to replicator state.
 void setPartitions(int availablePartitions)
          Sets the number of available partitions.
 void setShardMap(java.io.File shardMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShardListPartitioner

public ShardListPartitioner()
Create new instance of partitioner.

Method Detail

setShardMap

public void setShardMap(java.io.File shardMap)

setPartitions

public void setPartitions(int availablePartitions)
Sets the number of available partitions.

Specified by:
setPartitions in interface Partitioner
Parameters:
availablePartitions - Number of partitions available
See Also:
Partitioner.setPartitions(int)

setContext

public void setContext(PluginContext context)
Assigns the current runtime context in case the partitioner needs to refer to replicator state.

Specified by:
setContext in interface Partitioner
Parameters:
context - Replicator runtime context
See Also:
Partitioner.setContext(com.continuent.tungsten.replicator.plugin.PluginContext)

partition

public PartitionerResponse partition(ReplDBMSHeader event,
                                     int taskId)
                              throws ReplicatorException
Assign an event to a particular partition. All fragments of a particular sequence number must go to the same partition.

Specified by:
partition in interface Partitioner
Parameters:
event - Event to be assigned a partition
taskId - Task id of input thread
Returns:
Response containing partition ID and whether event requires a critical section
Throws:
ReplicatorException
See Also:
Partitioner.partition(com.continuent.tungsten.replicator.event.ReplDBMSHeader, int)