org.mobicents.tools.sip.balancer
Class PersistentConsistentHashBalancerAlgorithm

java.lang.Object
  extended by org.mobicents.tools.sip.balancer.DefaultBalancerAlgorithm
      extended by org.mobicents.tools.sip.balancer.PersistentConsistentHashBalancerAlgorithm
All Implemented Interfaces:
BalancerAlgorithm

public class PersistentConsistentHashBalancerAlgorithm
extends DefaultBalancerAlgorithm

Persistent Consistent Hash algorithm - see http://docs.google.com/present/view?id=dc5jp5vx_89cxdvtxcm Example algorithms section

Author:
vralev

Field Summary
protected  org.jboss.cache.Cache cache
           
protected  java.lang.String httpAffinityKey
           
protected  java.lang.String sipHeaderAffinityKey
           
 
Fields inherited from class org.mobicents.tools.sip.balancer.DefaultBalancerAlgorithm
properties
 
Constructor Summary
PersistentConsistentHashBalancerAlgorithm()
           
PersistentConsistentHashBalancerAlgorithm(java.lang.String headerName)
           
 
Method Summary
protected  int hashAffinityKeyword(java.lang.String keyword)
           
 void init()
          Lifecycle method.
 void modified(org.jboss.cache.notifications.event.Event event)
           
 void nodeAdded(SIPNode node)
          Notify the algorithm when a node is added.
 void nodeRemoved(SIPNode node)
          Notifying the algorithm when a node is dead.
 SIPNode processExternalRequest(javax.sip.message.Request request)
          When a request comes it is passed to the algorithm.
 SIPNode processHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest request)
          Handle HttpRequests here.
 void viewChanged(org.jboss.cache.notifications.event.ViewChangedEvent event)
           
 
Methods inherited from class org.mobicents.tools.sip.balancer.DefaultBalancerAlgorithm
assignToNode, getBalancerContext, getProperties, jvmRouteSwitchover, processAssignedExternalRequest, processExternalResponse, processInternalRequest, processInternalResponse, setProperties, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sipHeaderAffinityKey

protected java.lang.String sipHeaderAffinityKey

httpAffinityKey

protected java.lang.String httpAffinityKey

cache

protected org.jboss.cache.Cache cache
Constructor Detail

PersistentConsistentHashBalancerAlgorithm

public PersistentConsistentHashBalancerAlgorithm()

PersistentConsistentHashBalancerAlgorithm

public PersistentConsistentHashBalancerAlgorithm(java.lang.String headerName)
Method Detail

processExternalRequest

public SIPNode processExternalRequest(javax.sip.message.Request request)
Description copied from interface: BalancerAlgorithm
When a request comes it is passed to the algorithm. The algorithm must add the Route headers to the node or nodes where the request should go. The actual proxying is done at the LB. Allowing the algorithm to add headers allows more flexibility for example when you need to pass some information to the AS or the application to make further LB decisions or multiprotocol cooperative load balancing. It is very little effort for great flexibility.

Returns:

modified

public void modified(org.jboss.cache.notifications.event.Event event)

nodeAdded

public void nodeAdded(SIPNode node)
Description copied from interface: BalancerAlgorithm
Notify the algorithm when a node is added.

Specified by:
nodeAdded in interface BalancerAlgorithm
Overrides:
nodeAdded in class DefaultBalancerAlgorithm

nodeRemoved

public void nodeRemoved(SIPNode node)
Description copied from interface: BalancerAlgorithm
Notifying the algorithm when a node is dead.

Specified by:
nodeRemoved in interface BalancerAlgorithm
Overrides:
nodeRemoved in class DefaultBalancerAlgorithm

processHttpRequest

public SIPNode processHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest request)
Description copied from interface: BalancerAlgorithm
Handle HttpRequests here. Use the Netty API for Http request analysis.

Specified by:
processHttpRequest in interface BalancerAlgorithm
Overrides:
processHttpRequest in class DefaultBalancerAlgorithm
Returns:

hashAffinityKeyword

protected int hashAffinityKeyword(java.lang.String keyword)

viewChanged

public void viewChanged(org.jboss.cache.notifications.event.ViewChangedEvent event)

init

public void init()
Description copied from interface: BalancerAlgorithm
Lifecycle method. Notifies the algorithm when it's initialized with properties and balancer context.



Copyright © 2010. All Rights Reserved.