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) {
}
}
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" }
}
/**
......
......@@ -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)
}
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