From 67a5df97a1665a941692bd6d9d27419bccc6c240 Mon Sep 17 00:00:00 2001
From: David Georg Reichelt <davidgeorg_reichelt@dagere.de>
Date: Wed, 18 Aug 2021 11:08:09 +0200
Subject: [PATCH] Only download Kieker agent if it is not present

---
 frameworks/Kieker/scripts/benchmark.sh     |  2 ++
 frameworks/Kieker/scripts/run-benchmark.sh |  4 ----
 frameworks/common-functions.sh             | 11 +++++++++++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/frameworks/Kieker/scripts/benchmark.sh b/frameworks/Kieker/scripts/benchmark.sh
index f8633e4..25694a2 100755
--- a/frameworks/Kieker/scripts/benchmark.sh
+++ b/frameworks/Kieker/scripts/benchmark.sh
@@ -18,6 +18,8 @@ fi
 
 source ../../common-functions.sh
 
+getKiekerAgent
+
 if [ -f "${BASE_DIR}/common-functions" ] ; then
 	. ${BASE_DIR}/common-functions
 else
diff --git a/frameworks/Kieker/scripts/run-benchmark.sh b/frameworks/Kieker/scripts/run-benchmark.sh
index 4a2b585..b80da7c 100755
--- a/frameworks/Kieker/scripts/run-benchmark.sh
+++ b/frameworks/Kieker/scripts/run-benchmark.sh
@@ -28,10 +28,6 @@ cd ${BASE_DIR}
 ## setup
 # install benchmark
 tar -xvpf ${BASE_DIR}/../../../benchmark/build/distributions/benchmark.tar
-# get agent
-export VERSION_PATH=`curl "https://oss.sonatype.org/service/local/repositories/snapshots/content/net/kieker-monitoring/kieker/" | grep '<resourceURI>' | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | grep '/$'`
-export AGENT_PATH=`curl "${VERSION_PATH}" | grep 'aspectj.jar</resourceURI' | sort | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | tail -1`
-curl "${AGENT_PATH}" > "${AGENT}"
 # copy receiver
 tar -xvpf ${BASE_DIR}/../../../tools/receiver/build/distributions/receiver.tar
 # copy result compiler
diff --git a/frameworks/common-functions.sh b/frameworks/common-functions.sh
index 11ae83f..3be5520 100644
--- a/frameworks/common-functions.sh
+++ b/frameworks/common-functions.sh
@@ -12,6 +12,17 @@ function cleanup-results() {
   [ -f ${DATA_DIR}/nohup.out ] && > ${DATA_DIR}/nohup.out
 }
 
+function getKiekerAgent() {
+	echo "Checking whether Kieker is present in $AGENT"
+	if [ ! -f $AGENT ]
+	then
+		# get agent
+		export VERSION_PATH=`curl "https://oss.sonatype.org/service/local/repositories/snapshots/content/net/kieker-monitoring/kieker/" | grep '<resourceURI>' | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | grep '/$'`
+		export AGENT_PATH=`curl "${VERSION_PATH}" | grep 'aspectj.jar</resourceURI' | sort | sed 's/ *<resourceURI>//g' | sed 's/<\/resourceURI>//g' | tail -1`
+		curl "${AGENT_PATH}" > "${AGENT}"
+	fi
+}
+
 # Initialize all unset parameters
 if [ -z $SLEEP_TIME ]; then
 	SLEEP_TIME=30           ## 30
-- 
GitLab