PadicoTM

Documentation

« back to PM2 home.
ns-netselector.c
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2026 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
31#include "NetSelector.h"
32
33#include <Padico/Module.h>
34#include <Padico/Puk.h>
35
36static int ns_netselector_init(void);
37static void ns_netselector_finalize(void);
38
40
41PADICO_MODULE_ATTR(selector, "PADICO_NETSELECTOR", "NetSelector configuration string", string,
42 "inet=NetSelector_inet_default;default=NetSelector_basic,NetSelector_besteffort;trk_small=NetSelector_basic,NetSelector_madico;trk_large=NetSelector_basic,NetSelector_madico");
43
44/* ********************************************************* */
45
46static const char default_profile[] = "default";
47
56
62
65
66static struct
67{
71
74
80
81
82/* ********************************************************* */
83
84static void ns_selector_load_profile(const char*profile)
85{
87 /* parse profiles */
88 char*saveptr = NULL;
89 char*p = strtok_r(selector, ";", &saveptr);
90 while(p != NULL)
91 {
92 char*s = padico_strdup(p);
93 char*saveptr2 = NULL;
94 char*profile_name = strtok_r(s, "=", &saveptr2);
95 if(profile_name == NULL)
96 {
97 padico_fatal("invalid NetSelector config string = %s; invalid profile name.\n",
99 }
100 padico_out(12, "resolving selectors for profile *%s*\n", profile_name);
102 char*saveptr3 = NULL;
103 char*c = strtok_r(profile_components, ",", &saveptr3);
104 while(c != NULL)
105 {
106 padico_out(12, "profile = %s; loading selector = %s\n", profile_name, c);
107 if(strcmp(profile, profile_name) == 0)
108 {
111 if((mod == NULL) || padico_rc_iserror(rc))
112 {
113 padico_out(puk_verbose_critical, "error while resolving NetSelector *%s*: %s\n",
116 }
117 else
118 {
121 {
122 padico_out(puk_verbose_critical, "error while loading NetSelector *%s*: %s\n",
125 }
126 }
127 }
128 c = strtok_r(NULL, ",", &saveptr3);
129 }
130 padico_free(s);
131 p = strtok_r(NULL, ";", &saveptr);
132 }
134}
135
136static int ns_netselector_init(void)
137{
138 puk_iface_register("NetSelector");
141 return 0;
142}
143
144static void ns_netselector_finalize(void)
145{
147}
148
149/* ********************************************************* */
150
158
180
183{
184 const char*profile = _profile?:default_profile;
188 padico_out(20, "remote peer node=%s- computing assembly for iface=%s; profile=%s.\n",
190 assert(peer != NULL);
192 {
194 if(selector && selector->serial)
196 if(assembly)
197 break;
198 }
199 if(!assembly)
200 padico_warning("profile = %s; iface = %s; peer = %s; *** cannot find any valid component\n",
202 else
203 padico_out(20, "profile = %s; assembly = %s\n", profile, assembly->name);
204 return assembly;
205}
206
208 puk_iface_t iface, uint16_t port, int protocol)
209{
210 const char*profile = _profile?:default_profile;
214 padico_out(20, "remote peer host=%s- computing assembly for iface=%s; profile=%s.\n",
217 {
219 if(selector && selector->host)
220 {
221 padico_out(20, "trying selector *%s*\n", selector->name);
222 assembly = (*selector->host)(host, profile, iface, port, protocol);
223 if(assembly)
224 {
225 padico_out(20, "got answer from selector *%s*\n", selector->name);
226 break;
227 }
228 }
229 }
230 padico_out(20, "profile = %s; assembly = %s\n", profile, assembly->name);
231 return assembly;
232}
233
234/* ********************************************************* */
235
237{
239 int already = 0;
240
242 marcel_mutex_lock(&nsdb.lock);
244 if(!v)
245 {
248 }
249 else
250 {
253 {
254 if(component == i->component)
255 {
256 already = 1;
257 }
258 }
259 }
260 if(!already)
261 {
262 const struct netselector_entry_s e =
263 {
264 .component = component
265 };
267 }
269}
270
274{
276 marcel_mutex_lock(&nsdb.lock);
280 {
282 marcel_mutex_lock(&nsdb.lock);
285 }
287 {
288 padico_fatal("no selector for profile *%s*; NetSelector config string: PADICO_NETSELECTOR = %s.\n",
290 }
291 return v;
292}
API for protocol selection in PadicoTM.
assert(slab_size > 0)
padico_topo_node_t const char * profile
puk_component_t assembly
Serial assembly used.
struct ns_rulebucket_hash_entry_s * e
padico_topo_node_t const char puk_iface_t iface
return NULL
Definition Shm.h:88
puk_tagged_ptr_t p
Definition Shm.h:88
uintptr_t s
Definition Shm.h:88
padico_topo_host_t host
static padico_topo_node_t peer
void *static bench_vect_buffer_queue_t v
Definition bench_vect.c:22
static int done
Definition console-mod.c:49
puk_component_t component
component used for listening
puk_component_t selector
puk_component_t padico_ns_serial_selector(padico_topo_node_t peer, const char *_profile, puk_iface_t iface)
static const struct padico_netselector_driver_s * puk_component_get_driver_NetSelector(puk_component_t component, const char *label)
Definition NetSelector.h:78
void padico_ns_selector_register(puk_component_t selector)
void padico_ns_selector_unregister(puk_component_t selector)
puk_component_t padico_ns_host_selector(padico_topo_host_t host, const char *_profile, puk_iface_t iface, uint16_t port, int protocol)
padico_rc_t rc
Definition PadicoTM.h:146
padico_topo_node_t padico_topo_getlocalnode(void)
Definition topology.c:1891
const char * padico_topo_node_getname(padico_topo_node_t node)
Get the canonical name of a node.
Definition topology.c:1917
const char * padico_topo_host_getname(padico_topo_host_t host)
Get the canonical name of a host.
Definition topology.c:1944
struct padico_netselector_driver_s driver
static struct @43 nsdb
pthread_mutex_t lock
lock for accessing the hashtable
static puk_opt_type_string_t padico_module_attr_selector_getvalue(void)
static void ns_netselector_entry_destructor(char *profile, struct netselector_entry_vect_s *v)
static int ns_netselector_init(void)
typdef struct netselector_entry_vect_s * netselector_entry_vect_t
const struct padico_netselector_driver_s * padico_netselector_driver_t
static void ns_selector_insert(puk_component_t component)
static void ns_selector_load_profile(const char *profile)
static padico_netselector_driver_t ns_netselector_driver(puk_component_t component)
static void ns_netselector_finalize(void)
static netselector_entry_vect_t ns_selector_lookup(const char *profile)
returns the known selector entries (vect) for a given profile
static const char default_profile[]
struct netselector_entry_hashtable_s table
table of known selectors [ key: profile; data: netselector_entry_vect_t ]
describes an entry in the selectors hashtable
puk_component_t component
the component for the given selector
NetSelector driver interface.
Definition NetSelector.h:62
const char * profile
name of the targeted profile
Definition NetSelector.h:67
const char * name
name of this NetSelector implementation
Definition NetSelector.h:64
static int port
Definition vrp-test.c:15