Package org.apache.sling.discovery

# Interface DiscoveryService

@ProviderType public interface DiscoveryService
The discovery service can be used to get the current topology view.

The discovery service is in charge of managing live instances that have announced themselves as being part of a topology view. The exact details of how this announcement occurs is implementation dependent.

## Method Summary

Modifier and Type
Method
Description
`TopologyView`
`getTopology()`
Returns the topology that was last discovered by this service.

## Method Details

### getTopology

TopologyView getTopology()
Returns the topology that was last discovered by this service.

If for some reason the service is currently not able to do topology discovery it will return the last valid topology marked with `false` in the call to `TopologyView.isCurrent()`. This is also true if the service has noticed a potential change in the topology and is in the process of settling the change in the topology (eg with peers, ie voting).

Note that this call is synchronized with `TopologyEventListener.handleTopologyEvent()` calls: ie if calls to `TopologyEventListener.handleTopologyEvent()` are currently ongoing, then the call to this method will block until all `TopologyEventListener`s have been called. Be careful not to cause deadlock situations.

Returns:
  the topology that was last discovered by this service. This will never be null (ie even if a change in the topology is ongoing at the moment or the cluster consists only of the local instance).