public TopologyView getTopology()

in src/main/java/org/apache/sling/discovery/base/commons/BaseDiscoveryService.java [65:97]


    public TopologyView getTopology() {
        // create a new topology view
        final DefaultTopologyView topology = new DefaultTopologyView();

        LocalClusterView localClusterView = null;
        try {
            ClusterViewService clusterViewService = getClusterViewService();
            if (clusterViewService == null) {
                throw new UndefinedClusterViewException(
                        Reason.REPOSITORY_EXCEPTION,
                        "no ClusterViewService available at the moment");
            }
            localClusterView = clusterViewService.getLocalClusterView();
            topology.setLocalClusterView(localClusterView);
        } catch (UndefinedClusterViewException e) {
            // SLING-5030 : when we're cut off from the local cluster we also
            // treat it as being cut off from the entire topology, ie we don't
            // update the announcements but just return
            // the previous oldView marked as !current
            logger.info("getTopology: undefined cluster view: "+e.getReason()+"] "+e);
            oldView.setNotCurrent();
            if (e.getReason()==Reason.ISOLATED_FROM_TOPOLOGY) {
                handleIsolatedFromTopology();
            }
            return oldView;
        }

        Collection<InstanceDescription> attachedInstances = getAnnouncementRegistry()
                .listInstances(localClusterView);
        topology.addInstances(attachedInstances);

        return topology;
    }