Package org.distributeme.core.routing
Class RoundRobinRouterWithStickyFailoverToNextNode
java.lang.Object
org.distributeme.core.routing.AbstractRouter
org.distributeme.core.routing.AbstractRouterWithStickyFailOverToNextNode
org.distributeme.core.routing.RoundRobinRouterWithStickyFailoverToNextNode
- All Implemented Interfaces:
FailingStrategy,ConfigurableRouter,Router,RouterConfigurationObserver
public class RoundRobinRouterWithStickyFailoverToNextNode
extends AbstractRouterWithStickyFailOverToNextNode
This router sends each call to another instance. It is useful if you want to cluster a service.
In case of a failure it will resend the request to another instance in the cluster. As long as one service instance remains operational the whole cluster works.
- Version:
- $Id: $Id
- Author:
- lrosenberg
-
Field Summary
FieldsFields inherited from class org.distributeme.core.routing.AbstractRouterWithStickyFailOverToNextNode
ATTR_TRIED_INSTANCES, PARAMETER_KEY_SERVICES, PARAMETER_KEY_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddModRoutedMethod(String mName) Allow to add some custom method with some name using default 0 modable parameter position.protected voidaddModRoutedMethod(String mName, int modableParameterPosition) Allow to add some custom method with some name and modable parameter position to mod method registry.protected booleanAllow to turn on and off failing support.protected GenericRouterConfigurationGetter for the fieldconfiguration.protected org.slf4j.LoggergetLog()Simply return configuredLoggerinstance.protected longgetModableValue(Object parameter) Return long value for mod calculation.protected StringReturn serviceId based on Mod routing strategy.protected StringgetRRBasedServiceId(ClientSideCallContext context) Returns serviceId based on RoundRobin strategy.protected intReturn amount of services for which routing should be performed.protected RouterStrategyReturn RouterStrategy - which should be used for current Router implementation.Methods inherited from class org.distributeme.core.routing.AbstractRouterWithStickyFailOverToNextNode
callFailed, customize, getRandomInt, getServiceIdForCall, routerConfigurationChange, routerConfigurationFollowupChange, routerConfigurationInitialChange, setConfigurationNameMethods inherited from class org.distributeme.core.routing.AbstractRouter
customize, getRoutingStats, setServiceId
-
Field Details
-
UNDER_LINE
Underline constant.- See Also:
-
-
Constructor Details
-
RoundRobinRouterWithStickyFailoverToNextNode
public RoundRobinRouterWithStickyFailoverToNextNode()
-
-
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
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
-
getModableValue
Return long value for mod calculation.- Parameters:
parameter- some method incoming parameter- Returns:
- long value
-
getRRBasedServiceId
Returns serviceId based on RoundRobin strategy.- Parameters:
context-ClientSideCallContext- Returns:
- serviceId string
-
getModBasedServiceId
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 configuredLoggerinstance.- Returns:
Logger
-
getConfiguration
Getter for the field
configuration.- Returns:
- a
GenericRouterConfigurationobject.
-
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
-
addModRoutedMethod
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 strategymodableParameterPosition- position of method argument for mod calculations
-
addModRoutedMethod
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
-