impossible to mesure the latency this way (needs one byte-long tests)
WARNING: this changes the amok_bw_* function semantic. [MQ]
- Implements the link saturation stuff. [MQ]
- * Host management module:
+ * Peer management module:
New! module factorizing code that we wrote over and over [MQ].
XBT:
stdio may need to include it by themselves. [AL]
* Fixed xbt/log.h. A missing SG_BEGIN_DECL prevented compilation with
g++. [AL]
+ * Renamed xbt_host_t into xbt_peer_t since it betterly describes what I
+ meant. This breaks the API of AMOK and of xbt/config. Sorry about this,
+ but I guess that almost nobody used those parts.
--
@top_srcdir@/src/gras/Virtu \
@top_srcdir@/src/amok \
@top_srcdir@/src/amok/Bandwidth \
- @top_srcdir@/src/amok/HostManagement \
+ @top_srcdir@/src/amok/PeerManagement \
@top_srcdir@/src/simdag
# If the value of the INPUT tag contains directories, you can use the
xbt/graph.c \
xbt/set.c \
xbt/xbt_matrix.c \
- xbt/xbt_host.c \
+ xbt/xbt_peer.c \
xbt/module.c \
xbt/config.c \
xbt/cunit.c \
AMOK_SRC= \
amok/base.c \
amok/Bandwidth/bandwidth.c amok/Bandwidth/saturate.c \
- amok/HostManagement/hostmanagement.c
+ amok/PeerManagement/peermanagement.c
###
### Testing infrastructure
/* Build the Bandwidth datatype descriptions */
bw_request_desc = gras_datadesc_struct("s_bw_request_t");
- gras_datadesc_struct_append(bw_request_desc,"host",
- gras_datadesc_by_name("s_xbt_host_t"));
+ gras_datadesc_struct_append(bw_request_desc,"peer",
+ gras_datadesc_by_name("s_xbt_peer_t"));
gras_datadesc_struct_append(bw_request_desc,"buf_size",
gras_datadesc_by_name("unsigned long int"));
gras_datadesc_struct_append(bw_request_desc,"exp_size",
request->buf_size=buf_size;
request->exp_size=exp_size;
request->msg_size=msg_size;
- request->host.name = NULL;
- request->host.port = gras_socket_my_port(measMasterIn);
+ request->peer.name = NULL;
+ request->peer.port = gras_socket_my_port(measMasterIn);
DEBUG5("Handshaking with %s:%d to connect it back on my %d (expsize=%ld byte= %ld b)",
- gras_socket_peer_name(peer),gras_socket_peer_port(peer), request->host.port,
+ gras_socket_peer_name(peer),gras_socket_peer_port(peer), request->peer.port,
buf_size,request->buf_size);
TRY {
TRY {
measOut=gras_socket_client_ext(gras_socket_peer_name(peer),
- request_ack->host.port,
+ request_ack->peer.port,
request->buf_size,1);
} CATCH(e) {
RETHROW2("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
- gras_socket_peer_name(peer),request_ack->host.port);
+ gras_socket_peer_name(peer),request_ack->peer.port);
}
DEBUG1("Got ACK; conduct the experiment (msg_size=%ld)",request->msg_size);
static xbt_dynar_t msgtwaited=NULL;
DEBUG5("Handshaked to connect to %s:%d (sizes: buf=%lu exp=%lu msg=%lu)",
- gras_socket_peer_name(expeditor),request->host.port,
+ gras_socket_peer_name(expeditor),request->peer.port,
request->buf_size,request->exp_size,request->msg_size);
/* Build our answer */
answer->buf_size=request->buf_size;
answer->exp_size=request->exp_size;
answer->msg_size=request->msg_size;
- answer->host.port=gras_socket_my_port(measMasterIn);
+ answer->peer.port=gras_socket_my_port(measMasterIn);
TRY {
gras_msg_rpcreturn(60,ctx,&answer);
/* Don't connect asap to leave time to other side to enter the accept() */
TRY {
measOut = gras_socket_client_ext(gras_socket_peer_name(expeditor),
- request->host.port,
+ request->peer.port,
request->buf_size,1);
} CATCH(e) {
RETHROW2("Error encountered while opening a measurement socket back to %s:%d : %s",
- gras_socket_peer_name(expeditor),request->host.port);
+ gras_socket_peer_name(expeditor),request->peer.port);
/* FIXME: tell error to remote */
}
TRY {
measIn = gras_socket_meas_accept(measMasterIn);
DEBUG4("BW handshake answered. buf_size=%lu exp_size=%lu msg_size=%lu port=%d",
- answer->buf_size,answer->exp_size,answer->msg_size,answer->host.port);
+ answer->buf_size,answer->exp_size,answer->msg_size,answer->peer.port);
} CATCH(e) {
gras_socket_close(measMasterIn);
gras_socket_close(measIn);
}
/**
- * \brief request a bandwidth measurement between two remote hosts
+ * \brief request a bandwidth measurement between two remote peers
*
- * \arg from_name: Name of the first host
+ * \arg from_name: Name of the first peer
* \arg from_port: port on which the first process is listening for messages
- * \arg to_name: Name of the second host
+ * \arg to_name: Name of the second peer
* \arg to_port: port on which the second process is listening (for messages, do not
* give a measurement socket here. The needed measurement sockets will be created
* automatically and negociated between the peers)
* \arg sec: where the result (in seconds) should be stored.
* \arg bw: observed Bandwidth (in byte/s)
*
- * Conduct a bandwidth test from the process from_host:from_port to to_host:to_port.
+ * Conduct a bandwidth test from the process from_peer:from_port to to_peer:to_port.
* This call is blocking until the end of the experiment.
*
* Results are reported in last args, and sizes are in bytes.
request->msg_size=msg_size;
request->min_duration = min_duration;
- request->host.name = (char*)to_name;
- request->host.port = to_port;
+ request->peer.name = (char*)to_name;
+ request->peer.port = to_port;
sock = gras_socket_client(from_name,from_port);
DEBUG4("Ask for a BW test between %s:%d and %s:%d", from_name,from_port, to_name,to_port);
asker=gras_msg_cb_ctx_from(ctx);
VERB4("Asked by %s:%d to conduct a bw XP with %s:%d",
gras_socket_peer_name(asker),gras_socket_peer_port(asker),
- request->host.name,request->host.port);
- peer = gras_socket_client(request->host.name,request->host.port);
+ request->peer.name,request->peer.port);
+ peer = gras_socket_client(request->peer.name,request->peer.port);
amok_bw_test(peer,
request->buf_size,request->exp_size,request->msg_size,
request->min_duration,
gras_os_sleep(1);
gras_socket_close(peer); /* FIXME: it should be blocking in RL until everything is sent */
- free(request->host.name);
+ free(request->peer.name);
free(request);
free(result);
}
/** \brief builds a matrix of results of bandwidth measurement */
-double * amok_bw_matrix(xbt_dynar_t hosts,
+double * amok_bw_matrix(xbt_dynar_t peers,
int buf_size_bw, int exp_size_bw, int msg_size_bw,
double min_duration) {
double sec;
/* construction of matrices for bandwith and latency */
- int i,j,len=xbt_dynar_length(hosts);
+ int i,j,len=xbt_dynar_length(peers);
double *matrix_res = xbt_new0(double, len*len);
- xbt_host_t h1,h2;
+ xbt_peer_t p1,p2;
- xbt_dynar_foreach (hosts,i,h1) {
- xbt_dynar_foreach (hosts,j,h2) {
+ xbt_dynar_foreach (peers,i,p1) {
+ xbt_dynar_foreach (peers,j,p2) {
if (i!=j) {
/* Mesurements of Bandwidth */
- amok_bw_request(h1->name,h1->port,h2->name,h2->port,
+ amok_bw_request(p1->name,p1->port,p2->name,p2->port,
buf_size_bw,exp_size_bw,msg_size_bw,min_duration,
&sec,&matrix_res[i*len + j]);
}
***/
/* Request for a BW experiment.
- * If host==NULL, it should be between the sender and the receiver.
- * If not, it should be between between the receiver and host (3-tiers).
+ * If peer==NULL, it should be between the sender and the receiver.
+ * If not, it should be between between the receiver and peer (3-tiers).
*/
typedef struct {
- s_xbt_host_t host; /* host+raw socket to use */
+ s_xbt_peer_t peer; /* peer+raw socket to use */
unsigned long int buf_size;
unsigned long int exp_size;
unsigned long int msg_size;
* Saturation stuff
***/
-/* Description of a saturation experiment (payload asking some host to collaborate for that)
+/* Description of a saturation experiment (payload asking some peer to collaborate for that)
*/
typedef struct {
- s_xbt_host_t host; /* host+raw socket to use */
+ s_xbt_peer_t peer; /* peer+raw socket to use */
unsigned int msg_size;
unsigned int duration;
} s_sat_request_t,*sat_request_t;
/* Build the saturation datatype descriptions */
sat_request_desc = gras_datadesc_struct("s_sat_request_desc_t");
- gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("s_xbt_host_t"));
+ gras_datadesc_struct_append(sat_request_desc,"peer",gras_datadesc_by_name("s_xbt_peer_t"));
gras_datadesc_struct_append(sat_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(sat_request_desc,"duration",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_close(sat_request_desc);
/**
* @brief Ask 'from_name:from_port' to stop saturating going to to_name:to_name.
*
- * @param from_name: Name of the host we are asking to do a experiment with (to_name:to_port)
+ * @param from_name: Name of the peer we are asking to do a experiment with (to_name:to_port)
* @param from_port: port on which the process we are asking for an experiment is listening
* (for message, do not give a raw socket here. The needed raw socket will be negociated
* between the peers)
- * @param to_name: Name of the host with which we should conduct the experiment
+ * @param to_name: Name of the peer with which we should conduct the experiment
* @param to_port: port on which the peer process is listening for message
* @param msg_size: Size of each message sent.
* @param duration: How long in maximum should be the saturation.
sock = gras_socket_client(from_name,from_port);
- request->host.name = (char*)to_name;
- request->host.port = to_port;
+ request->peer.name = (char*)to_name;
+ request->peer.port = to_port;
request->duration=duration;
request->msg_size=msg_size;
VERB4("Asked by %s:%d to start a saturation to %s:%d",
gras_socket_peer_name(expeditor),gras_socket_peer_port(expeditor),
- request->host.name,request->host.port);
+ request->peer.name,request->peer.port);
gras_msg_rpcreturn(60,ctx, NULL);
- amok_bw_saturate_begin(request->host.name,request->host.port,
+ amok_bw_saturate_begin(request->peer.name,request->peer.port,
request->msg_size, request->duration,
NULL,NULL);
- free(request->host.name);
+ free(request->peer.name);
free(request);
return 1;
}
* @brief Start saturating between the current process and the designated peer
*
* Note that the only way to break this function before the end of the timeout
- * is to have a remote host calling amok_bw_saturate_stop to this process.
+ * is to have a remote peer calling amok_bw_saturate_stop to this process.
*
* If duration=0, the experiment will never timeout (you then have to manually
* stop it).
request->msg_size = msg_size;
request->duration = duration;
- request->host.name = NULL;
- request->host.port = 0;
+ request->peer.name = NULL;
+ request->peer.port = 0;
/* Size autodetection on need */
if (!msg_size) {
&request);
free(request);
gras_msg_rpc_async_wait(ctx,&request);
- meas=gras_socket_client_ext( to_name, request->host.port,
+ meas=gras_socket_client_ext( to_name, request->peer.port,
0 /*bufsize: auto*/,
1 /*meas: true*/);
free(request);
if (measMaster == NULL)
port++; /* prepare for a new loop */
}
- answer->host.port=port;
+ answer->peer.port=port;
gras_msg_rpcreturn(60, ctx, &answer);
free(answer);
/**
* @brief Ask 'from_name:from_port' to stop any saturation experiments
- * @param from_name: Name of the host we are asking to do a experiment with (to_name:to_port)
+ * @param from_name: Name of the peer we are asking to do a experiment with (to_name:to_port)
* @param from_port: port on which the process we are asking for an experiment is listening
* @param time: the duration of the experiment
* @param bw: the achieved bandwidth
/* $Id$ */
-/* amok host management - servers main loop and remote host stopping */
+/* amok peer management - servers main loop and remote peer stopping */
/* Copyright (c) 2006 Martin Quinson. All rights reserved. */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
-#include "xbt/host.h"
-#include "amok/hostmanagement.h"
+#include "xbt/peer.h"
+#include "amok/peermanagement.h"
#include "gras/Virtu/virtu_interface.h" /* libdata */
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok_hm,amok,"Host management");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok_hm,amok,"peer management");
/* libdata management */
xbt_dynar_t group = xbt_dict_get(g->groups, name);
gras_socket_t exp = gras_msg_cb_ctx_from(ctx);
- xbt_host_t dude = xbt_host_new(gras_socket_peer_name(exp),
+ xbt_peer_t dude = xbt_peer_new(gras_socket_peer_name(exp),
gras_socket_peer_port(exp));
VERB2("Contacted by %s:%d",dude->name,dude->port);
xbt_dynar_t group = xbt_dict_get(g->groups, name);
gras_socket_t exp = gras_msg_cb_ctx_from(ctx);
- xbt_host_t dude = xbt_host_new(gras_socket_peer_name(exp),
+ xbt_peer_t dude = xbt_peer_new(gras_socket_peer_name(exp),
gras_socket_peer_port(exp));
int cpt;
- xbt_host_t host_it;
+ xbt_peer_t peer_it;
- xbt_dynar_foreach(group, cpt, host_it) {
- if (!strcmp(host_it->name, dude->name) &&
- host_it->port == dude->port) {
+ xbt_dynar_foreach(group, cpt, peer_it) {
+ if (!strcmp(peer_it->name, dude->name) &&
+ peer_it->port == dude->port) {
xbt_dynar_cursor_rm (group,&cpt);
goto end;
}
/* Initialization stuff */
static short amok_hm_used = 0;
-/** \brief Initialize the host management module. Every process must run it before use */
+/** \brief Initialize the peer management module. Every process must run it before use */
void amok_hm_init() {
/* pure INIT part */
if (! amok_hm_used) {
&amok_hm_cb_shutdown);
}
-/** \brief Finalize the host management module. Every process should run it after use */
+/** \brief Finalize the peer management module. Every process should run it after use */
void amok_hm_exit() {
/* pure EXIT part */
amok_hm_used--;
}
}
-/** \brief kill a buddy identified by its hostname and port */
+/** \brief kill a buddy identified by its peername and port */
void amok_hm_kill_hp(char *name,int port) {
gras_socket_t sock=gras_socket_client(name,port);
amok_hm_kill(sock);
}
-/** \brief create a new hostmanagement group located on local host
+/** \brief create a new peermanagement group located on local peer
*
- * The dynar elements are of type xbt_host_t
+ * The dynar elements are of type xbt_peer_t
*/
xbt_dynar_t amok_hm_group_new(const char *group_name) {
amok_hm_libdata_t g;
- xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_host_t),
- xbt_host_free_voidp);
+ xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_peer_t),
+ xbt_peer_free_voidp);
xbt_assert0(amok_hm_libdata_id != -1,"Run amok_hm_init first!");
g=gras_libdata_by_id(amok_hm_libdata_id);
return res;
}
-/** \brief add current host to the given remote group */
+/** \brief add current peer to the given remote group */
void amok_hm_group_join(gras_socket_t master, const char *group_name) {
VERB3("Join group '%s' on %s:%d",
group_name,gras_socket_peer_name(master),gras_socket_peer_port(master));
VERB3("Joined group '%s' on %s:%d",
group_name,gras_socket_peer_name(master),gras_socket_peer_port(master));
}
-/** \brief remove current host from the given remote group if found
+/** \brief remove current peer from the given remote group if found
*
* If not found, call is ignored
*/
xbt_dynar_t group = xbt_dict_get(g->groups, group_name);
int cpt;
- xbt_host_t host_it;
+ xbt_peer_t peer_it;
- xbt_dynar_foreach(group, cpt, host_it) {
- amok_hm_kill_hp(host_it->name, host_it->port);
+ xbt_dynar_foreach(group, cpt, peer_it) {
+ amok_hm_kill_hp(peer_it->name, peer_it->port);
}
xbt_dynar_free(&group);
gras_datadesc_struct_close(ddt);
- /* specific datatype: xbt_host_t */
- ddt = gras_datadesc_struct("s_xbt_host_t");
+ /* specific datatype: xbt_peer_t */
+ ddt = gras_datadesc_struct("s_xbt_peer_t");
gras_datadesc_struct_append(ddt,"name",gras_datadesc_by_name("string"));
gras_datadesc_struct_append(ddt,"port",gras_datadesc_by_name("int"));
gras_datadesc_struct_close(ddt);
- ddt = gras_datadesc_ref("xbt_host_t",ddt);
+ ddt = gras_datadesc_ref("xbt_peer_t",ddt);
/* Dict containing the constant value (for the parsing macro) */
gras_dd_constants = xbt_dict_new();
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/ex.h"
-#include "xbt/host.h"
+#include "xbt/peer.h"
#include "portable.h"
#include "gras/Transport/transport_private.h"
/** @brief Opens a client socket to a remote host specified as '\a host:\a port' */
gras_socket_t
gras_socket_client_from_string(const char *host) {
- xbt_host_t h = xbt_host_from_string(host);
- gras_socket_t res = gras_socket_client_ext(h->name,h->port,0,0);
- xbt_host_free(h);
+ xbt_peer_t p = xbt_peer_from_string(host);
+ gras_socket_t res = gras_socket_client_ext(p->name,p->port,0,0);
+ xbt_peer_free(p);
return res;
}
#include "xbt/ex.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
-#include "xbt/host.h"
+#include "xbt/peer.h"
#include "xbt/config.h" /* prototypes of this module */
xbt_cfg_cb_t cb_rm;
/* actual content
- (cannot be an union because type host uses both str and i) */
+ (cannot be an union because type peer uses both str and i) */
xbt_dynar_t content;
} s_xbt_cfgelm_t,*xbt_cfgelm_t;
static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count]=
- {"int","double","string","host","any"};
+ {"int","double","string","peer","any"};
/* Internal stuff used in cache to free a variable */
static void xbt_cfgelm_free(void *data);
int ival;
char *sval;
double dval;
- xbt_host_t hval;
+ xbt_peer_t hval;
if (name)
printf("%s>> Dumping of the config set '%s':\n",indent,name);
}
break;
- case xbt_cfgelm_host:
+ case xbt_cfgelm_peer:
for (i=0; i<size; i++) {
- hval = xbt_dynar_get_as(variable->content,i,xbt_host_t);
+ hval = xbt_dynar_get_as(variable->content,i,xbt_peer_t);
printf ("%s %s:%d\n",indent,hval->name,hval->port);
}
break;
int found=0;
xbt_assert(cfg);
- xbt_assert4(type>=xbt_cfgelm_int && type<=xbt_cfgelm_host,
+ xbt_assert4(type>=xbt_cfgelm_int && type<=xbt_cfgelm_peer,
"type of %s not valid (%d should be between %d and %d)",
- name,type,xbt_cfgelm_int, xbt_cfgelm_host);
+ name,type,xbt_cfgelm_int, xbt_cfgelm_peer);
DEBUG5("Register cfg elm %s (%d to %d %s (=%d))",
name,min,max,xbt_cfgelm_type_name[type],type);
TRY {
res->content = xbt_dynar_new(sizeof(char*),&xbt_cfg_str_free);
break;
- case xbt_cfgelm_host:
- res->content = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
+ case xbt_cfgelm_peer:
+ res->content = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp);
break;
default:
*
* The string may consist in several variable descriptions separated by a space.
* Each of them must use the following syntax: \<name\>:\<min nb\>_to_\<max nb\>_\<type\>
- * with type being one of 'string','int', 'host' or 'double'.
+ * with type being one of 'string','int', 'peer' or 'double'.
*/
void
type++);
xbt_assert2(type < xbt_cfgelm_type_count,
"Invalid type in config element descriptor: %s%s",entry,
- "; Should be one of 'string', 'int', 'host' or 'double'.");
+ "; Should be one of 'string', 'int', 'peer' or 'double'.");
xbt_cfg_register(cfg,entrycpy,type,min,max,NULL,NULL);
}
switch (type) {
- case xbt_cfgelm_host:
+ case xbt_cfgelm_peer:
str = va_arg(pa, char *);
i=va_arg(pa,int);
- xbt_cfg_set_host(cfg,name,str,i);
+ xbt_cfg_set_peer(cfg,name,str,i);
break;
case xbt_cfgelm_string:
xbt_cfg_set_double(cfg,name,d); /* throws */
break;
- case xbt_cfgelm_host:
+ case xbt_cfgelm_peer:
str=val;
val=strchr(val,':');
if (!val) {
free(optionlist_cpy);
xbt_assert1(FALSE,
- "Value of option %s not valid. Should be an host (machine:port)",
+ "Value of option %s not valid. Should be an peer (machine:port)",
name);
}
if (val==NULL) {
free(optionlist_cpy);
xbt_assert1(FALSE,
- "Value of option %s not valid. Should be an host (machine:port)",
+ "Value of option %s not valid. Should be an peer (machine:port)",
name);
}
- xbt_cfg_set_host(cfg,name,str,i); /* throws */
+ xbt_cfg_set_peer(cfg,name,str,i); /* throws */
break;
default:
(*variable->cb_set)(name, xbt_dynar_length(variable->content) -1);
}
-/** @brief Set or add an host value to \a name within \a cfg
+/** @brief Set or add an peer value to \a name within \a cfg
*
* \arg cfg the config set
* \arg name the name of the variable
- * \arg host the host
+ * \arg peer the peer
* \arg port the port number
*
- * \e host values are composed of a string (hostname) and an integer (port)
+ * \e peer values are composed of a string (peername) and an integer (port)
*/
void
-xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
- const char *host,int port) {
+xbt_cfg_set_peer(xbt_cfg_t cfg,const char*name,
+ const char *peer,int port) {
xbt_cfgelm_t variable;
- xbt_host_t val=xbt_host_new(host,port);
+ xbt_peer_t val=xbt_peer_new(peer,port);
- VERB3("Configuration setting: %s=%s:%d",name,host,port);
+ VERB3("Configuration setting: %s=%s:%d",name,peer,port);
- variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
+ variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_peer);
if (variable->max == 1) {
if (variable->cb_rm && xbt_dynar_length(variable->content))
if (variable->max && xbt_dynar_length(variable->content) == variable->max)
THROW4(mismatch_error,0,
"Cannot add value %s:%d to the config element %s since it's already full (size=%d)",
- host,port,name,variable->max);
+ peer,port,name,variable->max);
xbt_dynar_push(variable->content,&val);
}
"Can't remove the value %s of config element %s: value not found.",val,name);
}
-/** @brief Remove the provided \e val host value from a variable
+/** @brief Remove the provided \e val peer value from a variable
*
* \arg cfg the config set
* \arg name the name of the variable
- * \arg host the hostname
+ * \arg peer the peername
* \arg port the port number
*/
void
-xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) {
+xbt_cfg_rm_peer(xbt_cfg_t cfg,const char*name, const char *peer,int port) {
xbt_cfgelm_t variable;
int cpt;
- xbt_host_t seen;
+ xbt_peer_t seen;
- variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
+ variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_peer);
if (xbt_dynar_length(variable->content) == variable->min)
THROW4(mismatch_error,0,
"Cannot remove value %s:%d from the config element %s since it's already at its minimal size (=%d)",
- host,port,name,variable->min);
+ peer,port,name,variable->min);
xbt_dynar_foreach(variable->content,cpt,seen) {
- if (!strcpy(seen->name,host) && seen->port == port) {
+ if (!strcpy(seen->name,peer) && seen->port == port) {
if (variable->cb_rm) (*variable->cb_rm)(name, cpt);
xbt_dynar_cursor_rm(variable->content,&cpt);
return;
THROW3(not_found_error,0,
"Can't remove the value %s:%d of config element %s: value not found.",
- host,port,name);
+ peer,port,name);
}
/** @brief Remove the \e pos th value from the provided variable */
return xbt_dynar_get_as(variable->content, 0, char *);
}
-/** @brief Retrieve an host value of a variable (get a warning if not uniq)
+/** @brief Retrieve an peer value of a variable (get a warning if not uniq)
*
* \arg cfg the config set
* \arg name the name of the variable
- * \arg host the host
+ * \arg peer the peer
* \arg port the port number
*
* Returns the first value from the config set under the given name.
* \warning the returned value is the actual content of the config set
*/
-void xbt_cfg_get_host (xbt_cfg_t cfg, const char *name,
- char **host, int *port) {
+void xbt_cfg_get_peer (xbt_cfg_t cfg, const char *name,
+ char **peer, int *port) {
xbt_cfgelm_t variable;
- xbt_host_t val;
+ xbt_peer_t val;
- variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
+ variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_peer);
if (xbt_dynar_length(variable->content) > 1) {
WARN2("You asked for the first value of the config element '%s', but there is %lu values\n",
name, xbt_dynar_length(variable->content));
}
- val = xbt_dynar_get_as(variable->content, 0, xbt_host_t);
- *host=val->name;
+ val = xbt_dynar_get_as(variable->content, 0, xbt_peer_t);
+ *peer=val->name;
*port=val->port;
}
return xbt_dynar_get_as(variable->content, pos, char*);
}
-/** @brief Retrieve one of the host value of a variable */
+/** @brief Retrieve one of the peer value of a variable */
void
-xbt_cfg_get_host_at(xbt_cfg_t cfg, const char *name, int pos,
- char **host, int *port) {
+xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name, int pos,
+ char **peer, int *port) {
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
- xbt_host_t val = xbt_dynar_get_ptr(variable->content, pos);
+ xbt_peer_t val = xbt_dynar_get_ptr(variable->content, pos);
*port = val->port;
- *host = val->name;
+ *peer = val->name;
}
set = xbt_cfg_new();
xbt_cfg_register_str(set,"speed:1_to_2_int");
- xbt_cfg_register_str(set,"hostname:1_to_1_string");
+ xbt_cfg_register_str(set,"peername:1_to_1_string");
xbt_cfg_register_str(set,"user:1_to_10_string");
return set;
XBT_TEST_UNIT("memuse",test_config_memuse,"Alloc and free a config set") {
xbt_cfg_t set=make_set();
xbt_test_add0("Alloc and free a config set");
- xbt_cfg_set_parse(set, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
+ xbt_cfg_set_parse(set, "peername:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
xbt_cfg_free(&set);
xbt_cfg_free(&set);
}
xbt_ex_t e;
xbt_test_add0("Having too few elements for speed");
- xbt_cfg_set_parse(set, "hostname:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
+ xbt_cfg_set_parse(set, "peername:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
TRY {
xbt_cfg_check(set);
} CATCH(e) {
xbt_test_add0("Having too much values of 'speed'");
set=make_set();
- xbt_cfg_set_parse(set,"hostname:toto:42 user:alegrand");
+ xbt_cfg_set_parse(set,"peername:toto:42 user:alegrand");
TRY {
xbt_cfg_set_parse(set,"speed:42 speed:24 speed:34");
} CATCH(e) {
int ival;
xbt_cfg_t myset=make_set();
- xbt_cfg_set_parse(myset,"hostname:toto:42 speed:42");
+ xbt_cfg_set_parse(myset,"peername:toto:42 speed:42");
ival = xbt_cfg_get_int(myset,"speed");
if (ival != 42)
xbt_test_fail1("Speed value = %d, I expected 42",ival);
xbt_dynar_t dyn;
xbt_cfg_t myset=make_set();
- xbt_cfg_set_parse(myset, "hostname:veloce user:foo\nuser:bar\tuser:toto");
+ xbt_cfg_set_parse(myset, "peername:veloce user:foo\nuser:bar\tuser:toto");
xbt_cfg_set_parse(myset,"speed:42");
xbt_cfg_check(myset);
dyn = xbt_cfg_get_dynar(myset,"user");