diff options
author | Alan Conway <aconway@apache.org> | 2007-07-02 22:35:33 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-07-02 22:35:33 +0000 |
commit | eb7f88e2818ddb98bc02ff7fc39c936d421d16d8 (patch) | |
tree | bd50d2cae9f686436513620f50eecfeac06d5585 /qpid/cpp/src/tests/Cluster.h | |
parent | 8380592eddec548cf70bc63cd43be886ea68a57f (diff) | |
download | qpid-python-eb7f88e2818ddb98bc02ff7fc39c936d421d16d8.tar.gz |
2007-06-30 <aconway@redhat.com>
* src/qpid/cluster/Cluster.cpp: Refactor - expose 4 handler points
for all traffic to/from cluster. Removed HandlerUpdater functionality,
separate class. Cluster only deals with membership and connecting
the 4 handler points to CPG multicast.
* src/tests/cluster.mk: Dropped newgrp ais wrapper scripts, its
much simpler if the user just does "newgrp ais" before building.
* src/tests/ais_check: Test script to check if users gid is ais
and give clear notice if not.
* src/tests/Cluster.cpp: Updated for changes to Cluster.
* src/qpid/cluster/Cpg.cpp: Better messages for common errors.
* Handler.h: Remove nextHandler() minor convenience is outweighted
by risk of undetected errors if handlers that expect next() to be
set are called when it's not set.
* src/qpid/cluster/Cpg.cpp: Added logging. Replaced boost::function
with traditional virtual interface (nasty stack traces.)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@552614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/Cluster.h')
-rw-r--r-- | qpid/cpp/src/tests/Cluster.h | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/qpid/cpp/src/tests/Cluster.h b/qpid/cpp/src/tests/Cluster.h index edb1f1524f..f37c87a9ad 100644 --- a/qpid/cpp/src/tests/Cluster.h +++ b/qpid/cpp/src/tests/Cluster.h @@ -27,6 +27,7 @@ #include <boost/bind.hpp> #include <iostream> #include <vector> +#include <functional> /** * Definitions for the Cluster.cpp and Cluster_child.cpp child program. @@ -39,45 +40,48 @@ using namespace qpid; using namespace qpid::cluster; using namespace qpid::framing; using namespace qpid::sys; +using namespace boost; void null_deleter(void*) {} -struct TestClusterHandler : - public std::vector<AMQFrame>, public FrameHandler, public Monitor - +struct TestFrameHandler : + public FrameHandler, public vector<AMQFrame>, public Monitor { - TestClusterHandler(Cluster& c) : cluster(c) { - cluster.join(make_shared_ptr(this, &null_deleter)); - cluster.setCallback(boost::bind(&Monitor::notify, this)); - } - - void handle(AMQFrame& f) { - ScopedLock l(*this); - push_back(f); + void handle(AMQFrame& frame) { + Mutex::ScopedLock l(*this); + push_back(frame); notifyAll(); } - /** Wait for the vector to contain n frames. */ - bool waitFrames(size_t n) { - ScopedLock l(*this); - AbsTime deadline(now(), TIME_SEC); + bool waitFor(size_t n) { + Mutex::ScopedLock l(*this); + AbsTime deadline(now(), 5*TIME_SEC); while (size() != n && wait(deadline)) ; return size() == n; } +}; - /** Wait for the cluster to have n members */ - bool waitMembers(size_t n) { - ScopedLock l(*this); - AbsTime deadline(now(), TIME_SEC); - while (cluster.size() != n && wait(deadline)) - ; - return cluster.size() == n; +void nullDeleter(void*) {} + +struct TestCluster : public Cluster +{ + TestCluster(string name, string url) : Cluster(name, url) + { + setFromChains( + FrameHandler::Chains( + make_shared_ptr(&in, nullDeleter), + make_shared_ptr(&out, nullDeleter) + )); } - Cluster& cluster; -}; + /** Wait for cluster to be of size n. */ + bool waitFor(size_t n) { + return wait(boost::bind(equal_to<size_t>(), bind(&Cluster::size,this), n)); + } + TestFrameHandler in, out; +}; |