Class AbstractParameterBasedModRouterWithFailOverToNextNode

java.lang.Object
org.distributeme.core.routing.AbstractRouter
org.distributeme.core.routing.AbstractRouterWithFailOverToNextNode
org.distributeme.core.routing.AbstractParameterBasedModRouterWithFailOverToNextNode
All Implemented Interfaces:
FailingStrategy, ConfigurableRouter, Router

public abstract class AbstractParameterBasedModRouterWithFailOverToNextNode extends AbstractRouterWithFailOverToNextNode
Abstract implementation of MOD strategy router which supports FailOver to next cluster node - strategy.
Version:
$Id: $Id
Author:
h3llka
  • Field Details

  • Constructor Details

    • AbstractParameterBasedModRouterWithFailOverToNextNode

      public AbstractParameterBasedModRouterWithFailOverToNextNode()
  • Method Details

    • failingSupported

      protected boolean failingSupported()
      Allow to turn on and off failing support. Actually can be enabled or disabled per some implementation.
      Returns:
      boolean value
    • getStrategy

      protected RouterStrategy getStrategy()
      Return RouterStrategy - which should be used for current Router implementation. Current method should not return NULL, value validation will be performed in constructor.
      Returns:
      RouterStrategy
    • callFailed

      public FailDecision callFailed(ClientSideCallContext clientSideCallContext)
      What should happen if a call is failed.
      Specified by:
      callFailed in interface FailingStrategy
      Parameters:
      clientSideCallContext - a ClientSideCallContext object.
      Returns:
      a FailDecision object.
    • getRRBasedServiceId

      protected String getRRBasedServiceId(ClientSideCallContext context)
      Returns serviceId based on RoundRobin strategy.
      Parameters:
      context - ClientSideCallContext
      Returns:
      serviceId string
    • getModBasedServiceId

      protected String getModBasedServiceId(ClientSideCallContext context)
      Return serviceId based on Mod routing strategy. NOTE : it's native that not all methods supports such kind of routing strategy [MOD]. So, if some method does not supports MOD - strategy - then ROUND-ROBIN strategy will be used for such call.
      Parameters:
      context - ClientSideCallContext
      Returns:
      serviceId string
    • getLog

      protected org.slf4j.Logger getLog()
      Simply return configured Logger instance.
      Returns:
      Logger
    • getConfiguration

      protected GenericRouterConfiguration getConfiguration()

      Getter for the field configuration.

      Returns:
      a GenericRouterConfiguration object.
    • setConfigurationName

      public void setConfigurationName(String serviceId, String configurationName)
      Sets the configuration name and the service id.
      Specified by:
      setConfigurationName in interface ConfigurableRouter
      Parameters:
      serviceId - a String object.
      configurationName - a String object.
    • getServiceAmount

      protected int getServiceAmount()
      Return amount of services for which routing should be performed. Current method should not return less then (int) 2 result, cause in that case router usage makes no sense, value validation will be performed in constructor.
      Returns:
      int value
    • getModableValue

      protected abstract long getModableValue(Object parameter)
      Return long value for mod calculation.
      Parameters:
      parameter - some method incoming parameter
      Returns:
      long value
    • addModRoutedMethod

      protected void addModRoutedMethod(String mName, int modableParameterPosition)
      Allow to add some custom method with some name and modable parameter position to mod method registry. Illegal argument exception will be thrown if any incoming parameter is not valid ( mName - is null or empty, modableParameterPosition is negative).
      Parameters:
      mName - name of method which should be routed using MOD strategy
      modableParameterPosition - position of method argument for mod calculations
    • addModRoutedMethod

      protected void addModRoutedMethod(String mName)
      Allow to add some custom method with some name using default 0 modable parameter position. Illegal argument exception will be thrown if mName - is null or empty.
      Parameters:
      mName - name of method which should be routed using MOD strategy