Class DefaultTopologyView

java.lang.Object
org.apache.sling.discovery.commons.providers.BaseTopologyView
org.apache.sling.discovery.base.commons.DefaultTopologyView
All Implemented Interfaces:
TopologyView

public class DefaultTopologyView extends BaseTopologyView
Default Implementation of the topology view interface
  • Constructor Details

    • DefaultTopologyView

      public DefaultTopologyView()
      Create a new empty topology
    • DefaultTopologyView

      public DefaultTopologyView(Collection<InstanceDescription> instances)
      Create a new topology filled with the given list of instances
  • Method Details

    • compareTopology

      public TopologyEvent.Type compareTopology(DefaultTopologyView other)
      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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getLocalInstance

      public InstanceDescription getLocalInstance()
      Description copied from interface: TopologyView
      Provides the InstanceDescription belonging to this instance.
      Returns:
      the InstanceDescription belonging to this instance
      See Also:
    • getInstances

      public Set<InstanceDescription> 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

      public void setLocalClusterView(LocalClusterView localClusterView)
      Adds the instances of the given ClusterView to this topology
    • addInstances

      public void addInstances(Collection<InstanceDescription> instances)
      Adds the given instances to this topology
    • findInstances

      public Set<InstanceDescription> findInstances(InstanceFilter picker)
      Description copied from interface: TopologyView
      Searches through this topology and picks those accepted by the provided InstanceFilter - 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

      public Set<ClusterView> 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

      public String toString()
      Overrides:
      toString in class Object
    • getLocalClusterSyncTokenId

      public String 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 class BaseTopologyView