PadicoTM

Documentation

« back to PM2 home.
soap_gk-mod.c
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2025 INRIA and the University of Rennes 1
4 * Alexandre DENIS <Alexandre.Denis@inria.fr>
5 * Christian PEREZ <Christian.Perez@inria.fr>
6 *
7 * The software has been registered at the Agency for the Protection of
8 * Programs (APP) under the number IDDN.FR.001.260013.000.S.P.2002.000.10000.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
34#include <Padico/Puk.h>
35#include <Padico/PadicoTM.h>
36#include <Padico/PM2.h>
37#include <Padico/Topology.h>
38#include <Padico/Module.h>
39
40#include <stdsoap2.h>
41
42#include "soapH.h"
43#include "PadicoGatekeeper.nsmap"
44
45#define SOAP_URL_MAXSIZE 1024
46
47static int soap_gk_init(void);
48static int soap_gk_start(void);
49static void*soap_gk_worker(void*);
50static void soap_gk_stop(void);
52
53static struct soap soap;
54
56
57PADICO_MODULE_ATTR(port, "SOAP_PORT", "port used by SOAP gatekeeper", int, 18083);
58
59/* ***** SOAP module/process methods *********************** */
60
62{
63 padico_out(10, "Ping.\n");
65 return 0;
66}
67
69{
70 padico_out(10, "Kill.\n");
73 return 0;
74}
75
86
97
102{
104 int argc = args.__sizeargv + 1;
105 char**argv;
106 int i;
107 argv = (char**)padico_malloc(sizeof(char*)*(argc+1));
110 argv[0] = padico_strdup(modname);
111 argv[argc] = NULL;
112 for(i=1; i<argc; i++)
113 argv[i] = padico_strdup(args.argv[i-1]);
114 padico_out(10, "RunModule %s\n", modname);
116 copy_rc(rc, outrc);
117 return 0;
118}
119
123 struct StartJobResponse *out)
124{
126 int argc = args.__sizeargv + 1;
127 char**argv;
128 int i;
129 argv = (char**)padico_malloc(sizeof(char*)*(argc+1));
132 argv[0] = padico_strdup(modname);
133 argv[argc] = NULL;
134 for(i=1; i<argc; i++)
135 argv[i] = padico_strdup(args.argv[i-1]);
136 padico_out(10, "StartJob %s\n", modname);
138 copy_rc(rc, out->outrc);
139 return 0;
140}
141
142
145{
147
148 padico_out(10, "ListModules\n");
151 return 0;
152}
153
154/* ***** SOAP group/topology methods *********************** */
155
160{
162 padico_print("creating group %s\n", groupID);
163 if(NULL != padico_group_lookup(groupID))
164 {
165 rc = padico_rc_error("cannot create group: groupID=**%s** already exists.", groupID);
166 }
167 else
168 {
170 int i;
171 padico_print("adding nodes to group %s\n", groupID);
172 for(i = 0; i < nodes.__sizenodes; i++)
173 {
174 char*nodeID = nodes.nodes[i];
176 padico_print("adding node %s to group %s\n", nodeID, groupID);
177 if(node == NULL)
178 {
179#if 0 /* XXX: establish a bridge- not implemented yet */
180 /* retry: establishes a bridge */
181 if(strchr(nodeID, ':') == NULL)
182 {
185 char*hostname = nodeID; /* trick: we assume that the nodeID may resolved into a hostID */
186 int soap_rc;
187 struct soap client_soap;
189 snprintf(server, SOAP_URL_MAXSIZE, "http://%s:%d/PadicoGatekeeper",
190 hostname, SOAP_DEFAULT_PORT);
191 padico_print("node %s not found-- trying %s\n",
192 nodeID, server);
193 /* get a bridge */
195 if(soap_rc)
196 {
197 padico_print("%s failed\n", server);
198 }
199 else
200 {
201 /* connect the bridge */
202 padico_print("connecting bridge to %s:%d.\n",
203 contact.hostID, contact.port);
207 padico_print("nodeID=%s solved into %p.\n",
208 nodeID, node);
209 }
211 }
212#endif /* XXX */
213 }
214 if(node != NULL)
215 {
217 }
218 else
219 {
220 rc = padico_rc_error("cannot add node **%s**: not recognized as a valid nodeID.", nodeID);
221 break;
222 }
223 }
225 {
227 }
228 }
229 copy_rc(rc, outrc);
230 return 0;
231}
232/*
233int padico_gatekeeper__GetGroupInfo(struct soap *soap,
234 padico_gatekeeper__groupID_t groupID,
235 struct GetGroupInfoResponse*out)
236{
237 padico_rc_t rc = NULL;
238 padico_group_t group = padico_group_lookup(groupID);
239 if(group != NULL)
240 {
241 padico_topo_node_vect_t nodes = group->nodes;
242 out->group.groupID = groupID;
243 out->group.node_list.__sizenodes = padico_node_vect_size(nodes);
244 out->group.node_list.nodes = padico_node_vect_begin(nodes);
245 }
246 else
247 {
248 rc = padico_rc_error("GetGroupInfo: group **%s** not found.", groupID);
249 }
250 copy_rc(rc, &out->rc);
251 return 0;
252}
253*/
256 struct GetNodeInfoResponse*out)
257{
260 if(node != NULL)
261 {
262 out->node.canonical_nodename = padico_topo_node_getname(node);
263#ifdef PADICO_MADIO
264 out->node.rank = padico_na_madio_getrank(node);
265#else
266 out->node.rank = 0;
267#endif
269 }
270 else
271 {
272 rc = padico_rc_error("GetNodeInfo: node **%s** not found.", nodeID);
273 }
274 copy_rc(rc, &out->rc);
275 return 0;
276}
277
283
286{
287 return -1; /* not implemented yet */
288 /*
289 out->port = padico_control_bridge_init();
290 out->hostID = padico_topo_hostname();
291 return 0;
292 */
293}
294
297 struct padico_gatekeeper__rc_t*out)
298{
299 return -1; /* not implemented yet */
300 /*
301 padico_rc_t rc = NULL;
302 padico_control_bridge_connect(contact.hostID, contact.port);
303 copy_rc(rc, out);
304 return 0;
305 */
306}
307
308
310 char*xml_command,
311 struct padico_gatekeeper__rc_t*out)
312{
313 struct puk_parse_entity_s pe;
314 padico_print("parsing: %s\n", xml_command);
316 padico_rc_show(pe.rc);
317 copy_rc(pe.rc, out);
318 return 0;
319}
320
321
322/* ***** Helper functions ********************************** */
323
325{
326 if(rc)
327 {
328 outrc->rc = rc->rc;
329 outrc->msg = padico_string_get(rc->msg);
330 }
331 else
332 {
333 outrc->rc = 0;
334 outrc->msg = NULL;
335 }
336}
337
338static int soap_gk_start(void)
339{
340 int rc = 0;
341 int m;
343
344 padico_trace("creating Gatekeeper on port %d\n", soap_port);
345 soap_init(&soap);
346 m = soap_bind(&soap, NULL, soap_port, 100);
347 if (m < 0)
348 {
350 rc = -1;
351 }
352 else
353 {
354 padico_print("MyURL=http://%s:%d/PadicoGatekeeper\n",
356 }
357 return rc;
358}
359
360static void* soap_gk_worker(void*dummy)
361{
362 int s;
363 padico_trace("starting Gatekeeper\n");
364 for ( ; ; )
365 {
366 s = soap_accept(&soap);
367 padico_trace("Socket connection successful: slave socket = %d\n", s);
368 if (s < 0)
369 {
370 padico_warning("SOAP fault: s=%d\n", s);
372 }
373 else
374 {
376 soap_end(&soap);
377 }
378 }
379 return NULL;
380}
381
382/* **** SOAP-Gatekeeper module entry points **************** */
383
384
386
387static int soap_gk_init(void)
388{
389 int rc;
390 rc = soap_gk_start();
391 if(!rc)
392 {
394 }
395 return rc;
396}
397
398static void soap_gk_stop(void)
399{
400 padico_out(10, "stop %s\n", padico_topo_nodename());
401 if(soap_gk_tid)
403 /* TODO: actually kill the thread. */
404}
#define SOAP_DEFAULT_PORT
return NULL
Definition Shm.h:88
uintptr_t s
Definition Shm.h:88
static int soap_port
Definition bench_SOAP.c:29
static padico_group_t group
static int done
Definition console-mod.c:49
padico_topo_node_vect_t nodes
static int server()
Definition datacheck.c:179
void padico_tm_exit(void)
unsigned int padico_tm_sleep(unsigned long seconds)
Definition tm-boot.c:389
padico_rc_t padico_tm_mod_action_args(enum padico_mtask_kind_e kind, const char *mod_name, int argc, char **argv)
Definition tm-mod.c:46
padico_rc_t rc
Definition PadicoTM.h:146
static padico_rc_t padico_tm_mod_action(enum padico_mtask_kind_e kind, const char *mod_name)
Definition PadicoTM.h:254
@ PADICO_TM_MOD_LOAD
Definition PadicoTM.h:200
@ PADICO_TM_MOD_RUN
Definition PadicoTM.h:202
@ PADICO_TM_MOD_UNLOAD
Definition PadicoTM.h:201
#define padico_topo_nodename()
Definition Topology.h:317
const char * padico_topo_node_getname(padico_topo_node_t node)
Get the canonical name of a node.
Definition topology.c:1917
padico_topo_host_t padico_topo_node_gethost(padico_topo_node_t node)
Get the host hosting a node.
Definition topology.c:1927
#define padico_topo_getlocalhost()
Definition Topology.h:319
padico_topo_node_t padico_topo_getnodebyname(const char *nodename)
node lookup, by node name
Definition topology.c:2389
const char * padico_topo_host_getname(padico_topo_host_t host)
Get the canonical name of a host.
Definition topology.c:1944
padico_topo_node_t node
Definition na-control.c:65
padico_group_t padico_group_init(const char *id)
Definition na-group.c:208
void padico_group_publish(padico_group_t group)
Publishes a group to its members.
Definition na-group.c:295
void padico_group_node_add(padico_group_t g, padico_topo_node_t node)
Definition na-group.c:233
padico_group_t padico_group_lookup(const char *id)
Definition na-group.c:225
padico_topo_network_t network
Definition psp-mx.c:113
static void copy_rc(padico_rc_t rc, struct padico_gatekeeper__rc_t *outrc)
int padico_gatekeeper__LoadModule(struct soap *soap, padico_gatekeeper__modID_t modname, struct padico_gatekeeper__rc_t *outrc)
Definition soap_gk-mod.c:76
static puk_opt_type_int_t padico_module_attr_port_getvalue(void)
Definition soap_gk-mod.c:57
int padico_gatekeeper__CreateGroup(struct soap *soap, padico_gatekeeper__groupID_t groupID, struct padico_gatekeeper__nodeID_list_s nodes, struct padico_gatekeeper__rc_t *outrc)
int padico_gatekeeper__RunModule(struct soap *soap, padico_gatekeeper__modID_t modname, struct padico_gatekeeper__job_args_s args, struct padico_gatekeeper__rc_t *outrc)
Definition soap_gk-mod.c:98
int padico_gatekeeper__Ping(struct soap *soap, struct padico_gatekeeper__rc_t *outrc)
Definition soap_gk-mod.c:61
int padico_gatekeeper__BridgeConnect(struct soap *soap, struct padico_gatekeeper__cluster_contact_s contact, struct padico_gatekeeper__rc_t *out)
static void soap_gk_stop(void)
int padico_gatekeeper__ListModules(struct soap *soap, struct padico_gatekeeper__mod_list_s *outlist)
static pthread_t soap_gk_tid
static int soap_gk_start(void)
static void * soap_gk_worker(void *)
int padico_gatekeeper__GetLocalNetworkInfo(struct soap *soap, struct padico_gatekeeper__network_s *network)
static int soap_gk_init(void)
#define SOAP_URL_MAXSIZE
Definition soap_gk-mod.c:45
int padico_gatekeeper__UnloadModule(struct soap *soap, padico_gatekeeper__modID_t modname, struct padico_gatekeeper__rc_t *outrc)
Definition soap_gk-mod.c:87
int padico_gatekeeper__StartJob(struct soap *soap, padico_gatekeeper__modID_t modname, struct padico_gatekeeper__job_args_s args, struct StartJobResponse *out)
int padico_gatekeeper__GetNodeInfo(struct soap *soap, padico_gatekeeper__nodeID_t nodeID, struct GetNodeInfoResponse *out)
int padico_gatekeeper__Kill(struct soap *soap, struct padico_gatekeeper__rc_t *outrc)
Definition soap_gk-mod.c:68
static struct soap soap
Definition soap_gk-mod.c:53
int padico_gatekeeper__BridgeInit(struct soap *soap, struct padico_gatekeeper__cluster_contact_s *out)
int padico_gatekeeper__RawXMLCommand(struct soap *soap, char *xml_command, struct padico_gatekeeper__rc_t *out)
char * padico_gatekeeper__modID_t
a module ID- currently, a string
Definition soap_gk.h:57
char * padico_gatekeeper__nodeID_t
Definition soap_gk.h:128
char * padico_gatekeeper__groupID_t
Definition soap_gk.h:131
arguments for new jobs
Definition soap_gk.h:61
return code- mapping for padico_rc_t
Definition soap_gk.h:39
a group of nodes
Definition na-group.c:43
static int port
Definition vrp-test.c:15