This ticket is about contributing a resource based implementation of the discovery api (see ) named discovery.impl to Sling. The implementation is attached as a .tar.gz - its md5 hash is d8891e5401114b2a629d3ff01044a1d6
Short description of the discovery.impl:
The discovery.impl is an out-of-the-box implementation of the discovery.api using standard features of Sling. The discovery.api provides a view of a topology consisting of a number of individual sling-instances. The instances are loosely coupled, except for being part of the topology they do not implicitly or necessarily share anything else. For those instances though that form a cluster - ie when connected to the same repository - the api has an abstraction called ClusterView.
The discovery.impl uses two mechanisms for discovering other instances:
- it stores information about the local instance at a unique location in the repository. Thus allowing other instances that access the same repository to see and recognize each other.
- it connects to 'remote' instances via a plain HTTP POST, announcing the instances that it can see, and getting back the instances of the counterpart
All of the above is done regularly using a heart-beat - thus allowing to get a view of the currently live instances.
The discovery.api additionally supports leader-election within a cluster: it ensures that one and only one instance is elected leader and stays leader until it disappears/shuts down/dies. The discovery.impl uses repository-based voting between the instances of a cluster to establish a common 'cluster view'. Based on an established view, the discovery.impl is then able to deterministically elect one of the instances of the view as the leader (namely the one with the lowest 'id').
Also, to support the PropertyProvider concept of the discovery.api, the properties of each instance are propagated to the other instances using the heartbeat as piggyback (either via the repository or via HTTP POSTs for remote instances).
To get an idea of the discovery.impl build and add and start the two bundles (org.apache.sling.discovery.api and org.apache.sling.discovery.impl) to your sling installation and open the browser to the provided, simplistic 'topology webconsole' at
Please let me know if anything needs further explanation, details. Looking forward to having this included in Sling!