org.apache.synapse.endpoints.algorithms
Class AlgorithmContext

java.lang.Object
  extended by org.apache.synapse.endpoints.algorithms.AlgorithmContext

public class AlgorithmContext
extends Object

Keeps the states of the load balance algorithm.This hides where those states are kept.For a cluster environment ,all states are kept in the axis2 configuration context in order to replicate those states so that other synapse instance in the same cluster can see those changes . This class can be evolved to keep any run time states related to the endpoint . For a non-clustered environment , all data are kept locally.

This class provide the abstraction need to separate the dynamic data from the static data and improve the high cohesion and provides capability to replicate only required state at a given time. This improves the performance when replicate data.


Constructor Summary
AlgorithmContext()
           
 
Method Summary
 ConfigurationContext getConfigurationContext()
          Get the configuration context instance .
 int getCurrentEndpointIndex()
          To get the position of the current EPR If there is no value and if there will not appear any errors , then '0' will be returned.
protected  void handleException(String msg)
          Helper methods for handle errors.
protected  void handleException(String msg, Exception e)
          Helper methods for handle errors.
 void setConfigurationContext(ConfigurationContext configCtx)
          Sets the ConfigurationContext instance .
 void setContextID(String contextID)
          Sets the identifier for this algorithm context , so that , this can be identified uniquely across the cluster.
 void setCurrentEPR(int currentEPR)
          The position of the current EPR
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlgorithmContext

public AlgorithmContext()
Method Detail

getCurrentEndpointIndex

public int getCurrentEndpointIndex()
To get the position of the current EPR If there is no value and if there will not appear any errors , then '0' will be returned.

Returns:
The position of the current EPR

setCurrentEPR

public void setCurrentEPR(int currentEPR)
The position of the current EPR

Parameters:
currentEPR - The current position

getConfigurationContext

public ConfigurationContext getConfigurationContext()
Get the configuration context instance . This is only available for cluster env.

Returns:
Returns the ConfigurationContext instance

setConfigurationContext

public void setConfigurationContext(ConfigurationContext configCtx)
Sets the ConfigurationContext instance . This is only used for cluster env. By setting this , indicates that this is a cluster env.

Parameters:
configCtx - The ConfigurationContext instance

setContextID

public void setContextID(String contextID)
Sets the identifier for this algorithm context , so that , this can be identified uniquely across the cluster. The id will be the name of the endpoint

Parameters:
contextID - The Id for this algorithm context

handleException

protected void handleException(String msg)
Helper methods for handle errors.

Parameters:
msg - The error message

handleException

protected void handleException(String msg,
                               Exception e)
Helper methods for handle errors.

Parameters:
msg - The error message
e - The exception


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.