ControlScripts: swift
authorP2P-Next <p2p-next@cs.pub.ro>
Fri, 19 Nov 2010 13:48:51 +0000 (15:48 +0200)
committerP2P-Next <p2p-next@cs.pub.ro>
Fri, 19 Nov 2010 13:49:01 +0000 (15:49 +0200)
ControlScripts/clients/swift/detect_complete_swift.sh [new file with mode: 0755]
ControlScripts/clients/swift/start_swift_leecher.sh [new file with mode: 0755]
ControlScripts/clients/swift/start_swift_seeder.sh [new file with mode: 0755]
ControlScripts/clients/swift/stop_swift.sh [new file with mode: 0755]
Results/.gitignore

diff --git a/ControlScripts/clients/swift/detect_complete_swift.sh b/ControlScripts/clients/swift/detect_complete_swift.sh
new file mode 100755 (executable)
index 0000000..4a5cd79
--- /dev/null
@@ -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 (executable)
index 0000000..83f9949
--- /dev/null
@@ -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 (executable)
index 0000000..d642c49
--- /dev/null
@@ -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 (executable)
index 0000000..c59a8f9
--- /dev/null
@@ -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
index 4de6864..6e7e6b4 100644 (file)
@@ -1,3 +1,2 @@
-/*campaign*
-/*performance*
-/tsup*
+*campaign*
+*performance*