24 #ifndef GROUPMANAGEMENT_HPP_
25 #define GROUPMANAGEMENT_HPP_
32 #include "messages/ModuleMessage.pb.h"
34 #include <boost/interprocess/sync/interprocess_mutex.hpp>
35 #include <boost/shared_ptr.hpp>
36 #include <boost/thread/mutex.hpp>
93 void Check(
const boost::system::error_code& err );
95 void Timeout(
const boost::system::error_code& err );
97 void Recovery(
const boost::system::error_code& err );
99 void Premerge(
const boost::system::error_code &err );
101 void Merge(
const boost::system::error_code& err );
119 ModuleMessage
PeerList(std::string requester=
"all");
121 const CPeerNode& coord, std::string requester=
"all");
140 void Reorganize(
const boost::system::error_code& err );
144 void StartMonitor(
const boost::system::error_code& err);
151 const GroupManagementMessage& message, std::string recipient =
"gm");
void Merge(const boost::system::error_code &err)
Sends invitations to all known nodes.
Definition: GroupManagement.cpp:760
static ModuleMessage PeerListQuery(std::string requester)
Generates a CMessage that can be used to query for the group.
Definition: GroupManagement.cpp:353
int GetStatus() const
Gets the status of a node.
Definition: GroupManagement.cpp:1524
void Premerge(const boost::system::error_code &err)
Waits a time period determined by UUID for merge.
Definition: GroupManagement.cpp:613
ModuleMessage AreYouCoordinatorResponse(std::string payload, int seq)
Creates A Response message.
Definition: GroupManagement.cpp:233
void HandlePeerList(const PeerListMessage &msg, CPeerNode peer)
Hadles recieving peerlists.
Definition: GroupManagement.cpp:1009
void HandleInvite(const InviteMessage &msg, CPeerNode peer)
Handles recieving invite messages.
Definition: GroupManagement.cpp:1157
void HandleResponseAYT(const AreYouThereResponseMessage &msg, CPeerNode peere)
Handles recieving AYT responses.
Definition: GroupManagement.cpp:1295
unsigned int m_GrpCounter
The number of groups being formed.
Definition: GroupManagement.hpp:167
ModuleMessage PeerList(std::string requester="all")
Generates a peer list.
Definition: GroupManagement.cpp:317
void StartMonitor(const boost::system::error_code &err)
Start the monitor after transient is over.
boost::posix_time::time_duration TIMEOUT_TIMEOUT
How long beteween AYT checks.
Definition: GroupManagement.hpp:181
Definition: GroupManagement.hpp:50
std::string m_GroupLeader
The uuid of the group leader.
Definition: GroupManagement.hpp:165
boost::asio::io_service m_localservice
The io_service used.
Definition: GroupManagement.hpp:171
ModuleMessage AreYouThere()
Creates a AYT, used for Timeout.
Definition: GroupManagement.cpp:295
void Reorganize(const boost::system::error_code &err)
Puts the system into the working state.
Definition: GroupManagement.cpp:865
void HandleAccept(const AcceptMessage &msg, CPeerNode peer)
Handles recieving accept messsages.
Definition: GroupManagement.cpp:1067
Base interface for agents/broker modules.
Definition: CPeerNode.hpp:37
std::map< std::string, bool > m_fidstate
A store for the state of attached FIDs.
Definition: GroupManagement.hpp:206
void Recovery()
Resets the algorithm to the default startup state.
Definition: GroupManagement.cpp:465
ModuleMessage Invitation()
Creates Group Invitation Message.
Definition: GroupManagement.cpp:212
void SystemState()
Outputs information about the current state to the logger.
Definition: GroupManagement.cpp:367
Definition: GroupManagement.hpp:50
int m_groupsjoined
Number of accepts sent.
Definition: GroupManagement.hpp:198
std::string m_fallback_coord
Definition: GroupManagement.hpp:210
void HandleResponseAYC(const AreYouCoordinatorResponseMessage &msg, CPeerNode peer)
Handles recieving AYC responses.
Definition: GroupManagement.cpp:1234
int Run()
Called to start the system.
Definition: GroupManagement.cpp:1495
TimedPeerSet m_AYTResponse
Nodes expecting AYT response from.
Definition: GroupManagement.hpp:160
Definition: GroupManagement.hpp:50
std::map< std::string, std::pair< CPeerNode, boost::posix_time::ptime > > TimedPeerSet
Similar to a PeerSet, but also tracks the time a peer was inserted.
Definition: PeerSets.hpp:49
static CPeerNode ProcessConnectedPeer(const ConnectedPeerMessage &cpm)
Converts a connected peer field to a CPeerNode.
Definition: GroupManagement.cpp:950
Definition: GroupManagement.hpp:50
Declaration of Garcia-Molina Invitation Leader Election algorithm.
Definition: GroupManagement.hpp:45
boost::posix_time::time_duration AYT_RESPONSE_TIMEOUT
How long to wait for responses from other nodes.
Definition: GroupManagement.hpp:187
CBroker::TimerHandle m_fidtimer
Timer for checking FIDs.
Definition: GroupManagement.hpp:175
void HandleEcnMessage(const ecn::EcnMessage &msg, CPeerNode peer)
Handles incoming ECN message.
Definition: GroupManagement.cpp:1361
PeerSet m_UpNodes
Nodes In My Group.
Definition: GroupManagement.hpp:154
PeerSet m_fallback_config
Definition: GroupManagement.hpp:209
boost::posix_time::time_duration FID_TIMEOUT
How long to wait before checking attached FIDs.
Definition: GroupManagement.hpp:183
ModuleMessage AreYouCoordinator()
Creates AYC Message.
Definition: GroupManagement.cpp:193
static ModuleMessage PrepareForSending(const GroupManagementMessage &message, std::string recipient="gm")
Wraps a GroupManagementMessage in a ModuleMessage.
Definition: GroupManagement.cpp:1554
int m_groupsbroken
Number of groups broken.
Definition: GroupManagement.hpp:194
void Timeout(const boost::system::error_code &err)
Checks that the leader is still alive and working.
Definition: GroupManagement.cpp:901
int m_membershipchecks
Number of membership checks.
Definition: GroupManagement.hpp:202
~GMAgent()
Module destructor.
Definition: GroupManagement.cpp:106
ModuleMessage Accept()
Creates an Accept Message.
Definition: GroupManagement.cpp:280
int m_status
A store for the status of this node.
Definition: GroupManagement.hpp:204
ModuleMessage AreYouThereResponse(std::string payload, int seq)
Creates A Response message.
Definition: GroupManagement.cpp:261
unsigned int TimerHandle
Definition: CBroker.hpp:66
void HandlePeerListQuery(const PeerListQueryMessage &msg, CPeerNode peer)
Handles recieving peerlist requests.
Definition: GroupManagement.cpp:1337
Definition: GroupManagement.hpp:50
void PushPeerList()
Sends the peer list to all group members.
Definition: GroupManagement.cpp:443
CPeerNode AddPeer(std::string uuid)
Adds a peer to the peer set from UUID.
Definition: GroupManagement.cpp:1456
An interface for an object which can handle recieving incoming messages.
Definition: IDGIModule.hpp:36
boost::posix_time::time_duration AYC_RESPONSE_TIMEOUT
How long to wait for responses from other nodes.
Definition: GroupManagement.hpp:185
PeerSet m_Coordinators
Known Coordinators.
Definition: GroupManagement.hpp:156
CPeerNode GetPeer(const std::string &uuid)
Gets a pointer to a peer from UUID.
Definition: GroupManagement.cpp:1485
int m_soft_ecn_mode
Definition: GroupManagement.hpp:208
int m_groupsformed
Number of groups formed.
Definition: GroupManagement.hpp:192
void HandleIncomingMessage(boost::shared_ptr< const ModuleMessage > msg, CPeerNode peer)
Handles received messages.
Definition: GroupManagement.cpp:122
void HandleAreYouThere(const AreYouThereMessage &msg, CPeerNode peer)
Handles recieving are you there messsages.
Definition: GroupManagement.cpp:1123
GMAgent()
Constructor for using this object as a module.
Definition: GroupManagement.cpp:78
std::string GetUUID() const
Gets the UUID of this process.
Definition: IDGIModule.cpp:45
void HandleAreYouCoordinator(const AreYouCoordinatorMessage &msg, CPeerNode peer)
Handles recieving are you coordinator messages.
Definition: GroupManagement.cpp:1094
static PeerSet ProcessPeerList(const PeerListMessage &msg)
Handles Processing a PeerList.
Definition: GroupManagement.cpp:984
std::string Coordinator() const
Returns the coordinators uuid.
Definition: GroupManagement.hpp:146
void Check(const boost::system::error_code &err)
Checks for other up leaders.
Definition: GroupManagement.cpp:551
CBroker::TimerHandle m_timer
A timer for stepping through the election process.
Definition: GroupManagement.hpp:173
bool IsCoordinator() const
Returns true if this node considers itself a coordinator.
Definition: GroupManagement.hpp:66
int m_membership
Total size of groups after all checks.
Definition: GroupManagement.hpp:200
int m_groupselection
Number of elections started.
Definition: GroupManagement.hpp:196
void InviteGroupNodes(const boost::system::error_code &err, PeerSet p_tempSet)
Sends invitations to all group members.
Definition: GroupManagement.cpp:825
void SetStatus(int status)
Sets the status of the node.
Definition: GroupManagement.cpp:1538
TimedPeerSet m_AYCResponse
Nodes expecting AYC response from.
Definition: GroupManagement.hpp:158
boost::posix_time::time_duration INVITE_RESPONSE_TIMEOUT
How long to wait for responses from other nodes.
Definition: GroupManagement.hpp:189
std::map< std::string, CPeerNode > PeerSet
Provides a PeerSet type for a module templated on T.
Definition: PeerSets.hpp:35
boost::posix_time::time_duration CHECK_TIMEOUT
How long between AYC checks.
Definition: GroupManagement.hpp:179
google::protobuf::uint32 m_GroupID
The ID number of the current group (Never initialized for fun)
Definition: GroupManagement.hpp:163