Class OperationDispatcher
java.lang.Object
org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOperationDispatcher(Configuration configuration, ExecutorService executorService, org.infinispan.commons.time.TimeService timeService, ClientListenerNotifier clientListenerNotifier, Consumer<io.netty.channel.ChannelPipeline> pipelineDecorator) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheTopologyInfoIfAbsent(String cacheName) addressForObject(Object routingObject, String cacheName) protected SocketAddressaddressForObject(Object routingObject, String cacheName, Set<SocketAddress> opFailedServers) protected booleancanRetry(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op) <E> CompletionStage<E> execute(HotRodOperation<E> operation) CompletionStage<io.netty.channel.Channel> executeAddListener(ClientListenerOperation operation) CompletionStage<io.netty.channel.Channel> executeAddListener(ClientListenerOperation operation, SocketAddress target) <E,O extends HotRodOperation<E>>
CompletionStage<E> executeBulk(String cacheName, HotRodBulkOperation<?, E, O> operation) <E> CompletionStage<E> executeOnSingleAddress(HotRodOperation<E> operation, SocketAddress socketAddress) getBalancer(String cacheName) getCacheInfo(String cacheName) getCacheTopologyInfo(String cacheName) getClientTopologyInfo(String cacheName) getConsistentHash(String cacheName) getHandlerForAddress(SocketAddress socketAddress) getPrimarySegmentsByAddress(String cacheName) longgetServers(String cacheName) org.infinispan.commons.time.TimeServiceintgetTopologyId(String cacheName) voidhandleChannelFailure(io.netty.channel.Channel channel, Throwable t) voidhandleConnectionFailure(OperationChannel operationChannel, Throwable t) <E> voidhandleResponse(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)<E> voidhandleResponse(HotRodOperation<E> op, long messageId, SocketAddress unresolvedAddress, E returnValue, Throwable t) protected final booleanprotected voidlogAndRetryOrFail(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op) protected voidlogAndRetryOrFail(Throwable t, org.infinispan.client.hotrod.impl.transport.netty.OperationDispatcher.RetryingHotRodOperation<?> op, AddClientListenerOperation aclo) booleanmanualSwitchToCluster(String clusterName) voidremoveListener(SocketAddress sa, byte[] listenerId) voidstart()voidstop()unresolvedAddressForChannel(io.netty.channel.Channel c) protected voidupdateCacheInfo(String cacheName, CacheInfo newCacheInfo) voidupdateTopology(String cacheName, HotRodOperation<?> operation, int responseTopologyId, InetSocketAddress[] addresses, SocketAddress[][] segmentOwners, short hashFunctionVersion)
-
Field Details
-
DEFAULT_CLUSTER_NAME
- See Also:
-
-
Constructor Details
-
OperationDispatcher
public OperationDispatcher(Configuration configuration, ExecutorService executorService, org.infinispan.commons.time.TimeService timeService, ClientListenerNotifier clientListenerNotifier, Consumer<io.netty.channel.ChannelPipeline> pipelineDecorator)
-
-
Method Details
-
getCacheInfo
-
getTimeService
public org.infinispan.commons.time.TimeService getTimeService() -
getClientListenerNotifier
-
start
public void start() -
stop
public void stop() -
getHandlerForAddress
-
execute
-
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
-
addressForObject
protected SocketAddress addressForObject(Object routingObject, String cacheName, Set<SocketAddress> opFailedServers) -
executeOnSingleAddress
public <E> CompletionStage<E> executeOnSingleAddress(HotRodOperation<E> operation, SocketAddress socketAddress) -
getBalancer
-
getClientIntelligence
-
getCacheTopologyInfo
-
getClientTopologyInfo
-
getPrimarySegmentsByAddress
-
getServers
-
updateTopology
public void updateTopology(String cacheName, HotRodOperation<?> operation, int responseTopologyId, InetSocketAddress[] addresses, SocketAddress[][] segmentOwners, short hashFunctionVersion) -
updateCacheInfo
-
manualSwitchToCluster
-
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 completedmessageId- the id of the message when sentchannel- the channel that performed the operationreturnValue- 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
-
unresolvedAddressForChannel
-
isServerError
-
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
-
handleChannelFailure
-
getCurrentClusterName
-
getRetries
public long getRetries() -
getConsistentHash
-
getTopologyId
-
getServers
-
addCacheTopologyInfoIfAbsent
-
getConnectionFailedServers
-