diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/WorkloadGeneratorStateCleaner.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/WorkloadGeneratorStateCleaner.kt index ca43e914b14693ae80d80440de284890d4dcad75..7b1f8c29d60032e7e0980af2192d2928cf8c0cf6 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/WorkloadGeneratorStateCleaner.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/WorkloadGeneratorStateCleaner.kt @@ -29,22 +29,27 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { } } + fun deleteAll() { + deleteRecusiveAll(this.path) + logger.info { "ZooKeeper reset was successful" } + } + /** * Deletes a Zookeeper node and its children with the corresponding path. */ - fun deleteAll() { + private fun deleteRecusiveAll(nodePath: String) { while (true) { - var children = emptyList<String>(); + var children: List<String> try { - children = zookeeperClient.getChildren(this.path, true) + children = zookeeperClient.getChildren(nodePath, true) } catch (e: KeeperException.NoNodeException) { break; } - // delete all children nodes + // recursivly delete all children nodes for (s: String in children) { try { - zookeeperClient.delete("${this.path}/$s", -1) + deleteRecusiveAll("$nodePath/$s") } catch (ex: Exception) { logger.info { "$ex" } } @@ -52,7 +57,7 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { // delete main node try { - zookeeperClient.delete(this.path, -1) + zookeeperClient.delete(nodePath, -1) break; } catch (ex: Exception) { // no instance of node found @@ -65,7 +70,6 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { Thread.sleep(retryAfter.toMillis()) logger.info { "ZooKeeper reset was not successful. Retrying in 5s" } } - logger.info { "ZooKeeper reset was successful" } } /** diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt index 7b168037d7f4d4874b065ece6654ccb2d92e93ec..0cb342a2912dfde8d976765c66114e86555128c5 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Benchmark.kt @@ -4,6 +4,7 @@ import theodolite.k8s.UC1Benchmark abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) { fun start(load: LoadDimension, resources: Resource) { + this.clearClusterEnvironment() this.initializeClusterEnvironment() this.startSUT(resources) this.startWorkloadGenerator(load) @@ -14,6 +15,5 @@ abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) { abstract fun startSUT(resources: Resource); - abstract fun startWorkloadGenerator(load: LoadDimension); - -} \ No newline at end of file + abstract fun startWorkloadGenerator(load: LoadDimension) +}