public InstanceReadResult readInstance()

in src/main/java/org/apache/sling/discovery/oak/cluster/ClusterReader.java [115:133]


    public InstanceReadResult readInstance(int clusterNodeId, boolean failOnMissingSyncToken, long seqNum) throws PersistenceException {
        final String slingId = idMapService.toSlingId(clusterNodeId, resourceResolver);
        if (slingId == null) {
            idMapService.clearCache();
            return InstanceReadResult.fromErrorMsg("no slingId mapped for clusterNodeId=" + clusterNodeId);
        }
        final String leaderElectionId = readLeaderElectionId(slingId);
        if (leaderElectionId == null) {
            return InstanceReadResult.fromErrorMsg("no leaderElectionId available yet for slingId=" + slingId);
        }
        final boolean hasSeenLocalInstance = hasSeenLocalInstance(clusterNodeId, slingId, leaderElectionId);
        final long syncToken = readSyncToken(slingId);
        if (failOnMissingSyncToken && !hasSeenLocalInstance) {
            if (syncToken == -1 || (seqNum != -1 && syncToken < seqNum)) {
                return InstanceReadResult.fromErrorMsg("no valid syncToken available yet for slingId=" + slingId + ", syncToken=" + syncToken);
            }
        }
        return InstanceReadResult.fromInstance(new InstanceInfo(clusterNodeId, slingId, syncToken, leaderElectionId));
    }