Class JGroupsTransport
- java.lang.Object
-
- org.infinispan.remoting.transport.jgroups.JGroupsTransport
-
- All Implemented Interfaces:
org.infinispan.commons.api.Lifecycle
,Transport
public class JGroupsTransport extends 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
JGroupsChannelLookup
instance
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 Address
address
protected ActionSequencer
backupSequencer
protected org.jgroups.JChannel
channel
static String
CHANNEL_LOOKUP
protected boolean
closeChannel
protected ClusterView
clusterView
protected GlobalConfiguration
configuration
static String
CONFIGURATION_FILE
static String
CONFIGURATION_STRING
static String
CONFIGURATION_XML
protected boolean
connectChannel
protected static String
DEFAULT_JGROUPS_CONFIGURATION_FILE
protected boolean
disconnectChannel
protected InboundInvocationHandler
invocationHandler
protected org.infinispan.commons.marshall.StreamingMarshaller
marshaller
protected CacheManagerNotifier
notifier
protected Address
physicalAddress
protected org.infinispan.commons.util.TypedProperties
props
protected ExecutorService
remoteExecutor
static short
REPLY_FLAGS
protected ScheduledExecutorService
timeoutExecutor
protected org.infinispan.commons.time.TimeService
timeService
-
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 BackupResponse
backupRemotely(Collection<XSiteBackup> backups, XSiteReplicateCommand command)
void
checkTotalOrderSupported()
check if the transport has configured with total order deliver properties (has the sequencer in JGroups protocol stack.Address
getAddress()
Retrieves the current cache instance's network addressorg.jgroups.JChannel
getChannel()
Address
getCoordinator()
Log
getLog()
List<Address>
getMembers()
Returns a list of members in the current cluster view.List<Address>
getPhysicalAddresses()
Retrieves the current cache instance's physical network addresses.Set<String>
getSitesView()
Get the view of interconnected sites.int
getViewId()
protected void
initChannel()
<T> CompletionStage<T>
invokeCommand(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
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, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Invoke a command on a single node and pass the response to aResponseCollector
.<T> CompletionStage<T>
invokeCommandOnAll(Collection<Address> requiredTargets, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Invoke a command on all the nodes in the cluster and pass the responses to aResponseCollector
.<T> CompletionStage<T>
invokeCommandOnAll(ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
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, DeliverOrder deliverOrder, long timeout, TimeUnit timeUnit)
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, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Invoke a command on a collection of nodes and pass the responses to aResponseCollector
.Map<Address,Response>
invokeRemotely(Map<Address,ReplicableCommand> commands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)
Deprecated.CompletableFuture<Map<Address,Response>>
invokeRemotelyAsync(Collection<Address> recipients, ReplicableCommand command, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)
boolean
isCoordinator()
boolean
isMulticastCapable()
Tests whether the transport supports true multicastprotected void
receiveClusterView(org.jgroups.View newView)
void
sendTo(Address destination, ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the destination using the specifiedDeliverOrder
.void
sendToAll(ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the entire cluster.void
sendToMany(Collection<Address> targets, ReplicableCommand command, DeliverOrder deliverOrder)
Asynchronously sends theReplicableCommand
to the set of destination using the specifiedDeliverOrder
.void
start()
Invoked on component startvoid
stop()
Invoked on component stopvoid
waitForView(int viewId)
CompletableFuture<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 String CONFIGURATION_STRING
- See Also:
- Constant Field Values
-
CONFIGURATION_XML
public static final String CONFIGURATION_XML
- See Also:
- Constant Field Values
-
CONFIGURATION_FILE
public static final String CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
CHANNEL_LOOKUP
public static final String CHANNEL_LOOKUP
- See Also:
- Constant Field Values
-
REPLY_FLAGS
public static final short REPLY_FLAGS
-
DEFAULT_JGROUPS_CONFIGURATION_FILE
protected static final String DEFAULT_JGROUPS_CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
configuration
protected GlobalConfiguration configuration
-
marshaller
protected org.infinispan.commons.marshall.StreamingMarshaller marshaller
-
notifier
protected CacheManagerNotifier notifier
-
timeService
protected org.infinispan.commons.time.TimeService timeService
-
invocationHandler
protected InboundInvocationHandler invocationHandler
-
timeoutExecutor
protected ScheduledExecutorService timeoutExecutor
-
remoteExecutor
protected ExecutorService remoteExecutor
-
backupSequencer
protected ActionSequencer backupSequencer
-
connectChannel
protected boolean connectChannel
-
disconnectChannel
protected boolean disconnectChannel
-
closeChannel
protected boolean closeChannel
-
props
protected org.infinispan.commons.util.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 CompletableFuture<Map<Address,Response>> invokeRemotelyAsync(Collection<Address> recipients, ReplicableCommand command, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast)
- Specified by:
invokeRemotelyAsync
in interfaceTransport
-
sendTo
public void sendTo(Address destination, ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:Transport
Asynchronously sends theReplicableCommand
to the destination using the specifiedDeliverOrder
.- Specified by:
sendTo
in interfaceTransport
- Parameters:
destination
- the destination'sAddress
.command
- theReplicableCommand
to send.deliverOrder
- theDeliverOrder
to use.
-
sendToMany
public void sendToMany(Collection<Address> targets, ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:Transport
Asynchronously sends theReplicableCommand
to the set of destination using the specifiedDeliverOrder
.- Specified by:
sendToMany
in interfaceTransport
- Parameters:
targets
- the collection of destination'sAddress
. Ifnull
, it sends to all the members in the cluster.command
- theReplicableCommand
to send.deliverOrder
- theDeliverOrder
to use.
-
invokeRemotely
@Deprecated public Map<Address,Response> invokeRemotely(Map<Address,ReplicableCommand> commands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast) throws Exception
Deprecated.- Specified by:
invokeRemotely
in interfaceTransport
- Throws:
Exception
-
backupRemotely
public BackupResponse backupRemotely(Collection<XSiteBackup> backups, XSiteReplicateCommand command)
- Specified by:
backupRemotely
in interfaceTransport
-
isCoordinator
public boolean isCoordinator()
- Specified by:
isCoordinator
in interfaceTransport
- Returns:
- true if the current Channel is the coordinator of the cluster.
-
getCoordinator
public Address getCoordinator()
- Specified by:
getCoordinator
in interfaceTransport
- Returns:
- the Address of the current coordinator.
-
getAddress
public Address getAddress()
Description copied from interface:Transport
Retrieves the current cache instance's network address- Specified by:
getAddress
in interfaceTransport
- Returns:
- an Address
-
getPhysicalAddresses
public List<Address> getPhysicalAddresses()
Description copied from interface:Transport
Retrieves 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:
getPhysicalAddresses
in interfaceTransport
- Returns:
- an List of Address
-
getMembers
public List<Address> getMembers()
Description copied from interface:Transport
Returns a list of members in the current cluster view.- Specified by:
getMembers
in interfaceTransport
- Returns:
- a list of members. Typically, this would be defensively copied.
-
isMulticastCapable
public boolean isMulticastCapable()
Description copied from interface:Transport
Tests whether the transport supports true multicast- Specified by:
isMulticastCapable
in interfaceTransport
- Returns:
- true if the transport supports true multicast
-
start
public void start()
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component start
-
initChannel
protected void initChannel()
-
receiveClusterView
protected void receiveClusterView(org.jgroups.View newView)
-
stop
public void stop()
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component stop
-
withView
public CompletableFuture<Void> withView(int expectedViewId)
- Specified by:
withView
in interfaceTransport
- Returns:
- A
CompletableFuture
that completes when the transport has installed the expected view.
-
waitForView
public void waitForView(int viewId) throws InterruptedException
- Specified by:
waitForView
in interfaceTransport
- Throws:
InterruptedException
-
checkTotalOrderSupported
public final void checkTotalOrderSupported()
Description copied from interface:Transport
check if the transport has configured with total order deliver properties (has the sequencer in JGroups protocol stack.- Specified by:
checkTotalOrderSupported
in interfaceTransport
-
getSitesView
public Set<String> getSitesView()
Description copied from interface:Transport
Get 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:
getSitesView
in interfaceTransport
- Returns:
- set containing the connected sites, or null if no cross site replication has been enabled.
-
invokeCommand
public <T> CompletionStage<T> invokeCommand(Address target, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Description copied from interface:Transport
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 not
DeliverOrder.TOTAL
, the command is never executed, andResponseCollector.finish()
is called directly.- Specified by:
invokeCommand
in interfaceTransport
-
invokeCommand
public <T> CompletionStage<T> invokeCommand(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Description copied from interface:Transport
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 not
DeliverOrder.TOTAL
, the command is only executed on the remote nodes.- Specified by:
invokeCommand
in interfaceTransport
-
invokeCommandOnAll
public <T> CompletionStage<T> invokeCommandOnAll(ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Description copied from interface:Transport
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 is
DeliverOrder.TOTAL
. The command is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAll
in interfaceTransport
-
invokeCommandOnAll
public <T> CompletionStage<T> invokeCommandOnAll(Collection<Address> requiredTargets, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Description copied from interface:Transport
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 is
DeliverOrder.TOTAL
. The command is not sent across RELAY2 bridges to remote sites.- Specified by:
invokeCommandOnAll
in interfaceTransport
-
invokeCommandStaggered
public <T> CompletionStage<T> invokeCommandStaggered(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit unit)
Description copied from interface:Transport
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 if
ResponseCollector.addResponse(Address, Response)
returns a non-null
value.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:
invokeCommandStaggered
in interfaceTransport
-
invokeCommands
public <T> CompletionStage<T> invokeCommands(Collection<Address> targets, Function<Address,ReplicableCommand> commandGenerator, ResponseCollector<T> collector, DeliverOrder deliverOrder, long timeout, TimeUnit timeUnit)
Description copied from interface:Transport
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 not
DeliverOrder.TOTAL
, the command is only executed on the remote nodes.- Specified by:
invokeCommands
in interfaceTransport
-
sendToAll
public void sendToAll(ReplicableCommand command, DeliverOrder deliverOrder)
Description copied from interface:Transport
Asynchronously sends theReplicableCommand
to the entire cluster.
-
getChannel
public org.jgroups.JChannel getChannel()
-
-