org.apache.camel.processor.loadbalancer
Class StickyLoadBalancer

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.loadbalancer.LoadBalancerSupport
          extended by org.apache.camel.processor.loadbalancer.QueueLoadBalancer
              extended by org.apache.camel.processor.loadbalancer.StickyLoadBalancer
All Implemented Interfaces:
AsyncProcessor, Navigate<Processor>, Processor, LoadBalancer, Service, ShutdownableService

public class StickyLoadBalancer
extends QueueLoadBalancer

Implements a sticky load balancer using an Expression to calculate a correlation key to perform the sticky load balancing; rather like jsessionid in the web or JMSXGroupID in JMS.

Version:
$Revision: 15303 $

Field Summary
 
Fields inherited from class org.apache.camel.processor.loadbalancer.LoadBalancerSupport
log
 
Constructor Summary
StickyLoadBalancer(Expression correlationExpression)
           
StickyLoadBalancer(Expression correlationExpression, QueueLoadBalancer loadBalancer)
           
 
Method Summary
protected  Processor chooseProcessor(List<Processor> processors, Exchange exchange)
           
 Expression getCorrelationExpression()
           
 int getNumberOfHashGroups()
           
protected  Object getStickyKey(Object value)
          A strategy to create the key for the sticky load balancing map.
 void removeProcessor(Processor processor)
          Removes the given processor from the load balancer
 void setNumberOfHashGroups(int numberOfHashGroups)
           
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.loadbalancer.QueueLoadBalancer
process, process
 
Methods inherited from class org.apache.camel.processor.loadbalancer.LoadBalancerSupport
addProcessor, doStart, doStop, getProcessors, hasNext, next
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StickyLoadBalancer

public StickyLoadBalancer(Expression correlationExpression)

StickyLoadBalancer

public StickyLoadBalancer(Expression correlationExpression,
                          QueueLoadBalancer loadBalancer)
Method Detail

getCorrelationExpression

public Expression getCorrelationExpression()

chooseProcessor

protected Processor chooseProcessor(List<Processor> processors,
                                    Exchange exchange)
Specified by:
chooseProcessor in class QueueLoadBalancer

removeProcessor

public void removeProcessor(Processor processor)
Description copied from interface: LoadBalancer
Removes the given processor from the load balancer

Specified by:
removeProcessor in interface LoadBalancer
Overrides:
removeProcessor in class LoadBalancerSupport
Parameters:
processor - the processor to be removed from the load balancer

getNumberOfHashGroups

public int getNumberOfHashGroups()

setNumberOfHashGroups

public void setNumberOfHashGroups(int numberOfHashGroups)

getStickyKey

protected Object getStickyKey(Object value)
A strategy to create the key for the sticky load balancing map. The default implementation uses the hash code of the value then modulos by the numberOfHashGroups to avoid the sticky map getting too big

Parameters:
value - the correlation value
Returns:
the key to be used in the sticky map

toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL