Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Let's take the compatibilities issues seriously
[simgrid.git] / include / amok / peermanagement.h
1 /* $Id$ */
2
3 /* amok peer management - servers main loop and remote peer 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_PEER_MANAGEMENT_H
11 #define AMOK_PEER_MANAGEMENT_H
12
13 #include <gras.h>
14 #include <amok/base.h>
15
16 /** \addtogroup AMOK_pm
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_pm_group_join(), so that the master now it)
33  *   - entering the endless loop (with amok_pm_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_pm_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 algoritpm. For this, it may call RPC on slaves, or explicitely wait (with gras_msg_wait()) for the answers it expects.
47
48  * \section AMOK_pm_compat Compatibility issues
49  * 
50  * The API described here is as of SimGrid 3.2 and higher. In version 3.1
51  * (where this module were introduced), all functions were named amok_hm_*
52  * This was because the module used to be named HostManagement, but it was
53  * renamed before being released to betterly express its purpose.
54  * Unfortunately, the rename was not done properly before version 3.2.
55  * 
56  * @{
57  */
58
59 /* module handling */
60 void amok_pm_init(void);
61 void amok_pm_exit(void);
62
63 void amok_pm_mainloop(double timeOut);
64
65 void amok_pm_kill_hp(char *name,int port);
66 void amok_pm_kill(gras_socket_t buddy);
67 void amok_pm_kill_sync(gras_socket_t buddy);
68
69 xbt_dynar_t amok_pm_group_new(const char *group_name);
70 xbt_dynar_t amok_pm_group_get(gras_socket_t master, const char *group_name);
71
72 void        amok_pm_group_join(gras_socket_t master, const char *group_name);
73 void        amok_pm_group_leave(gras_socket_t master, const char *group_name);
74
75
76 void amok_pm_group_shutdown(const char *group_name);
77 void amok_pm_group_shutdown_remote(gras_socket_t master, const char *group_name);
78
79
80 /** @} */
81 #endif /* AMOK_peer_MANAGEMENT_H */