public class DefaultTopologyView extends BaseTopologyView
Constructor and Description |
---|
DefaultTopologyView()
Create a new empty topology
|
DefaultTopologyView(java.util.Collection<InstanceDescription> instances)
Create a new topology filled with the given list of instances
|
Modifier and Type | Method and Description |
---|---|
void |
addInstances(java.util.Collection<InstanceDescription> instances)
Adds the given instances to this topology
|
TopologyEvent.Type |
compareTopology(DefaultTopologyView other)
Compare this topology with the given one and determine how they compare
|
boolean |
equals(java.lang.Object obj) |
java.util.Set<InstanceDescription> |
findInstances(InstanceFilter picker)
Searches through this topology and picks those accepted by the provided
InstanceFilter - and returns them without any particular order |
java.util.Set<ClusterView> |
getClusterViews()
Provides the collection of ClusterViews.
|
java.util.Set<InstanceDescription> |
getInstances()
Provides the set of InstanceDescriptions in the entire topology,
without any particular order
|
java.lang.String |
getLocalClusterSyncTokenId()
Returns the id that shall be used in the syncToken
by the ClusterSyncService.
|
InstanceDescription |
getLocalInstance()
Provides the InstanceDescription belonging to this instance.
|
int |
hashCode() |
void |
setLocalClusterView(LocalClusterView localClusterView)
Adds the instances of the given ClusterView to this topology
|
java.lang.String |
toString() |
getInstance, isCurrent, setNotCurrent, toShortString
public DefaultTopologyView()
public DefaultTopologyView(java.util.Collection<InstanceDescription> instances)
public TopologyEvent.Type compareTopology(DefaultTopologyView other)
other
- the other topology against which to compareTopologyEvent.Type
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public InstanceDescription getLocalInstance()
TopologyView
TopologyView.getLocalInstance()
public java.util.Set<InstanceDescription> getInstances()
TopologyView
TopologyView.getInstances()
public void setLocalClusterView(LocalClusterView localClusterView)
public void addInstances(java.util.Collection<InstanceDescription> instances)
public java.util.Set<InstanceDescription> findInstances(InstanceFilter picker)
TopologyView
InstanceFilter
- and returns them without any particular orderpicker
- the filter to useTopologyView.findInstances(org.apache.sling.discovery.InstanceFilter)
public java.util.Set<ClusterView> getClusterViews()
TopologyView
Note that all InstanceDescriptions belong to exactly one ClusterView - including InstanceDescriptions that form "a cluster of 1"
TopologyView.getClusterViews()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLocalClusterSyncTokenId()
BaseTopologyView
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.
getLocalClusterSyncTokenId
in class BaseTopologyView
Copyright © 2022 The Apache Software Foundation. All rights reserved.