private boolean modifyConnectorOffsetsChecks(String connName, Callback<Message> callback) {
        if (checkRebalanceNeeded(callback)) {
            return false;
        }

        if (!isLeader()) {
            callback.onCompletion(new NotLeaderException("Only the leader can process external offsets modification requests", leaderUrl()), null);
            return false;
        }

        if (!refreshConfigSnapshot(workerSyncTimeoutMs)) {
            throw new ConnectException("Failed to read to end of config topic before modifying connector offsets");
        }

        if (!configState.contains(connName)) {
            callback.onCompletion(new NotFoundException("Connector " + connName + " not found", null), null);
            return false;
        }

        // If the target state for the connector is stopped, its task count is 0, and there is no rebalance pending (checked above),
        // we can be sure that the tasks have at least been attempted to be stopped (or cancelled if they took too long to stop).
        // Zombie tasks are handled by a round of zombie fencing for exactly once source connectors. Zombie sink tasks are handled
        // naturally because requests to alter consumer group offsets / delete consumer groups will fail if there are still active members
        // in the group.
        if (configState.targetState(connName) != TargetState.STOPPED || configState.taskCount(connName) != 0) {
            callback.onCompletion(new BadRequestException("Connectors must be in the STOPPED state before their offsets can be modified. This can be done " +
                    "for the specified connector by issuing a 'PUT' request to the '/connectors/" + connName + "/stop' endpoint"), null);
            return false;
        }
        return true;
    }
This method performs a few checks for external requests to modify (alter or reset) connector offsets and
completes the callback exceptionally if any check fails.
@param connName the name of the connector whose offsets are to be modified
@param callback callback to invoke upon completion
@return true if all the checks passed, false otherwise
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java