X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=test%2Flib%2FCluster.cpp;h=3ecc6e9abea2d629009e3a54cf05e610bdef2e7c;hb=5a18a901fcfc7b5bef004eb9110a2386fe87224a;hp=e1375bfde90ed50c65fcb52a3f0cff54c3be35fa;hpb=e9b1c46e3490e2940ec36cfa53ffcee5945a27d2;p=awesomized%2Flibmemcached diff --git a/test/lib/Cluster.cpp b/test/lib/Cluster.cpp index e1375bfd..3ecc6e9a 100644 --- a/test/lib/Cluster.cpp +++ b/test/lib/Cluster.cpp @@ -7,13 +7,12 @@ Cluster::Cluster(Server serv, uint16_t cnt) : count{cnt} , proto{move(serv)} { - if (count < 4) { - count = stoi(getenv_else("MEMCACHED_CLUSTER", "4")); - } if (!count) { count = 1; } - reset(); + for (int i = 0; i < count; ++i) { + cluster.push_back(proto); + } } Cluster::~Cluster() { @@ -25,14 +24,6 @@ const vector &Cluster::getServers() const { return cluster; } -void Cluster::reset() { - pids.clear(); - cluster.clear(); - for (int i = 0; i < count; ++i) { - cluster.push_back(proto); - } -} - bool Cluster::start() { bool started = true; @@ -45,11 +36,15 @@ bool Cluster::start() { return started; } -void Cluster::stop() { +void Cluster::stop(bool graceful) { for (auto &server : cluster) { server.drain(); - // no cookies for memcached; TERM is just too slow - server.signal(SIGKILL); + if (graceful) { + server.stop(); + } else { + // no cookies for memcached; TERM is just too slow + server.signal(SIGKILL); + } } } @@ -111,3 +106,9 @@ void Cluster::wait() { } } } + +bool Cluster::restart() { + stop(); + wait(); + return start(); +}