Class DefaultTopologyView
- All Implemented Interfaces:
TopologyView
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new empty topologyDefaultTopologyView
(Collection<InstanceDescription> instances) Create a new topology filled with the given list of instances -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstances
(Collection<InstanceDescription> instances) Adds the given instances to this topologyCompare this topology with the given one and determine how they compareboolean
findInstances
(InstanceFilter picker) Searches through this topology and picks those accepted by the providedInstanceFilter
- and returns them without any particular orderProvides the collection of ClusterViews.Provides the set of InstanceDescriptions in the entire topology, without any particular orderReturns the id that shall be used in the syncToken by the ClusterSyncService.Provides the InstanceDescription belonging to this instance.int
hashCode()
void
setLocalClusterView
(LocalClusterView localClusterView) Adds the instances of the given ClusterView to this topologytoString()
Methods inherited from class org.apache.sling.discovery.commons.providers.BaseTopologyView
getInstance, isCurrent, setNotCurrent, toShortString
-
Constructor Details
-
DefaultTopologyView
public DefaultTopologyView()Create a new empty topology -
DefaultTopologyView
Create a new topology filled with the given list of instances
-
-
Method Details
-
compareTopology
Compare this topology with the given one and determine how they compare- Parameters:
other
- the other topology against which to compare- Returns:
- the type describing how these two compare
- See Also:
-
equals
-
hashCode
public int hashCode() -
getLocalInstance
Description copied from interface:TopologyView
Provides the InstanceDescription belonging to this instance.- Returns:
- the InstanceDescription belonging to this instance
- See Also:
-
getInstances
Description copied from interface:TopologyView
Provides the set of InstanceDescriptions in the entire topology, without any particular order- Returns:
- the set of InstanceDescriptions in the entire topology, without any particular order
- See Also:
-
setLocalClusterView
Adds the instances of the given ClusterView to this topology -
addInstances
Adds the given instances to this topology -
findInstances
Description copied from interface:TopologyView
Searches through this topology and picks those accepted by the providedInstanceFilter
- and returns them without any particular order- Parameters:
picker
- the filter to use- Returns:
- the set of InstanceDescriptions which were accepted by the InstanceFilter, without any particular order
- See Also:
-
getClusterViews
Description copied from interface:TopologyView
Provides the collection of ClusterViews.Note that all InstanceDescriptions belong to exactly one ClusterView - including InstanceDescriptions that form "a cluster of 1"
- Returns:
- the set of ClusterViews, without any particular order
- See Also:
-
toString
-
getLocalClusterSyncTokenId
Description copied from class:BaseTopologyView
Returns the id that shall be used in the syncToken by the ClusterSyncService.The clusterSyncId uniquely identifies each change of the local cluster for all participating instances. That means, all participating instances know of the clusterSyncId and it is the same for all instances. Whenever an instance joins/leaves the cluster, this clusterSyncId must change.
Since this method returns the *local* clusterSyncId, it doesn't care if a remote cluster experienced changes - it must only change when the local cluster changes. However, it *can* change when a remote cluster changes too. So the requirement is just that it changes *at least* when the local cluster changes - but implementations can opt to regard this rather as a TopologyView-ID too (ie an ID that identifies a particular incarnation of the TopologyView for all participating instances in the whole topology).
This id can further safely be used by the ClusterSyncService to identify a syncToken that it writes and that all other instances in the lcoal cluster wait for, before sending a TOPOLOGY_CHANGED event.
Note that this is obviously not to be confused with the ClusterView.getId() which is stable throughout the lifetime of a cluster.
- Specified by:
getLocalClusterSyncTokenId
in classBaseTopologyView
-