Package org.infinispan.remoting.rpc
Class RpcManagerImpl
- java.lang.Object
-
- org.infinispan.remoting.rpc.RpcManagerImpl
-
- All Implemented Interfaces:
JmxStatisticsExposer
,RpcManager
public class RpcManagerImpl extends Object implements RpcManager, JmxStatisticsExposer
This component really is just a wrapper around aTransport
implementation, and is used to set up the transport and provide lifecycle and dependency hooks into external transport implementations.- Since:
- 4.0
- Author:
- Manik Surtani, Galder ZamarreƱo, Mircea.Markus@jboss.com, Pedro Ruivo
-
-
Constructor Summary
Constructors Constructor Description RpcManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> T
blocking(CompletionStage<T> request)
Block on a request and return its result.Address
getAddress()
Returns the address associated with this RpcManager or null if not part of the cluster.long
getAsyncXSiteAcksCount()
long
getAsyncXSiteCount()
long
getAverageAsyncXSiteReplicationTime()
long
getAverageReplicationTime()
long
getAverageXSiteReplicationTime()
String
getCommittedViewAsString()
RpcOptions
getDefaultRpcOptions(boolean sync)
Creates a newRpcOptionsBuilder
.RpcOptions
getDefaultRpcOptions(boolean sync, DeliverOrder deliverOrder)
Creates a newRpcOptionsBuilder
.long
getMaximumAsyncXSiteReplicationTime()
long
getMaximumXSiteReplicationTime()
List<Address>
getMembers()
Returns members of a cluster scoped to the cache owning this RpcManager.long
getMinimumAsyncXSiteReplicationTime()
long
getMinimumXSiteReplicationTime()
String
getPendingViewAsString()
long
getReplicationCount()
long
getReplicationFailures()
RpcOptionsBuilder
getRpcOptionsBuilder(ResponseMode responseMode)
Creates a newRpcOptionsBuilder
.RpcOptionsBuilder
getRpcOptionsBuilder(ResponseMode responseMode, DeliverOrder deliverOrder)
Creates a newRpcOptionsBuilder
.String
getSitesView()
boolean
getStatisticsEnabled()
Returns whether an interceptor's statistics are being captured.String
getSuccessRatio()
double
getSuccessRatioFloatingPoint()
RpcOptions
getSyncRpcOptions()
long
getSyncXSiteCount()
int
getTopologyId()
Returns the current topology id.RpcOptions
getTotalSyncRpcOptions()
Transport
getTransport()
<T> CompletionStage<T>
invokeCommand(Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Invoke a command on a collection of node and pass the responses to aResponseCollector
.<T> CompletionStage<T>
invokeCommand(Address target, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Invoke a command on a single node and pass the response to aResponseCollector
.<T> CompletionStage<T>
invokeCommandOnAll(org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Invoke a command on all the nodes in the cluster and pass the responses to aResponseCollector
.<T> CompletionStage<T>
invokeCommands(Collection<Address> targets, Function<Address,org.infinispan.commands.ReplicableCommand> commandGenerator, ResponseCollector<T> collector, RpcOptions rpcOptions)
Invoke different commands on a collection of nodes and pass the responses to aResponseCollector
.<T> CompletionStage<T>
invokeCommandStaggered(Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Invoke a command on a collection of nodes and pass the responses to aResponseCollector
.Map<Address,Response>
invokeRemotely(Collection<Address> recipients, org.infinispan.commands.ReplicableCommand rpc, RpcOptions options)
Invokes an RPC call on other caches in the cluster.Map<Address,Response>
invokeRemotely(Map<Address,org.infinispan.commands.ReplicableCommand> rpcs, RpcOptions options)
CompletableFuture<Map<Address,Response>>
invokeRemotelyAsync(Collection<Address> recipients, org.infinispan.commands.ReplicableCommand rpc, RpcOptions options)
Invokes a command on remote nodes.BackupResponse
invokeXSite(Collection<XSiteBackup> sites, XSiteReplicateCommand command)
Invokes theXSiteReplicateCommand
to one or more remote sites.boolean
isStatisticsEnabled()
void
resetStatistics()
Resets an interceptor's cache statisticsvoid
sendTo(Address destination, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the destination using the specifiedDeliverOrder
.void
sendToAll(org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the entire cluster.void
sendToMany(Collection<Address> destinations, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the set of destination using the specifiedDeliverOrder
.void
setStatisticsEnabled(boolean statisticsEnabled)
Deprecated.We already have an attribute, we shouldn't have an operation for the same thing.void
setTransport(Transport t)
-
-
-
Method Detail
-
getCommittedViewAsString
public String getCommittedViewAsString()
-
getPendingViewAsString
public String getPendingViewAsString()
-
invokeCommand
public <T> CompletionStage<T> invokeCommand(Address target, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Description copied from interface:RpcManager
Invoke a command on a single node and pass the response to aResponseCollector
. If the target is the local node and the delivery order is notDeliverOrder.TOTAL
, the command is never executed, andResponseCollector.finish()
is called directly.- Specified by:
invokeCommand
in interfaceRpcManager
-
invokeCommand
public <T> CompletionStage<T> invokeCommand(Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Description copied from interface:RpcManager
Invoke a command on a collection of node and pass the responses to aResponseCollector
. If one of the targets is the local nodes and the delivery order is notDeliverOrder.TOTAL
, the command is only executed on the remote nodes.- Specified by:
invokeCommand
in interfaceRpcManager
-
invokeCommandOnAll
public <T> CompletionStage<T> invokeCommandOnAll(org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Description copied from interface:RpcManager
Invoke a command on all the nodes in the cluster and pass the responses to aResponseCollector
. The command is only executed on the local node if the delivery order isDeliverOrder.TOTAL
. The command is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAll
in interfaceRpcManager
-
invokeCommandStaggered
public <T> CompletionStage<T> invokeCommandStaggered(Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions)
Description copied from interface:RpcManager
Invoke a command on a collection of nodes and pass the responses to aResponseCollector
. The command is only sent immediately to the first target, and there is an implementation-dependent delay before sending the command to each target. There is no delay if the target responds or leaves the cluster. The remaining targets are skipped ifResponseCollector.addResponse(Address, Response)
returns a non-null
value. If one of the targets is the local node and the delivery order is notDeliverOrder.TOTAL
, the command is only executed on the remote nodes.- Specified by:
invokeCommandStaggered
in interfaceRpcManager
-
invokeCommands
public <T> CompletionStage<T> invokeCommands(Collection<Address> targets, Function<Address,org.infinispan.commands.ReplicableCommand> commandGenerator, ResponseCollector<T> collector, RpcOptions rpcOptions)
Description copied from interface:RpcManager
Invoke different commands on a collection of nodes and pass the responses to aResponseCollector
. If one of the targets is the local node and the delivery order is notDeliverOrder.TOTAL
, the command is only executed on the remote nodes.- Specified by:
invokeCommands
in interfaceRpcManager
-
blocking
public <T> T blocking(CompletionStage<T> request)
Description copied from interface:RpcManager
Block on a request and return its result.- Specified by:
blocking
in interfaceRpcManager
-
invokeRemotelyAsync
public CompletableFuture<Map<Address,Response>> invokeRemotelyAsync(Collection<Address> recipients, org.infinispan.commands.ReplicableCommand rpc, RpcOptions options)
Description copied from interface:RpcManager
Invokes a command on remote nodes.- Specified by:
invokeRemotelyAsync
in interfaceRpcManager
- Parameters:
recipients
- A list of nodes, ornull
to invoke the command on all the members of the clusterrpc
- The command to invokeoptions
- The invocation options- Returns:
- A future that, when completed, returns the responses from the remote nodes.
-
invokeRemotely
public Map<Address,Response> invokeRemotely(Collection<Address> recipients, org.infinispan.commands.ReplicableCommand rpc, RpcOptions options)
Description copied from interface:RpcManager
Invokes an RPC call on other caches in the cluster.- Specified by:
invokeRemotely
in interfaceRpcManager
- Parameters:
recipients
- a list of Addresses to invoke the call on. If this isnull
, the call is broadcast to the entire cluster.rpc
- command to execute remotely.options
- it configures the invocation. The same instance can be re-used sinceRpcManager
does not change it. Any change inRpcOptions
during a remote invocation can lead to unpredictable behavior.- Returns:
- a map of responses from each member contacted.
-
invokeRemotely
public Map<Address,Response> invokeRemotely(Map<Address,org.infinispan.commands.ReplicableCommand> rpcs, RpcOptions options)
- Specified by:
invokeRemotely
in interfaceRpcManager
-
sendTo
public void sendTo(Address destination, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:RpcManager
Asynchronously sends theReplicableCommand
to the destination using the specifiedDeliverOrder
.- Specified by:
sendTo
in interfaceRpcManager
- Parameters:
destination
- the destination'sAddress
.command
- theReplicableCommand
to send.deliverOrder
- theDeliverOrder
to use.
-
sendToMany
public void sendToMany(Collection<Address> destinations, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:RpcManager
Asynchronously sends theReplicableCommand
to the set of destination using the specifiedDeliverOrder
.- Specified by:
sendToMany
in interfaceRpcManager
- Parameters:
destinations
- the collection of destination'sAddress
. Ifnull
, it sends to all the members in the cluster.command
- theReplicableCommand
to send.deliverOrder
- theDeliverOrder
to use.
-
sendToAll
public void sendToAll(org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:RpcManager
Asynchronously sends theReplicableCommand
to the entire cluster.- Specified by:
sendToAll
in interfaceRpcManager
-
invokeXSite
public BackupResponse invokeXSite(Collection<XSiteBackup> sites, XSiteReplicateCommand command) throws Exception
Description copied from interface:RpcManager
Invokes theXSiteReplicateCommand
to one or more remote sites.- Specified by:
invokeXSite
in interfaceRpcManager
- Parameters:
sites
- The sites to where the command is sent.command
- TheXSiteReplicateCommand
to send.- Returns:
- The
BackupResponse
with the responses. - Throws:
Exception
-
getTransport
public Transport getTransport()
- Specified by:
getTransport
in interfaceRpcManager
- Returns:
- a reference to the underlying transport.
-
resetStatistics
public void resetStatistics()
Description copied from interface:JmxStatisticsExposer
Resets an interceptor's cache statistics- Specified by:
resetStatistics
in interfaceJmxStatisticsExposer
-
getReplicationCount
public long getReplicationCount()
-
getReplicationFailures
public long getReplicationFailures()
-
isStatisticsEnabled
public boolean isStatisticsEnabled()
-
getStatisticsEnabled
public boolean getStatisticsEnabled()
Description copied from interface:JmxStatisticsExposer
Returns whether an interceptor's statistics are being captured.- Specified by:
getStatisticsEnabled
in interfaceJmxStatisticsExposer
- Returns:
- true if statistics are captured
-
setStatisticsEnabled
@Deprecated public void setStatisticsEnabled(boolean statisticsEnabled)
Deprecated.We already have an attribute, we shouldn't have an operation for the same thing.Description copied from interface:JmxStatisticsExposer
Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.- Specified by:
setStatisticsEnabled
in interfaceJmxStatisticsExposer
- Parameters:
statisticsEnabled
- true if statistics should be captured
-
getSuccessRatio
public String getSuccessRatio()
-
getSuccessRatioFloatingPoint
public double getSuccessRatioFloatingPoint()
-
getAverageReplicationTime
public long getAverageReplicationTime()
-
getSitesView
public String getSitesView()
-
getAverageXSiteReplicationTime
public long getAverageXSiteReplicationTime()
-
getMinimumXSiteReplicationTime
public long getMinimumXSiteReplicationTime()
-
getMaximumXSiteReplicationTime
public long getMaximumXSiteReplicationTime()
-
getSyncXSiteCount
public long getSyncXSiteCount()
-
getAsyncXSiteCount
public long getAsyncXSiteCount()
-
getAverageAsyncXSiteReplicationTime
public long getAverageAsyncXSiteReplicationTime()
-
getMinimumAsyncXSiteReplicationTime
public long getMinimumAsyncXSiteReplicationTime()
-
getMaximumAsyncXSiteReplicationTime
public long getMaximumAsyncXSiteReplicationTime()
-
getAsyncXSiteAcksCount
public long getAsyncXSiteAcksCount()
-
setTransport
public void setTransport(Transport t)
-
getAddress
public Address getAddress()
Description copied from interface:RpcManager
Returns the address associated with this RpcManager or null if not part of the cluster.- Specified by:
getAddress
in interfaceRpcManager
-
getTopologyId
public int getTopologyId()
Description copied from interface:RpcManager
Returns the current topology id. As opposed to the viewId which is updated whenever the cluster changes, the topologyId is updated when a new cache instance is started or removed - this doesn't necessarily coincide with a node being added/removed to the cluster.- Specified by:
getTopologyId
in interfaceRpcManager
-
getSyncRpcOptions
public RpcOptions getSyncRpcOptions()
- Specified by:
getSyncRpcOptions
in interfaceRpcManager
- Returns:
- The default options for synchronous remote invocations.
-
getTotalSyncRpcOptions
public RpcOptions getTotalSyncRpcOptions()
- Specified by:
getTotalSyncRpcOptions
in interfaceRpcManager
- Returns:
- The default options for total order remote invocations.
-
getRpcOptionsBuilder
public RpcOptionsBuilder getRpcOptionsBuilder(ResponseMode responseMode)
Description copied from interface:RpcManager
Creates a newRpcOptionsBuilder
. TheRpcOptionsBuilder
is configured with theResponseMode
and withDeliverOrder.NONE
if theResponseMode
is synchronous otherwise, withDeliverOrder.PER_SENDER
if asynchronous.- Specified by:
getRpcOptionsBuilder
in interfaceRpcManager
- Parameters:
responseMode
- theResponseMode
.- Returns:
- a new
RpcOptionsBuilder
with the default options. The response and deliver mode are set as described.
-
getRpcOptionsBuilder
public RpcOptionsBuilder getRpcOptionsBuilder(ResponseMode responseMode, DeliverOrder deliverOrder)
Description copied from interface:RpcManager
Creates a newRpcOptionsBuilder
.- Specified by:
getRpcOptionsBuilder
in interfaceRpcManager
- Parameters:
responseMode
- theResponseMode
.deliverOrder
- theDeliverOrder
.- Returns:
- a new
RpcOptionsBuilder
with the default options and the response mode and deliver mode set by the parameters.
-
getDefaultRpcOptions
public RpcOptions getDefaultRpcOptions(boolean sync)
Description copied from interface:RpcManager
Creates a newRpcOptionsBuilder
. TheRpcOptionsBuilder
is configured withDeliverOrder.NONE
if the {@param sync} istrue
otherwise, withDeliverOrder.PER_SENDER
.- Specified by:
getDefaultRpcOptions
in interfaceRpcManager
- Parameters:
sync
-true
for Synchronous RpcOptions- Returns:
- the default Synchronous/Asynchronous RpcOptions
-
getDefaultRpcOptions
public RpcOptions getDefaultRpcOptions(boolean sync, DeliverOrder deliverOrder)
Description copied from interface:RpcManager
Creates a newRpcOptionsBuilder
.- Specified by:
getDefaultRpcOptions
in interfaceRpcManager
- Parameters:
sync
-true
for Synchronous RpcOptionsdeliverOrder
- theDeliverOrder
to use.- Returns:
- the default Synchronous/Asynchronous RpcOptions with the deliver order set by the parameter.
-
getMembers
public List<Address> getMembers()
Description copied from interface:RpcManager
Returns members of a cluster scoped to the cache owning this RpcManager. Note that this List is always a subset ofTransport.getMembers()
- Specified by:
getMembers
in interfaceRpcManager
- Returns:
- a list of cache scoped cluster members
-
-