Class JGroupsTransport

  • All Implemented Interfaces:
    Lifecycle, Transport, org.jgroups.ChannelListener

    public class JGroupsTransport
    extends Object
    implements Transport, org.jgroups.ChannelListener
    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
    These are normally passed in as Properties in TransportConfigurationBuilder.withProperties(Properties) or in the Infinispan XML configuration file.
    Since:
    4.0
    Author:
    Manik Surtani, Galder ZamarreƱo
    • Field Detail

      • REQUEST_FLAGS_UNORDERED

        public static final short REQUEST_FLAGS_UNORDERED
      • REQUEST_FLAGS_PER_SENDER

        public static final short REQUEST_FLAGS_PER_SENDER
      • REPLY_FLAGS

        public static final short REPLY_FLAGS
      • log

        public static final org.infinispan.util.logging.Log log
      • invocationHandler

        protected org.infinispan.remoting.inboundhandler.InboundInvocationHandler invocationHandler
      • globalXSiteAdminOperations

        protected org.infinispan.xsite.GlobalXSiteAdminOperations globalXSiteAdminOperations
      • metricsCollector

        protected ComponentRef<org.infinispan.metrics.impl.MetricsCollector> metricsCollector
      • connectChannel

        protected boolean connectChannel
      • disconnectChannel

        protected boolean disconnectChannel
      • closeChannel

        protected boolean closeChannel
      • 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

      • findFork

        public static org.jgroups.protocols.FORK findFork​(org.jgroups.JChannel channel)
      • sendTo

        public void sendTo​(Address destination,
                           ReplicableCommand command,
                           org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder)
        Description copied from interface: Transport
        Asynchronously sends the ReplicableCommand to the destination using the specified DeliverOrder.
        Specified by:
        sendTo in interface Transport
        Parameters:
        destination - the destination's Address.
        command - the ReplicableCommand to send.
        deliverOrder - the DeliverOrder to use.
      • sendToMany

        public void sendToMany​(Collection<Address> targets,
                               ReplicableCommand command,
                               org.infinispan.remoting.inboundhandler.DeliverOrder deliverOrder)
        Description copied from interface: Transport
        Asynchronously sends the ReplicableCommand to the set of destination using the specified DeliverOrder.
        Specified by:
        sendToMany in interface Transport
        Parameters:
        targets - the collection of destination's Address. If null, it sends to all the members in the cluster.
        command - the ReplicableCommand to send.
        deliverOrder - the DeliverOrder to use.
      • backupRemotely

        public <O> XSiteResponse<O> backupRemotely​(org.infinispan.xsite.XSiteBackup backup,
                                                   org.infinispan.xsite.XSiteReplicateCommand<O> rpcCommand)
        Description copied from interface: Transport
        Sends 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() returns false, the XSiteResponse is only completed when the an ACK from the remote site is received. The invoker needs to make sure not to wait for the XSiteResponse.

        Specified by:
        backupRemotely in interface Transport
        Parameters:
        backup - The remote site.
        rpcCommand - The command to send.
        Returns:
        A XSiteResponse that is completed when the request is completed.
      • isCoordinator

        public boolean isCoordinator()
        Specified by:
        isCoordinator in interface Transport
        Returns:
        true if the current Channel is the coordinator of the cluster.
      • getCoordinator

        public Address getCoordinator()
        Specified by:
        getCoordinator in interface Transport
        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 interface Transport
        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 as Transport.getAddress().
        Specified by:
        getPhysicalAddresses in interface Transport
        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 interface Transport
        Returns:
        a list of members. Typically, this would be defensively copied.
      • getMembersPhysicalAddresses

        public List<Address> getMembersPhysicalAddresses()
        Description copied from interface: Transport
        Returns physical addresses of members in the current cluster view.
        Specified by:
        getMembersPhysicalAddresses in interface Transport
        Returns:
        a list of physical addresses
      • isMulticastCapable

        public boolean isMulticastCapable()
        Description copied from interface: Transport
        Tests whether the transport supports true multicast
        Specified by:
        isMulticastCapable in interface Transport
        Returns:
        true if the transport supports true multicast
      • localSiteName

        public String localSiteName()
        Specified by:
        localSiteName in interface Transport
        Returns:
        The local site name or null if this Transport cannot make cross-site requests.
      • localNodeName

        public String localNodeName()
        Specified by:
        localNodeName in interface Transport
        Returns:
        The local node name, defaults to the local node address.
      • start

        public void start()
        Description copied from interface: Lifecycle
        Invoked on component start
        Specified by:
        start in interface Lifecycle
        Specified by:
        start in interface Transport
      • initChannel

        protected void initChannel()
      • startJGroupsChannelIfNeeded

        protected void startJGroupsChannelIfNeeded()
        When overwriting this method, it allows third-party libraries to create a new behavior like: After JChannel has been created and before it is connected.
      • receiveClusterView

        protected void receiveClusterView​(org.jgroups.View newView)
      • stop

        public void stop()
        Description copied from interface: Lifecycle
        Invoked on component stop
        Specified by:
        stop in interface Lifecycle
        Specified by:
        stop in interface Transport
      • getLog

        public org.infinispan.util.logging.Log getLog()
        Specified by:
        getLog in interface Transport
      • 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 interface Transport
        Returns:
        set containing the connected sites, or null if no cross site replication has been enabled.
      • isSiteCoordinator

        public boolean isSiteCoordinator()
        Specified by:
        isSiteCoordinator in interface Transport
        Returns:
        true if this node is a cross-site replication coordinator.
      • raftManager

        public org.infinispan.remoting.transport.raft.RaftManager raftManager()
        Specified by:
        raftManager in interface Transport
        Returns:
        The RaftManager instance,
      • getChannel

        public org.jgroups.JChannel getChannel()
      • channelConnected

        public void channelConnected​(org.jgroups.JChannel channel)
        Specified by:
        channelConnected in interface org.jgroups.ChannelListener
      • channelDisconnected

        public void channelDisconnected​(org.jgroups.JChannel channel)
        Specified by:
        channelDisconnected in interface org.jgroups.ChannelListener
      • channelClosed

        public void channelClosed​(org.jgroups.JChannel channel)
        Specified by:
        channelClosed in interface org.jgroups.ChannelListener