Package org.infinispan.remoting.rpc
Class RpcManagerImpl
java.lang.Object
org.infinispan.remoting.rpc.RpcManagerImpl
- All Implemented Interfaces:
JmxStatisticsExposer,org.infinispan.metrics.impl.CustomMetricsSupplier,RpcManager
@MBean(objectName="RpcManager",
description="Manages all remote calls to remote cache instances in the cluster.")
public class RpcManagerImpl
extends Object
implements RpcManager, JmxStatisticsExposer, org.infinispan.metrics.impl.CustomMetricsSupplier
This component really is just a wrapper around a
Transport 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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Tblocking(CompletionStage<T> request) Block on a request and return its result.Returns the address associated with this RpcManager or null if not part of the cluster.longlonglonggetAverageXSiteReplicationTimeTo(String dstSite) getCustomMetrics(GlobalMetricsConfiguration configuration) longlonggetMaximumXSiteReplicationTimeTo(String dstSite) Returns members of a cluster scoped to the cache owning this RpcManager.longlonggetMinimumXSiteReplicationTimeTo(String dstSite) longlonglonggetNumberXSiteRequestsReceivedFrom(String srcSite) longgetNumberXSiteRequestsSentTo(String dstSite) longlongbooleanReturns whether an interceptor's statistics are being captured.doubleintReturns the current topology id.<T> CompletionStage<T>invokeCommand(Collection<Address> targets, 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, ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Invoke a command on a single node and pass the response to aResponseCollector.<T> CompletionStage<T>invokeCommandOnAll(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, 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, ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Invoke a command on a collection of nodes and pass the responses to aResponseCollector.invokeRemotelyAsync(Collection<Address> recipients, ReplicableCommand rpc, RpcOptions options) Invokes a command on remote nodes.<O> XSiteResponse<O>invokeXSite(org.infinispan.xsite.XSiteBackup backup, XSiteCacheRequest<O> command) Sends theXSiteCacheRequestto a remote site.booleanvoidResets an interceptor's cache statisticsvoidsendTo(Address destination, ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Asynchronously sends theReplicableCommandto the destination using the specifiedDeliverOrder.voidsendToAll(ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Asynchronously sends theReplicableCommandto the entire cluster.voidsendToMany(Collection<Address> destinations, ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Asynchronously sends theReplicableCommandto the set of destination using the specifiedDeliverOrder.voidsetStatisticsEnabled(boolean statisticsEnabled) Deprecated, for removal: This API element is subject to removal in a future version.We already have an attribute, we shouldn't have an operation for the same thing.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.remoting.rpc.RpcManager
getTotalSyncRpcOptions
-
Field Details
-
OBJECT_NAME
- See Also:
-
-
Constructor Details
-
RpcManagerImpl
public RpcManagerImpl()
-
-
Method Details
-
getCustomMetrics
-
getCommittedViewAsString
@ManagedAttribute(description="Retrieves the committed view.", displayName="Committed view", dataType=TRAIT) public String getCommittedViewAsString() -
getPendingViewAsString
@ManagedAttribute(description="Retrieves the pending view.", displayName="Pending view", dataType=TRAIT) public String getPendingViewAsString() -
invokeCommand
public <T> CompletionStage<T> invokeCommand(Address target, ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Description copied from interface:RpcManagerInvoke a command on a single node and pass the response to aResponseCollector. If the target is the local node, the command is never executed andResponseCollector.finish()is called directly.- Specified by:
invokeCommandin interfaceRpcManager
-
invokeCommand
public <T> CompletionStage<T> invokeCommand(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Description copied from interface:RpcManagerInvoke a command on a collection of node and pass the responses to aResponseCollector. If one of the targets is the local node, it is ignored. The command is only executed on the remote nodes.- Specified by:
invokeCommandin interfaceRpcManager
-
invokeCommandOnAll
public <T> CompletionStage<T> invokeCommandOnAll(ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Description copied from interface:RpcManagerInvoke a command on all the nodes in the cluster and pass the responses to aResponseCollector. The command is not executed locally and it is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAllin interfaceRpcManager
-
invokeCommandStaggered
public <T> CompletionStage<T> invokeCommandStaggered(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, RpcOptions rpcOptions) Description copied from interface:RpcManagerInvoke 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-nullvalue. The command is only executed on the remote nodes.- Specified by:
invokeCommandStaggeredin interfaceRpcManager
-
invokeCommands
public <T> CompletionStage<T> invokeCommands(Collection<Address> targets, Function<Address, ReplicableCommand> commandGenerator, ResponseCollector<T> collector, RpcOptions rpcOptions) Description copied from interface:RpcManagerInvoke different commands on a collection of nodes and pass the responses to aResponseCollector. The command is only executed on the remote nodes and it is not executed in the local node even if it is in thetargets.- Specified by:
invokeCommandsin interfaceRpcManager
-
blocking
Description copied from interface:RpcManagerBlock on a request and return its result.- Specified by:
blockingin interfaceRpcManager
-
invokeRemotelyAsync
public CompletableFuture<Map<Address,Response>> invokeRemotelyAsync(Collection<Address> recipients, ReplicableCommand rpc, RpcOptions options) Description copied from interface:RpcManagerInvokes a command on remote nodes.- Specified by:
invokeRemotelyAsyncin interfaceRpcManager- Parameters:
recipients- A list of nodes, ornullto 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.
-
sendTo
public void sendTo(Address destination, ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Description copied from interface:RpcManagerAsynchronously sends theReplicableCommandto the destination using the specifiedDeliverOrder.- Specified by:
sendToin interfaceRpcManager- Parameters:
destination- the destination'sAddress.command- theReplicableCommandto send.deliverOrder- theDeliverOrderto use.
-
sendToMany
public void sendToMany(Collection<Address> destinations, ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Description copied from interface:RpcManagerAsynchronously sends theReplicableCommandto the set of destination using the specifiedDeliverOrder.- Specified by:
sendToManyin interfaceRpcManager- Parameters:
destinations- the collection of destination'sAddress. Ifnull, it sends to all the members in the cluster.command- theReplicableCommandto send.deliverOrder- theDeliverOrderto use.
-
sendToAll
public void sendToAll(ReplicableCommand command, org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder) Description copied from interface:RpcManagerAsynchronously sends theReplicableCommandto the entire cluster.- Specified by:
sendToAllin interfaceRpcManager
-
invokeXSite
public <O> XSiteResponse<O> invokeXSite(org.infinispan.xsite.XSiteBackup backup, XSiteCacheRequest<O> command) Description copied from interface:RpcManagerSends theXSiteCacheRequestto a remote site.If
XSiteBackup.isSync()returnsfalse, theXSiteResponseis only completed when the an ACK from the remote site is received. The invoker needs to make sure not to wait for theXSiteResponse.- Specified by:
invokeXSitein interfaceRpcManager- Parameters:
backup- The site to where the command is sent.command- The command to send.- Returns:
- A
XSiteResponsethat is completed when the request is completed.
-
getTransport
- Specified by:
getTransportin interfaceRpcManager- Returns:
- a reference to the underlying transport.
-
resetStatistics
@ManagedOperation(description="Resets statistics gathered by this component", displayName="Reset statistics") public void resetStatistics()Description copied from interface:JmxStatisticsExposerResets an interceptor's cache statistics- Specified by:
resetStatisticsin interfaceJmxStatisticsExposer
-
getReplicationCount
@ManagedAttribute(description="Number of successful replications", displayName="Number of successful replications", measurementType=TRENDSUP) public long getReplicationCount() -
getReplicationFailures
@ManagedAttribute(description="Number of failed replications", displayName="Number of failed replications", measurementType=TRENDSUP) public long getReplicationFailures() -
isStatisticsEnabled
@ManagedAttribute(description="Enables or disables the gathering of statistics by this component", displayName="Statistics enabled", dataType=TRAIT, writable=true) public boolean isStatisticsEnabled() -
getStatisticsEnabled
public boolean getStatisticsEnabled()Description copied from interface:JmxStatisticsExposerReturns whether an interceptor's statistics are being captured.- Specified by:
getStatisticsEnabledin interfaceJmxStatisticsExposer- Returns:
- true if statistics are captured
-
setStatisticsEnabled
@Deprecated(forRemoval=true) @ManagedOperation(displayName="Enable/disable statistics. Deprecated, use the statisticsEnabled attribute instead.") public void setStatisticsEnabled(@Parameter(name="enabled",description="Whether statistics should be enabled or disabled (true/false)") boolean statisticsEnabled) Deprecated, for removal: This API element is subject to removal in a future version.We already have an attribute, we shouldn't have an operation for the same thing.Description copied from interface:JmxStatisticsExposerEnables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.- Specified by:
setStatisticsEnabledin interfaceJmxStatisticsExposer- Parameters:
statisticsEnabled- true if statistics should be captured
-
getSuccessRatio
@ManagedAttribute(description="Successful replications as a ratio of total replications", displayName="Successful replications ratio") public String getSuccessRatio() -
getSuccessRatioFloatingPoint
@ManagedAttribute(description="Successful replications as a ratio of total replications in numeric double format", displayName="Successful replication ratio", units=PERCENTAGE) public double getSuccessRatioFloatingPoint() -
getAverageReplicationTime
@ManagedAttribute(description="The average time spent in the transport layer, in milliseconds", displayName="Average time spent in the transport layer", units=MILLISECONDS) public long getAverageReplicationTime() -
getSitesView
@ManagedAttribute(description="Retrieves the x-site view.", displayName="Cross site (x-site) view", dataType=TRAIT) public String getSitesView() -
getAverageXSiteReplicationTime
@ManagedAttribute(description="Returns the average replication time, in milliseconds, for a cross-site replication request", displayName="Average Cross-Site replication time", units=MILLISECONDS) public long getAverageXSiteReplicationTime() -
getAverageXSiteReplicationTimeTo
@ManagedOperation(description="Returns the average replication time, in milliseconds, for cross-site request sent to the remote site.", displayName="Average Cross-Site replication time to Site", name="AverageXSiteReplicationTimeTo") public long getAverageXSiteReplicationTimeTo(@Parameter(name="dstSite",description="Destination site name") String dstSite) -
getMinimumXSiteReplicationTime
@ManagedAttribute(description="Returns the minimum replication time, in milliseconds, for a cross-site replication request", displayName="Minimum Cross-Site replication time", units=MILLISECONDS, measurementType=TRENDSDOWN) public long getMinimumXSiteReplicationTime() -
getMinimumXSiteReplicationTimeTo
@ManagedOperation(description="Returns the minimum replication time, in milliseconds, for cross-site request sent to the remote site.", displayName="Minimum Cross-Site replication time to Site", name="MinimumXSiteReplicationTimeTo") public long getMinimumXSiteReplicationTimeTo(@Parameter(name="dstSite",description="Destination site name") String dstSite) -
getMaximumXSiteReplicationTime
@ManagedAttribute(description="Returns the maximum replication time, in milliseconds, for a cross-site replication request", displayName="Maximum Cross-Site replication time", units=MILLISECONDS, measurementType=TRENDSUP) public long getMaximumXSiteReplicationTime() -
getMaximumXSiteReplicationTimeTo
@ManagedOperation(description="Returns the maximum replication time, in milliseconds, for cross-site request sent to the remote site.", displayName="Maximum Cross-Site replication time to Site", name="MaximumXSiteReplicationTimeTo") public long getMaximumXSiteReplicationTimeTo(@Parameter(name="dstSite",description="Destination site name") String dstSite) -
getNumberXSiteRequests
@ManagedAttribute(description="Returns the number of sync cross-site requests", displayName="Cross-Site replication requests", measurementType=TRENDSUP) public long getNumberXSiteRequests() -
getNumberXSiteRequestsSentTo
@ManagedOperation(description="Returns the number of cross-site requests sent to the remote site.", displayName="Number of Cross-Site request sent to site", name="NumberXSiteRequestsSentTo") public long getNumberXSiteRequestsSentTo(@Parameter(name="dstSite",description="Destination site name") String dstSite) -
getNumberXSiteRequestsReceived
@ManagedAttribute(description="Returns the number of cross-site requests received from all nodes", displayName="Number of Cross-Site Requests Received from all sites", measurementType=TRENDSUP) public long getNumberXSiteRequestsReceived() -
getNumberXSiteRequestsReceivedFrom
@ManagedOperation(description="Returns the number of cross-site requests received from the remote site.", displayName="Number of Cross-Site request received from site", name="NumberXSiteRequestsReceivedFrom") public long getNumberXSiteRequestsReceivedFrom(@Parameter(name="srcSite",description="Originator site name") String srcSite) -
setTransport
-
getAddress
Description copied from interface:RpcManagerReturns the address associated with this RpcManager or null if not part of the cluster.- Specified by:
getAddressin interfaceRpcManager
-
getTopologyId
public int getTopologyId()Description copied from interface:RpcManagerReturns 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:
getTopologyIdin interfaceRpcManager
-
getSyncRpcOptions
- Specified by:
getSyncRpcOptionsin interfaceRpcManager- Returns:
- The default options for synchronous remote invocations.
-
getMembers
Description copied from interface:RpcManagerReturns members of a cluster scoped to the cache owning this RpcManager. Note that this List is always a subset ofTransport.getMembers()- Specified by:
getMembersin interfaceRpcManager- Returns:
- a list of cache scoped cluster members
-