Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s/xbt_host_t/xbt_peer_t/
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 12 Jul 2006 11:39:35 +0000 (11:39 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 12 Jul 2006 11:39:35 +0000 (11:39 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2536 48e7efb5-ca39-0410-a469-dd3cf9ba447f

12 files changed:
examples/amok/bandwidth/bandwidth.c
examples/amok/saturate/saturate.c
examples/gras/all2all/all2all.c
examples/gras/pmm/pmm.c
include/Makefile.am
include/amok/peermanagement.h [moved from include/amok/hostmanagement.h with 94% similarity]
include/xbt.h
include/xbt/config.h
include/xbt/host.h [deleted file]
include/xbt/peer.h [new file with mode: 0644]
src/xbt/xbt_host.c [deleted file]
src/xbt/xbt_peer.c [new file with mode: 0644]

index 2568bf4..148a86c 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "gras.h"
 #include "amok/bandwidth.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example");
 
@@ -59,7 +59,7 @@ int maestro(int argc,char *argv[]) {
    
   gras_socket_t peer;
   gras_socket_t mysock;
-  xbt_host_t h1,h2;
+  xbt_peer_t h1,h2;
   xbt_dynar_t group;
 
   gras_init(&argc, argv);
@@ -82,8 +82,8 @@ int maestro(int argc,char *argv[]) {
              xbt_dynar_length(group));
      xbt_die(msg);
   }
-  h1 = *(xbt_host_t*) xbt_dynar_get_ptr(group, 0);
-  h2 = *(xbt_host_t*)xbt_dynar_get_ptr(group, 1);
+  h1 = *(xbt_peer_t*) xbt_dynar_get_ptr(group, 0);
+  h2 = *(xbt_peer_t*)xbt_dynar_get_ptr(group, 1);
 
   INFO2("Contact %s:%d",h1->name, h1->port);
   peer = gras_socket_client(h1->name, h1->port);
index ca62e93..108e595 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "gras.h"
 #include "amok/bandwidth.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
 
@@ -100,12 +100,12 @@ static void kill_buddy(char *name,int port){
   gras_socket_close(sock);
 }
 static void kill_buddy_dynar(void *b) {
-  xbt_host_t buddy=*(xbt_host_t*)b;
+  xbt_peer_t buddy=*(xbt_peer_t*)b;
   kill_buddy(buddy->name,buddy->port);
 }
 
-static void free_host(void *d){
-  xbt_host_t h=*(xbt_host_t*)d;
+static void free_peer(void *d){
+  xbt_peer_t h=*(xbt_peer_t*)d;
   free(h->name);
   free(h);
 }
@@ -139,8 +139,8 @@ static void full_fledged_saturation(int argc, char*argv[]) {
   int begin;
 
   /* where are the sensors */
-  xbt_dynar_t hosts;
-  int nb_hosts;
+  xbt_dynar_t peers;
+  int nb_peers;
 
   /* results */
   double *bw;
@@ -148,16 +148,16 @@ static void full_fledged_saturation(int argc, char*argv[]) {
 
   /* iterators */
   int i,j,k,l;
-  xbt_host_t h1,h2,h3,h4;
+  xbt_peer_t h1,h2,h3,h4;
 
   /* Init the group */
-  hosts=amok_hm_group_new("saturate");
+  peers=amok_hm_group_new("saturate");
   /* wait 4 dudes */
   gras_msg_handle(60);
   gras_msg_handle(60);
   gras_msg_handle(60);
   gras_msg_handle(60);
-  nb_hosts = xbt_dynar_length(hosts);
+  nb_peers = xbt_dynar_length(peers);
 
   INFO0("Let's go for the bw_matrix");
 
@@ -165,15 +165,15 @@ static void full_fledged_saturation(int argc, char*argv[]) {
   begin=time(NULL);
   begin_simulated=gras_os_time();
 
-  bw=amok_bw_matrix(hosts,buf_size,exp_size,msg_size,min_duration);
+  bw=amok_bw_matrix(peers,buf_size,exp_size,msg_size,min_duration);
 
   INFO2("Did all BW tests in %ld sec (%.2f simulated(?) sec)",
          time(NULL)-begin,gras_os_time()-begin_simulated);
 
   /* Do the test with saturation */
-  bw_sat=xbt_new(double,nb_hosts*nb_hosts);
-  xbt_dynar_foreach(hosts,i,h1) {
-    xbt_dynar_foreach(hosts,j,h2) {
+  bw_sat=xbt_new(double,nb_peers*nb_peers);
+  xbt_dynar_foreach(peers,i,h1) {
+    xbt_dynar_foreach(peers,j,h2) {
       if (i==j) continue;
 
       TRY {
@@ -182,16 +182,16 @@ static void full_fledged_saturation(int argc, char*argv[]) {
                               0, /* Be nice, compute msg_size yourself */
                               0  /* no timeout */);  
       } CATCH(e) {
-       RETHROW0("Cannot ask hosts to saturate the link: %s");
+       RETHROW0("Cannot ask peers to saturate the link: %s");
       }
       gras_os_sleep(5);
 
       begin=time(NULL);
       begin_simulated=gras_os_time();
-      xbt_dynar_foreach(hosts,k,h3) {
+      xbt_dynar_foreach(peers,k,h3) {
        if (i==k || j==k) continue;
 
-       xbt_dynar_foreach(hosts,l,h4) {
+       xbt_dynar_foreach(peers,l,h4) {
          double ratio;
          if (i==l || j==l || k==l) continue;
 
@@ -199,13 +199,13 @@ static void full_fledged_saturation(int argc, char*argv[]) {
                h1->name,h2->name,h3->name,h4->name);
          amok_bw_request(h3->name,h3->port, h4->name,h4->port,
                          buf_size,exp_size,msg_size,min_duration,
-                         NULL,&(bw_sat[k*nb_hosts + l]));
+                         NULL,&(bw_sat[k*nb_peers + l]));
 
-         ratio=bw_sat[k*nb_hosts + l] / bw[k*nb_hosts + l];
+         ratio=bw_sat[k*nb_peers + l] / bw[k*nb_peers + l];
          INFO8("SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s",
                h1->name,h2->name,h3->name,h4->name,
                ratio,
-               bw[k*nb_hosts + l] , bw_sat[k*nb_hosts + l],
+               bw[k*nb_peers + l] , bw_sat[k*nb_peers + l],
                ratio < 0.7 ? " THERE IS SOME INTERFERENCE !!!": "");
        }
       }
index badb068..5c029da 100644 (file)
@@ -80,21 +80,21 @@ int sender (int argc,char *argv[]) {
   int i; /* iterator */
   char *data; /* data exchanged */
   int datasize; /* size of message */
-  xbt_host_t h; /* iterator */
+  xbt_peer_t h; /* iterator */
   
   gras_socket_t peer;  /* socket to node */
   
  
-  /* xbt_dynar for hosts */
-  xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
+  /* xbt_dynar for peers */
+  xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp);
  
   /* Init the GRAS infrastructure and declare my globals */
   gras_init(&argc,argv);
  
   /* Get the node location from argc/argv */
   for (i=1; i<argc-1; i++){
-    xbt_host_t host = xbt_host_from_string(argv[i]);
-    xbt_dynar_push(hosts,&host);
+    xbt_peer_t peer = xbt_peer_from_string(argv[i]);
+    xbt_dynar_push(peers,&peer);
   }
   
   datasize=atoi(argv[argc-1]);
@@ -113,7 +113,7 @@ int sender (int argc,char *argv[]) {
   gras_os_sleep(1);
 
   /* write 'em */
-  xbt_dynar_foreach(hosts,i,h) {
+  xbt_dynar_foreach(peers,i,h) {
      
      peer = gras_socket_client(h->name,h->port);
      gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
@@ -123,7 +123,7 @@ int sender (int argc,char *argv[]) {
   }
 
   /* Free the allocated resources, and shut GRAS down */
-  xbt_dynar_free(&hosts);
+  xbt_dynar_free(&peers);
      
   gras_exit();
   return 0;
index dc7da5b..b41dfad 100755 (executable)
@@ -10,7 +10,7 @@
 
 #include "gras.h"
 #include "xbt/matrix.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
 
 #define PROC_MATRIX_SIZE 3
 #define NEIGHBOR_COUNT PROC_MATRIX_SIZE - 1
@@ -33,8 +33,8 @@ typedef struct s_result result_t;
 GRAS_DEFINE_TYPE(s_pmm_assignment,struct s_pmm_assignment {
   int linepos;
   int rowpos;
-  xbt_host_t line[NEIGHBOR_COUNT];
-  xbt_host_t row[NEIGHBOR_COUNT];
+  xbt_peer_t line[NEIGHBOR_COUNT];
+  xbt_peer_t row[NEIGHBOR_COUNT];
   xbt_matrix_t A GRAS_ANNOTE(subtype,double);
   xbt_matrix_t B GRAS_ANNOTE(subtype,double);
 });
@@ -86,8 +86,8 @@ int master (int argc,char *argv[]) {
 
   gras_socket_t from;
 
-  xbt_dynar_t hosts; /* group of slaves */
-  xbt_host_t grid[SLAVE_COUNT]; /* The slaves as an array */
+  xbt_dynar_t peers; /* group of slaves */
+  xbt_peer_t grid[SLAVE_COUNT]; /* The slaves as an array */
   gras_socket_t socket[SLAVE_COUNT]; /* sockets for brodcast to slaves */
 
   /* Init the GRAS's infrastructure */
@@ -102,16 +102,16 @@ int master (int argc,char *argv[]) {
        
   /* Create the connexions */
   gras_socket_server(atoi(argv[1]));
-  hosts=amok_hm_group_new("pmm");
+  peers=amok_hm_group_new("pmm");
   INFO0("Wait for peers for 10 sec");
   gras_msg_handleall(10); /* friends, we're ready. Come and play */
-  INFO1("Got %ld pals",xbt_dynar_length(hosts));
+  INFO1("Got %ld pals",xbt_dynar_length(peers));
 
   for (i=0;
-       i<xbt_dynar_length(hosts) && i<SLAVE_COUNT;
+       i<xbt_dynar_length(peers) && i<SLAVE_COUNT;
        i++) {
 
-    xbt_dynar_get_cpy(hosts,i,&grid[i]);
+    xbt_dynar_get_cpy(peers,i,&grid[i]);
     socket[i]=gras_socket_client(grid[i]->name,grid[i]->port);
     INFO2("Connected to %s:%d.",grid[i]->name,grid[i]->port);
   }
@@ -120,10 +120,10 @@ int master (int argc,char *argv[]) {
              i,SLAVE_COUNT);
 
   /* Kill surnumerous slaves */
-  for (i=SLAVE_COUNT; i<xbt_dynar_length(hosts); ) {
-    xbt_host_t h;
+  for (i=SLAVE_COUNT; i<xbt_dynar_length(peers); ) {
+    xbt_peer_t h;
 
-    xbt_dynar_get_cpy(hosts,i,&h);
+    xbt_dynar_get_cpy(peers,i,&h);
     amok_hm_kill_hp(h->name,h->port);
     free(h);
   }
@@ -252,12 +252,12 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   for (i=0 ; i<PROC_MATRIX_SIZE-1 ; i++){
     socket_line[i]=gras_socket_client(assignment.line[i]->name,
                                      assignment.line[i]->port);
-    xbt_host_free(assignment.line[i]);
+    xbt_peer_free(assignment.line[i]);
   }
   for (i=0 ; i<PROC_MATRIX_SIZE-1 ; i++){
     socket_row[i]=gras_socket_client(assignment.row[i]->name,
                                     assignment.row[i]->port);
-    xbt_host_free(assignment.row[i]);    
+    xbt_peer_free(assignment.row[i]);    
   }
 
   for (step=0; step<PROC_MATRIX_SIZE;step++) {
index 12e39ae..e77d47a 100644 (file)
@@ -12,7 +12,7 @@ nobase_include_HEADERS = \
        xbt/fifo.h \
        xbt/swag.h \
        xbt/matrix.h \
-       xbt/host.h \
+       xbt/peer.h \
        xbt/config.h \
        xbt/cunit.h \
        xbt/graphxml_parse.h \
@@ -33,7 +33,7 @@ nobase_include_HEADERS = \
        gras/messages.h gras/timer.h \
        \
        amok/base.h \
-       amok/hostmanagement.h \
+       amok/peermanagement.h \
        amok/bandwidth.h
 
 surf/surfxml.h:
similarity index 94%
rename from include/amok/hostmanagement.h
rename to include/amok/peermanagement.h
index f9ec126..ba80b4d 100644 (file)
@@ -1,14 +1,14 @@
 /* $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.                  */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef AMOK_HOST_MANAGEMENT_H
-#define AMOK_HOST_MANAGEMENT_H
+#ifndef AMOK_PEER_MANAGEMENT_H
+#define AMOK_PEER_MANAGEMENT_H
 
 #include <gras.h>
 #include <amok/base.h>
@@ -71,4 +71,4 @@ void amok_hm_group_shutdown_remote(gras_socket_t master, const char *group_name)
 
 
 /** @} */
-#endif /* AMOK_HOST_MANAGEMENT_H */
+#endif /* AMOK_peer_MANAGEMENT_H */
index 8a528a4..4cd44e7 100644 (file)
@@ -25,7 +25,7 @@
 #include <xbt/swag.h>
 #include <xbt/heap.h>
 
-#include <xbt/host.h>
+#include <xbt/peer.h>
 #include <xbt/config.h>
 #include <xbt/cunit.h>
 
index da9457d..25254ad 100644 (file)
@@ -107,8 +107,8 @@ void xbt_cfg_set_double(xbt_cfg_t cfg, const char *name,
                        double val);
 void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, 
                        const char *val);
-void xbt_cfg_set_host  (xbt_cfg_t cfg, const char *name, 
-                       const char *host,int port);
+void xbt_cfg_set_peer  (xbt_cfg_t cfg, const char *name, 
+                       const char *peer,int port);
 
 /*
  Remove the provided value from the cell @name in @cfg.
@@ -119,8 +119,8 @@ void xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name,
                       double val);
 void xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name, 
                       const char *val);
-void xbt_cfg_rm_host  (xbt_cfg_t cfg, const char *name, 
-                      const char *host,int port);
+void xbt_cfg_rm_peer  (xbt_cfg_t cfg, const char *name, 
+                      const char *peer,int port);
                                  
 /*
  Remove the value at position \e pos from the config \e cfg
@@ -143,7 +143,7 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
     xbt_cfgelm_int=0,  /**< int */
     xbt_cfgelm_double, /**< double */
     xbt_cfgelm_string, /**< char* */
-    xbt_cfgelm_host,   /**< both a char* (representing the hostname) and an integer (representing the port) */
+    xbt_cfgelm_peer,   /**< both a char* (representing the peername) and an integer (representing the port) */
     
     xbt_cfgelm_any,    /* not shown to users to prevent errors */
     xbt_cfgelm_type_count 
@@ -193,13 +193,13 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
   int         xbt_cfg_get_int   (xbt_cfg_t cfg, const char *name);
   double      xbt_cfg_get_double(xbt_cfg_t cfg, const char *name);
   char*       xbt_cfg_get_string(xbt_cfg_t cfg, const char *name);
-  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_dynar_t xbt_cfg_get_dynar (xbt_cfg_t cfg, const char *name);
 
   int    xbt_cfg_get_int_at   (xbt_cfg_t cfg, const char *name, int pos);
   double xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos);
   char*  xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos);
-  void   xbt_cfg_get_host_at  (xbt_cfg_t cfg, const char *name, int pos, char  **host, int *port);
+  void   xbt_cfg_get_peer_at  (xbt_cfg_t cfg, const char *name, int pos, char  **peer, int *port);
 
 /** @} */
 
diff --git a/include/xbt/host.h b/include/xbt/host.h
deleted file mode 100644 (file)
index 8fd25a2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $Id$ */
-
-/* host.h - host management functions                                       */
-
-/* Copyright (c) 2006 Arnaud Legrand.                                       */
-/* All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef XBT_HOST_H
-#define XBT_HOST_H
-
-#include "xbt/misc.h"
-
-SG_BEGIN_DECL()
-
-typedef struct {  
-   char *name;
-   int port;
-} s_xbt_host_t, *xbt_host_t;
-
-xbt_host_t xbt_host_new(const char *name, int port);
-xbt_host_t xbt_host_from_string(const char *hostport);
-xbt_host_t xbt_host_copy(xbt_host_t h);
-void xbt_host_free(xbt_host_t host);
-void xbt_host_free_voidp(void *d);
-
-SG_END_DECL()
-
-
-#endif /* XBT_MISC_H */
diff --git a/include/xbt/peer.h b/include/xbt/peer.h
new file mode 100644 (file)
index 0000000..5f56799
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Id$ */
+
+/* peer.h - peer (remote processes) management functions                    */
+
+/* Copyright (c) 2006 Arnaud Legrand.                                       */
+/* Copyright (c) 2006 Martin Quinson.                                       */
+/* All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef XBT_PEER_H
+#define XBT_PEER_H
+
+#include "xbt/misc.h"
+
+SG_BEGIN_DECL()
+
+typedef struct {  
+   char *name;
+   int port;
+} s_xbt_peer_t, *xbt_peer_t;
+
+xbt_peer_t xbt_peer_new(const char *name, int port);
+xbt_peer_t xbt_peer_from_string(const char *peerport);
+xbt_peer_t xbt_peer_copy(xbt_peer_t h);
+void xbt_peer_free(xbt_peer_t peer);
+void xbt_peer_free_voidp(void *d);
+
+SG_END_DECL()
+
+
+#endif /* XBT_PEER_H */
diff --git a/src/xbt/xbt_host.c b/src/xbt/xbt_host.c
deleted file mode 100644 (file)
index d1b3930..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $Id$ */
-
-/* xbt_host_t management functions                                          */
-
-/* Copyright (c) 2006 Martin Quinson. All rights reserved.                  */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/host.h"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host,xbt,"Host management");
-
-/** \brief constructor */
-xbt_host_t xbt_host_new(const char *name, int port)  {
-   xbt_host_t res=xbt_new(s_xbt_host_t, 1);
-   res->name = xbt_strdup(name);
-   res->port = port;
-   return res;
-}
-
-xbt_host_t xbt_host_copy(xbt_host_t h) {
-   return xbt_host_new(h->name,h->port);
-}
-
-/** \brief constructor. Argument should be of form '<hostname>:<port>'. */
-xbt_host_t xbt_host_from_string(const char *hostport)  {
-   xbt_host_t res=xbt_new(s_xbt_host_t, 1);
-   char *name=xbt_strdup(hostport);
-   char *port_str=strchr(name,':');
-   xbt_assert1(port_str,"argument of xbt_host_from_string should be of form <hostname>:<port>, it's '%s'", hostport);
-   *port_str='\0';
-   port_str++;
-   
-   res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */
-   res->port = atoi(port_str);
-   free(name);
-   return res;
-}
-
-/** \brief destructor */
-void xbt_host_free(xbt_host_t host) {
-   if (host) {
-      if (host->name) free(host->name);
-      free(host);
-   }
-}
-
-/** \brief Freeing function for dynars of xbt_host_t */
-void xbt_host_free_voidp(void *d) {
-   xbt_host_free( (xbt_host_t) *(void**)d );
-}
diff --git a/src/xbt/xbt_peer.c b/src/xbt/xbt_peer.c
new file mode 100644 (file)
index 0000000..d5b3598
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$ */
+
+/* xbt_peer_t management functions                                          */
+
+/* Copyright (c) 2006 Martin Quinson. All rights reserved.                  */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/peer.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(peer,xbt,"peer management");
+
+/** \brief constructor */
+xbt_peer_t xbt_peer_new(const char *name, int port)  {
+   xbt_peer_t res=xbt_new(s_xbt_peer_t, 1);
+   res->name = xbt_strdup(name);
+   res->port = port;
+   return res;
+}
+
+xbt_peer_t xbt_peer_copy(xbt_peer_t h) {
+   return xbt_peer_new(h->name,h->port);
+}
+
+/** \brief constructor. Argument should be of form '<peername>:<port>'. */
+xbt_peer_t xbt_peer_from_string(const char *peerport)  {
+   xbt_peer_t res=xbt_new(s_xbt_peer_t, 1);
+   char *name=xbt_strdup(peerport);
+   char *port_str=strchr(name,':');
+   xbt_assert1(port_str,"argument of xbt_peer_from_string should be of form <peername>:<port>, it's '%s'", peerport);
+   *port_str='\0';
+   port_str++;
+   
+   res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */
+   res->port = atoi(port_str);
+   free(name);
+   return res;
+}
+
+/** \brief destructor */
+void xbt_peer_free(xbt_peer_t peer) {
+   if (peer) {
+      if (peer->name) free(peer->name);
+      free(peer);
+   }
+}
+
+/** \brief Freeing function for dynars of xbt_peer_t */
+void xbt_peer_free_voidp(void *d) {
+   xbt_peer_free( (xbt_peer_t) *(void**)d );
+}