Package org.apache.cxf.clustering
Class FailoverTargetSelector
java.lang.Object
org.apache.cxf.endpoint.AbstractConduitSelector
org.apache.cxf.clustering.FailoverTargetSelector
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.cxf.endpoint.ConduitSelector
- Direct Known Subclasses:
CircuitBreakerTargetSelector,LoadDistributorTargetSelector
public class FailoverTargetSelector
extends org.apache.cxf.endpoint.AbstractConduitSelector
Implements a target selection strategy based on failover to an
alternate target endpoint when a transport level failure is
encountered.
Note that this feature changes the conduit on the fly and thus makes
the Client not thread safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classRecords the context of an invocation. -
Field Summary
FieldsFields inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
CONDUIT_COMPARE_FULL_URL, conduits, endpoint, KEEP_CONDUIT_ALIVE -
Constructor Summary
ConstructorsConstructorDescriptionNormal constructor.FailoverTargetSelector(String clientBootstrapAddress) FailoverTargetSelector(org.apache.cxf.transport.Conduit c) Constructor, allowing a specific conduit to override normal selection. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete(org.apache.cxf.message.Exchange exchange) Called on completion of the MEP for which the Conduit was required.protected voiddoComplete(org.apache.cxf.message.Exchange exchange) protected longReturns delay (in milliseconds) between retriesprotected org.apache.cxf.endpoint.EndpointgetFailoverTarget(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) Get the failover target endpoint, if a suitable one is available.protected FailoverTargetSelector.InvocationContextprotected StringgetInvocationKey(org.apache.cxf.message.Exchange e) protected Loggerbooleanprotected voidonFailure(FailoverTargetSelector.InvocationContext context, Exception ex) protected voidprotected voidoverrideAddressProperty(Map<String, Object> context) Override the ENDPOINT_ADDRESS property in the request contextprotected voidoverrideAddressProperty(Map<String, Object> context, String address) protected booleanperformFailover(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) voidprepare(org.apache.cxf.message.Message message) Called prior to the interceptor chain being traversed.protected booleanreplaceEndpointAddressPropertyIfNeeded(org.apache.cxf.message.Message message, String endpointAddress, org.apache.cxf.transport.Conduit cond) protected booleanrequiresFailover(org.apache.cxf.message.Exchange exchange, Exception ex) Check if the exchange is suitable for a failover.org.apache.cxf.transport.ConduitselectConduit(org.apache.cxf.message.Message message) Called when a Conduit is actually required.voidsetClientBootstrapAddress(String clientBootstrapAddress) protected voidvoidsetStrategy(FailoverStrategy strategy) voidsetSupportNotAvailableErrorsOnly(boolean support) protected voidsetupExchangeExceptionProperties(org.apache.cxf.message.Exchange ex) updateContextAlternatives(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) Fetches and updates the alternative address or/and alternative endpoints (depending on the strategy) for current invocation context.Methods inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
close, createConduit, findCompatibleConduit, getEndpoint, getSelectedConduit, removeConduit, setEndpoint
-
Field Details
-
failoverStrategy
-
-
Constructor Details
-
FailoverTargetSelector
public FailoverTargetSelector()Normal constructor. -
FailoverTargetSelector
-
FailoverTargetSelector
public FailoverTargetSelector(org.apache.cxf.transport.Conduit c) Constructor, allowing a specific conduit to override normal selection.- Parameters:
c- specific conduit
-
-
Method Details
-
prepare
public void prepare(org.apache.cxf.message.Message message) Called prior to the interceptor chain being traversed.- Parameters:
message- the current Message
-
setupExchangeExceptionProperties
protected void setupExchangeExceptionProperties(org.apache.cxf.message.Exchange ex) -
selectConduit
public org.apache.cxf.transport.Conduit selectConduit(org.apache.cxf.message.Message message) Called when a Conduit is actually required.- Parameters:
message-- Returns:
- the Conduit to use for mediation of the message
-
getInvocationContext
-
complete
public void complete(org.apache.cxf.message.Exchange exchange) Called on completion of the MEP for which the Conduit was required.- Specified by:
completein interfaceorg.apache.cxf.endpoint.ConduitSelector- Overrides:
completein classorg.apache.cxf.endpoint.AbstractConduitSelector- Parameters:
exchange- represents the completed MEP
-
doComplete
protected void doComplete(org.apache.cxf.message.Exchange exchange) -
setOriginalEndpoint
-
performFailover
protected boolean performFailover(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) -
onSuccess
-
onFailure
-
setStrategy
- Parameters:
strategy- the FailoverStrategy to use
-
getStrategy
- Returns:
- strategy the FailoverStrategy to use
-
getLogger
- Specified by:
getLoggerin classorg.apache.cxf.endpoint.AbstractConduitSelector- Returns:
- the logger to use
-
getDelayBetweenRetries
protected long getDelayBetweenRetries()Returns delay (in milliseconds) between retries- Returns:
- delay, 0 means no delay
-
requiresFailover
Check if the exchange is suitable for a failover.- Parameters:
exchange- the current Exchange- Returns:
- boolean true if a failover should be attempted
-
getFailoverTarget
protected org.apache.cxf.endpoint.Endpoint getFailoverTarget(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) Get the failover target endpoint, if a suitable one is available.- Parameters:
exchange- the current Exchangeinvocation- the current InvocationContext- Returns:
- a failover endpoint if one is available
-
updateContextAlternatives
protected List<String> updateContextAlternatives(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation) Fetches and updates the alternative address or/and alternative endpoints (depending on the strategy) for current invocation context.- Parameters:
exchange- the current Exchangeinvocation- the current InvocationContext- Returns:
- alternative addresses
-
overrideAddressProperty
Override the ENDPOINT_ADDRESS property in the request context- Parameters:
context- the request context
-
overrideAddressProperty
-
replaceEndpointAddressPropertyIfNeeded
protected boolean replaceEndpointAddressPropertyIfNeeded(org.apache.cxf.message.Message message, String endpointAddress, org.apache.cxf.transport.Conduit cond) - Overrides:
replaceEndpointAddressPropertyIfNeededin classorg.apache.cxf.endpoint.AbstractConduitSelector
-
isSupportNotAvailableErrorsOnly
public boolean isSupportNotAvailableErrorsOnly() -
setSupportNotAvailableErrorsOnly
public void setSupportNotAvailableErrorsOnly(boolean support) -
getClientBootstrapAddress
-
setClientBootstrapAddress
-
getInvocationKey
-