boolean handlesNewView()

in src/main/java/org/apache/sling/discovery/commons/providers/base/MinEventDelayHandler.java [83:133]


    boolean handlesNewView(BaseTopologyView newView) {
        if (isDelaying) {
            // already delaying, so we'll soon ask the DiscoveryServiceImpl for the
            // latest view and go ahead then
            logSilencer.infoOrDebug("handlesNewView-" + newView.getLocalClusterSyncTokenId(),
                    "handleNewView: already delaying, ignoring new view meanwhile");
            return true;
        }
        
        if (!viewStateManager.hadPreviousView()) {
            logSilencer.infoOrDebug("handlesNewView-" + newView.getLocalClusterSyncTokenId(),
                    "handlesNewView: never had a previous view, hence no delaying applicable");
            return false;
        }

        if (viewStateManager.equalsIgnoreSyncToken(newView)) {
            // this is a frequent case, hence only log.debug
            logger.debug("handlesNewView: equalsIgnoreSyncToken, hence no delaying applicable");
            return false;
        }
        
        if (viewStateManager.onlyDiffersInProperties(newView)) {
            logSilencer.infoOrDebug("handlesNewView-" + newView.getLocalClusterSyncTokenId(),
                    "handlesNewView: only properties differ, hence no delaying applicable");
            return false;
        }
        
        if (viewStateManager.unchanged(newView)) {
            // this will be the most frequent case
            // hence log only with trace
            logger.trace("handlesNewView: view is unchanged, hence no delaying applicable");
            return false;
        }
        
        // thanks to force==true this will always return true
        if (!triggerAsyncDelaying(newView)) {
            logSilencer.infoOrDebug("handlesNewView-" + newView.getLocalClusterSyncTokenId(),
                    "handleNewView: could not trigger async delaying, sending new view now.");
            viewStateManager.handleNewViewNonDelayed(newView);
        } else {
            // if triggering the async event was successful, then we should also
            // ensure that we sent out a TOPOLOGY_CHANGING *before* that delayed event hits.
            //
            // and, we're still in lock.lock() - so we are safe to do a handleChanging() here
            // even though there is the very unlikely possibility that the async-delay-thread
            // would compete - but even if it would, thanks to the lock.lock() that would be safe.
            // so: we're going to do a handleChanging here:
            viewStateManager.handleChanging();
        }
        return true;
    }