From: mquinson Date: Mon, 10 Jul 2006 00:13:18 +0000 (+0000) Subject: Convert to amok/hostmanagement; kill ENV from here X-Git-Tag: v3.3~2842 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/54de3cbb5467f6b0e990fae260f06ad5ce645baf Convert to amok/hostmanagement; kill ENV from here git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2516 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/amok/saturate/saturate.c b/examples/amok/saturate/saturate.c index 8e452502bf..4eebdf03aa 100644 --- a/examples/amok/saturate/saturate.c +++ b/examples/amok/saturate/saturate.c @@ -14,6 +14,7 @@ #include "gras.h" #include "amok/bandwidth.h" +#include "amok/hostmanagement.h" XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example"); @@ -21,49 +22,27 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example"); * Sensor code * **********************************************************************/ -/* Global private data */ -typedef struct { - gras_socket_t sock; - int done; -} sensor_data_t; - /* Function prototypes */ int sensor (int argc,char *argv[]); -static int sensor_cb_kill(gras_msg_cb_ctx_t ctx, - void *payload_data) { - - sensor_data_t *g=gras_userdata_get(); - g->done = 1; - INFO0("Killed"); - return 1; -} int sensor (int argc,char *argv[]) { - sensor_data_t *g; - xbt_ex_t e; + gras_socket_t mysock; + gras_socket_t master; - gras_init(&argc,argv); + gras_init(&argc, argv); amok_bw_init(); - - g=gras_userdata_new(sensor_data_t); - g->sock = gras_socket_server(atoi(argv[1])); - - g->done = 0; - gras_msgtype_declare("kill",NULL); - gras_cb_register(gras_msgtype_by_name("kill"),&sensor_cb_kill); - - while (!g->done) { - TRY { - gras_msg_handle(20.0); - } CATCH(e) { - if (e.category != timeout_error) - RETHROW; - xbt_ex_free(e); - } - } - - gras_socket_close(g->sock); - free(g); + amok_hm_init(); + + mysock = gras_socket_server_range(3000,9999,0,0); + INFO1("Sensor starting (on port %d)",gras_os_myport()); + gras_os_sleep(0.5); /* let the master get ready */ + master = gras_socket_client_from_string(argv[1]); + + amok_hm_group_join(master,"saturate"); + amok_hm_mainloop(600); + + gras_socket_close(mysock); + gras_socket_close(master); gras_exit(); return 0; } @@ -151,114 +130,6 @@ static void simple_saturation(int argc, char*argv[]) { kill_buddy(argv[3],atoi(argv[4])); } /********************************************************************************************/ -static void env_hosttohost_bw(int argc, char*argv[]) { - - /* where are the sensors */ - xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host); - int nb_hosts; - - /* results */ - double sec, bw; - - /* iterators */ - int i; - xbt_host_t h1; - - gras_socket_t peer; /* socket to sensor */ - - /* wait to ensure that all server sockets are there before starting the experiment */ - gras_os_sleep(0.5); - - /* Get the sensor location from argc/argv */ - for (i=1; iname=strdup(argv[i]); - host->port=atoi(argv[i+1]); - INFO2("New sensor: %s:%d",host->name,host->port); - xbt_dynar_push(hosts,&host); - } - nb_hosts = xbt_dynar_length(hosts); - - INFO0(">>> start Test1: ENV end to end mesurements"); - - xbt_dynar_foreach(hosts,i,h1) { - peer = gras_socket_client(h1->name,h1->port); - amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw); - INFO6("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s", - h1->name,h1->port, - exp_size,msg_size, - sec,((double)bw)/1024.0); - } - - xbt_dynar_map(hosts,kill_buddy_dynar); - xbt_dynar_free(&hosts); - -} -/********************************************************************************************/ -static void env_Pairwisehost_bw(int argc, char*argv[]) { - xbt_ex_t e; - - /* where are the sensors */ - xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host); - int nb_hosts; - - /* getting the name of maestro for the saturation and the concurrent bandwidth measurements */ - char* host_test=argv[0]; - - /* results */ - double sec, bw; - - /* iterators */ - int i,j; - xbt_host_t h1,h2; - - /* socket to sensor */ - gras_socket_t peer; - - /* wait to ensure that all server sockets are there before starting the experiment */ - gras_os_sleep(0.5); - - INFO1(">>>>>< le maestro est: %s ",argv[0]); - /* Get the sensor location from argc/argv */ - for (i=1; iname=strdup(argv[i]); - host->port=atoi(argv[i+1]); - INFO2("New sensor: %s:%d",host->name,host->port); - xbt_dynar_push(hosts,&host); - } - nb_hosts = xbt_dynar_length(hosts); - - INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements"); - xbt_dynar_foreach(hosts,i,h1) { - - TRY { - amok_bw_saturate_start(h1->name,h1->port, - host_test,h1->port,//"Ginette" - msg_size,120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB - } CATCH(e) { - RETHROW0("Cannot ask hosts to saturate the link: %s"); - } - // gras_os_sleep(1.0); - - xbt_dynar_foreach(hosts,j,h2) { - if (i==j) continue; - - peer = gras_socket_client(h2->name,h2->port); - amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw); - INFO6("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s", - h2->name,h1->name, - exp_size,msg_size, - sec,((double)bw)/1024.0); - - } - amok_bw_saturate_stop(h1->name,h1->port,NULL,NULL); -} - xbt_dynar_map(hosts,kill_buddy_dynar); - xbt_dynar_free(&hosts); - -} -/********************************************************************************************/ static void full_fledged_saturation(int argc, char*argv[]) { xbt_ex_t e; //unsigned int time1=5,bw1=5; @@ -268,7 +139,7 @@ static void full_fledged_saturation(int argc, char*argv[]) { int begin; /* where are the sensors */ - xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host); + xbt_dynar_t hosts; int nb_hosts; /* results */ @@ -279,15 +150,12 @@ static void full_fledged_saturation(int argc, char*argv[]) { int i,j,k,l; xbt_host_t h1,h2,h3,h4; - /* Get the sensor location from argc/argv */ - for (i=1; iname,host->port); - xbt_dynar_push(hosts,&host); - } + /* Init the group */ + hosts=amok_hm_group_new("saturate"); + INFO0("Wait for peers for 5 sec"); + gras_msg_handleall(5); /* friends, we're ready. Come and play */ nb_hosts = xbt_dynar_length(hosts); - gras_os_sleep(2); /* wait for my pals to get ready */ INFO0("Let's go for the bw_matrix"); /* Do the test without saturation */ @@ -296,7 +164,7 @@ static void full_fledged_saturation(int argc, char*argv[]) { bw=amok_bw_matrix(hosts,buf_size,exp_size,msg_size,min_duration); - INFO2("Did all BW tests in %ld sec (%.2f simulated sec)", + INFO2("Did all BW tests in %ld sec (%.2f simulated(?) sec)", time(NULL)-begin,gras_os_time()-begin_simulated); /* Do the test with saturation */ @@ -346,8 +214,8 @@ static void full_fledged_saturation(int argc, char*argv[]) { } free(bw_sat); free(bw); - xbt_dynar_map(hosts,kill_buddy_dynar); - xbt_dynar_free(&hosts); + /* Game is over, friends */ + amok_hm_group_shutdown ("saturate"); } @@ -355,11 +223,9 @@ int maestro(int argc,char *argv[]) { gras_init(&argc,argv); amok_bw_init(); + amok_hm_init(); - gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */ - - //env_Pairwisehost_bw(argc,argv); - //env_hosttohost_bw(argc,argv); + gras_socket_server(atoi(argv[1])); // simple_saturation(argc,argv); full_fledged_saturation(argc, argv); diff --git a/examples/amok/saturate/saturate_deployment.xml b/examples/amok/saturate/saturate_deployment.xml index a4269f6fd1..2b33d6c4f7 100644 --- a/examples/amok/saturate/saturate_deployment.xml +++ b/examples/amok/saturate/saturate_deployment.xml @@ -1,15 +1,12 @@ - - - - - - - - - - + + + + + + + diff --git a/examples/amok/saturate/test_rl.in b/examples/amok/saturate/test_rl.in index 0c0613cb77..5aa4269c80 100755 --- a/examples/amok/saturate/test_rl.in +++ b/examples/amok/saturate/test_rl.in @@ -6,6 +6,8 @@ else exenv=wine fi -$exenv ./saturate_sensor@EXEEXT@ 4000 $@& -$exenv ./saturate_sensor@EXEEXT@ 5000 $@& -$exenv ./saturate_maestro@EXEEXT@ 127.0.0.1 4000 127.0.0.1 5000 $@ +$exenv ./saturate_sensor@EXEEXT@ 127.0.0.1:3333 $@ & +$exenv ./saturate_sensor@EXEEXT@ 127.0.0.1:3333 $@ & +$exenv ./saturate_sensor@EXEEXT@ 127.0.0.1:3333 $@ & +$exenv ./saturate_sensor@EXEEXT@ 127.0.0.1:3333 $@ & +$exenv ./saturate_maestro@EXEEXT@ 3333 $@