public LocalClusterView getLocalClusterView()

in src/main/java/org/apache/sling/discovery/impl/cluster/ClusterViewServiceImpl.java [90:151]


    public LocalClusterView getLocalClusterView() throws UndefinedClusterViewException {
    	if (resourceResolverFactory==null) {
    		logger.warn("getClusterView: no resourceResolverFactory set at the moment.");
    		throw new UndefinedClusterViewException(Reason.REPOSITORY_EXCEPTION,
    		        "no resourceResolverFactory set");
    	}
        ResourceResolver resourceResolver = null;
        try {
            resourceResolver = resourceResolverFactory
                    .getServiceResourceResolver(null);

            View view = ViewHelper.getEstablishedView(resourceResolver, config);
            if (view == null) {
                logger.debug("getClusterView: no view established at the moment. isolated mode");
                throw new UndefinedClusterViewException(Reason.NO_ESTABLISHED_VIEW,
                        "no established view at the moment");
            }

            if (failedEstablishedViewId != null
                    && failedEstablishedViewId.equals(view.getResource().getName())) {
                // SLING-5195 : the heartbeat-handler-self-check has declared the currently
                // established view as invalid - hence we should now treat this as
                // undefined clusterview
                logger.debug("getClusterView: current establishedView is marked as invalid: "+failedEstablishedViewId);
                throw new UndefinedClusterViewException(Reason.NO_ESTABLISHED_VIEW,
                        "current established view was marked as invalid");
            }

            EstablishedClusterView clusterViewImpl = new EstablishedClusterView(
                    config, view, getSlingId());

            InstanceDescription local = clusterViewImpl.getLocalInstance();
            if (local != null) {
                return clusterViewImpl;
            } else {
                logger.info("getClusterView: the local instance ("+getSlingId()+") is currently not included in the existing established view! "
                        + "This is normal at startup. At other times is pseudo-network-partitioning is an indicator for repository/network-delays or clocks-out-of-sync (SLING-3432). "
                        + "(increasing the heartbeatTimeout can help as a workaround too) "
                        + "The local instance will stay in TOPOLOGY_CHANGING or pre _INIT mode until a new vote was successful.");
                throw new UndefinedClusterViewException(Reason.ISOLATED_FROM_TOPOLOGY,
                        "established view does not include local instance - isolated");
            }
        } catch (UndefinedClusterViewException e) {
            // pass through
            throw e;
        } catch (LoginException e) {
            logger.error(
                    "handleEvent: could not log in administratively: " + e, e);
            throw new UndefinedClusterViewException(Reason.REPOSITORY_EXCEPTION,
                    "could not log in administratively: "+e);
        } catch (Exception e) {
            logger.error(
                    "handleEvent: got an exception: " + e, e);
            throw new UndefinedClusterViewException(Reason.REPOSITORY_EXCEPTION,
                    "could not log in administratively: "+e);
        } finally {
            if (resourceResolver != null) {
                resourceResolver.close();
            }
        }

    }