17 #ifndef __M2ETIS_WRAPPER_CHIMERA_CHIMERAWRAPPERIMPL_H__
18 #define __M2ETIS_WRAPPER_CHIMERA_CHIMERAWRAPPERIMPL_H__
31 #include "boost/date_time/posix_time/posix_time_types.hpp"
32 #include "boost/thread.hpp"
35 #include "chimera/chimera.h"
53 const static int CHIMERA_MESSAGE_TYPE_BASE = 15;
55 ChimeraWrapperImpl() : _cb(nullptr), _initialized(false), _me(new ChimeraHost), _state(new ChimeraState), periodic_(
boost::posix_time::milliseconds(3000)), purge_distance_(
boost::posix_time::milliseconds(6000)), neighbors_(), neighbors_mutex_(), purging_(true), purger_(
boost::bind(&
ChimeraWrapperImpl::manageHeartbeats, this)), map_mutex_(), map_() {
64 typedef std::shared_ptr<ChimeraHost> HostPtr;
66 typedef std::shared_ptr<ChimeraState> StatePtr;
70 return CHIMERA_MESSAGE_TYPE_BASE +
static_cast<int>(type);
80 std::list<net::NodeHandle<net::NetworkType<net::CHIMERA> >::Ptr> createList(ChimeraHost **,
int size)
const;
82 static ChimeraWrapperImpl * _impl;
84 static void forward_upcall(Key **, Message **, ChimeraHost **);
85 static void update_upcall(Key * k, ChimeraHost * h,
int joined);
86 static void deliver_upcall(Key * k, Message * m);
88 const boost::posix_time::time_duration periodic_;
89 const boost::posix_time::time_duration purge_distance_;
91 typedef std::pair<boost::posix_time::ptime, net::NetworkType<net::CHIMERA>::Key> TimePair;
92 typedef std::vector<TimePair> TimeList;
93 typedef boost::unique_lock<boost::mutex> Guard;
94 typedef std::map<net::NetworkType<net::CHIMERA>::Key, ChimeraHost *> KeyHostMap;
97 mutable boost::mutex neighbors_mutex_;
98 volatile bool purging_;
99 boost::thread purger_;
100 mutable boost::mutex map_mutex_;
104 void manageHeartbeats();
113 void init(
const int port);
114 void init(
const int port,
const std::string & known_hostname,
const int know_hostport);
126 std::list<net::NodeHandle<net::NetworkType<net::CHIMERA> >::Ptr>
neighborSet(
const int num)
const;
virtual ~ChimeraWrapperImpl()
std::list< net::NodeHandle< net::NetworkType< net::CHIMERA > >::Ptr > replicaSet(const net::NetworkType< net::CHIMERA >::Key &key, const int maxRank) const
NodeHandle in different structured p2p-systems.
void init(const int port)
void send(const typename message::NetworkMessage< net::NetworkType< net::CHIMERA >>::Ptr msg, typename net::NodeHandle< net::NetworkType< net::CHIMERA >>::Ptr_const hint)
bool isResponsibleFor(const net::NetworkType< net::CHIMERA >::Key &key, const net::NetworkType< net::CHIMERA >::Key &node) const
The C++-wrapper around chimera.
net::NodeHandle< net::NetworkType< net::CHIMERA > >::Ptr getSelfNodeHandle() const
The C++-wrapper around chimera.
std::list< net::NodeHandle< net::NetworkType< net::CHIMERA > >::Ptr > neighborSet(const int num) const
bool range(const net::NodeHandle< net::NetworkType< net::CHIMERA > >::Ptr node, const int rank, const net::NetworkType< net::CHIMERA >::Key &lkey, const net::NetworkType< net::CHIMERA >::Key &rkey) const
void registerMessageType(const message::MessageType type, const bool ack) const
std::list< net::NodeHandle< net::NetworkType< net::CHIMERA > >::Ptr > local_lookup(const net::NetworkType< net::CHIMERA >::Key &key, const int num, const bool safe) const