GHS
Leader Election Based on GHS Minimum Spanning Tree
msg.h
Go to the documentation of this file.
1 
41 #ifndef GHS_MSG_H
42 #define GHS_MSG_H
43 
44 #include "ghs/agent.h"
45 #include "ghs/level.h"
46 #include "ghs/edge.h"
47 
50 namespace le{
54  namespace ghs{
55 
56  namespace msg{
58  enum Type
59  {
68  };
69 
71  struct NoopPayload{
72  };
73 
75  struct SrchPayload{
76  agent_t your_leader;
77  level_t your_level;
78  };
79 
86  agent_t to;
87  agent_t from;
88  metric_t metric;
89  };
90 
92  struct InPartPayload{
93  agent_t leader;
94  level_t level;
95  };
96 
98  struct AckPartPayload{
99  };
100 
103  };
104 
109  struct JoinUsPayload{
110  agent_t join_peer;
111  agent_t join_root;
112  agent_t proposed_leader;
113  level_t proposed_level;
114  };
115 
116  union Data{
117  NoopPayload noop;
118  SrchPayload srch;
119  SrchRetPayload srch_ret;
120  InPartPayload in_part;
121  AckPartPayload ack_part;
122  NackPartPayload nack_part;
123  JoinUsPayload join_us;
124  };
125  }
126 
127 
143  class Msg
144  {
145 
146  public:
147 
148  Msg();
149 
153  Msg(agent_t to, agent_t from, msg::NoopPayload p);
154  Msg(agent_t to, agent_t from, msg::SrchPayload p);
155  Msg(agent_t to, agent_t from, msg::SrchRetPayload p);
156  Msg(agent_t to, agent_t from, msg::InPartPayload p);
157  Msg(agent_t to, agent_t from, msg::AckPartPayload p);
159  Msg(agent_t to, agent_t from, msg::JoinUsPayload p);
160 
164  Msg(agent_t to, agent_t from, const Msg &other);
165 
169  Msg(agent_t to, agent_t from, msg::Type t, msg::Data d);
170 
171  ~Msg();
172 
173  agent_t to() const {return to_;}
174  agent_t from() const {return from_;}
175  msg::Type type() const {return type_;}
176  msg::Data data() const {return data_;}
177 
178  private:
180  agent_t to_;
181 
183  agent_t from_;
184 
185  msg::Data data_;
186 
187  msg::Type type_;
188 
189  };
190 
195  const unsigned int MAX_MSG_SZ= sizeof(Msg);
196 
197  }
198 }
199 
200 #endif
le::ghs::agent_t
int agent_t
problems for GhsState
Definition: agent.h:51
le::ghs::msg::SRCH
@ SRCH
data is a SrchPayload
Definition: msg.h:62
le::ghs::msg::NACK_PART
@ NACK_PART
data is a NackPartPayload
Definition: msg.h:66
le::ghs::msg::NOOP
@ NOOP
data is a NoopPayload
Definition: msg.h:61
le::ghs::msg::NoopPayload
No further action necessary (i.e., we have completed the MST construction)
Definition: msg.h:71
le::ghs::metric_t
unsigned long metric_t
Definition: edge.h:63
le::ghs::msg::Type
Type
Stores what type of Msg this is.
Definition: msg.h:58
le::ghs::Msg
An aggregate type containing all the data to exchange with to/from information.
Definition: msg.h:143
le::ghs::msg::SrchRetPayload
Returns an edge that represents the minimum weight outgoing edge.
Definition: msg.h:85
le::ghs::MAX_MSG_SZ
const unsigned int MAX_MSG_SZ
Definition: msg.h:195
level.h
defintion for le::ghs::level_t
le
Definition: agent.h:43
le::ghs::msg::ACK_PART
@ ACK_PART
data is a AckPartPayload
Definition: msg.h:65
le::ghs::msg::SrchPayload
Requests a search begin in the MST subtree rooted at the receiver, for the minimum weight outgoing ed...
Definition: msg.h:75
edge.h
Edge structure definition and functions.
le::ghs::msg::JoinUsPayload
Msgs to merge /absorb two partitions across a given edge.
Definition: msg.h:109
le::ghs::msg::JOIN_US
@ JOIN_US
data is a JoinUsPayload
Definition: msg.h:67
le::ghs::msg::AckPartPayload
States "I am in your partition".
Definition: msg.h:98
agent.h
provides le::ghs::agent_t defintion
le::ghs::msg::InPartPayload
Asks "Are you in my partition".
Definition: msg.h:92
le::ghs::msg::NackPartPayload
States "I am not in your partition".
Definition: msg.h:102
le::ghs::msg::Data
Definition: msg.h:116
le::ghs::msg::UNASSIGNED
@ UNASSIGNED
Error checking for unassigned messages.
Definition: msg.h:60
le::ghs::level_t
int level_t
A "level" which is an internal item for GhsState to track how many times the MST has merged with anot...
Definition: level.h:49
le::ghs::msg::IN_PART
@ IN_PART
data is a InPartPayload
Definition: msg.h:64
le::ghs::msg::SRCH_RET
@ SRCH_RET
data is a SrchRetPayload
Definition: msg.h:63