Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The prototypes of the min_duration addition
[simgrid.git] / include / amok / hostmanagement.h
1 /* $Id$ */
2
3 /* amok host management - servers main loop and remote host stopping        */
4
5 /* Copyright (c) 2006 Martin Quinson. All rights reserved.                  */
6
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. */
9
10 #ifndef AMOK_HOST_MANAGEMENT_H
11 #define AMOK_HOST_MANAGEMENT_H
12
13 #include <gras.h>
14 #include <amok/base.h>
15
16 /** \addtogroup AMOK_hm
17  *  \brief Managing remote servers
18  * 
19  * This module provide the main loop of servers designed to answer to
20  * callbacks. They can furthermore be stopped remotely.  
21  * 
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
25  * slaves. 
26   
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()). 
34  
35  * The <b>master</b>, on its side, should create declare the datatypes and
36  * messages just like slaves. It should then create a group with
37  * amok_hm_group_new().
38  
39  * Afterward, there is two solutions. 
40  *   - If your master is a deamon which never stops itself (just like regular UNIX daemons), it should: 
41  *      - register the needed callbacks to messages comming from slaves
42  *      - register repetitive actions 
43  *      - entering the main loop.
44  *   - If the master is not a deamon, it should:
45  *      - wait a moment for the slaves registration (using gras_msg_handleall())
46  *      - run its algorithm. For this, it may call RPC on slaves, or explicitely wait (with gras_msg_wait()) for the answers it expects.
47
48  *
49  * @{
50  */
51
52 /* module handling */
53 void amok_hm_init(void);
54 void amok_hm_exit(void);
55
56 void amok_hm_mainloop(double timeOut);
57
58 void amok_hm_kill_hp(char *name,int port);
59 void amok_hm_kill(gras_socket_t buddy);
60 void amok_hm_kill_sync(gras_socket_t buddy);
61
62 xbt_dynar_t amok_hm_group_new(const char *group_name);
63 xbt_dynar_t amok_hm_group_get(gras_socket_t master, const char *group_name);
64
65 void        amok_hm_group_join(gras_socket_t master, const char *group_name);
66 void        amok_hm_group_leave(gras_socket_t master, const char *group_name);
67
68
69 void amok_hm_group_shutdown(const char *group_name);
70 void amok_hm_group_shutdown_remote(gras_socket_t master, const char *group_name);
71
72
73 /** @} */
74 #endif /* AMOK_HOST_MANAGEMENT_H */