public static List plan()

in lagerta-core/src/main/java/com/epam/lagerta/subscriber/util/PlannerUtil.java [42:72]


    public static List<ReaderTxScope> plan(
            ReadTransactions read,
            CommittedTransactions committed,
            Set<Long> inProgress,
            Set<UUID> lostReaders) {

        Map<String, Set<?>> blocked = new HashMap<>();
        Map<UUID, Map<String, Set<?>>> claimed = new HashMap<>();
        List<ReaderTxScope> plan = new ArrayList<>();

        for (ReaderTxScope info : read) {
            long id = info.getTransactionId();
            if (!committed.contains(id)) {
                List<Entry<String, List>> scope = info.getScope();
                if (inProgress.contains(id) || lostReaders.contains(info.getReaderId())
                        || info.isOrphan() || isIntersected(blocked, scope)) {
                    scope.forEach(addTo(blocked));
                } else {
                    UUID readerId = info.getReaderId();
                    if (isIntersectedWithClaimed(readerId, scope, claimed)) {
                        scope.forEach(addTo(blocked));
                    } else {
                        Map<String, Set<?>> claimedScope = claimed.computeIfAbsent(readerId, CLAIMED);
                        scope.forEach(addTo(claimedScope));
                        plan.add(info);
                    }
                }
            }
        }
        return plan;
    }