Skip to content
Snippets Groups Projects
Commit 6efbd7b5 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Make WorkloadGeneratorStateCleaner recursive

parent 6d9d375e
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
...@@ -29,22 +29,27 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { ...@@ -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. * Deletes a Zookeeper node and its children with the corresponding path.
*/ */
fun deleteAll() { private fun deleteRecusiveAll(nodePath: String) {
while (true) { while (true) {
var children = emptyList<String>(); var children: List<String>
try { try {
children = zookeeperClient.getChildren(this.path, true) children = zookeeperClient.getChildren(nodePath, true)
} catch (e: KeeperException.NoNodeException) { } catch (e: KeeperException.NoNodeException) {
break; break;
} }
// delete all children nodes // recursivly delete all children nodes
for (s: String in children) { for (s: String in children) {
try { try {
zookeeperClient.delete("${this.path}/$s", -1) deleteRecusiveAll("$nodePath/$s")
} catch (ex: Exception) { } catch (ex: Exception) {
logger.info { "$ex" } logger.info { "$ex" }
} }
...@@ -52,7 +57,7 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { ...@@ -52,7 +57,7 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) {
// delete main node // delete main node
try { try {
zookeeperClient.delete(this.path, -1) zookeeperClient.delete(nodePath, -1)
break; break;
} catch (ex: Exception) { } catch (ex: Exception) {
// no instance of node found // no instance of node found
...@@ -65,7 +70,6 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) { ...@@ -65,7 +70,6 @@ class WorkloadGeneratorStateCleaner(ip: String, val path: String) {
Thread.sleep(retryAfter.toMillis()) Thread.sleep(retryAfter.toMillis())
logger.info { "ZooKeeper reset was not successful. Retrying in 5s" } logger.info { "ZooKeeper reset was not successful. Retrying in 5s" }
} }
logger.info { "ZooKeeper reset was successful" }
} }
/** /**
......
...@@ -4,6 +4,7 @@ import theodolite.k8s.UC1Benchmark ...@@ -4,6 +4,7 @@ import theodolite.k8s.UC1Benchmark
abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) { abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) {
fun start(load: LoadDimension, resources: Resource) { fun start(load: LoadDimension, resources: Resource) {
this.clearClusterEnvironment()
this.initializeClusterEnvironment() this.initializeClusterEnvironment()
this.startSUT(resources) this.startSUT(resources)
this.startWorkloadGenerator(load) this.startWorkloadGenerator(load)
...@@ -14,6 +15,5 @@ abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) { ...@@ -14,6 +15,5 @@ abstract class Benchmark(val config: UC1Benchmark.UC1BenchmarkConfig) {
abstract fun startSUT(resources: Resource); abstract fun startSUT(resources: Resource);
abstract fun startWorkloadGenerator(load: LoadDimension); abstract fun startWorkloadGenerator(load: LoadDimension)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment