org.terracotta.cluster
Class TerracottaClusterInfo

java.lang.Object
  extended by org.terracotta.cluster.TerracottaClusterInfo
All Implemented Interfaces:
ClusterInfo

public class TerracottaClusterInfo
extends Object
implements ClusterInfo


Constructor Summary
TerracottaClusterInfo()
           
 
Method Summary
 void addClusterListener(ClusterListener listener)
          Adds a cluster events listener.
 boolean areOperationsEnabled()
          Indicates whether operations are enabled on the current node.
 ClusterTopology getClusterTopology()
          Retrieves a view of the topology of the cluster, as seen from the current node.
 ClusterNode getCurrentNode()
          Retrieves the ClusterNode instance that corresponds to the current node.
<K> Set<K>
getKeysForLocalValues(Map<K,?> map)
          Retrieve a set of keys for map values that are faulted on the current node out of a clustered map for which partialness is supported.
<K> Set<K>
getKeysForOrphanedValues(Map<K,?> map)
          Retrieve a set of keys for map values that are not faulted anywhere out of a clustered map for which partialness is supported.
<K> Map<K,Set<ClusterNode>>
getNodesWithKeys(Map<K,?> map, Collection<? extends K> keys)
           
 Map<?,Set<ClusterNode>> getNodesWithObjects(Collection<?> objects)
          Determine where a collection of clustered objects is faulted.
 String getUniversallyUniqueClientID()
          Returns a universally unique identifier for the life-time of this client in the cluster.
 boolean isClusterInitialized()
          Indicates whether the cluster infrastructure was initialized when this info instance was created.
 boolean isNodeJoined()
          Indicates whether the current node has joined the cluster.
 void removeClusterListener(ClusterListener listener)
          Removes a cluster events listener.
 ClusterNode waitUntilNodeJoinsCluster()
          Waits until the current node has successfully joined the cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerracottaClusterInfo

public TerracottaClusterInfo()
Method Detail

isClusterInitialized

public boolean isClusterInitialized()
Description copied from interface: ClusterInfo
Indicates whether the cluster infrastructure was initialized when this info instance was created.

Note that a cluster needs to be initialized for any of the other methods to function. If there's a chance that the code that's using this cluster info instance is using it with an uninitialized cluster infrastructure, the return value of this method should be checked before using the cluster info.

Specified by:
isClusterInitialized in interface ClusterInfo
Returns:
true when the cluster was initialized; or false when this was not the case

getUniversallyUniqueClientID

public String getUniversallyUniqueClientID()
Description copied from interface: ClusterInfo
Returns a universally unique identifier for the life-time of this client in the cluster.

It will be the same for the entire life-time of this cluster client. However once the client is restarted, this identifier will be different. No two identifiers will ever be the same for different life-times or for different clients.

Specified by:
getUniversallyUniqueClientID in interface ClusterInfo
Returns:
the identifier as a string

addClusterListener

public void addClusterListener(ClusterListener listener)
Description copied from interface: ClusterInfo
Adds a cluster events listener.

If the cluster events listener instance has already been registered before, this method will not register it again.

When the cluster is already joined or the operations have already been enabled, those events will be immediately triggered on the listener when it's registered.

Specified by:
addClusterListener in interface ClusterInfo
Parameters:
listener - the cluster listener instance that will be registered

areOperationsEnabled

public boolean areOperationsEnabled()
Description copied from interface: ClusterInfo
Indicates whether operations are enabled on the current node.

Specified by:
areOperationsEnabled in interface ClusterInfo
Returns:
true if operations are enabled on the current node; false otherwise

getClusterTopology

public ClusterTopology getClusterTopology()
Description copied from interface: ClusterInfo
Retrieves a view of the topology of the cluster, as seen from the current node.

Note that the returned topology instance will be updated internally as nodes joined and leave the cluster. If you want a snapshot of the current nodes in the cluster, you should use the ClusterTopology.getNodes() method.

Specified by:
getClusterTopology in interface ClusterInfo
Returns:
an instance of the cluster topology as seen from the current node

getCurrentNode

public ClusterNode getCurrentNode()
Description copied from interface: ClusterInfo
Retrieves the ClusterNode instance that corresponds to the current node.

Specified by:
getCurrentNode in interface ClusterInfo
Returns:
the ClusterNode instance that corresponds to the current node

getKeysForLocalValues

public <K> Set<K> getKeysForLocalValues(Map<K,?> map)
                             throws UnclusteredObjectException
Description copied from interface: ClusterInfo
Retrieve a set of keys for map values that are faulted on the current node out of a clustered map for which partialness is supported.

Specified by:
getKeysForLocalValues in interface ClusterInfo
Parameters:
map - the map with the values that will be checked
Returns:
the set of keys for the values that are faulted on the current node;

an empty set if the map doesn't support partialness;

this never returns null, so null checks aren't needed

Throws:
UnclusteredObjectException - when the map isn't clustered

getKeysForOrphanedValues

public <K> Set<K> getKeysForOrphanedValues(Map<K,?> map)
                                throws UnclusteredObjectException
Description copied from interface: ClusterInfo
Retrieve a set of keys for map values that are not faulted anywhere out of a clustered map for which partialness is supported.

Specified by:
getKeysForOrphanedValues in interface ClusterInfo
Parameters:
map - the map with the values that will be checked
Returns:
the set of keys for the values that are faulted nowhere;

an empty set if the map doesn't support partialness;

this never returns null, so null checks aren't needed

Throws:
UnclusteredObjectException - when the map isn't clustered

getNodesWithKeys

public <K> Map<K,Set<ClusterNode>> getNodesWithKeys(Map<K,?> map,
                                                    Collection<? extends K> keys)

getNodesWithObjects

public Map<?,Set<ClusterNode>> getNodesWithObjects(Collection<?> objects)
                                            throws UnclusteredObjectException
Description copied from interface: ClusterInfo
Determine where a collection of clustered objects is faulted.

Each object will be a key in the map that is returned, with sets of nodes as values that indicate where the objects are faulted.

Specified by:
getNodesWithObjects in interface ClusterInfo
Parameters:
objects - the objects that will be checked
Returns:
the map of nodes where the objects are faulted;

this never returns null, so null checks aren't needed

Throws:
UnclusteredObjectException - when any of the objects isn't clustered

isNodeJoined

public boolean isNodeJoined()
Description copied from interface: ClusterInfo
Indicates whether the current node has joined the cluster.

Specified by:
isNodeJoined in interface ClusterInfo
Returns:
true if the current node has joined the cluster; false otherwise

removeClusterListener

public void removeClusterListener(ClusterListener listener)
Description copied from interface: ClusterInfo
Removes a cluster events listener.

If the cluster events listener instance was not registered before, this method will have no effect.

Specified by:
removeClusterListener in interface ClusterInfo
Parameters:
listener - the cluster listener instance that will be unregistered

waitUntilNodeJoinsCluster

public ClusterNode waitUntilNodeJoinsCluster()
Description copied from interface: ClusterInfo
Waits until the current node has successfully joined the cluster.

Specified by:
waitUntilNodeJoinsCluster in interface ClusterInfo
Returns:
the ClusterNode instance that corresponds to the current node


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.