From 6e92616c44cb0d4b71f54af8a1cbcb836e515e0c Mon Sep 17 00:00:00 2001 From: P2P-Next User Date: Wed, 24 Nov 2010 12:42:01 +0200 Subject: [PATCH] swift client integration update -- *.log.mon file generation; *.log.data file generation (parsing swift log files) --- ControlScripts/client_script_mappings | 3 ++ .../clients/swift/start_swift_leecher.sh | 8 +++++ ControlScripts/hook_monitor_pid.sh | 1 + ControlScripts/schedule_client.sh | 35 ++++++++++++++++--- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ControlScripts/client_script_mappings b/ControlScripts/client_script_mappings index e483efd..ffd19ec 100644 --- a/ControlScripts/client_script_mappings +++ b/ControlScripts/client_script_mappings @@ -190,5 +190,8 @@ parse_client_log() "tribler_proxy_04") clients/tribler/parse_tribler.sh ${log_folder} ${log_file} ;; + "swift_seeder" | "swift_leecher") + clients/swift/parse_swift.sh ${log_folder} ${log_file} + ;; esac } diff --git a/ControlScripts/clients/swift/start_swift_leecher.sh b/ControlScripts/clients/swift/start_swift_leecher.sh index 3fd34fe..e3e723a 100755 --- a/ControlScripts/clients/swift/start_swift_leecher.sh +++ b/ControlScripts/clients/swift/start_swift_leecher.sh @@ -36,4 +36,12 @@ cd $SWIFT_ABS_PATH echo ./swift -h "$HASH" -t "${TRACKER_IP}:6881" -p > ~/deb ./swift -h "$HASH" -t "${TRACKER_IP}:6881" -p +# +#./swift -h "$HASH" -t "${TRACKER_IP}:6881" -p & +# ps -ef | grep shedule bla bla # proper way of determining PID of schedule (master) process +# kill -USR1 $SCHEDULE_PID # SCHEDULE_PID is pid for master process +# +# wait # wait for client process to complete +# + rm -f ${HASH}* diff --git a/ControlScripts/hook_monitor_pid.sh b/ControlScripts/hook_monitor_pid.sh index 7bff3c6..b336789 100755 --- a/ControlScripts/hook_monitor_pid.sh +++ b/ControlScripts/hook_monitor_pid.sh @@ -18,6 +18,7 @@ pid=$1 kill -0 $pid > /dev/null 2>&1 if test $? -ne 0; then echo -e "PID $pid does not exists.\nUsage: $0 " 1>&2 + ps -ef exit 1 fi diff --git a/ControlScripts/schedule_client.sh b/ControlScripts/schedule_client.sh index 42d78a0..0bf2078 100755 --- a/ControlScripts/schedule_client.sh +++ b/ControlScripts/schedule_client.sh @@ -79,6 +79,15 @@ test_infinite() fi } +cleanup() +{ + stop_client ${CLIENT_TYPE} + kill ${mon_pid} +} + +# use cleanup function when receiving signals +trap cleanup 0 1 2 3 15 + parse_periods DEBUG echo "start_time is ${start_time}" @@ -96,8 +105,25 @@ DEBUG echo "CLIENT_TYPE is ${CLIENT_TYPE}" start_client ${CLIENT_TYPE} ${DL_BW} ${UL_BW} ${NO_CONNECTIONS} background_pid=$! DEBUG echo "background_pid is ${background_pid}" + +# wait_for_usr1() +# { +# # do nothing, successfully +# } +# +# trap wait_for_usr1 10 # wait_for_usr1 is simple handler (waits for SIGUSR1 from start_client process) +# + +sleep 5 +client_pid=$(pgrep -P ${background_pid}) +DEBUG echo "client_pid is ${client_pid}" old_time=${start_time} +# Monitor client's resources +echo "$client_pid" +./hook_monitor_pid.sh "$client_pid" >> $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/$(hostname).log.mon 2>&1 & +mon_pid=$! + for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do # Sleeping while the client runs. When i wake up i will suspend the client test_infinite ${suspend_resume[$i]} @@ -108,10 +134,7 @@ for ((i = 0; i < ${#suspend_resume[@]}; i += 2)); do DEBUG echo "client_pid is ${client_pid}" suspend_client ${client_pid} old_time=${suspend_resume[$i]} - - # Monitor client's resources - ./hook_monitor_pid $client_pid >> $REMOTE_PATH/P2P-Testing-Infrastructure/ClientWorkingFolders/TmpLogs/\$(hostname).log.mon 2>&1 & - + # Client is suspended. Sleeping until the client should be restarted. When i wake up i will start the client test_infinite ${suspend_resume[$(($i+1))]} @@ -128,4 +151,6 @@ test_infinite ${stop_time} to_sleep=$((${stop_time} - ${old_time})) sleep ${to_sleep} -stop_client ${CLIENT_TYPE} + +# stop client and monitoring script +cleanup -- 2.20.1