8 #include "evs_message2.hpp"
11 #include "gcomm/uuid.hpp"
12 #include "gu_datetime.hpp"
13 #include "gu_logger.hpp"
27 std::ostream& operator<<(std::ostream&,
const Node&);
29 class OperationalSelect;
37 Node(
const gu::datetime::Period& inactive_timeout,
38 const gu::datetime::Period& suspect_timeout)
40 index_ (std::numeric_limits<size_t>::max()),
48 suspect_timeout_ (suspect_timeout),
49 inactive_timeout_(inactive_timeout),
50 tstamp_ (gu::datetime::Date::now()),
59 void set_index(
const size_t idx) { index_ = idx; }
60 size_t index()
const {
return index_; }
62 void set_operational(
const bool op)
67 bool operational()
const {
return operational_; }
69 void set_suspected(
const bool s)
73 bool suspected()
const {
return suspected_; }
75 void set_committed(
const bool comm) { committed_ = comm; }
76 bool committed()
const {
return committed_; }
77 void set_installed(
const bool inst) { installed_ = inst; }
78 bool installed()
const {
return installed_; }
82 const JoinMessage* join_message()
const {
return join_message_; }
86 const LeaveMessage* leave_message()
const {
return leave_message_; }
88 void set_tstamp(
const gu::datetime::Date& t) { tstamp_ = t; }
89 const gu::datetime::Date& tstamp()
const {
return tstamp_; }
91 void set_fifo_seq(
const int64_t seq) { fifo_seq_ = seq; }
92 int64_t fifo_seq()
const {
return fifo_seq_; }
93 SegmentId segment()
const {
return segment_; }
95 bool is_inactive()
const;
96 bool is_suspected()
const;
98 void set_suspect_timeout(
const gu::datetime::Period& p)
100 suspect_timeout_ = p;
102 void set_inactive_timeout(
const gu::datetime::Period& p)
104 inactive_timeout_ = p;
109 void operator=(
const Node&);
127 gu::datetime::Period suspect_timeout_;
129 gu::datetime::Period inactive_timeout_;
131 gu::datetime::Date tstamp_;
145 void operator()(
const NodeMap::value_type& vt)
const
147 if (NodeMap::value(vt).operational() ==
true)
149 nm.insert_unique(vt);
160 void operator()(std::pair<const gcomm::UUID, Node>& p)
const
162 Node& node(p.second);
163 gu::datetime::Date now(gu::datetime::Date::now());
164 if (node.tstamp() + node.suspect_timeout_ < now)
166 if (node.suspected_ ==
false)
168 log_debug <<
"declaring node with index "
170 <<
" suspected, timeout " << node.suspect_timeout_;
172 node.suspected_ =
true;
176 node.suspected_ =
false;
178 if (node.tstamp() + node.inactive_timeout_ < now)
180 if (node.inactive_ ==
false)
182 log_debug <<
"declaring node with index "
183 << node.index_ <<
" inactive ";
185 node.inactive_ =
true;
189 node.inactive_ =
false;
195 #endif // EVS_NODE_HPP
Definition: evs_node.hpp:34
Definition: evs_message2.hpp:520
Definition: evs_node.hpp:157
Definition: evs_node.hpp:140
Definition: evs_message2.hpp:585
Definition: evs_node.hpp:137
#define gcomm_assert(cond_)
Definition: exception.hpp:21