diff --git a/theodolite-quarkus/README.md b/theodolite-quarkus/README.md index 053c3e214f8ff24a53b7ffb068c6033c3d449fd1..bb99f34e80f8b61b42f9b10b4c1d988871b74cb0 100644 --- a/theodolite-quarkus/README.md +++ b/theodolite-quarkus/README.md @@ -29,17 +29,18 @@ The application is now runnable using `java -jar build/theodolite-quarkus-1.0.0- ## Creating a native executable -You can create a native executable using: +You can create a native executable using: ```shell script ./gradlew build -Dquarkus.package.type=native ``` -Or, if you don't have GraalVM installed, you can run the native executable build in a container using: +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: ```shell script ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true ``` -You can then execute your native executable with: `./build/theodolite-quarkus-1.0.0-SNAPSHOT-runner` +You can then execute your native executable with: +```./build/theodolite-quarkus-1.0.0-SNAPSHOT-runner``` If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling. @@ -48,3 +49,28 @@ If you want to learn more about building native executables, please consult http <p>A Hello World RESTEasy resource</p> Guide: https://quarkus.io/guides/rest-json + +## Build and afterwards run the application in Docker container + +```build_jvm.sh``` to build the jvm version + +```build_native.sh``` to build the native image graal version + +## Install Detekt Code analysis Plugin + + +Install https://plugins.jetbrains.com/plugin/10761-detekt + +- Install the plugin +- Navigate to Settings/Preferences -> Tools -> Detekt +- Check Enable Detekt +- Specify your detekt configuration and baseline file (optional) + + +-> detekt issues will be annotated on-the-fly while coding + +**ingore Failures in build:** add + +```ignoreFailures = true``` + + to build.gradle detekt task diff --git a/theodolite-quarkus/build.gradle b/theodolite-quarkus/build.gradle index b3848d24140a12b8f61724e4886439ee5862da51..ffb2bcd64558cbe7e555a7ea34e8dfdb3f0f2959 100644 --- a/theodolite-quarkus/build.gradle +++ b/theodolite-quarkus/build.gradle @@ -2,11 +2,13 @@ plugins { id 'org.jetbrains.kotlin.jvm' version "1.3.72" id "org.jetbrains.kotlin.plugin.allopen" version "1.3.72" id 'io.quarkus' + id "io.gitlab.arturbosch.detekt" version "1.15.0" } repositories { mavenLocal() mavenCentral() + jcenter() } dependencies { @@ -21,6 +23,8 @@ dependencies { implementation 'io.fabric8:kubernetes-client:5.0.0-alpha-2' //implementation 'com.fkorotkov:kubernetes-dsl:2.8.1' + compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.7.0' + compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.6.2' } group 'theodolite' @@ -45,3 +49,8 @@ compileKotlin { compileTestKotlin { kotlinOptions.jvmTarget = JavaVersion.VERSION_11 } +detekt { + failFast = true // fail build on any finding + buildUponDefaultConfig = true + ignoreFailures = true +} \ No newline at end of file diff --git a/theodolite-quarkus/build_jvm.sh b/theodolite-quarkus/build_jvm.sh new file mode 100755 index 0000000000000000000000000000000000000000..f3970d08e62ac3661dac038148b011b774276ceb --- /dev/null +++ b/theodolite-quarkus/build_jvm.sh @@ -0,0 +1,7 @@ + +./gradlew build + +docker build -f src/main/docker/Dockerfile.jvm -t quarkus/theodolite-quarkus-jvm . + + +docker run -i --rm -p 8080:8080 quarkus/theodolite-quarkus-jvm diff --git a/theodolite-quarkus/build_native.sh b/theodolite-quarkus/build_native.sh new file mode 100755 index 0000000000000000000000000000000000000000..8b663f6edd909554acf4e53c5ff3304f7c8f150b --- /dev/null +++ b/theodolite-quarkus/build_native.sh @@ -0,0 +1,7 @@ + +./gradlew build -Dquarkus.package.type=native + + +docker build -f src/main/docker/Dockerfile.native -t quarkus/theodolite-quarkus . + +docker run -i --rm -p 8080:8080 quarkus/theodolite-quarkus diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/BenchmarkExecutor.kt new file mode 100644 index 0000000000000000000000000000000000000000..cf31b75ed26b8f214dd455d6a05e77b8599d6f8e --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/BenchmarkExecutor.kt @@ -0,0 +1,82 @@ +package theodolite + +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 org.apache.zookeeper.WatchedEvent + + + + +class RunUc (){ + val bootstrapServer = "my-confluent-cp-zookeeper:2181" + val ip = "172.18.0.9:5556" + val props = hashMapOf<String, Any>(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to "172.18.0.9:5556") + lateinit var kafkaAdmin: AdminClient + + init { + try { + kafkaAdmin = AdminClient.create(props) + } + catch (e: Exception) { + System.out.println(e.toString()) + + } + } + fun waitExecution(executionMinutes: Int) { + var milliToMinutes = 60000 + System.out.println("Wait while executing") + for (i in 1.rangeTo(executionMinutes)) { + Thread.sleep((milliToMinutes*i).toLong()); + System.out.println("Executed: "+i.toString()+" minutes") + } + + System.out.println("Execution finished") + } + + fun createTopics(topics: Map<String, Int>,replicationfactor: Short) { + + val newTopics = mutableSetOf<NewTopic>() + for (i in topics) { + val tops = NewTopic(i.key,i.value,replicationfactor) + newTopics.add(tops) + } + kafkaAdmin.createTopics(newTopics) + System.out.println("Topics created") + } + + fun deleteTopics(topics: List<String>) { + + var result = kafkaAdmin.deleteTopics(topics) + System.out.println(result.values().toString()) + + } + + fun getTopics(): ListTopicsResult? { + return kafkaAdmin.listTopics() + + } + + 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){ + + } +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt index 63de4f5004cf883da95430e1524223f63acc5475..c8a44751e13f4317a71616ccc3bbae0de8f188b2 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/Main.kt @@ -7,7 +7,7 @@ import theodolite.execution.TheodoliteExecutor object Main { @JvmStatic fun main(args: Array<String>) { - val theodolite = TheodoliteExecutor(); + val theodolite = TheodoliteExecutor() theodolite.run() } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/WorkloadGeneratorStateCleaner.kt b/theodolite-quarkus/src/main/kotlin/theodolite/WorkloadGeneratorStateCleaner.kt new file mode 100644 index 0000000000000000000000000000000000000000..c519b0c843ae3f75c21a7596446c700972b44753 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/WorkloadGeneratorStateCleaner.kt @@ -0,0 +1,58 @@ +package theodolite + +import org.apache.zookeeper.KeeperException +import org.apache.zookeeper.WatchedEvent +import org.apache.zookeeper.Watcher +import org.apache.zookeeper.ZooKeeper + +class WorkloadGeneratorStateCleaner(ip: String) { + val path = "/workload-generation" + val sessionTimeout = 60 + val retryTime = 3000L + lateinit var zookeeperClient: ZooKeeper + + init { + try { + val watcher: Watcher = ZookeperWatcher() // defined below + zookeeperClient = ZooKeeper(ip, sessionTimeout, watcher) + } catch (e:Exception) { + System.out.println(e.toString()) + } + } + + fun deleteAll() { + var deleted = false + while (!deleted) { + + // + try { + zookeeperClient.delete(path, -1) + } catch (ex: Exception) { + System.out.println(ex.toString()) + } + + try { + val clients = zookeeperClient.getChildren(path, true) + if (clients.isEmpty()){ + break; + } + } catch (ex: Exception) { + when (ex) { + is KeeperException -> { deleted = true } + is InterruptedException -> { + System.out.println(ex.toString()) + } + } + } + Thread.sleep(retryTime) + System.out.println("ZooKeeper reset was not successful. Retrying in 5s") + } + + System.out.println("ZooKeeper reset was successful") + } +} + +private class ZookeperWatcher : Watcher { + + override fun process(event: WatchedEvent) {} +} diff --git a/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt b/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt deleted file mode 100644 index 6f17e6294d428a769d5e02958628820a37e42f66..0000000000000000000000000000000000000000 --- a/theodolite-quarkus/src/native-test/kotlin/theodolite/NativeGreetingResourceIT.kt +++ /dev/null @@ -1,6 +0,0 @@ -package theodolite - -import io.quarkus.test.junit.NativeImageTest - -@NativeImageTest -class NativeGreetingResourceIT : CompositeStrategyTest() \ No newline at end of file