Class BaseTopologyView
- java.lang.Object
-
- org.apache.sling.discovery.commons.providers.BaseTopologyView
-
- All Implemented Interfaces:
TopologyView
public abstract class BaseTopologyView extends java.lang.Object implements TopologyView
Very simple abstract base class for the TopologyView which comes with the 'setNotCurrent()' method - that allows the ViewStateManager to mark a topologyView as no longer current - and the isCurrent() is handled accordingly.
-
-
Constructor Summary
Constructors Constructor Description BaseTopologyView()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description InstanceDescription
getInstance(java.lang.String slingId)
Simple getter for a particular slingIdabstract java.lang.String
getLocalClusterSyncTokenId()
Returns the id that shall be used in the syncToken by the ClusterSyncService.boolean
isCurrent()
Checks if this TopologyView is currently valid - or if the service knows of a topology change just going on (or another uncertainty about the topology such as IOException etc)void
setNotCurrent()
Marks this view as no longer current - this typically results in a TOPOLOGY_CHANGING event to be sent.java.lang.String
toShortString()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sling.discovery.TopologyView
findInstances, getClusterViews, getInstances, getLocalInstance
-
-
-
-
Method Detail
-
isCurrent
public boolean isCurrent()
Checks if this TopologyView is currently valid - or if the service knows of a topology change just going on (or another uncertainty about the topology such as IOException etc)- Specified by:
isCurrent
in interfaceTopologyView
- Returns:
- true if this TopologyView is currently valid, false if the service knows of a topology change just going on (or another issue with discovery like IOException etc)
-
setNotCurrent
public void setNotCurrent()
Marks this view as no longer current - this typically results in a TOPOLOGY_CHANGING event to be sent.Note that once marked as not current, it can no longer be reverted to current==true
-
getLocalClusterSyncTokenId
public abstract java.lang.String getLocalClusterSyncTokenId()
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.
-
toShortString
public java.lang.String toShortString()
-
getInstance
public InstanceDescription getInstance(java.lang.String slingId)
Simple getter for a particular slingId- Parameters:
slingId
- the slingId for which to lookup the InstanceDescription- Returns:
- the InstanceDescription matching the provided slingId - or null if it doesn't exist
-
-