Class DefaultClusterView
- java.lang.Object
-
- org.apache.sling.discovery.commons.providers.DefaultClusterView
-
- All Implemented Interfaces:
ClusterView
- Direct Known Subclasses:
LocalClusterView
@Deprecated(since="2021-09-30") public class DefaultClusterView extends Object implements ClusterView
Deprecated.This API is not supported in Cloud Service.Default implementation of the ClusterView interface.Besides implementing the interface methods it also adds add/remove of InstanceDescriptions as well as implementing equals and hashCode.
-
-
Constructor Summary
Constructors Constructor Description DefaultClusterView(String id)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddInstanceDescription(DefaultInstanceDescription instance)Deprecated.Add the given instance to this cluster and set the cluster on the instance (back pointer)booleanequals(Object obj)Deprecated.StringgetId()Deprecated.Returns a stable id of the cluster represented by this cluster view.List<InstanceDescription>getInstances()Deprecated.Provides the list of InstanceDescriptions with a stable ordering.InstanceDescriptiongetLeader()Deprecated.Provides the InstanceDescription belonging to the leader instance.InstanceDescriptiongetLocalInstance()Deprecated.Returns the local InstanceDescription or null if no local instance is listedinthashCode()Deprecated.booleanremoveInstanceDescription(InstanceDescription instance)Deprecated.Removes the given instance from this cluster.StringtoString()Deprecated.
-
-
-
Constructor Detail
-
DefaultClusterView
public DefaultClusterView(String id)
Deprecated.
-
-
Method Detail
-
getId
public String getId()
Deprecated.Description copied from interface:ClusterViewReturns 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:
getIdin interfaceClusterView- Returns:
- an id of this cluster view
- See Also:
- SLING-3164
-
addInstanceDescription
public void addInstanceDescription(DefaultInstanceDescription instance)
Deprecated.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
public List<InstanceDescription> getInstances()
Deprecated.Description copied from interface:ClusterViewProvides 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:
getInstancesin interfaceClusterView- Returns:
- the list of InstanceDescriptions (with a stable ordering)
-
getLeader
public InstanceDescription getLeader()
Deprecated.Description copied from interface:ClusterViewProvides 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:
getLeaderin interfaceClusterView- Returns:
- the InstanceDescription belonging to the leader instance
-
removeInstanceDescription
public boolean removeInstanceDescription(InstanceDescription instance)
Deprecated.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
public InstanceDescription getLocalInstance()
Deprecated.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
-
-