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

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

public class LoadBalancingPartitioner
extends java.lang.Object
implements StatefulPartitioner

Partitions event by assigning to the least loaded queue.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
LoadBalancingPartitioner()
           
 
Method Summary
 PartitionerResponse partition(ReplDBMSHeader event, int taskId)
          Returns the partition with the smallest current size or the first partition that has a current size of zero.
 void setContext(PluginContext context)
          Assigns the current runtime context in case the partitioner needs to refer to replicator state.
 void setPartitionMetadata(java.util.List<PartitionMetadata> partitions)
          Sets metadata for partitions.
 void setPartitions(int availablePartitions)
          Sets the number of available partitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadBalancingPartitioner

public LoadBalancingPartitioner()
Method Detail

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)

setPartitionMetadata

public void setPartitionMetadata(java.util.List<PartitionMetadata> partitions)
Sets metadata for partitions.

Specified by:
setPartitionMetadata in interface StatefulPartitioner
Parameters:
partitions - List of partition metadata instances
See Also:
StatefulPartitioner.setPartitionMetadata(java.util.List)

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)
Returns the partition with the smallest current size or the first partition that has a current size of zero.

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