From 0a53429a453a1268f10622b80c7e14a8f540b1bf Mon Sep 17 00:00:00 2001 From: P2P-Next Date: Fri, 19 Nov 2010 15:48:51 +0200 Subject: [PATCH] ControlScripts: swift --- .../clients/swift/detect_complete_swift.sh | 47 +++++++++++++++ .../clients/swift/start_swift_leecher.sh | 37 ++++++++++++ .../clients/swift/start_swift_seeder.sh | 58 +++++++++++++++++++ ControlScripts/clients/swift/stop_swift.sh | 14 +++++ Results/.gitignore | 5 +- 5 files changed, 158 insertions(+), 3 deletions(-) create mode 100755 ControlScripts/clients/swift/detect_complete_swift.sh create mode 100755 ControlScripts/clients/swift/start_swift_leecher.sh create mode 100755 ControlScripts/clients/swift/start_swift_seeder.sh create mode 100755 ControlScripts/clients/swift/stop_swift.sh diff --git a/ControlScripts/clients/swift/detect_complete_swift.sh b/ControlScripts/clients/swift/detect_complete_swift.sh new file mode 100755 index 0000000..4a5cd79 --- /dev/null +++ b/ControlScripts/clients/swift/detect_complete_swift.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# 2010, Calin-Andrei Burloiu, calin.burloiu@gmail.com +# +# Bash script used to detect when a regular client finished +# downloading a torrent +# +# The script +# * monitors a log file provided as an argument +# * as long as the doe is not finished the script keeps running +# * when the doe is finished it returns 0 +# * blocks the caller - the script exits only when the doe has completed +# the download +# +# Script arguments: +# * log file + +if [ ! $# -eq 1 ]; then + echo "usage: $0 log-file" + exit 1 +fi + +LOG_FILE=$1 + +while true; do + # check for complete transfer + if cat $LOG_FILE | grep "DONE" &> /dev/null; then + echo "Torrent transfer finished" + exit 0 + fi + + if cat $LOG_FILE | grep "Segmentation fault" &> /dev/null; then + echo "Segmentation fault when transferring torrent" + exit 0 + fi + + # check stat client is alive + if ! pgrep "swift" &> /dev/null; then + if ! pgrep -f "schedule_client.sh" &> /dev/null; then + echo "No swift and no schedule_client.sh process" + exit 0 + fi + fi + + # Don't do continuous polling + sleep 5 +done diff --git a/ControlScripts/clients/swift/start_swift_leecher.sh b/ControlScripts/clients/swift/start_swift_leecher.sh new file mode 100755 index 0000000..83f9949 --- /dev/null +++ b/ControlScripts/clients/swift/start_swift_leecher.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# 2010 Calin-Andrei Burloiu, calin.burloiu@gmail.com +# +# Bash script used to start a swift instance +# The script +# * changes current working directory to TorrentsAndData +# * starts a swift session +# * at the end deletes the downloaded data +# +# If you run this script manually, you must run it from the P2P-Testing-Infrastructure/ControlScripts folder +# + +# Read the global configuration file +# Check if the global configuration file exists +if [ ! -e globalconfig ]; then + echo "Warning: The global config file globalconfig does not exist." +else + source globalconfig +fi + +# Read the node-specific configuration file (TORRENT_FILE) +# Check if the node-specific configuration file exists +if [ ! -e ../ClientWorkingFolders/TmpLogs/node_config ]; then + echo "Warning: The global config file ../ClientWorkingFolders/TmpLogs/node_config does not exist." +else + source ../ClientWorkingFolders/TmpLogs/node_config +fi + +HASH=$(echo $TORRENT_FILE | cut -d"/" -f1) +TRACKER_IP=$(echo $TORRENT_FILE | cut -d"/" -f2) + +cd $SWIFT_ABS_PATH + +./swift -h $HASH -t ${TRACKER_IP}:6881 -p + +#rm -f ${HASH}* diff --git a/ControlScripts/clients/swift/start_swift_seeder.sh b/ControlScripts/clients/swift/start_swift_seeder.sh new file mode 100755 index 0000000..d642c49 --- /dev/null +++ b/ControlScripts/clients/swift/start_swift_seeder.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# 2010 Calin-Andrei Burloiu, calin.burloiu@gmail.com +# +# Bash script used to start a swift instance +# The script +# * changes current working directory to TorrentsAndData +# * starts a swift session +# * at the end deletes the downloaded data +# +# If you run this script manually, you must run it from the P2P-Testing-Infrastructure/ControlScripts folder +# + +# Read the global configuration file +# Check if the global configuration file exists +if [ ! -e globalconfig ]; then + echo "Warning: The global config file globalconfig does not exist." +else + source globalconfig +fi + +# Read the node-specific configuration file (TORRENT_FILE) +# Check if the node-specific configuration file exists +if [ ! -e ../ClientWorkingFolders/TmpLogs/node_config ]; then + echo "Warning: The global config file ../ClientWorkingFolders/TmpLogs/node_config does not exist." +else + source ../ClientWorkingFolders/TmpLogs/node_config +fi + +# convert host_id and veid to veth IP address in 10.0.0.0/8 network +host_veid_to_eth_ip() +{ + host_id=$1 + veid=$2 + ip_part1=$(($veid / 100)) + ip_part2=$(($veid % 100)) + id=$(echo "$host_id" | awk '{printf "%d", $1;}') + echo "10.$ip_part1.$id.$ip_part2" +} + +# convert p2p-next-${host_id}-${veid} hostname to veth IP address +hostname_to_ip() +{ + hostname=$1 + + veid=${hostname##*-} +tmp=${hostname%-*} + host_id=${tmp##*-} + + host_veid_to_eth_ip $host_id $veid +} + +OWN_IP=$(host_name_to_ip $(hostname)) +DATA_PATH=$WORKING_FOLDER_REL_PATH/TorrentsAndData/ + +cd $SWIFT_ABS_PATH + +./swift -f ${DATA_PATH}/${TORRENT_FILE} -l ${OWN_IP}:6881 -p diff --git a/ControlScripts/clients/swift/stop_swift.sh b/ControlScripts/clients/swift/stop_swift.sh new file mode 100755 index 0000000..c59a8f9 --- /dev/null +++ b/ControlScripts/clients/swift/stop_swift.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# 2010, Calin-Andrei Burloiu. calin.burloiu@gmail.com +# +# Bash script used to stop all swift instances +# The script +# * stops all the swift instances + +if [ ! $# -eq 0 ]; then + echo "usage: $0" + exit 1 +fi + +pkill swift diff --git a/Results/.gitignore b/Results/.gitignore index 4de6864..6e7e6b4 100644 --- a/Results/.gitignore +++ b/Results/.gitignore @@ -1,3 +1,2 @@ -/*campaign* -/*performance* -/tsup* +*campaign* +*performance* -- 2.20.1