3 /* amok host management - servers main loop and remote host stopping */
5 /* Copyright (c) 2006 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #ifndef AMOK_HOST_MANAGEMENT_H
11 #define AMOK_HOST_MANAGEMENT_H
14 #include <amok/base.h>
16 /** \addtogroup AMOK_hm
17 * \brief Managing remote servers
19 * This module provide the main loop of servers designed to answer to
20 * callbacks. They can furthermore be stopped remotely.
22 * This module is especially useful to program following the centralized
23 * master/slave architecture. In this architecture, one of the processes
24 * acts as a master dispatching orders to the others, which are called
27 * The source code of the <b>slaves</b> then only consists in:
28 * - declaring the gras datatypes (see \ref GRAS_dd)
29 * - declaring the messages (with gras_msgtype_declare() or gras_msgtype_declare_rpc())
30 * - attaching the right callbacks to the messages (with gras_cb_register())
31 * - declaring the right repetitive actions (see \ref GRAS_timer)
32 * - joining the group (with amok_hm_group_join(), so that the master now it)
33 * - entering the endless loop (with amok_hm_mainloop()).
35 * The <b>master</b>, on its side, should create declare the datatypes and messages just like slaves.
36 * Afterward, there is two solutions.
37 * - If your master is a deamon which never stops itself (just like regular UNIX daemons), it should:
38 * - register the needed callbacks to messages comming from slaves
39 * - register repetitive actions
40 * - entering the main loop.
41 * - If the master is not a deamon, it should:
42 * - wait a moment for the slaves registration (using gras_msg_handleall())
43 * - run its algorithm. For this, it may call RPC on slaves, or explicitely wait (with gras_msg_wait()) for the answers it expects.
50 void amok_hm_init(void);
51 void amok_hm_exit(void);
53 void amok_hm_mainloop(double timeOut);
55 void amok_hm_kill_hp(char *name,int port);
56 void amok_hm_kill(gras_socket_t buddy);
57 void amok_hm_kill_sync(gras_socket_t buddy);
59 xbt_dynar_t amok_hm_group_new(char *group_name);
60 xbt_dynar_t amok_hm_group_get(gras_socket_t master,char *group_name);
62 void amok_hm_group_join(gras_socket_t master, char *group_name);
63 void amok_hm_group_leave(gras_socket_t master, char *group_name);
66 void amok_hm_group_shutdown_local(char *group_name);
67 void amok_hm_group_shutdown_remote(gras_socket_t master, char *group_name);
71 #endif /* AMOK_HOST_MANAGEMENT_H */