Commit 4e4f6e91 authored by jan.koester's avatar jan.koester
Browse files

test

parent 7ef37b86
Loading
Loading
Loading
Loading
Loading
+9 −0
Changes for src/backends/cluster.cpp: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
#include <cstring>
#include <iostream>
#include <algorithm>
#include <thread>
#include <chrono>

#include <crypto/sha.h>
#include <netplus/exception.h>
@@ -55,7 +57,9 @@ namespace authdb {
        // Fetch from local store
        auto &store = g_Cluster->getStore();
        std::vector<uint8_t> local_data;
        try {
            store.fetch(dgid, 0, local_data);
        } catch (...) {}

        // Also try fetching from peer nodes
        std::vector<uint8_t> peer_data;
@@ -71,6 +75,8 @@ namespace authdb {
            } catch (const std::exception &e) {
                std::cerr << "ClusterBackend::fetchFromCluster: fetch_from_peers failed: "
                          << e.what() << std::endl;
            } catch (...) {
                std::cerr << "ClusterBackend::fetchFromCluster: fetch_from_peers failed (unknown)" << std::endl;
            }
        }

@@ -124,6 +130,9 @@ namespace authdb {
    ClusterBackend::ClusterBackend(const char *domain, size_t version, const char *filepath)
        : _Domain(domain), _Pos(0), _Dirty(false)
    {
        // Give peer servers time to start their event loops
        std::this_thread::sleep_for(std::chrono::seconds(2));

        // Try to fetch existing data from cluster/store
        fetchFromCluster();