Class JGroupsTransport
- java.lang.Object
-
- org.infinispan.remoting.transport.jgroups.JGroupsTransport
-
public class JGroupsTransport extends java.lang.Object implements Transport
An encapsulation of a JGroups transport. JGroups transports can be configured using a variety of methods, usually by passing in one of the following properties:- configurationString - a JGroups configuration String
- configurationXml - JGroups configuration XML as a String
- configurationFile - String pointing to a JGroups XML configuration file
- channelLookup - Fully qualified class name of a
JGroupsChannelLookupinstance
TransportConfigurationBuilder.withProperties(Properties)or in the Infinispan XML configuration file.- Since:
- 4.0
- Author:
- Manik Surtani, Galder ZamarreƱo
-
-
Field Summary
Fields Modifier and Type Field Description protected Addressaddressprotected org.jgroups.JChannelchannelstatic java.lang.StringCHANNEL_CONFIGURATORstatic java.lang.StringCHANNEL_LOOKUPprotected booleancloseChannelprotected ClusterViewclusterViewprotected GlobalConfigurationconfigurationstatic java.lang.StringCONFIGURATION_FILEstatic java.lang.StringCONFIGURATION_STRINGstatic java.lang.StringCONFIGURATION_XMLprotected booleanconnectChannelprotected static java.lang.StringDEFAULT_JGROUPS_CONFIGURATION_FILEprotected booleandisconnectChannelprotected InboundInvocationHandlerinvocationHandlerprotected CacheManagerJmxRegistrationjmxRegistrationstatic org.infinispan.util.logging.Loglogprotected StreamingMarshallermarshallerprotected CacheManagerNotifiernotifierprotected AddressphysicalAddressprotected TypedPropertiespropsprotected java.util.concurrent.ExecutorServiceremoteExecutorstatic shortREPLY_FLAGSprotected java.util.concurrent.ScheduledExecutorServicetimeoutExecutorprotected TimeServicetimeService
-
Constructor Summary
Constructors Constructor Description JGroupsTransport()JGroupsTransport(org.jgroups.JChannel channel)This form is used when the transport is created by an external source and passed in to the GlobalConfiguration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BackupResponsebackupRemotely(java.util.Collection<XSiteBackup> backups, XSiteReplicateCommand command)XSiteResponsebackupRemotely(XSiteBackup backup, XSiteReplicateCommand rpcCommand)Sends a cross-site request to a remote site.voidcheckTotalOrderSupported()check if the transport has configured with total order deliver properties (has the sequencer in JGroups protocol stack.AddressgetAddress()Retrieves the current cache instance's network addressorg.jgroups.JChannelgetChannel()AddressgetCoordinator()org.infinispan.util.logging.LoggetLog()java.util.List<Address>getMembers()Returns a list of members in the current cluster view.java.util.List<Address>getMembersPhysicalAddresses()Returns physical addresses of members in the current cluster view.java.util.List<Address>getPhysicalAddresses()Retrieves the current cache instance's physical network addresses.java.util.Set<java.lang.String>getSitesView()Get the view of interconnected sites.intgetViewId()protected voidinitChannel()<T> java.util.concurrent.CompletionStage<T>invokeCommand(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Invoke a command on a collection of node and pass the responses to aResponseCollector.<T> java.util.concurrent.CompletionStage<T>invokeCommand(Address target, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Invoke a command on a single node and pass the response to aResponseCollector.<T> java.util.concurrent.CompletionStage<T>invokeCommandOnAll(java.util.Collection<Address> requiredTargets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Invoke a command on all the nodes in the cluster and pass the responses to aResponseCollector.<T> java.util.concurrent.CompletionStage<T>invokeCommandOnAll(org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Invoke a command on all the nodes in the cluster and pass the responses to aResponseCollector.<T> java.util.concurrent.CompletionStage<T>invokeCommands(java.util.Collection<Address> targets, java.util.function.Function<Address,org.infinispan.commands.ReplicableCommand> commandGenerator, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit timeUnit)Invoke different commands on a collection of nodes and pass the responses to aResponseCollector.<T> java.util.concurrent.CompletionStage<T>invokeCommandStaggered(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Invoke a command on a collection of nodes and pass the responses to aResponseCollector.java.util.Map<Address,Response>invokeRemotely(java.util.Map<Address,org.infinispan.commands.ReplicableCommand> commands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)Deprecated.java.util.concurrent.CompletableFuture<java.util.Map<Address,Response>>invokeRemotelyAsync(java.util.Collection<Address> recipients, org.infinispan.commands.ReplicableCommand command, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)booleanisCoordinator()booleanisMulticastCapable()Tests whether the transport supports true multicastprotected voidreceiveClusterView(org.jgroups.View newView)voidsendTo(Address destination, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)Asynchronously sends theReplicableCommandto the destination using the specifiedDeliverOrder.voidsendToAll(org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)Asynchronously sends theReplicableCommandto the entire cluster.voidsendToMany(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)Asynchronously sends theReplicableCommandto the set of destination using the specifiedDeliverOrder.voidstart()Invoked on component startprotected voidstartJGroupsChannelIfNeeded()When overwriting this method, it allows third-party libraries to create a new behavior like: AfterJChannelhas been created and before it is connected.voidstop()Invoked on component stopvoidwaitForView(int viewId)java.util.concurrent.CompletableFuture<java.lang.Void>withView(int expectedViewId)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.remoting.transport.Transport
invokeCommands, invokeRemotely, invokeRemotely
-
-
-
-
Field Detail
-
CONFIGURATION_STRING
public static final java.lang.String CONFIGURATION_STRING
- See Also:
- Constant Field Values
-
CONFIGURATION_XML
public static final java.lang.String CONFIGURATION_XML
- See Also:
- Constant Field Values
-
CONFIGURATION_FILE
public static final java.lang.String CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
CHANNEL_LOOKUP
public static final java.lang.String CHANNEL_LOOKUP
- See Also:
- Constant Field Values
-
CHANNEL_CONFIGURATOR
public static final java.lang.String CHANNEL_CONFIGURATOR
- See Also:
- Constant Field Values
-
REPLY_FLAGS
public static final short REPLY_FLAGS
-
DEFAULT_JGROUPS_CONFIGURATION_FILE
protected static final java.lang.String DEFAULT_JGROUPS_CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
log
public static final org.infinispan.util.logging.Log log
-
configuration
protected GlobalConfiguration configuration
-
marshaller
protected StreamingMarshaller marshaller
-
notifier
protected CacheManagerNotifier notifier
-
timeService
protected TimeService timeService
-
invocationHandler
protected InboundInvocationHandler invocationHandler
-
timeoutExecutor
protected java.util.concurrent.ScheduledExecutorService timeoutExecutor
-
remoteExecutor
protected java.util.concurrent.ExecutorService remoteExecutor
-
jmxRegistration
protected CacheManagerJmxRegistration jmxRegistration
-
connectChannel
protected boolean connectChannel
-
disconnectChannel
protected boolean disconnectChannel
-
closeChannel
protected boolean closeChannel
-
props
protected TypedProperties props
-
channel
protected org.jgroups.JChannel channel
-
address
protected Address address
-
physicalAddress
protected Address physicalAddress
-
clusterView
protected volatile ClusterView clusterView
-
-
Constructor Detail
-
JGroupsTransport
public JGroupsTransport(org.jgroups.JChannel channel)
This form is used when the transport is created by an external source and passed in to the GlobalConfiguration.- Parameters:
channel- created and running channel to use
-
JGroupsTransport
public JGroupsTransport()
-
-
Method Detail
-
invokeRemotelyAsync
public java.util.concurrent.CompletableFuture<java.util.Map<Address,Response>> invokeRemotelyAsync(java.util.Collection<Address> recipients, org.infinispan.commands.ReplicableCommand command, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)
- Specified by:
invokeRemotelyAsyncin interfaceTransport
-
sendTo
public void sendTo(Address destination, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:TransportAsynchronously sends theReplicableCommandto the destination using the specifiedDeliverOrder.- Specified by:
sendToin interfaceTransport- Parameters:
destination- the destination'sAddress.command- theReplicableCommandto send.deliverOrder- theDeliverOrderto use.
-
sendToMany
public void sendToMany(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:TransportAsynchronously sends theReplicableCommandto the set of destination using the specifiedDeliverOrder.- Specified by:
sendToManyin interfaceTransport- Parameters:
targets- the collection of destination'sAddress. Ifnull, it sends to all the members in the cluster.command- theReplicableCommandto send.deliverOrder- theDeliverOrderto use.
-
invokeRemotely
@Deprecated public java.util.Map<Address,Response> invokeRemotely(java.util.Map<Address,org.infinispan.commands.ReplicableCommand> commands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast) throws java.lang.Exception
Deprecated.- Specified by:
invokeRemotelyin interfaceTransport- Throws:
java.lang.Exception
-
backupRemotely
public BackupResponse backupRemotely(java.util.Collection<XSiteBackup> backups, XSiteReplicateCommand command)
- Specified by:
backupRemotelyin interfaceTransport
-
backupRemotely
public XSiteResponse backupRemotely(XSiteBackup backup, XSiteReplicateCommand rpcCommand)
Description copied from interface:TransportSends a cross-site request to a remote site.Currently, no reply values are supported. Or the request completes successfully or it throws an
Exception.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:
backupRemotelyin interfaceTransport- Parameters:
backup- The remote site.rpcCommand- The command to send.- Returns:
- A
XSiteResponsethat is completed when the request is completed.
-
isCoordinator
public boolean isCoordinator()
- Specified by:
isCoordinatorin interfaceTransport- Returns:
- true if the current Channel is the coordinator of the cluster.
-
getCoordinator
public Address getCoordinator()
- Specified by:
getCoordinatorin interfaceTransport- Returns:
- the Address of the current coordinator.
-
getAddress
public Address getAddress()
Description copied from interface:TransportRetrieves the current cache instance's network address- Specified by:
getAddressin interfaceTransport- Returns:
- an Address
-
getPhysicalAddresses
public java.util.List<Address> getPhysicalAddresses()
Description copied from interface:TransportRetrieves the current cache instance's physical network addresses. Some implementations might differentiate between logical and physical addresses in which case, this method allows clients to query the physical ones associated with the logical address. Implementations where logical and physical address are the same will simply return a single entry List that contains the same Address asTransport.getAddress().- Specified by:
getPhysicalAddressesin interfaceTransport- Returns:
- an List of Address
-
getMembers
public java.util.List<Address> getMembers()
Description copied from interface:TransportReturns a list of members in the current cluster view.- Specified by:
getMembersin interfaceTransport- Returns:
- a list of members. Typically, this would be defensively copied.
-
getMembersPhysicalAddresses
public java.util.List<Address> getMembersPhysicalAddresses()
Description copied from interface:TransportReturns physical addresses of members in the current cluster view.- Specified by:
getMembersPhysicalAddressesin interfaceTransport- Returns:
- a list of physical addresses
-
isMulticastCapable
public boolean isMulticastCapable()
Description copied from interface:TransportTests whether the transport supports true multicast- Specified by:
isMulticastCapablein interfaceTransport- Returns:
- true if the transport supports true multicast
-
start
public void start()
Description copied from interface:LifecycleInvoked on component start
-
initChannel
protected void initChannel()
-
startJGroupsChannelIfNeeded
protected void startJGroupsChannelIfNeeded()
When overwriting this method, it allows third-party libraries to create a new behavior like: AfterJChannelhas been created and before it is connected.
-
receiveClusterView
protected void receiveClusterView(org.jgroups.View newView)
-
stop
public void stop()
Description copied from interface:LifecycleInvoked on component stop
-
withView
public java.util.concurrent.CompletableFuture<java.lang.Void> withView(int expectedViewId)
-
waitForView
public void waitForView(int viewId) throws java.lang.InterruptedException- Specified by:
waitForViewin interfaceTransport- Throws:
java.lang.InterruptedException
-
checkTotalOrderSupported
public final void checkTotalOrderSupported()
Description copied from interface:Transportcheck if the transport has configured with total order deliver properties (has the sequencer in JGroups protocol stack.- Specified by:
checkTotalOrderSupportedin interfaceTransport
-
getSitesView
public java.util.Set<java.lang.String> getSitesView()
Description copied from interface:TransportGet the view of interconnected sites. If no cross site replication has been configured, this method returns null. Inspecting the site view can be useful to see if the different sites have managed to join each other, which is pre-requisite to get cross replication working.- Specified by:
getSitesViewin interfaceTransport- Returns:
- set containing the connected sites, or null if no cross site replication has been enabled.
-
invokeCommand
public <T> java.util.concurrent.CompletionStage<T> invokeCommand(Address target, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:TransportInvoke a command on a single node and pass the response to aResponseCollector.If the target is the local node and the delivery order is not
DeliverOrder.TOTAL, the command is never executed, andResponseCollector.finish()is called directly.- Specified by:
invokeCommandin interfaceTransport
-
invokeCommand
public <T> java.util.concurrent.CompletionStage<T> invokeCommand(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:TransportInvoke 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 not
DeliverOrder.TOTAL, the command is only executed on the remote nodes.- Specified by:
invokeCommandin interfaceTransport
-
invokeCommandOnAll
public <T> java.util.concurrent.CompletionStage<T> invokeCommandOnAll(org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)Description copied from interface:TransportInvoke 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 is
DeliverOrder.TOTAL. The command is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAllin interfaceTransport
-
invokeCommandOnAll
public <T> java.util.concurrent.CompletionStage<T> invokeCommandOnAll(java.util.Collection<Address> requiredTargets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:TransportInvoke 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 is
DeliverOrder.TOTAL. The command is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAllin interfaceTransport
-
invokeCommandStaggered
public <T> java.util.concurrent.CompletionStage<T> invokeCommandStaggered(java.util.Collection<Address> targets, org.infinispan.commands.ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:TransportInvoke 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 if
ResponseCollector.addResponse(Address, Response)returns a non-nullvalue.If one of the targets is the local node and the delivery order is not
DeliverOrder.TOTAL, the command is only executed on the remote nodes.- Specified by:
invokeCommandStaggeredin interfaceTransport
-
invokeCommands
public <T> java.util.concurrent.CompletionStage<T> invokeCommands(java.util.Collection<Address> targets, java.util.function.Function<Address,org.infinispan.commands.ReplicableCommand> commandGenerator, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, java.util.concurrent.TimeUnit timeUnit)
Description copied from interface:TransportInvoke 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 not
DeliverOrder.TOTAL, the command is only executed on the remote nodes.- Specified by:
invokeCommandsin interfaceTransport
-
sendToAll
public void sendToAll(org.infinispan.commands.ReplicableCommand command, DeliverOrder deliverOrder)Description copied from interface:TransportAsynchronously sends theReplicableCommandto the entire cluster.
-
getChannel
public org.jgroups.JChannel getChannel()
-
-