9 #ifndef GCOMM_GMCAST_HPP
10 #define GCOMM_GMCAST_HPP
12 #include "gcomm/uuid.hpp"
15 #include "gcomm/types.hpp"
19 #ifndef GCOMM_GMCAST_MAX_VERSION
20 #define GCOMM_GMCAST_MAX_VERSION 0
21 #endif // GCOMM_GMCAST_MAX_VERSION
43 void handle_stable_view(
const View& view);
44 bool set_param(
const std::string& key,
const std::string& val);
46 const UUID& uuid()
const {
return my_uuid_; }
47 SegmentId segment()
const {
return segment_; }
49 void connect(
const gu::URI&);
50 void close(
bool force =
false);
51 void close(
const UUID& uuid) { gmcast_forget(uuid); }
55 gu_throw_fatal <<
"gmcast transport listen not implemented";
58 std::string listen_addr()
const
62 gu_throw_error(ENOTCONN) <<
"not connected";
64 return listener_->listen_addr();
69 gu_throw_fatal <<
"gmcast transport accept not implemented";
74 return pnet_.mtu() - (4 + UUID::serial_size());
82 static const long max_retry_cnt_;
88 AddrEntry(
const gu::datetime::Date& last_seen,
89 const gu::datetime::Date& next_reconnect,
93 last_seen_ (last_seen),
94 next_reconnect_ (next_reconnect),
99 const UUID& uuid()
const {
return uuid_; }
101 void set_last_seen(
const gu::datetime::Date& d) { last_seen_ = d; }
103 const gu::datetime::Date& last_seen()
const
104 {
return last_seen_; }
106 void set_next_reconnect(
const gu::datetime::Date& d)
107 { next_reconnect_ = d; }
109 const gu::datetime::Date& next_reconnect()
const
110 {
return next_reconnect_; }
112 void set_retry_cnt(
const int r) { retry_cnt_ = r; }
114 int retry_cnt()
const {
return retry_cnt_; }
116 void set_max_retries(
int mr) { max_retries_ = mr; }
117 int max_retries()
const {
return max_retries_; }
120 friend std::ostream& operator<<(std::ostream&,
const AddrEntry&);
121 void operator=(
const AddrEntry&);
123 gu::datetime::Date last_seen_;
124 gu::datetime::Date next_reconnect_;
132 class AddrListUUIDCmp
135 AddrListUUIDCmp(
const UUID& uuid) : uuid_(uuid) { }
136 bool operator()(
const AddrList::value_type& cmp)
const
138 return (cmp.second.uuid() == uuid_);
145 static const int max_version_ = GCOMM_GMCAST_MAX_VERSION;
149 std::string group_name_;
150 std::string listen_addr_;
151 std::set<std::string> initial_addrs_;
152 std::string mcast_addr_;
153 std::string bind_ip_;
164 std::set<Socket*> relay_set_;
166 typedef std::vector<Socket*> Segment;
167 typedef std::map<uint8_t, Segment> SegmentMap;
168 SegmentMap segment_map_;
171 gu::datetime::Period time_wait_;
172 gu::datetime::Period check_period_;
173 gu::datetime::Period peer_timeout_;
174 int max_initial_reconnect_attempts_;
175 gu::datetime::Date next_check_;
176 gu::datetime::Date handle_timers();
179 void gmcast_accept();
181 void gmcast_connect(
const std::string&);
194 bool is_connected(
const std::string& addr,
const UUID& uuid)
const;
196 void insert_address(
const std::string& addr,
const UUID& uuid,
AddrList&);
198 void update_addresses();
200 void check_liveness();
202 const void* exclude_id);
206 void set_initial_addr(
const gu::URI&);
207 void add_or_del_addr(
const std::string&);
209 std::string self_string()
const
211 std::ostringstream os;
212 os <<
'(' << my_uuid_ <<
", '" << listen_addr_ <<
"')";
216 friend std::ostream& operator<<(std::ostream&,
const AddrEntry&);
219 inline std::ostream& operator<<(std::ostream& os,
const GMCast::AddrEntry& ae)
221 return (os << ae.uuid_
222 <<
" last_seen=" << ae.last_seen_
223 <<
" next_reconnect=" << ae.next_reconnect_
224 <<
" retry_cnt=" << ae.retry_cnt_);
229 #endif // GCOMM_GMCAST_HPP
Definition: protonet.hpp:37
Transport interface.
Definition: transport.hpp:34
Definition: gmcast_proto.hpp:24
GComm exception definitions.
Definition: gmcast.hpp:33
Definition: gmcast_message.hpp:22
Definition: gmcast_proto.hpp:170
Definition: socket.hpp:72
Datagram container.
Definition: datagram.hpp:151