Class OperationDispatcher

java.lang.Object
org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher

public class OperationDispatcher extends Object
This class handles dispatching various HotRodOperations to the appropriate server. It also handles retries and failover operations.

Depending upon the operation it is first determined which server it should go to, it is then sent to the ChannelHandler which creates a new channel if needed for the operation which then hands it off to the OperationChannel which actually dispatches the command to the socket.

When an operation is dispatched it is first registered with the HeaderDecoder so that its response can be processed.

  • Field Details

  • Constructor Details

  • Method Details

    • getCacheInfo

      public CacheInfo getCacheInfo(String cacheName)
    • getTimeService

      public org.infinispan.commons.time.TimeService getTimeService()
    • getClientListenerNotifier

      public ClientListenerNotifier getClientListenerNotifier()
    • start

      public void start()
    • stop

      public void stop()
    • getHandlerForAddress

      public OperationChannel getHandlerForAddress(SocketAddress socketAddress)
    • execute

      public <E> CompletionStage<E> execute(HotRodOperation<E> operation)
    • executeBulk

      public <E, O extends HotRodOperation<E>> CompletionStage<E> executeBulk(String cacheName, HotRodBulkOperation<?,E,O> operation)
    • executeAddListener

      public CompletionStage<io.netty.channel.Channel> executeAddListener(ClientListenerOperation operation)
    • executeAddListener

      public CompletionStage<io.netty.channel.Channel> executeAddListener(ClientListenerOperation operation, SocketAddress target)
    • addressForObject

      public SocketAddress addressForObject(Object routingObject, String cacheName)
    • addressForObject

      protected SocketAddress addressForObject(Object routingObject, String cacheName, Set<SocketAddress> opFailedServers)
    • executeOnSingleAddress

      public <E> CompletionStage<E> executeOnSingleAddress(HotRodOperation<E> operation, SocketAddress socketAddress)
    • getBalancer

      public FailoverRequestBalancingStrategy getBalancer(String cacheName)
    • getClientIntelligence

      public ClientIntelligence getClientIntelligence()
    • getCacheTopologyInfo

      public CacheTopologyInfo getCacheTopologyInfo(String cacheName)
    • getClientTopologyInfo

      public ClientTopology getClientTopologyInfo(String cacheName)
    • getPrimarySegmentsByAddress

      public Map<SocketAddress,Set<Integer>> getPrimarySegmentsByAddress(String cacheName)
    • getServers

      public Collection<InetSocketAddress> getServers()
    • updateTopology

      public void updateTopology(String cacheName, HotRodOperation<?> operation, int responseTopologyId, InetSocketAddress[] addresses, SocketAddress[][] segmentOwners, short hashFunctionVersion)
    • updateCacheInfo

      protected void updateCacheInfo(String cacheName, CacheInfo newCacheInfo)
    • manualSwitchToCluster

      public boolean manualSwitchToCluster(String clusterName)
    • handleResponse

      public <E> void handleResponse(HotRodOperation<E> op, long messageId, io.netty.channel.Channel channel, E returnValue, Throwable t)
      This method is called back whenever an operation is completed either through success (null Throwable) or through exception/error (non null Throwable)
      Type Parameters:
      E - the operation result type
      Parameters:
      op - the operation that completed
      messageId - the id of the message when sent
      channel - the channel that performed the operation
      returnValue - the return value for the operation (may be null)
      t - the throwable, which if a problem was encountered will be not null, otherwise null
    • handleResponse

      public <E> void handleResponse(HotRodOperation<E> op, long messageId, SocketAddress unresolvedAddress, E returnValue, Throwable t)
    • removeListener

      public void removeListener(SocketAddress sa, byte[] listenerId)
    • unresolvedAddressForChannel

      public SocketAddress unresolvedAddressForChannel(io.netty.channel.Channel c)
    • isServerError

      protected final boolean isServerError(Throwable t)
    • logAndRetryOrFail

      protected void logAndRetryOrFail(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op)
    • logAndRetryOrFail

      protected void logAndRetryOrFail(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op, AddClientListenerOperation aclo)
    • canRetry

      protected boolean canRetry(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op)
    • handleConnectionFailure

      public void handleConnectionFailure(OperationChannel operationChannel, Throwable t)
    • handleChannelFailure

      public void handleChannelFailure(io.netty.channel.Channel channel, Throwable t)
    • getCurrentClusterName

      public String getCurrentClusterName()
    • getRetries

      public long getRetries()
    • getConsistentHash

      public ConsistentHash getConsistentHash(String cacheName)
    • getTopologyId

      public int getTopologyId(String cacheName)
    • getServers

      public Collection<InetSocketAddress> getServers(String cacheName)
    • addCacheTopologyInfoIfAbsent

      public void addCacheTopologyInfoIfAbsent(String cacheName)
    • getConnectionFailedServers

      public Set<SocketAddress> getConnectionFailedServers()