Class JGroupsCluster

java.lang.Object
java.util.AbstractMap<K,V>
org.jgroups.blocks.ReplicatedHashMap<String,NodeModel>
de.xima.fc.cluster.impl.jgroup.JGroupsCluster
All Implemented Interfaces:
ICluster, Closeable, Serializable, AutoCloseable, ConcurrentMap<String,NodeModel>, Map<String,NodeModel>, org.jgroups.blocks.ReplicatedMap<String,NodeModel>, org.jgroups.Receiver

public class JGroupsCluster extends org.jgroups.blocks.ReplicatedHashMap<String,NodeModel> implements ICluster
Implementation of a ICluster that uses EClusterImplementation.JGROUPS.
Since:
3.1.0
Author:
XIMA MEDIA GmbH
See Also:
  • Constructor Details

    • JGroupsCluster

      public JGroupsCluster(org.jgroups.JChannel channel, JGroupsClusterConnection clusterConnection)
      Creates a new JGroups cluster implementation.
      Parameters:
      channel - Channel to use for the local node.
      clusterConnection - JGroups cluster connection to use.
  • Method Details

    • start

      public void start() throws Exception
      Starts the cluster when not started yet.
      Throws:
      Exception - When the cluster could not be started.
    • viewAccepted

      public void viewAccepted(org.jgroups.View view)
      Specified by:
      viewAccepted in interface org.jgroups.Receiver
      Overrides:
      viewAccepted in class org.jgroups.blocks.ReplicatedHashMap<String,NodeModel>
    • getID

      public String getID()
      Specified by:
      getID in interface ICluster
      Returns:
      The ID of the entire cluster.
    • getNodeList

      public List<NodeModel> getNodeList()
      Specified by:
      getNodeList in interface ICluster
      Returns:
      All nodes that are part of the cluster, whether or not they are currently connected.
    • getNodeIDs

      public String[] getNodeIDs()
      Specified by:
      getNodeIDs in interface ICluster
      Returns:
      A list of the IDs of all nodes that are part of the cluster, whether or not they are currently connected.
    • getLocaleNode

      public NodeModel getLocaleNode()
      Specified by:
      getLocaleNode in interface ICluster
      Returns:
      The local node, i.e. the node that corresponds to the server running this code.
    • disconnect

      public void disconnect()
      Disconnects the channel of this getLocaleNode().
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class org.jgroups.blocks.ReplicatedHashMap<String,NodeModel>
    • sendMessage

      public void sendMessage(IClusterMessage msg) throws Exception
      Description copied from interface: ICluster
      Attempts to send a message to other nodes in the cluster.
      Specified by:
      sendMessage in interface ICluster
      Parameters:
      msg - Message to send to other nodes.
      Throws:
      Exception - When the message could not be sent, such as due to network failures.
    • changeLocaleNodeState

      public void changeLocaleNodeState(ENodeState state)
      Description copied from interface: ICluster
      Changes the state of the local node, i.e. the node that corresponds to the server running this code.
      Specified by:
      changeLocaleNodeState in interface ICluster
      Parameters:
      state - The new state for the node.