Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
you're too verbose, dude
[simgrid.git] / src / amok / Bandwidth / saturate.c
index d6cfa91..c0cf41b 100644 (file)
@@ -10,8 +10,7 @@
 #include "amok/Bandwidth/bandwidth_private.h"
 #include "gras/Msg/msg_private.h" /* FIXME: This mucks with contextes to answer RPC directly */
 
-XBT_LOG_EXTERNAL_CATEGORY(amok_bw);
-XBT_LOG_DEFAULT_CATEGORY(amok_bw);
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok_bw_sat,amok_bw,"Everything concerning the SATuration part of the amok_bw module");
 
 static int amok_bw_cb_sat_start(gras_msg_cb_ctx_t ctx, void *payload);
 static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload);
@@ -157,7 +156,7 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
   free(request);
 
   gras_socket_close(peer_cmd);
-  INFO2("Saturation from %s to %s started",gras_os_myname(),to_name);
+  INFO2("Saturation(%s->%s) started",gras_os_myname(),to_name);
 
   /* Start experiment */
   start=gras_os_time();
@@ -184,9 +183,9 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
 
     /* Check whether the experiment has to be terminated by now */
     elapsed=gras_os_time()-start;
-    VERB2("elapsed %f duration %f",elapsed, duration);
+    DEBUG2("elapsed %f duration %f",elapsed, duration);
 
-  } while (duration==0 || saturate_further && elapsed < duration);
+  } while (saturate_further && (duration==0 || elapsed < duration));
 
   bw = ((double)(packet_sent*msg_size)) / elapsed;
 
@@ -213,7 +212,7 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
     gras_msg_rpcreturn(60,&ctx,&answer);
     free(answer);
   } else {
-    INFO3("Saturation from %s to %s elapsed after %f sec (achieving %f kb/s)",
+    INFO4("Saturation from %s to %s elapsed after %f sec (achieving %f kb/s)",
          gras_os_myname(),to_name,elapsed,bw/1024.0);
   }
   
@@ -227,6 +226,7 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){
   volatile int saturate_further = 1;
   xbt_ex_t e;
   gras_socket_t measMaster=NULL,meas=NULL;
+  gras_socket_t from=gras_msg_cb_ctx_from(ctx);
 
   int port=6000;
   while (port <= 10000 && measMaster == NULL) {
@@ -261,13 +261,16 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){
 
   while (saturate_further) {
     TRY {
-      gras_socket_meas_recv(meas,120,request->msg_size,request->msg_size);
+      gras_socket_meas_recv(meas,5,request->msg_size,request->msg_size);
     } CATCH(e) {
       saturate_further = 0;
       xbt_ex_free(e);
     }
   }
-  INFO1("Saturation stopped on %s",gras_os_myname());
+  INFO3("Saturation comming from %s:%d stopped on %s",
+       gras_socket_peer_name(from),gras_socket_peer_port(from),
+       gras_os_myname());
+
   gras_socket_close(meas);
   if (gras_if_RL()) /* On SG, accepted=master */
     gras_socket_close(measMaster); 
@@ -285,11 +288,18 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){
  */
 void amok_bw_saturate_stop(const char* from_name,unsigned int from_port,
                           /*out*/ double *time, double *bw) {
-
+  xbt_ex_t e;
+   
   gras_socket_t sock = gras_socket_client(from_name,from_port);
   bw_res_t answer;
-  gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat stop"),NULL,&answer);
+  VERB2("Ask %s:%d to stop the saturation",from_name,from_port);
+  TRY {        
+     gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat stop"),NULL,&answer);
+  } CATCH(e) {
+     RETHROW2("Cannot ask %s:%d to stop saturation: %s",from_name, from_port);
+  }
   gras_socket_close(sock);
   if (time) *time=answer->sec;
   if (bw)   *bw  =answer->bw;
+  free(answer);
 }