public void handleTopologyEvent()

in src/main/java/org/apache/sling/discovery/oak/SlingIdCleanupTask.java [266:297]


    public void handleTopologyEvent(TopologyEvent event) {
        if (!isEnabled()) {
            hasTopology = false; // stops potentially ongoing deletion
            currentView = null;
            // cancel cleanup schedule
            stop();
            logger.debug("handleTopologyEvent: slingId cleanup is disabled");
            return;
        }
        final TopologyView newView = event.getNewView();
        if (event.getType() == Type.PROPERTIES_CHANGED) {
            // ignore those
        } else if (newView == null) {
            // that's a TOPOLOGY_CHANGING
            hasTopology = false; // stops potentially ongoing deletion
            currentView = null;
            // cancel cleanup schedule
            stop();
        } else {
            // that's TOPOLOGY_INIT or TOPOLOGY_CHANGED
            hasTopology = true;
            currentView = newView;
            seenInstances.addAll(getActiveSlingIds(newView));
            if (newView.getLocalInstance().isLeader()) {
                // only execute on leader
                recreateSchedule();
            } else {
                // should not be necessary, but lets stop anyway on non-leaders:
                stop();
            }
        }
    }