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.
  • Field Details

  • Constructor Details

    • FailoverTargetSelector

      public FailoverTargetSelector()
      Normal constructor.
    • FailoverTargetSelector

      public FailoverTargetSelector(String clientBootstrapAddress)
    • 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

      protected FailoverTargetSelector.InvocationContext getInvocationContext(String key)
    • complete

      public void complete(org.apache.cxf.message.Exchange exchange)
      Called on completion of the MEP for which the Conduit was required.
      Specified by:
      complete in interface org.apache.cxf.endpoint.ConduitSelector
      Overrides:
      complete in class org.apache.cxf.endpoint.AbstractConduitSelector
      Parameters:
      exchange - represents the completed MEP
    • doComplete

      protected void doComplete(org.apache.cxf.message.Exchange exchange)
    • setOriginalEndpoint

      protected void setOriginalEndpoint(FailoverTargetSelector.InvocationContext invocation)
    • performFailover

      protected boolean performFailover(org.apache.cxf.message.Exchange exchange, FailoverTargetSelector.InvocationContext invocation)
    • onSuccess

      protected void onSuccess(FailoverTargetSelector.InvocationContext context)
    • onFailure

      protected void onFailure(FailoverTargetSelector.InvocationContext context, Exception ex)
    • setStrategy

      public void setStrategy(FailoverStrategy strategy)
      Parameters:
      strategy - the FailoverStrategy to use
    • getStrategy

      public FailoverStrategy getStrategy()
      Returns:
      strategy the FailoverStrategy to use
    • getLogger

      protected Logger getLogger()
      Specified by:
      getLogger in class org.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

      protected boolean requiresFailover(org.apache.cxf.message.Exchange exchange, Exception ex)
      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 Exchange
      invocation - 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 Exchange
      invocation - the current InvocationContext
      Returns:
      alternative addresses
    • overrideAddressProperty

      protected void overrideAddressProperty(Map<String,Object> context)
      Override the ENDPOINT_ADDRESS property in the request context
      Parameters:
      context - the request context
    • overrideAddressProperty

      protected void overrideAddressProperty(Map<String,Object> context, String address)
    • replaceEndpointAddressPropertyIfNeeded

      protected boolean replaceEndpointAddressPropertyIfNeeded(org.apache.cxf.message.Message message, String endpointAddress, org.apache.cxf.transport.Conduit cond)
      Overrides:
      replaceEndpointAddressPropertyIfNeeded in class org.apache.cxf.endpoint.AbstractConduitSelector
    • isSupportNotAvailableErrorsOnly

      public boolean isSupportNotAvailableErrorsOnly()
    • setSupportNotAvailableErrorsOnly

      public void setSupportNotAvailableErrorsOnly(boolean support)
    • getClientBootstrapAddress

      public String getClientBootstrapAddress()
    • setClientBootstrapAddress

      public void setClientBootstrapAddress(String clientBootstrapAddress)
    • getInvocationKey

      protected String getInvocationKey(org.apache.cxf.message.Exchange e)