Package de.xima.fc.cluster.impl.jgroup
Class 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 aICluster
that usesEClusterImplementation.JGROUPS
.- Since:
- 3.1.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.blocks.ReplicatedHashMap
org.jgroups.blocks.ReplicatedHashMap.Notification<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description JGroupsCluster(org.jgroups.JChannel channel, JGroupsClusterConnection clusterConnection)
Creates a new JGroups cluster implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeLocaleNodeState(ENodeState state)
Changes the state of the local node, i.e. the node that corresponds to the server running this code.void
close()
void
disconnect()
Disconnects the channel of thisgetLocaleNode()
.String
getID()
NodeModel
getLocaleNode()
String[]
getNodeIDs()
List<NodeModel>
getNodeList()
void
sendMessage(IClusterMessage msg)
Attempts to send a message to other nodes in the cluster.void
start()
Starts the cluster when not started yet.void
viewAccepted(org.jgroups.View view)
-
Methods inherited from class org.jgroups.blocks.ReplicatedHashMap
_clear, _put, _putAll, _putIfAbsent, _remove, _remove, _replace, _replace, addNotifier, clear, containsKey, containsValue, entrySet, get, getChannel, getClusterName, getLocalAddress, getState, getTimeout, init, isBlockingUpdates, put, putAll, putIfAbsent, remove, remove, removeNotifier, replace, replace, setBlockingUpdates, setState, setTimeout, start, stop, synchronizedMap
-
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
-
-
-
Constructor Detail
-
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 Detail
-
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)
-
getID
public String getID()
-
getNodeList
public List<NodeModel> getNodeList()
- Specified by:
getNodeList
in interfaceICluster
- Returns:
- All nodes that are part of the cluster, whether or not they are currently connected.
-
getNodeIDs
public String[] getNodeIDs()
- Specified by:
getNodeIDs
in interfaceICluster
- 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 interfaceICluster
- Returns:
- The local node, i.e. the node that corresponds to the server running this code.
-
disconnect
public void disconnect()
Disconnects the channel of thisgetLocaleNode()
.
-
close
public void close()
-
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 interfaceICluster
- 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 interfaceICluster
- Parameters:
state
- The new state for the node.
-
-