From 047d3dba34a58286cf2bbc7071d8aa53676fb786 Mon Sep 17 00:00:00 2001
From: lorenz <stu203404@mail.uni-kiel.de>
Date: Sun, 10 Jan 2021 23:43:02 +0100
Subject: [PATCH] Add naive reset Zookeeper

---
 .../src/main/kotlin/theodolite/Main.kt        |  1 +
 .../src/main/kotlin/theodolite/RunUc.kt       | 21 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt
index 705d18a25..e83c7bdff 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt
@@ -15,5 +15,6 @@ object Main {
         run.createTopics(testtopic, 1.toShort())
         run.deleteTopics(listOf("test"))
         //Quarkus.run()
+        run.resetZookeeper()
     }
 }
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/RunUc.kt b/theodolite-quarkus/src/main/kotlin/theodolite/RunUc.kt
index c88bc17f0..d9d0071dd 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/RunUc.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/RunUc.kt
@@ -4,7 +4,13 @@ import org.apache.kafka.clients.admin.AdminClient
 import org.apache.kafka.clients.admin.AdminClientConfig
 import org.apache.kafka.clients.admin.ListTopicsResult
 import org.apache.kafka.clients.admin.NewTopic
+import org.apache.zookeeper.Watcher
+import org.apache.zookeeper.ZooKeeper
 import java.util.*
+import org.apache.zookeeper.WatchedEvent
+
+
+
 
 class RunUc (){
     val bootstrapServer = "my-confluent-cp-zookeeper:2181"
@@ -52,12 +58,25 @@ class RunUc (){
 
     fun getTopics(): ListTopicsResult? {
         return kafkaAdmin.listTopics()
+
     }
 
-    fun reset_zookeeper(){
+    fun resetZookeeper(){
+        val watcher :Watcher = startWatcher()
 
+        val zookeeperclient = ZooKeeper(ip,60, watcher)
+        zookeeperclient.delete("/workload-generation", -1)
+        System.out.println("Deletion executed")
     }
 
+    private fun startWatcher(): Watcher {
+        return Watcher { event ->
+            System.out.println(event.toString())
+            System.out.println(event.state.toString())
+        }
+    }
+
+
     fun start_workload_generator(wg: String, dim_value:Integer, uc_id: String){
 
     }
-- 
GitLab