14 #ifndef __INCLUDED_SCOPIRA_AGENT_CLUSTERAGENT_H__ 15 #define __INCLUDED_SCOPIRA_AGENT_CLUSTERAGENT_H__ 19 #include <scopira/tool/netflow.h> 20 #include <scopira/tool/url.h> 21 #include <scopira/tool/uuid.h> 22 #include <scopira/tool/time.h> 23 #include <scopira/core/register.h> 24 #include <scopira/agent/localagent.h> 56 bool pm_isdirectroute;
65 void parse_options(
const std::string &options);
79 enum { default_port_c = 5555 };
84 friend class scopira::agent::uptime_task;
92 virtual void notify_stop(
void);
97 virtual void enqueue_network_quit(
void);
101 virtual bool failed(
void)
const;
109 virtual int universe_size(
void);
114 virtual void launch_slaves(
scopira::tool::uuid masterid,
int numtotalps,
const std::type_info &t,
128 const node_spec & spec(
void)
const {
return dm_nodespec; }
151 virtual const char * get_debug_name(
void)
const = 0;
152 virtual short get_type(
void)
const {
return type_normal_c; }
159 class network_msg :
public admin_msg
168 : pm_src(src), pm_id(
id) { }
179 virtual void execute_agent_link(
cluster_agent &e, link *lk) = 0;
181 void set_net_link(net_link *l);
183 void set_xtion(
const xtion_t &x) { dm_xtion = x; }
184 const xtion_t & get_xtion(
void)
const {
return dm_xtion; }
205 class reply_msg :
public network_msg
209 reply_msg(
int errorcode = 0);
215 virtual const char * get_debug_name(
void)
const {
return "reply_msg"; }
216 virtual short get_type(
void)
const {
return type_instant_c; }
220 int get_code(
void)
const {
return dm_errorcode; }
228 class remove_link_msg;
230 class peer_hello_msg;
231 class nottmp_hello_msg;
232 class make_back_link_msg;
234 class resolve_agent_msg;
235 class reply_resolve_agent_msg;
237 class master_launch_task_msg;
238 class reply_master_launch_task_msg;
240 class client_wait_msg;
241 class client_wait_task;
242 class client_kill_msg;
243 class client_is_alive_msg;
245 class bcast_data_msg;
246 class find_services_msg;
247 class reply_find_services_msg;
248 class reg_context_msg;
250 class default_group_size_msg;
281 friend class network_msg;
284 blocksize_c = 1024*8,
285 magic_c = 0xE23A34F7,
301 queue_area(
void) : pm_link(0), pm_alive(
true) { }
331 void set_link(link *l);
340 void set_sendmsg(network_msg *msg);
343 static void* recv_thread_func(
void *herep);
344 static void* send_thread_func(
void *herep);
354 typedef std::list<scopira::tool::count_ptr<network_msg> > msgqueue_t;
356 friend class peer_hello_msg;
357 friend class nottmp_hello_msg;
377 bool pm_remotemaster;
381 queue_area(
void) : pm_remotetmp(
true), pm_remotemaster(
false) { }
391 bool is_tmpaddress(
void)
const {
return dm_tmpaddress; }
398 void accept_net_link(net_link *nl);
401 void enqueue_msg(network_msg *msg);
404 void print_status(
void);
410 void on_sent(network_msg *msg);
411 void on_recv(network_msg *msg);
413 void on_close_net_link(
void);
429 typedef std::map<scopira::tool::uuid, scopira::tool::count_ptr<link> > peers_t;
445 peer_area(
void) : pm_alive(
false) { }
448 typedef std::list<scopira::tool::count_ptr<admin_msg> > msgqueue_t;
451 double pm_triggertime;
454 cron_item(
void) : pm_triggertime(0) { }
455 cron_item(
double triggertime, admin_msg *msg) : pm_triggertime(triggertime), pm_msg(msg) { }
457 bool operator<(
const cron_item &rhs)
const {
return pm_triggertime > rhs.pm_triggertime; }
459 typedef std::priority_queue<cron_item> cronqueue_t;
469 msgqueue_t pm_main_queue;
470 cronqueue_t pm_cron_queue;
478 admin_area(
void) : pm_alive(
false), pm_failedstate(failed_initting_c), pm_agenterror(0) { }
490 typedef std::vector<scopira::tool::uuid> taskslist_t;
493 taskslist_t pm_tasks;
499 typedef std::map<scopira::tool::uuid, scopira::tool::count_ptr<meta_node> > nodemap_t;
500 typedef std::map<scopira::tool::uuid, scopira::tool::uuid> taskmap_t;
518 typedef std::map<int, scopira::tool::count_ptr<network_msg> > netmsgmap_t;
519 typedef std::map<int, scopira::tool::count_ptr<reply_msg> > repmsgmap_t;
525 repmsgmap_t pm_replies;
528 netmsgmap_t pm_handlers;
534 xtion_area(
void) : pm_nextid(3000), pm_alive(
true) { }
537 typedef std::map<scopira::tool::uuid, scopira::tool::count_ptr<reply_resolve_agent_msg> > resolvemap_t;
543 resolvemap_t pm_resolves;
555 std::string dm_password;
590 void enqueue_msg(admin_msg *msg);
601 void enqueue_reply_msg(network_msg *theq, reply_msg *thereply)
602 { enqueue_reply_msg(theq->get_xtion(), thereply); }
613 void enqueue_cron_msg(
double w, admin_msg *msg);
631 network_msg *msg, network_msg *handler);
642 void print_status(
void);
645 static void* listen_thread_func(
void *herep);
646 static void* udp_thread_func(
void *herep);
647 static void* admin_thread_func(
void *herep);
651 void print_status(admin_area *area);
Definition: clusteragent.h:75
Definition: clusteragent.h:163
node_spec(void)
zero initing
Definition: clusteragent.h:44
Definition: archiveflow.h:20
Definition: localagent.h:70
Definition: localagent.h:43