From: mquinson Date: Wed, 12 Jul 2006 11:59:59 +0000 (+0000) Subject: s/xbt_host_t/xbt_peer_t/ X-Git-Tag: v3.3~2819 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/be437b7fa306304527b4b99a22d4bd017586cd68 s/xbt_host_t/xbt_peer_t/ git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2539 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index f8bd2af3e0..8642b05039 100644 --- a/ChangeLog +++ b/ChangeLog @@ -57,7 +57,7 @@ SimGrid (3.1) unstable; urgency=low 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: @@ -79,6 +79,9 @@ SimGrid (3.1) unstable; urgency=low 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. -- diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 83d80673d9..235acfecdf 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -424,7 +424,7 @@ INPUT = @srcdir@/index.doc \ @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 diff --git a/src/Makefile.am b/src/Makefile.am index 348a37dffe..185e625140 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,7 +123,7 @@ COMMON_SRC=\ 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 \ @@ -184,7 +184,7 @@ SG_SRC= \ AMOK_SRC= \ amok/base.c \ amok/Bandwidth/bandwidth.c amok/Bandwidth/saturate.c \ - amok/HostManagement/hostmanagement.c + amok/PeerManagement/peermanagement.c ### ### Testing infrastructure diff --git a/src/amok/Bandwidth/bandwidth.c b/src/amok/Bandwidth/bandwidth.c index cbf0049d6f..74400db016 100644 --- a/src/amok/Bandwidth/bandwidth.c +++ b/src/amok/Bandwidth/bandwidth.c @@ -60,8 +60,8 @@ void amok_bw_bw_init() { /* 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", @@ -154,10 +154,10 @@ void amok_bw_test(gras_socket_t peer, 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 { @@ -170,11 +170,11 @@ void amok_bw_test(gras_socket_t peer, 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); @@ -243,7 +243,7 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t ctx, 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 */ @@ -265,7 +265,7 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t ctx, 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); @@ -279,18 +279,18 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t ctx, /* 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); @@ -344,11 +344,11 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t ctx, } /** - * \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) @@ -358,7 +358,7 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t ctx, * \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. @@ -382,8 +382,8 @@ void amok_bw_request(const char* from_name,unsigned int from_port, 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); @@ -415,8 +415,8 @@ int amok_bw_cb_bw_request(gras_msg_cb_ctx_t ctx, 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, @@ -426,7 +426,7 @@ int amok_bw_cb_bw_request(gras_msg_cb_ctx_t ctx, 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); @@ -434,23 +434,23 @@ int amok_bw_cb_bw_request(gras_msg_cb_ctx_t ctx, } /** \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]); } diff --git a/src/amok/Bandwidth/bandwidth_private.h b/src/amok/Bandwidth/bandwidth_private.h index a90431d6c5..39d71c2be4 100644 --- a/src/amok/Bandwidth/bandwidth_private.h +++ b/src/amok/Bandwidth/bandwidth_private.h @@ -29,11 +29,11 @@ void amok_bw_sat_leave(void);/* Each process must run it */ ***/ /* 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; @@ -52,10 +52,10 @@ typedef struct { * 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; diff --git a/src/amok/Bandwidth/saturate.c b/src/amok/Bandwidth/saturate.c index 84d65e424b..7631d539eb 100644 --- a/src/amok/Bandwidth/saturate.c +++ b/src/amok/Bandwidth/saturate.c @@ -22,7 +22,7 @@ void amok_bw_sat_init(void) { /* 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); @@ -54,11 +54,11 @@ void amok_bw_sat_leave(void) { /** * @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. @@ -75,8 +75,8 @@ void amok_bw_saturate_start(const char* from_name,unsigned int from_port, 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; @@ -95,13 +95,13 @@ static int amok_bw_cb_sat_start(gras_msg_cb_ctx_t ctx, void *payload){ 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; } @@ -110,7 +110,7 @@ static int amok_bw_cb_sat_start(gras_msg_cb_ctx_t ctx, void *payload){ * @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). @@ -145,8 +145,8 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port, 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) { @@ -166,7 +166,7 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port, &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); @@ -260,7 +260,7 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){ 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); @@ -296,7 +296,7 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){ /** * @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 diff --git a/src/amok/HostManagement/hostmanagement.c b/src/amok/PeerManagement/peermanagement.c similarity index 87% rename from src/amok/HostManagement/hostmanagement.c rename to src/amok/PeerManagement/peermanagement.c index f417e8a385..7650f35509 100644 --- a/src/amok/HostManagement/hostmanagement.c +++ b/src/amok/PeerManagement/peermanagement.c @@ -1,6 +1,6 @@ /* $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. */ @@ -8,11 +8,11 @@ * 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 */ @@ -74,7 +74,7 @@ static int amok_hm_cb_join(gras_msg_cb_ctx_t ctx, void *payload) { 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); @@ -90,15 +90,15 @@ static int amok_hm_cb_leave(gras_msg_cb_ctx_t ctx, void *payload) { 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; } @@ -123,7 +123,7 @@ static int amok_hm_cb_shutdown(gras_msg_cb_ctx_t ctx, void *payload) { /* 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) { @@ -172,7 +172,7 @@ void amok_hm_init() { &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--; @@ -204,7 +204,7 @@ void amok_hm_mainloop(double timeOut) { } } -/** \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); @@ -222,14 +222,14 @@ void amok_hm_kill_sync(gras_socket_t buddy) { } -/** \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); @@ -248,7 +248,7 @@ xbt_dynar_t amok_hm_group_get(gras_socket_t master, const char *group_name) { 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)); @@ -257,7 +257,7 @@ void amok_hm_group_join(gras_socket_t master, const char *group_name) { 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 */ @@ -274,10 +274,10 @@ void amok_hm_group_shutdown(const char *group_name) { 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); diff --git a/src/gras/DataDesc/datadesc.c b/src/gras/DataDesc/datadesc.c index d0202e291b..f84a068bd1 100644 --- a/src/gras/DataDesc/datadesc.c +++ b/src/gras/DataDesc/datadesc.c @@ -136,13 +136,13 @@ gras_datadesc_init(void) { 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(); diff --git a/src/gras/Transport/transport.c b/src/gras/Transport/transport.c index a4ca06928e..94290c5699 100644 --- a/src/gras/Transport/transport.c +++ b/src/gras/Transport/transport.c @@ -8,7 +8,7 @@ * 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" @@ -330,9 +330,9 @@ gras_socket_client(const char *host, /** @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; } diff --git a/src/xbt/config.c b/src/xbt/config.c index 1ab5aec20a..505ce0fd8a 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -15,7 +15,7 @@ #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 */ @@ -36,12 +36,12 @@ typedef struct { 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); @@ -110,7 +110,7 @@ void xbt_cfg_dump(const char *name,const char *indent,xbt_cfg_t cfg) { 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); @@ -147,9 +147,9 @@ void xbt_cfg_dump(const char *name,const char *indent,xbt_cfg_t cfg) { } break; - case xbt_cfgelm_host: + case xbt_cfgelm_peer: for (i=0; icontent,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; @@ -199,9 +199,9 @@ xbt_cfg_register(xbt_cfg_t cfg, 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 { @@ -241,8 +241,8 @@ xbt_cfg_register(xbt_cfg_t cfg, 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: @@ -274,7 +274,7 @@ xbt_cfg_unregister(xbt_cfg_t cfg,const char *name) { * * The string may consist in several variable descriptions separated by a space. * Each of them must use the following syntax: \:\_to_\_\ - * with type being one of 'string','int', 'host' or 'double'. + * with type being one of 'string','int', 'peer' or 'double'. */ void @@ -312,7 +312,7 @@ xbt_cfg_register_str(xbt_cfg_t cfg,const char *entry) { 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); @@ -441,10 +441,10 @@ xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) { } 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: @@ -609,13 +609,13 @@ xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) { 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); } @@ -624,11 +624,11 @@ xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) { 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: @@ -740,25 +740,25 @@ xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) { (*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)) @@ -769,7 +769,7 @@ xbt_cfg_set_host(xbt_cfg_t cfg,const char*name, 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); } @@ -874,29 +874,29 @@ xbt_cfg_rm_string(xbt_cfg_t cfg,const char*name, const char *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; @@ -905,7 +905,7 @@ xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) { 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 */ @@ -1034,11 +1034,11 @@ char* xbt_cfg_get_string(xbt_cfg_t cfg, const char *name) { 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. @@ -1048,20 +1048,20 @@ char* xbt_cfg_get_string(xbt_cfg_t cfg, const char *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; } @@ -1119,16 +1119,16 @@ xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos) { 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; } @@ -1143,7 +1143,7 @@ static xbt_cfg_t make_set(){ 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; @@ -1152,7 +1152,7 @@ static xbt_cfg_t make_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); } @@ -1162,7 +1162,7 @@ XBT_TEST_UNIT("validation",test_config_validation,"Validation tests") { 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) { @@ -1178,7 +1178,7 @@ XBT_TEST_UNIT("validation",test_config_validation,"Validation tests") { 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) { @@ -1204,7 +1204,7 @@ XBT_TEST_UNIT("use",test_config_use,"Data retrieving tests") { 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); @@ -1217,7 +1217,7 @@ XBT_TEST_UNIT("use",test_config_use,"Data retrieving tests") { 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");