summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/cluster/Cpg.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-07-02 22:35:33 +0000
committerAlan Conway <aconway@apache.org>2007-07-02 22:35:33 +0000
commit83b4417af81df92cb640de1694488156ba29d85f (patch)
tree630449e321fb571476080b737febd841e605ff2d /cpp/src/qpid/cluster/Cpg.h
parenta36bef1975b1d273a65dd0e74994106fbaad4389 (diff)
downloadqpid-python-83b4417af81df92cb640de1694488156ba29d85f.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/qpid@552614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/Cpg.h')
-rw-r--r--cpp/src/qpid/cluster/Cpg.h53
1 files changed, 30 insertions, 23 deletions
diff --git a/cpp/src/qpid/cluster/Cpg.h b/cpp/src/qpid/cluster/Cpg.h
index e164ed1215..d616be74e2 100644
--- a/cpp/src/qpid/cluster/Cpg.h
+++ b/cpp/src/qpid/cluster/Cpg.h
@@ -21,8 +21,9 @@
#include "qpid/Exception.h"
#include "qpid/cluster/Dispatchable.h"
-#include <boost/function.hpp>
+
#include <cassert>
+
extern "C" {
#include <openais/cpg.h>
}
@@ -69,31 +70,36 @@ class Cpg : public Dispatchable {
return std::string(n.value, n.length);
}
- typedef boost::function<void (
- cpg_handle_t /*handle*/,
- struct cpg_name *group,
- uint32_t /*nodeid*/,
- uint32_t /*pid*/,
- void* /*msg*/,
- int /*msg_len*/)> DeliverFn;
-
- typedef boost::function<void (
- cpg_handle_t /*handle*/,
- struct cpg_name */*group*/,
- struct cpg_address */*members*/, int /*nMembers*/,
- struct cpg_address */*left*/, int /*nLeft*/,
- struct cpg_address */*joined*/, int /*nJoined*/
- )> ConfigChangeFn;
+ struct Handler {
+ virtual ~Handler() {};
+ virtual void deliver(
+ cpg_handle_t /*handle*/,
+ struct cpg_name *group,
+ uint32_t /*nodeid*/,
+ uint32_t /*pid*/,
+ void* /*msg*/,
+ int /*msg_len*/) = 0;
+
+ virtual void configChange(
+ cpg_handle_t /*handle*/,
+ struct cpg_name */*group*/,
+ struct cpg_address */*members*/, int /*nMembers*/,
+ struct cpg_address */*left*/, int /*nLeft*/,
+ struct cpg_address */*joined*/, int /*nJoined*/
+ ) = 0;
+ };
/** Open a CPG handle.
- *@param deliver - free function called when a message is delivered.
- *@param reconfig - free function called when CPG configuration changes.
+ *@param handler for CPG events.
*/
- Cpg(DeliverFn deliver, ConfigChangeFn reconfig);
-
- /** Disconnect from CPG. */
+ Cpg(Handler&);
+
+ /** Destructor calls shutdown. */
~Cpg();
+ /** Disconnect from CPG */
+ void shutdown();
+
/** Dispatch CPG events.
*@param type one of
* - CPG_DISPATCH_ONE - dispatch exactly one event.
@@ -128,7 +134,9 @@ class Cpg : public Dispatchable {
private:
class Handles;
+ struct ClearHandleOnExit;
friend class Handles;
+ friend struct ClearHandleOnExit;
static std::string errorStr(cpg_error_t err, const std::string& msg);
static std::string cantJoinMsg(const Name&);
@@ -159,8 +167,7 @@ class Cpg : public Dispatchable {
static Handles handles;
cpg_handle_t handle;
- DeliverFn deliver;
- ConfigChangeFn configChange;
+ Handler& handler;
};
std::ostream& operator <<(std::ostream& out, const Cpg::Id& id);