public interface ClusterSupport
Modifier and Type | Method and Description |
---|---|
boolean |
canFailover(String nodeName)
Can this node act as the failover node for the given node name
|
int |
getActiveNodeCount()
Gives the number of active nodes in the current nodes cluster domain
|
List<String> |
getActiveNodeNames()
Gives the node names of the active nodes in the current nodes cluster domain
|
List<String> |
getCurrentlyActingAsNodeGroups()
Gives the acting as node group list that this node is currently acting as
|
List<String> |
getCurrentlyActingAsNodes()
Gives the acting as node name list that this node is currently acting as
|
String |
getDomain()
Gives the cluster domain of the cluster, if clustering is enabled
|
List<String> |
getFailoverNodeNames()
Gives the list of node names to which this node provides failover facility
|
String |
getNodeName()
Gives the node name of this node in the cluster domain
|
String |
getQualifiedSessionId()
Gives the current session of this node in the cluster domain in the form of,
$DOMAIN:$NODE_NAME:$SESSION_ID where the
$DOMAIN is getDomain()
$NODE_NAME is getNodeName()
$SESSION_ID is the current local session id of this node in the cluster
|
boolean |
isActingAs(String nodeName)
Is this node acting as the given node
|
boolean |
isAlive()
Checks whether the node is connected to the cluster or not.
|
boolean |
isClustered()
Checks whether the clustering is enabled or not
|
int |
nextSequenceNumber(String path)
Gets a distributed continuously increasing sequence number for the given path.
|
String |
publishCommand(ControlCommand command)
Publishes a
ControlCommand into the complete cluster. |
void |
releaseLock(String path)
Release any distributed locks for the given path, and tries to deletes the path itself.
|
boolean |
tryLock(String path)
This methods never blocks or wait to acquire the lock.
|
void |
unwatchActiveNodes(NodeWatcher watcher)
Un-register the previously registered node watcher, it is unregistered at the functional level, where your
NodeWatcher will not get any further notifications from this point onwards.
|
void |
watchActiveNodes(NodeWatcher watcher)
Watches the active nodes space and notify the provided node watcher in-case of a node leaving the cluster or new
node joining the cluster.
|
boolean isClustered()
boolean isAlive()
String getDomain()
String getNodeName()
String getQualifiedSessionId()
$DOMAIN:$NODE_NAME:$SESSION_ID
where the
getDomain()
getNodeName()
List<String> getActiveNodeNames()
int getActiveNodeCount()
List<String> getCurrentlyActingAsNodes()
List<String> getCurrentlyActingAsNodeGroups()
List<String> getFailoverNodeNames()
boolean isActingAs(String nodeName)
nodeName
- the node name to check the acting asboolean canFailover(String nodeName)
nodeName
- the node name to test for failoverboolean tryLock(String path)
This method doesn't guarantee to acquire the lock, if the lock can be acquired it does so but do not wait and try to acquire it again and again. Should be useful in cases where you need a distributed access to a single location. The path can be a hierarchical path where the '/' being the path delimiter. However locks are not hierarchical meaning that getting a lock at path messages/db doesn't block another user from taking a lock at path messages/db/foo.
Any successful lock acquired by this method should be released as sooner as possible to let any other node take the lock. However any lock miss (that is a false return from this method will clear the lock nodes created to try to acquire the lock within its protocol). Hence the usage pattern of this method should happen within a try-finally block as shown below
String path = "messages/db/foo";
boolean lockAcquired;
try {
lockAcquired = mediation.getClusterSupport().tryLock(path);
if (lockAcquired) {
// do the processing with the lock
}
} catch(Exception e) {
// exception handling
} finally {
if (lockAcquired) {
mediation.getClusterSupport().releaseLock(path);
}
}
path
- the global path representing the lockvoid releaseLock(String path)
tryLockPath
method to
make sure the lock cleanup works to some extent.path
- the path for which the lock to be releasedString publishCommand(ControlCommand command)
ControlCommand
into the complete cluster. Note that the publishing node will also execute
this command via the command execution framework.command
- the command to be executed by the clustervoid watchActiveNodes(NodeWatcher watcher)
unwatchActiveNodes(org.adroitlogic.ultraesb.api.mediation.helper.NodeWatcher)
. You may call this method
more than once with different NodeWatcher references.watcher
- the watcher to be notified.void unwatchActiveNodes(NodeWatcher watcher)
watcher
- the watcher to be un-registeredint nextSequenceNumber(String path)
Integer.MAX_VALUE
path
- the path to which the sequence number is generatedCopyright © 2010–2016 AdroitLogic. All rights reserved.