public ScheduleDecision scheduleDecision()

in server/src/main/java/org/apache/cassandra/sidecar/coordination/ClusterLeaseClaimTask.java [110:140]


    public ScheduleDecision scheduleDecision()
    {
        // The Sidecar schema feature is required for this implementation
        // so skip when the feature is not enabled
        boolean isEnabled = config.schemaKeyspaceConfiguration().isEnabled() && configuration.enabled();
        boolean isMember = false;
        if (isEnabled)
        {
            // Do expensive call when the feature is enabled to determine if this Sidecar is member
            // of the electorate
            try
            {
                isMember = electorateMembership.isMember();
            }
            catch (Throwable t)
            {
                LOGGER.debug("Membership determination fails due to unexpected exception", t);
                // isMember remains false
            }
            LOGGER.debug("Sidecar instance part of electorate isMember={}", isMember);
        }
        if (!isEnabled || !isMember)
        {
            clusterLease.setOwnership(ClusterLease.Ownership.LOST);
            return ScheduleDecision.SKIP;
        }

        // When accessor is available, it permits execution (where accessor is used)
        // Otherwise, it reschedules to skip the run and retry sooner, assuming initial delay is less than delay
        return accessor.isAvailable() ? ScheduleDecision.EXECUTE : ScheduleDecision.RESCHEDULE;
    }