Browse Source

[Hexagon] Delete MongoDB DB support (#6783)

* Fix error with URLs in JEE servers

* Clean up

* Avoid classpath URLs

* Fix template loading error

* Fix template loading error

* Chores

* Fix template loading error

* Delete MongoDB DB support

Storage support in Hexagon will be moved outside the Toolkit, and so, it will be left outside the benchmark.

* Fix runtime problem

* Update Hexagon version

* Make Jackson Blackbird module optional
Juanjo Aguililla 4 years ago
parent
commit
85cca42381

+ 1 - 4
frameworks/Kotlin/hexagon/README.md

@@ -18,10 +18,7 @@ You can run tests against any running server passing the `verify.endpoint` proje
 
 ## Test URLs
 
-In URLs replace `${DB_ENGINE}` with one of:
-
-* mongodb
-* postgresql
+In URLs replace `${DB_ENGINE}` with: `postgresql`
 
 and `${TEMPLATE_ENGINE}` with: `pebble`
 

+ 1 - 47
frameworks/Kotlin/hexagon/benchmark_config.json

@@ -3,52 +3,6 @@
     "tests": [
         {
             "default": {
-                "json_url": "/json",
-                "db_url": "/mongodb/db",
-                "query_url": "/mongodb/query?queries=",
-                "fortune_url": "/mongodb/pebble/fortunes",
-                "update_url": "/mongodb/update?queries=",
-                "cached_query_url": "/mongodb/cached?count=",
-                "plaintext_url": "/plaintext",
-                "port": 9090,
-                "approach": "Realistic",
-                "classification": "Micro",
-                "database": "mongodb",
-                "framework": "Hexagon",
-                "language": "Kotlin",
-                "orm": "Raw",
-                "platform": "Servlet",
-                "webserver": "None",
-                "os": "Linux",
-                "database_os": "Linux",
-                "display_name": "Hexagon Jetty MongoDB",
-                "notes": "http://hexagonkt.com",
-                "versus": "servlet"
-            },
-            "resin-mongodb": {
-                "json_url": "/json",
-                "db_url": "/mongodb/db",
-                "query_url": "/mongodb/query?queries=",
-                "fortune_url": "/mongodb/pebble/fortunes",
-                "update_url": "/mongodb/update?queries=",
-                "cached_query_url": "/mongodb/cached?count=",
-                "plaintext_url": "/plaintext",
-                "port": 8080,
-                "approach": "Realistic",
-                "classification": "Micro",
-                "database": "mongodb",
-                "framework": "Hexagon",
-                "language": "Kotlin",
-                "orm": "Raw",
-                "platform": "Servlet",
-                "webserver": "None",
-                "os": "Linux",
-                "database_os": "Linux",
-                "display_name": "Hexagon Resin MongoDB",
-                "notes": "http://hexagonkt.com",
-                "versus": "servlet"
-            },
-            "jetty-postgresql": {
                 "json_url": "/json",
                 "db_url": "/postgresql/db",
                 "query_url": "/postgresql/query?queries=",
@@ -71,7 +25,7 @@
                 "notes": "http://hexagonkt.com",
                 "versus": "servlet"
             },
-            "resin-postgresql": {
+            "resin": {
                 "json_url": "/json",
                 "db_url": "/postgresql/db",
                 "query_url": "/postgresql/query?queries=",

+ 2 - 3
frameworks/Kotlin/hexagon/build.gradle

@@ -4,9 +4,9 @@ plugins {
 }
 
 ext {
-    gradleScripts = "https://raw.githubusercontent.com/hexagonkt/hexagon/1.4.0/gradle"
+    gradleScripts = "https://raw.githubusercontent.com/hexagonkt/hexagon/1.4.2/gradle"
 
-    hexagonVersion = "1.4.0"
+    hexagonVersion = "1.4.2"
     hikariVersion = "5.0.0"
     jettyVersion = "10.0.6"
     postgresqlVersion = "42.2.23"
@@ -32,7 +32,6 @@ war {
 installDist.dependsOn("war")
 
 dependencies {
-    implementation("com.hexagonkt:store_mongodb:$hexagonVersion")
     implementation("com.hexagonkt:http_server_jetty:$hexagonVersion")
     implementation("com.hexagonkt:templates_pebble:$hexagonVersion")
     implementation("com.hexagonkt:logging_slf4j_jul:$hexagonVersion")

+ 1 - 37
frameworks/Kotlin/hexagon/config.toml

@@ -4,24 +4,6 @@ name = "hexagon"
 [main]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
-urls.db = "/mongodb/db"
-urls.query = "/mongodb/query?queries="
-urls.update = "/mongodb/update?queries="
-urls.fortune = "/mongodb/pebble/fortunes"
-urls.cached_query = "/mongodb/cached?count="
-approach = "Realistic"
-classification = "Micro"
-database = "mongodb"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Servlet"
-webserver = "None"
-versus = "servlet"
-
-[resin-postgresql]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
 urls.db = "/postgresql/db"
 urls.query = "/postgresql/query?queries="
 urls.update = "/postgresql/update?queries="
@@ -37,7 +19,7 @@ platform = "Servlet"
 webserver = "None"
 versus = "servlet"
 
-[jetty-postgresql]
+[resin]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 urls.db = "/postgresql/db"
@@ -54,21 +36,3 @@ orm = "Raw"
 platform = "Servlet"
 webserver = "None"
 versus = "servlet"
-
-[resin-mongodb]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/mongodb/db"
-urls.query = "/mongodb/query?queries="
-urls.update = "/mongodb/update?queries="
-urls.fortune = "/mongodb/pebble/fortunes"
-urls.cached_query = "/mongodb/cached?count="
-approach = "Realistic"
-classification = "Micro"
-database = "mongodb"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Servlet"
-webserver = "None"
-versus = "servlet"

+ 0 - 25
frameworks/Kotlin/hexagon/hexagon-jetty-postgresql.dockerfile

@@ -1,25 +0,0 @@
-#
-# BUILD
-#
-FROM gradle:7.1-jdk11 AS gradle_build
-USER root
-WORKDIR /hexagon
-
-COPY src src
-COPY build.gradle build.gradle
-RUN gradle --quiet --exclude-task test
-
-#
-# RUNTIME
-#
-FROM adoptopenjdk:11-jre-hotspot-bionic
-ENV DBSTORE postgresql
-ENV POSTGRESQL_DB_HOST tfb-database
-ENV WEBENGINE jetty
-ENV PROJECT hexagon
-
-COPY --from=gradle_build /hexagon/build/install/$PROJECT /opt/$PROJECT
-
-EXPOSE 9090
-
-ENTRYPOINT /opt/$PROJECT/bin/$PROJECT

+ 0 - 26
frameworks/Kotlin/hexagon/hexagon-resin-mongodb.dockerfile

@@ -1,26 +0,0 @@
-#
-# BUILD
-#
-FROM gradle:7.1-jdk11 AS gradle_build
-USER root
-WORKDIR /hexagon
-
-COPY src src
-COPY build.gradle build.gradle
-RUN gradle --quiet --exclude-task test
-
-#
-# RUNTIME
-#
-FROM adoptopenjdk:11-jre-hotspot-bionic
-ENV DBSTORE mongodb
-ENV MONGODB_DB_HOST tfb-database
-ENV RESIN http://caucho.com/download/resin-4.0.65.tar.gz
-
-WORKDIR /resin
-RUN curl -sL $RESIN | tar xz --strip-components=1
-RUN rm -rf webapps/*
-COPY --from=gradle_build /hexagon/build/libs/ROOT.war webapps/ROOT.war
-COPY src/main/resources/fortunes.pebble.html fortunes.pebble.html
-EXPOSE 9090
-CMD ["java", "-jar", "lib/resin.jar", "console"]

+ 2 - 2
frameworks/Kotlin/hexagon/hexagon-resin-postgresql.dockerfile → frameworks/Kotlin/hexagon/hexagon-resin.dockerfile

@@ -1,13 +1,13 @@
 #
 # BUILD
 #
-FROM gradle:7.1-jdk11 AS gradle_build
+FROM gradle:7.2-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
 COPY src src
 COPY build.gradle build.gradle
-RUN gradle --quiet --exclude-task test
+RUN gradle --quiet
 
 #
 # RUNTIME

+ 4 - 4
frameworks/Kotlin/hexagon/hexagon.dockerfile

@@ -1,20 +1,20 @@
 #
 # BUILD
 #
-FROM gradle:7.1-jdk11 AS gradle_build
+FROM gradle:7.2-jdk11 AS gradle_build
 USER root
 WORKDIR /hexagon
 
 COPY src src
 COPY build.gradle build.gradle
-RUN gradle --quiet --exclude-task test
+RUN gradle --quiet
 
 #
 # RUNTIME
 #
 FROM adoptopenjdk:11-jre-hotspot-bionic
-ENV DBSTORE mongodb
-ENV MONGODB_DB_HOST tfb-database
+ENV DBSTORE postgresql
+ENV POSTGRESQL_DB_HOST tfb-database
 ENV WEBENGINE jetty
 ENV PROJECT hexagon
 

+ 3 - 6
frameworks/Kotlin/hexagon/src/main/kotlin/Benchmark.kt

@@ -6,7 +6,6 @@ import com.hexagonkt.http.server.ServerPort
 import com.hexagonkt.http.server.ServerSettings
 import com.hexagonkt.http.server.jetty.JettyServletAdapter
 import com.hexagonkt.serialization.*
-import com.hexagonkt.store.BenchmarkMongoDbStore
 import com.hexagonkt.store.BenchmarkSqlStore
 import com.hexagonkt.store.BenchmarkStore
 import com.hexagonkt.templates.TemplatePort
@@ -14,10 +13,7 @@ import com.hexagonkt.templates.pebble.PebbleAdapter
 import java.net.InetAddress
 
 internal val benchmarkStores: Map<String, BenchmarkStore> by lazy {
-    mapOf(
-        "mongodb" to BenchmarkMongoDbStore("mongodb"),
-        "postgresql" to BenchmarkSqlStore("postgresql")
-    )
+    mapOf("postgresql" to BenchmarkSqlStore("postgresql"))
 }
 
 internal val benchmarkTemplateEngines: Map<String, TemplatePort> by lazy {
@@ -40,7 +36,8 @@ internal val benchmarkServer: Server by lazy {
 }
 
 fun main() {
-    Json.mapper.registerModule(BlackbirdModule())
+    if (System.getenv().containsKey("ENABLE_BLACKBIRD"))
+        Json.mapper.registerModule(BlackbirdModule())
     SerializationManager.mapper = JacksonMapper
     SerializationManager.formats = linkedSetOf(Json)
 

+ 0 - 57
frameworks/Kotlin/hexagon/src/main/kotlin/store/BenchmarkMongoDbStore.kt

@@ -1,57 +0,0 @@
-package com.hexagonkt.store
-
-import com.hexagonkt.CachedWorld
-import com.hexagonkt.Fortune
-import com.hexagonkt.Settings
-import com.hexagonkt.World
-import com.hexagonkt.helpers.Jvm
-import com.hexagonkt.helpers.fail
-import com.hexagonkt.store.mongodb.MongoDbStore
-import org.cache2k.Cache
-
-internal class BenchmarkMongoDbStore(engine: String, private val settings: Settings = Settings())
-    : BenchmarkStore(settings) {
-
-    data class MongoDbWorld(val _id: Int, val id: Int, val randomNumber: Int)
-    data class MongoDbFortune(val _id: Int, val message: String)
-
-    private val dbHost: String by lazy { Jvm.systemSetting("${engine.uppercase()}_DB_HOST") ?: "localhost" }
-
-    private val dbUrl: String by lazy { "mongodb://$dbHost/${settings.databaseName}" }
-
-    private val worldRepository: MongoDbStore<MongoDbWorld, Int> by lazy {
-        MongoDbStore(MongoDbWorld::class, MongoDbWorld::_id, dbUrl, settings.worldName)
-    }
-
-    private val fortuneRepository by lazy {
-        MongoDbStore(MongoDbFortune::class, MongoDbFortune::_id, dbUrl, settings.fortuneName)
-    }
-
-    override fun findAllFortunes(): List<Fortune> = fortuneRepository.findAll().map { Fortune(it._id, it.message) }
-
-    override fun findWorlds(ids: List<Int>): List<World> =
-        ids.mapNotNull { worldRepository.findOne(it) }.map { World(it.id, it.randomNumber) }
-
-    override fun replaceWorlds(worlds: List<World>) {
-        worlds.forEach {
-            val world = worldRepository.findOne(it.id) ?: fail
-            val worldCopy = world.copy(randomNumber = it.randomNumber)
-            worldRepository.replaceOne(worldCopy)
-        }
-    }
-
-    override fun initWorldsCache(cache: Cache<Int, CachedWorld>) {
-        worldRepository.findAll().forEach {
-            cache.put(it.id, CachedWorld(it.id, it.randomNumber))
-        }
-    }
-
-    override fun loadCachedWorld(id: Int): CachedWorld =
-        worldRepository.findOne(id)
-            ?.let { world -> CachedWorld(world.id, world.randomNumber)  }
-            ?: error("World not found: $id")
-
-    override fun close() {
-        /* Not needed */
-    }
-}