Class DefaultInstanceDescription
- java.lang.Object
-
- org.apache.sling.discovery.commons.providers.DefaultInstanceDescription
-
- All Implemented Interfaces:
InstanceDescription
- Direct Known Subclasses:
NonLocalInstanceDescription
public class DefaultInstanceDescription extends java.lang.Object implements InstanceDescription
Base implementation for the InstanceDescription interface.Allows creation of the object with clusterview and/or properties null - to be set later but before usage!
-
-
Field Summary
-
Fields inherited from interface org.apache.sling.discovery.InstanceDescription
PROPERTY_DESCRIPTION, PROPERTY_ENDPOINTS, PROPERTY_NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultInstanceDescription(DefaultClusterView clusterView, boolean isLeader, boolean isOwn, java.lang.String slingId, java.util.Map<java.lang.String,java.lang.String> properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)ClusterViewgetClusterView()Returns the ClusterView of which this instance is part of.java.util.Map<java.lang.String,java.lang.String>getProperties()Returns a Map containing all properties of this instance.java.lang.StringgetProperty(java.lang.String name)Returns the value of a particular property.java.lang.StringgetSlingId()The identifier of the running Sling instance.inthashCode()booleanisLeader()If an instance is part of a cluster, it can potentially be a leader of that cluster - this information is queried here.booleanisLocal()Determines whether this InstanceDescription is representing the local instance.voidsetProperty(java.lang.String key, java.lang.String value)for testing only!java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultInstanceDescription
public DefaultInstanceDescription(DefaultClusterView clusterView, boolean isLeader, boolean isOwn, java.lang.String slingId, java.util.Map<java.lang.String,java.lang.String> properties)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getClusterView
public ClusterView getClusterView()
Description copied from interface:InstanceDescriptionReturns the ClusterView of which this instance is part of.Every instance is part of a ClusterView even if it is standalone.
- Specified by:
getClusterViewin interfaceInstanceDescription- Returns:
- the ClusterView
-
isLeader
public boolean isLeader()
Description copied from interface:InstanceDescriptionIf an instance is part of a cluster, it can potentially be a leader of that cluster - this information is queried here.If an instance is not part of a cluster, this method returns true.
Only one instance of a cluster is guaranteed to be the leader at any time. This guarantee is provided by this service. If the leader goes down, the service elects a new leader and announces it to TopologyEventListener listeners.
- Specified by:
isLeaderin interfaceInstanceDescription- Returns:
- true if this instance is the - only - leader in this cluster, false if it is one of the slaves, or true if it is not at all part of a cluster
-
isLocal
public boolean isLocal()
Description copied from interface:InstanceDescriptionDetermines whether this InstanceDescription is representing the local instance.- Specified by:
isLocalin interfaceInstanceDescription- Returns:
- whether this InstanceDescription is representing the local instance.
-
getSlingId
public java.lang.String getSlingId()
Description copied from interface:InstanceDescriptionThe identifier of the running Sling instance.- Specified by:
getSlingIdin interfaceInstanceDescription
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:InstanceDescriptionReturns the value of a particular property.Note that there are no hard guarantees or requirements as to how quickly a property is available once it is set on a distant instance.
- Specified by:
getPropertyin interfaceInstanceDescription- Parameters:
name- The property name- Returns:
- The value of the property or
null - See Also:
DiscoveryService#setProperty(String, String)
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Description copied from interface:InstanceDescriptionReturns a Map containing all properties of this instance. This method always returns a map, it might be empty. The returned map is not modifiable.- Specified by:
getPropertiesin interfaceInstanceDescription- Returns:
- a Map containing all properties of this instance
-
setProperty
public void setProperty(java.lang.String key, java.lang.String value)for testing only!
-
-