Skip to content

Commit 6066c32

Browse files
authored
vertx-web-kotlin-dsljson updates (#10492)
1 parent b4f299a commit 6066c32

File tree

5 files changed

+20
-67
lines changed

5 files changed

+20
-67
lines changed

frameworks/Kotlin/vertx-web-kotlin-dsljson/build.gradle.kts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import nu.studer.gradle.rocker.RockerConfig
1+
import java.net.URI
2+
import java.nio.charset.StandardCharsets
23
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
34
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
45
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
56
import org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask
6-
import java.net.URI
7-
import java.nio.charset.StandardCharsets
87

98
plugins {
109
alias(libs.plugins.kotlin.jvm)
@@ -73,8 +72,12 @@ dependencies {
7372

7473
// Log4j
7574
implementation(libs.log4j.core)
75+
kapt(libs.log4j.core)
76+
7677
implementation(libs.log4j.api)
7778
implementation(libs.log4j.api.kotlin)
79+
80+
// Disruptor
7881
implementation(libs.disruptor)
7982

8083
// Rocker
@@ -85,7 +88,7 @@ dependencies {
8588
rocker {
8689
version = libs.versions.rocker.asProvider().get()
8790
configurations {
88-
create("main") {
91+
create("main").apply {
8992
javaVersion = "25"
9093
templateDir = project.layout.projectDirectory.dir("src/main/resources/rocker")
9194
outputDir = project.layout.buildDirectory.dir("generated/source/rocker")
@@ -171,7 +174,12 @@ tasks {
171174
}
172175

173176
shadowJar {
177+
mainClass = application.mainClass.get()
174178
archiveClassifier = "fat"
175179
mergeServiceFiles()
180+
entryCompression = ZipEntryCompression.STORED
181+
182+
exclude("META-INF/versions/**/module-info.class")
183+
exclude("module-info.class")
176184
}
177185
}

frameworks/Kotlin/vertx-web-kotlin-dsljson/gradle.properties

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ org.gradle.daemon=true
22
org.gradle.parallel=true
33
org.gradle.caching=true
44
org.gradle.configureondemand=true
5-
6-
org.gradle.jvmargs=-Xms512m -Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8
7-
org.gradle.workers.max=8
5+
org.gradle.jvmargs=-Xms2g -Xmx4g -XX:MaxMetaspaceSize=512m -XX:+UseParallelGC -Dfile.encoding=UTF-8
86

97
kotlin.incremental=true
108
kotlin.parallel.tasks.in.project=true

frameworks/Kotlin/vertx-web-kotlin-dsljson/src/main/kotlin/com/example/starter/db/WorldRepository.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ import io.vertx.sqlclient.Tuple
1212
import io.vertx.sqlclient.impl.SqlClientInternal
1313
import io.vertx.sqlclient.internal.ArrayTuple
1414
import java.util.concurrent.ThreadLocalRandom
15-
import java.util.concurrent.atomic.AtomicInteger
1615

1716
@Suppress("NOTHING_TO_INLINE", "UNCHECKED_CAST")
1817
class WorldRepository private constructor(
1918
conn: PgConnection,
2019
private val selectWorldQuery: PreparedQuery<RowSet<Row>>,
2120
private val updateWorldQueries: Array<PreparedQuery<RowSet<Row>>>,
2221
) : AbstractRepository<World>(conn) {
22+
2323
fun selectRandomWorld(): Future<World> = selectWorldQuery
2424
.execute(Tuple.of(randomWorld()))
2525
.map { map(it.first()) }
2626

2727
fun selectRandomWorlds(numWorlds: Int): Future<Array<World>> {
2828
val promise = Promise.promise<Array<World>>()
2929
val arr = arrayOfNulls<World>(numWorlds)
30-
val count = AtomicInteger(0)
30+
var count = 0
3131
(this.conn as SqlClientInternal).group { c ->
3232
val query = c.preparedQuery(SELECT_WORLD_SQL)
3333
repeat(numWorlds) { _ ->
@@ -36,13 +36,13 @@ class WorldRepository private constructor(
3636
when {
3737
ar.succeeded() -> {
3838
val result = ar.result()
39-
val index = count.getAndIncrement()
39+
val index = count++
4040
arr[index] = map(result.iterator().next())
4141
if (index == numWorlds - 1) {
4242
promise.complete(arr as Array<World>)
4343
}
4444
}
45-
else -> promise.fail(ar.cause())
45+
else -> promise.tryFail(ar.cause())
4646
}
4747
}
4848
}
@@ -68,6 +68,7 @@ class WorldRepository private constructor(
6868
private const val SELECT_WORLD_SQL = "SELECT id, randomnumber FROM world WHERE id = $1"
6969

7070
private inline fun randomWorld(): Int = 1 + ThreadLocalRandom.current().nextInt(10_000)
71+
7172
private inline fun map(row: Row): World = World(
7273
row.getInteger(0),
7374
row.getInteger(1),

frameworks/Kotlin/vertx-web-kotlin-dsljson/src/main/kotlin/com/example/starter/handlers/DefaultHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import io.vertx.core.buffer.Buffer
66
import io.vertx.core.http.HttpServerRequest
77

88
class DefaultHandler : AbstractHandler() {
9+
910
fun plaintext(req: HttpServerRequest): Future<Void> = req
1011
.response().apply {
1112
headers().setAll(PeriodicResolver.plaintext)

frameworks/Kotlin/vertx-web-kotlin-dsljson/src/main/kotlin/com/example/starter/helpers/Properties.kt

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,12 @@ object Properties {
2626
*/
2727
val EVENT_LOOP_POOL_SIZE: Int = SystemPropertyUtil.getInt("tfb.eventLoopPoolSize", CpuCoreSensor.availableProcessors())
2828

29-
/**
30-
* Whether metrics are enabled.
31-
* Default: Reverse of `vertx.disableMetrics` (defaults to true)
32-
*/
33-
val METRICS_ENABLED: Boolean = SystemPropertyUtil.getBoolean("vertx.disableMetrics", true).not()
34-
3529
/**
3630
* Port the HTTP server listens on.
3731
* Default: 8080 (tfb.http.port)
3832
*/
3933
val HTTP_PORT: Int = SystemPropertyUtil.getInt("tfb.http.port", 8080)
4034

41-
/**
42-
* Size of TCP send buffer for HTTP connections, in bytes.
43-
* Default: 32768 (tfb.http.sendBufferSize)
44-
*/
45-
val HTTP_SEND_BUFFER_SIZE: Int = SystemPropertyUtil.getInt("tfb.http.sendBufferSize", 256 * 1024)
46-
47-
/**
48-
* Size of TCP receive buffer for HTTP connections, in bytes.
49-
* Default: 32768 (tfb.http.receiveBufferSize)
50-
*/
51-
val HTTP_RECEIVE_BUFFER_SIZE: Int = SystemPropertyUtil.getInt("tfb.http.receiveBufferSize", 256 * 1024)
52-
53-
/**
54-
* Enables TCP Fast Open on the HTTP server.
55-
* Default: true (tfb.http.tcpFastOpen)
56-
*/
57-
val HTTP_TCP_FASTOPEN: Boolean = SystemPropertyUtil.getBoolean("tfb.http.tcpFastOpen", false)
58-
59-
/**
60-
* Enables TCP_NODELAY (disables Nagle) on HTTP connections.
61-
* Default: true (tfb.http.tcpNoDelay)
62-
*/
63-
val HTTP_TCP_NODELAY: Boolean = SystemPropertyUtil.getBoolean("tfb.http.tcpNoDelay", false)
64-
65-
/**
66-
* Idle timeout for HTTP connections in seconds.
67-
* 0 disables idle timeout.
68-
* Default: 0 (tfb.http.idleTimeout)
69-
*/
70-
val HTTP_IDLE_TIMEOUT: Int = SystemPropertyUtil.getInt("tfb.http.idleTimeout", 0)
71-
72-
/**
73-
* Enables SO_REUSEADDR on the HTTP server socket.
74-
* Default: true (tfb.http.reuseAddress)
75-
*/
76-
val HTTP_REUSE_ADDRESS: Boolean = SystemPropertyUtil.getBoolean("tfb.http.reuseAddress", true)
77-
78-
/**
79-
* Enables SO_REUSEPORT on the HTTP server socket.
80-
* Default: true (tfb.http.reusePort)
81-
*/
82-
val HTTP_REUSE_PORT: Boolean = SystemPropertyUtil.getBoolean("tfb.http.reusePort", true)
83-
84-
/**
85-
* Size of the TCP accept backlog for the HTTP server.
86-
* Default: 8192 (tfb.http.acceptBacklog)
87-
*/
88-
val HTTP_ACCEPT_BACKLOG: Int = SystemPropertyUtil.getInt("tfb.http.acceptBacklog", 8192)
89-
9035
/**
9136
* PostgreSQL username used for connections.
9237
* Default: benchmarkdbuser (tfb.pg.user)
@@ -157,7 +102,7 @@ object Properties {
157102
cachePreparedStatements = PG_CACHE_PREPARED_STATEMENTS,
158103
preparedStatementCacheMaxSize = PG_PREPARED_STATEMENT_CACHE_MAX_SIZE,
159104
tracingPolicy = TracingPolicy.IGNORE,
160-
pipeliningLimit = PG_PIPELINING_LIMIT
105+
pipeliningLimit = PG_PIPELINING_LIMIT,
161106
)
162107
}
163108
}

0 commit comments

Comments
 (0)