Commit eecc2452 authored by jan.koester's avatar jan.koester
Browse files

test

parent 7cedcb57
Loading
Loading
Loading
Loading
Loading
+35 −27
Changes for src/cluster.cpp: 35 added lines, 27 removed lines.
Original line number Diff line number Diff line
@@ -973,39 +973,47 @@ namespace authdb {
        return false;
    }

    std::vector<SessionInfo> Cluster::listAllSessions()
    {
        std::vector<SessionInfo> sessions;
        const auto groups = listAllGroups();
    std::vector<Cluster::SessionInfo> Cluster::listAllSessions() {
        std::vector<SessionInfo> out;
        
        for (const auto gid : groups) {
            try {
                const auto data = retrieve(gid);
        if (!session_read_client_) 
            return out;
        std::set<std::string> seen_sids;

                SessionInfo session;
                if (!deserializeSession(data, session)) {
                    std::cerr
                        << "[SESSIONS-DIAG] gid=" << gid
                        << " skipped: payload is not a valid session"
                        << std::endl;
                    continue;
        std::set<uint64_t> all_groups;
        try {
            // Try to retrieve and deserialize each group as a session
            for (uint64_t gid : all_groups) {
                try {
                    auto data = session_read_client_->retrieve(gid, deadline);
                    SessionInfo info;
                    bool deser = SessionBlock::deserialize(data, info.sid, info.uid, info.did,
                                                  info.members, info.username, info.gpo_results,
                                                  info.created_at);
                    std::cerr << "[SESSIONS-DIAG] deserialize gid=" << gid
                              << " ok=" << deser
                              << " sid=" << (deser ? info.sid.c_str() : "?") << std::endl;
                    if (deser) {
                        std::string key = info.sid.c_str();
                        if (!info.sid.empty() && seen_sids.find(key) == seen_sids.end()) {
                            seen_sids.insert(key);
                            out.push_back(std::move(info));
                        }
                    }

                sessions.emplace_back(std::move(session));
                } catch (const std::exception &e) {
                std::cerr
                    << "[SESSIONS-DIAG] gid=" << gid
                    << " skipped: " << e.what()
                    << std::endl;
                    std::cerr << "[SESSIONS-DIAG] retrieve/deserialize gid=" << gid
                              << " EXCEPTION: " << e.what() << std::endl;
                } catch (...) {
                    std::cerr << "[SESSIONS-DIAG] retrieve/deserialize gid=" << gid
                              << " unknown exception" << std::endl;
                }
            }

        std::cerr
            << "[SESSIONS-DIAG] listAllSessions result="
            << sessions.size()
            << std::endl;

        return sessions;
        } catch (const std::exception &e) {
            std::cerr << "[SESSIONS-DIAG] listAllSessions outer EXCEPTION: " << e.what() << std::endl;
        } catch (...) {
            std::cerr << "[SESSIONS-DIAG] listAllSessions outer unknown exception" << std::endl;
        }
        return out;
    }

    // --- DataOpBlock serialization ---