Class DefaultClusterView
- All Implemented Interfaces:
ClusterView
- Direct Known Subclasses:
LocalClusterView
Besides implementing the interface methods it also adds add/remove of InstanceDescriptions as well as implementing equals and hashCode.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given instance to this cluster and set the cluster on the instance (back pointer)boolean
getId()
Returns a stable id of the cluster represented by this cluster view.Provides the list of InstanceDescriptions with a stable ordering.Provides the InstanceDescription belonging to the leader instance.Returns the local InstanceDescription or null if no local instance is listedint
hashCode()
boolean
removeInstanceDescription
(InstanceDescription instance) Removes the given instance from this cluster.toString()
-
Constructor Details
-
DefaultClusterView
-
-
Method Details
-
equals
-
toString
-
hashCode
public int hashCode() -
getId
Description copied from interface:ClusterView
Returns a stable id of the cluster represented by this cluster view.Similar to the SlingID, this id is persisted and thus remains stable accross instance/cluster restarts.
When an instance joins a cluster, it will inherit the id from the joined cluster (thus incurs a cluster id change).
Note: When instances part from a cluster (eg due to a network partitioning) the cluster id is retained. This results in potentially multiple clusters with the same id. This fact could be used to detect such partitioning/split brain situations. It also implies though that the cluster id is not guaranteed to be unique in a topology!
Addition in 1.0.4: this id must consist only of alphanumeric characters plus dash '-' and underscore '_'.
- Specified by:
getId
in interfaceClusterView
- Returns:
- an id of this cluster view
- See Also:
-
addInstanceDescription
Add the given instance to this cluster and set the cluster on the instance (back pointer)- Parameters:
instance
- the instance to add to this cluster
-
getInstances
Description copied from interface:ClusterView
Provides the list of InstanceDescriptions with a stable ordering.Stable ordering implies that unless an instance leaves the cluster (due to shutdown/crash/network problems) the instance keeps the relative position in the list.
- Specified by:
getInstances
in interfaceClusterView
- Returns:
- the list of InstanceDescriptions (with a stable ordering)
-
getLeader
Description copied from interface:ClusterView
Provides the InstanceDescription belonging to the leader instance.Every ClusterView is guaranteed to have one and only one leader.
The leader is stable: once a leader is elected it stays leader unless it leaves the cluster (due to shutdown/crash/network problems)
- Specified by:
getLeader
in interfaceClusterView
- Returns:
- the InstanceDescription belonging to the leader instance
-
removeInstanceDescription
Removes the given instance from this cluster.Note that the instance will still have a pointer to this cluster however.
- Parameters:
instance
- the instance to remove from this cluster
-
getLocalInstance
Returns the local InstanceDescription or null if no local instance is listed- Returns:
- the local InstanceDescription or null if no local instance is listed
- Throws:
IllegalStateException
- if multiple local instances are listed
-