PadicoTM

Documentation

« back to PM2 home.
control-twostep-selector.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
29#include <Padico/Puk.h>
30#include <Padico/Module.h>
31#include <Padico/PadicoTM.h>
32
33#include <Padico/NetSelector.h>
34#include <Padico/PadicoControl.h>
35#include <Padico/AddrDB.h>
36
37static int control_twostep_selector_init(void);
38static void control_twostep_selector_finalize(void);
39
41
61
64
65static struct
66{
67 struct twostep_selector_controler_hashtable_s table; /* routing table- hashtable: node -> controler descriptor */
69} twostep_selector = { .selector = NULL };
70
72
74
75
76/* ********************************************************* */
77
85
86/* ********************************************************* */
87
88
90
92{
93 padico_print("loading.\n");
94 twostep_selector.selector =
95 puk_component_declare("ControlTwoStepSelector",
96 puk_component_provides("ControlSelector", "selector", &control_twostep_selector_driver));
99 .xml_tag = "ControlTwoStepSelector:ConnectorNew",
101 .end_handler = NULL,
102 .required_level = PUK_TRUST_CONTROL
103 });
106 return 0;
107}
108
114
115/* ********************************************************** */
116/* *** ControlTwoStepSelector ******************************* */
117
123
126{
127 struct control_twostep_remote_node_s*remote = key;
129 {
130 padico_warning("advertise_new_node(): failed to setup the controler for node %s (%s).\n",
131 padico_topo_node_getname(remote->node), reply?padico_rc_gettext(reply):"unknown error");
132 }
133 else
134 {
135 padico_out(20, "Connection established.\n");
138 if(step_controler != NULL)
139 {
141 if(remote->controler != NULL)
142 {
143 step_controler->direct_controler = remote->controler;
144 padico_print("node=%s is now served by assembly %s.\n",
145 padico_topo_node_getname(remote->node), remote->controler->component->name);
146 }
147 else
148 {
149 padico_print("node=%s fall back on boostrap channel.\n", padico_topo_node_getname(remote->node));
150 }
151 }
153 }
155 padico_free(remote);
156}
157
159{
160 const char*s_remote_node = puk_parse_getattr(e, "node");
162 padico_print("received request from node = %s\n", (char*)padico_topo_node_getuuid(remote_node));
164 if(!remote_node)
165 {
166 rc = padico_rc_error("Connector: unknown node=%s.", s_remote_node);
167 goto error;
168 }
170 if(!step_controler)
171 {
172 rc = padico_rc_error("Connector: node=%s not in routing table.", s_remote_node);
173 goto error;
174 }
176 {
177 rc = padico_rc_error("Connector: node=%s already connected (or in progress).", s_remote_node);
178 goto error;
179 }
183 {
184 rc = padico_rc_error("Connector: node=%s- no suitable assembly found (PadicoControl, PadicoConnector).",
186 goto error;
187 }
191 if(r.driver == NULL)
192 {
193 rc = padico_rc_error("Connector: node=%s- assembly=%s has no 'PadicoConnector' facet.",
195 goto error;
196 }
198 *remote = (struct control_twostep_remote_node_s) {
200 .node = remote_node
201 };
202 /* padico_req_t req = padico_tm_req_new(&control_twostep_connector_notifier, remote); */
203 /* TODO: convert to new PadicoConnector with AddrDB */
204 /*
205 int rc2 = (*r.driver->connect)(r._status, req, remote_node);
206 if(rc2)
207 {
208 rc = padico_rc_error("Connector: node=%s- error while invoking connector->connect on %s.",
209 padico_topo_nodename(), component->name);
210 goto error;
211 }
212 */
213
214 error:
216 {
217 padico_warning("connector handler error: %s.\n", padico_rc_gettext(rc));
218 }
220}
221
222
223/* ********************************************************* */
224/* ** 'ControlSelector' facet */
225
227{
230 padico_out(50, "request for node=%s\n", padico_topo_node_getname(node));
233 {
234 padico_out(60, "selector step=%d\n", step_controler->step);
235 switch(step_controler->step)
236 {
238 {
240 puk_component_t controler =
242 if(controler)
243 padico_print("controler = %s\n", controler->name);
244 else
245 padico_print("controler = NULL\n");
246
247 if((controler != NULL) && (controler != step_controler->bootstrap_controler->component))
248 {
250 padico_out(20, "init remote connector (remote node=%s)..\n", padico_topo_node_getname(node));
252 *remote = (struct control_twostep_remote_node_s) {
254 .node = node
255 };
257 padico_string_catf(str_new, "<ControlTwoStepSelector:ConnectorNew node=\"%s\"/>", padico_topo_nodename());
262 padico_out(20, "connecting to remote node=%s...\n", padico_topo_node_getname(node));
263 /* padico_req_t req = padico_tm_req_new(&control_twostep_connector_notifier, remote); */
264 padico_print("sending request to remote node\n");
265 /* TODO: convert to new PadicoConnector with AddrDB */
266 /* (*r.driver->connect)(r._status, req, node); */
267 control_instance = step_controler->bootstrap_controler;
268 }
269 else
270 {
271 padico_print("no suitable assembly found (PadicoControl, PadicoConnector), stick on boostrap channel.\n");
272 step_controler->step = CONTROL_TWOSTEP_SELECTOR_DIRECT;
273 control_instance = step_controler->direct_controler;
274 }
275 padico_print("[%s] bootstrap = %s\n",
277 control_instance->component->name);
278 }
279 break;
280
281 case CONTROL_TWOSTEP_SELECTOR_INPROGRESS:
282 {
283 control_instance = step_controler->bootstrap_controler;
284 padico_print("[%s] inprogress = %s\n",
286 control_instance->component->name);
287 }
288 break;
289
290 case CONTROL_TWOSTEP_SELECTOR_DIRECT:
291 {
292 control_instance = step_controler->direct_controler;
293 padico_print("[%s] direct = %s\n",
295 control_instance->component->name);
296 }
297 break;
298
299 default:
300 break;
301 }
302 padico_out(50, "node served by assembly %s\n", control_instance->component->name);
303 }
304 else
305 {
306 padico_warning("no assembly found for control channel to node %s.\n",
308 }
310
311 return control_instance;
312}
313
314/* ********************************************************* */
315/* ** Topology events handler to update routing table */
316
318{
319 assert(controler != NULL);
320
322 if(step_controler == NULL)
323 {
326 step_controler->bootstrap_controler = controler;
328 padico_out(40, "init node event- new node *%s* served by %s\n",
329 padico_topo_node_getname(node), controler->component->name);
330 }
331}
332
334{
336 switch(event->kind)
337 {
339 {
341 const puk_instance_t controler = event->INIT_CONTROLER.controler;
344 {
346 }
347 }
348 break;
349
351 {
352 const padico_topo_node_t node = event->NODE.node;
353 const puk_instance_t controler = event->NODE.controler;
355 }
356 break;
357
359 {
360 const padico_topo_node_t node = event->NODE.node;
362 {
364 }
365 }
366 break;
367
368 default:
369 break;
370 }
371}
assert(slab_size > 0)
struct ns_rulebucket_hash_entry_s * e
const const struct ns_rule_bucket_s * key
return NULL
Definition Shm.h:88
int r
Definition Shm.h:88
static int done
Definition console-mod.c:49
padico_topo_node_vect_t nodes
puk_component_t component
component used for listening
puk_instance_t instance
the listening bootstrap instance
struct twostep_selector_controler_hash_entry_block_lfstack_s __attribute__
static puk_instance_t control_twostep_select_controler(padico_topo_node_t node)
static struct @20 twostep_selector
static void control_twostep_connector_new_handler(puk_parse_entity_t e)
static int control_twostep_selector_init(void)
struct twostep_selector_controler_hashtable_s table
static void control_twostep_selector_event_listener(void *arg)
puk_component_t selector
static void control_twostep_new_node(const puk_instance_t controler, const padico_topo_node_t node)
static void control_twostep_selector_finalize(void)
static const struct padico_control_selector_driver_s control_twostep_selector_driver
'ControlSelector' facet for the ControlTwoStepSelector component
puk_component_t padico_ns_serial_selector(padico_topo_node_t node, const char *profile, puk_iface_t iface)
static void padico_control_send_async(padico_topo_node_t node, const char *cmd, padico_task_notifier_t notify, void *key)
Send an async request on the control channel.
static void padico_control_event_enable(void)
static void padico_control_event_disable(void)
static void padico_control_event_unsubscribe(padico_event_listener_t l)
static void padico_control_event_subscribe(padico_event_listener_t l)
static puk_iface_t puk_iface_PadicoConnector(void)
static const struct padico_control_driver_s * puk_component_get_driver_PadicoControl(puk_component_t component, const char *label)
static void padico_control_unplug_selector(puk_component_t selector)
static void padico_control_plug_selector(puk_component_t selector)
static void puk_instance_indirect_PadicoConnector(puk_instance_t instance, const char *label, struct puk_receptacle_PadicoConnector_s *receptacle)
void * arg
Definition PadicoTM.h:167
padico_rc_t rc
Definition PadicoTM.h:146
#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
typdef struct padico_topo_node_vect_s * padico_topo_node_vect_t
Definition Topology.h:84
padico_topo_uuid_t padico_topo_node_getuuid(padico_topo_node_t node)
Get the UUID of a node.
Definition topology.c:1912
padico_topo_node_t padico_topo_getnodebyname(const char *nodename)
node lookup, by node name
Definition topology.c:2389
padico_topo_node_t node
Definition na-control.c:65
padico_topo_node_t remote_node
Definition psp-ibv.c:195
struct padico_control_event_s::@47::@49 INIT_CONTROLER
puk_instance_t controler
@ PADICO_CONTROL_EVENT_INIT_CONTROLER
initial event sent to new controlers to get the past events and current topology state
@ PADICO_CONTROL_EVENT_DELETE_NODE
a node was deleted/disconnected/became unreachable
@ PADICO_CONTROL_EVENT_NEW_NODE
a new node appeared in the known topology
padico_topo_node_vect_t nodes
Interface: "ControlSelector".
puk_instance_t(* router)(padico_topo_node_t node)
returns an instance with a PadicoControl facet
enum twostep_selector_controler_s::@21 step
marcel_cond_t event
Definition tm-boot.c:65