fixed native image configuration task
All checks were successful
CI / build (push) Successful in 37m16s
All checks were successful
CI / build (push) Successful in 37m16s
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package net.woggioni.rbcs.cli.graal
|
||||
|
||||
import net.woggioni.jwo.NullOutputStream
|
||||
import net.woggioni.rbcs.api.Configuration
|
||||
import net.woggioni.rbcs.api.Configuration.User
|
||||
import net.woggioni.rbcs.api.Role
|
||||
import net.woggioni.rbcs.cli.RemoteBuildCacheServerCli
|
||||
import net.woggioni.rbcs.cli.impl.commands.BenchmarkCommand
|
||||
import net.woggioni.rbcs.cli.impl.commands.GetCommand
|
||||
import net.woggioni.rbcs.cli.impl.commands.HealthCheckCommand
|
||||
import net.woggioni.rbcs.client.RemoteBuildCacheClient
|
||||
import net.woggioni.rbcs.cli.impl.commands.PutCommand
|
||||
import net.woggioni.rbcs.common.HostAndPort
|
||||
import net.woggioni.rbcs.common.PasswordSecurity.hashPassword
|
||||
import net.woggioni.rbcs.common.RBCS
|
||||
@@ -16,12 +18,15 @@ import net.woggioni.rbcs.server.cache.FileSystemCacheConfiguration
|
||||
import net.woggioni.rbcs.server.cache.InMemoryCacheConfiguration
|
||||
import net.woggioni.rbcs.server.configuration.Parser
|
||||
import net.woggioni.rbcs.server.memcache.MemcacheCacheConfiguration
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.net.URI
|
||||
import java.nio.file.Path
|
||||
import java.time.Duration
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.concurrent.ExecutionException
|
||||
import java.util.zip.Deflater
|
||||
import net.woggioni.rbcs.client.Configuration as ClientConfiguration
|
||||
import net.woggioni.rbcs.client.impl.Parser as ClientConfigurationParser
|
||||
|
||||
object GraalNativeImageConfiguration {
|
||||
@JvmStatic
|
||||
@@ -30,15 +35,16 @@ object GraalNativeImageConfiguration {
|
||||
val serverDoc = RemoteBuildCacheServer.DEFAULT_CONFIGURATION_URL.openStream().use {
|
||||
Xml.parseXml(RemoteBuildCacheServer.DEFAULT_CONFIGURATION_URL, it)
|
||||
}
|
||||
Parser.parse(doc)
|
||||
Parser.parse(serverDoc)
|
||||
|
||||
val clientDoc = RemoteBuildCacheClient.Configuration.openStream().use {
|
||||
Xml.parseXml(RemoteBuildCacheServer.DEFAULT_CONFIGURATION_URL, it)
|
||||
val url = URI.create("file:conf/rbcs-client.xml").toURL()
|
||||
val clientDoc = url.openStream().use {
|
||||
Xml.parseXml(url, it)
|
||||
}
|
||||
Parser.parse(doc)
|
||||
ClientConfigurationParser.parse(clientDoc)
|
||||
|
||||
val PASSWORD = "password"
|
||||
val readersGroup = Configuration.Group("readers", setOf(Role.Reader), null, null)
|
||||
val readersGroup = Configuration.Group("readers", setOf(Role.Reader, Role.Healthcheck), null, null)
|
||||
val writersGroup = Configuration.Group("writers", setOf(Role.Writer), null, null)
|
||||
|
||||
|
||||
@@ -126,30 +132,44 @@ object GraalNativeImageConfiguration {
|
||||
val serverHandle = RemoteBuildCacheServer(serverConfiguration).run()
|
||||
|
||||
|
||||
val clientProfile = RemoteBuildCacheClient.Configuration.Profile(
|
||||
val clientProfile = ClientConfiguration.Profile(
|
||||
URI.create("http://127.0.0.1:$serverPort/"),
|
||||
null,
|
||||
RemoteBuildCacheClient.Configuration.Authentication.BasicAuthenticationCredentials("user3", PASSWORD),
|
||||
ClientConfiguration.Authentication.BasicAuthenticationCredentials("user3", PASSWORD),
|
||||
Duration.ofSeconds(3),
|
||||
10,
|
||||
true,
|
||||
RemoteBuildCacheClient.Configuration.RetryPolicy(
|
||||
ClientConfiguration.RetryPolicy(
|
||||
3,
|
||||
1000,
|
||||
1.2
|
||||
),
|
||||
RemoteBuildCacheClient.Configuration.TrustStore(null, null, false, false)
|
||||
ClientConfiguration.TrustStore(null, null, false, false)
|
||||
)
|
||||
|
||||
HealthCheckCommand.run(clientProfile)
|
||||
HealthCheckCommand.execute(clientProfile)
|
||||
|
||||
BenchmarkCommand.run(
|
||||
BenchmarkCommand.execute(
|
||||
clientProfile,
|
||||
1000,
|
||||
0x100,
|
||||
true
|
||||
)
|
||||
|
||||
PutCommand.execute(
|
||||
clientProfile,
|
||||
"some-file.bin",
|
||||
ByteArrayInputStream(ByteArray(0x1000) { it.toByte() }),
|
||||
"application/octet-setream",
|
||||
"attachment; filename=\"some-file.bin\""
|
||||
)
|
||||
|
||||
GetCommand.execute(
|
||||
clientProfile,
|
||||
"some-file.bin",
|
||||
NullOutputStream()
|
||||
)
|
||||
|
||||
serverHandle.sendShutdownSignal()
|
||||
try {
|
||||
serverHandle.get()
|
@@ -30,10 +30,10 @@ class BenchmarkCommand : RbcsCommand() {
|
||||
companion object {
|
||||
private val log = createLogger<BenchmarkCommand>()
|
||||
|
||||
fun run(profile : Configuration.Profile,
|
||||
numberOfEntries : Int,
|
||||
entrySize : Int,
|
||||
useRandomValue : Boolean,
|
||||
fun execute(profile : Configuration.Profile,
|
||||
numberOfEntries : Int,
|
||||
entrySize : Int,
|
||||
useRandomValue : Boolean,
|
||||
) {
|
||||
val progressThreshold = LongMath.ceilDiv(numberOfEntries.toLong(), 20)
|
||||
RemoteBuildCacheClient(profile).use { client ->
|
||||
@@ -176,7 +176,7 @@ class BenchmarkCommand : RbcsCommand() {
|
||||
clientCommand.configuration.profiles[profileName]
|
||||
?: throw IllegalArgumentException("Profile $profileName does not exist in configuration")
|
||||
}
|
||||
run(
|
||||
execute(
|
||||
profile,
|
||||
numberOfEntries,
|
||||
size,
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package net.woggioni.rbcs.cli.impl.commands
|
||||
|
||||
import net.woggioni.rbcs.cli.impl.RbcsCommand
|
||||
import net.woggioni.rbcs.client.Configuration
|
||||
import net.woggioni.rbcs.client.RemoteBuildCacheClient
|
||||
import net.woggioni.rbcs.common.createLogger
|
||||
import picocli.CommandLine
|
||||
import java.io.OutputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
|
||||
@@ -13,8 +15,20 @@ import java.nio.file.Path
|
||||
showDefaultValues = true
|
||||
)
|
||||
class GetCommand : RbcsCommand() {
|
||||
companion object{
|
||||
companion object {
|
||||
private val log = createLogger<GetCommand>()
|
||||
|
||||
fun execute(profile : Configuration.Profile, key : String, outputStream: OutputStream) {
|
||||
RemoteBuildCacheClient(profile).use { client ->
|
||||
client.get(key).thenApply { value ->
|
||||
value?.let {
|
||||
outputStream.use {
|
||||
it.write(value)
|
||||
}
|
||||
} ?: throw NoSuchElementException("No value found for key $key")
|
||||
}.get()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CommandLine.Spec
|
||||
@@ -40,14 +54,6 @@ class GetCommand : RbcsCommand() {
|
||||
clientCommand.configuration.profiles[profileName]
|
||||
?: throw IllegalArgumentException("Profile $profileName does not exist in configuration")
|
||||
}
|
||||
RemoteBuildCacheClient(profile).use { client ->
|
||||
client.get(key).thenApply { value ->
|
||||
value?.let {
|
||||
(output?.let(Files::newOutputStream) ?: System.out).use {
|
||||
it.write(value)
|
||||
}
|
||||
} ?: throw NoSuchElementException("No value found for key $key")
|
||||
}.get()
|
||||
}
|
||||
execute(profile, key, (output?.let(Files::newOutputStream) ?: System.out))
|
||||
}
|
||||
}
|
@@ -17,7 +17,7 @@ class HealthCheckCommand : RbcsCommand() {
|
||||
companion object{
|
||||
private val log = createLogger<HealthCheckCommand>()
|
||||
|
||||
fun run(profile : Configuration.Profile) {
|
||||
fun execute(profile : Configuration.Profile) {
|
||||
RemoteBuildCacheClient(profile).use { client ->
|
||||
val random = Random(SecureRandom.getInstance("NativePRNGNonBlocking").nextLong())
|
||||
val nonce = ByteArray(0xa0)
|
||||
@@ -48,6 +48,6 @@ class HealthCheckCommand : RbcsCommand() {
|
||||
clientCommand.configuration.profiles[profileName]
|
||||
?: throw IllegalArgumentException("Profile $profileName does not exist in configuration")
|
||||
}
|
||||
run(profile)
|
||||
execute(profile)
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ import net.woggioni.jwo.JWO
|
||||
import net.woggioni.jwo.NullOutputStream
|
||||
import net.woggioni.rbcs.api.CacheValueMetadata
|
||||
import net.woggioni.rbcs.cli.impl.RbcsCommand
|
||||
import net.woggioni.rbcs.client.Configuration
|
||||
import net.woggioni.rbcs.client.RemoteBuildCacheClient
|
||||
import net.woggioni.rbcs.common.createLogger
|
||||
import picocli.CommandLine
|
||||
@@ -19,8 +20,22 @@ import java.util.UUID
|
||||
showDefaultValues = true
|
||||
)
|
||||
class PutCommand : RbcsCommand() {
|
||||
companion object{
|
||||
companion object {
|
||||
private val log = createLogger<PutCommand>()
|
||||
|
||||
fun execute(profile: Configuration.Profile,
|
||||
actualKey : String,
|
||||
inputStream: InputStream,
|
||||
mimeType : String?,
|
||||
contentDisposition: String?
|
||||
) {
|
||||
RemoteBuildCacheClient(profile).use { client ->
|
||||
inputStream.use {
|
||||
client.put(actualKey, it.readAllBytes(), CacheValueMetadata(contentDisposition, mimeType))
|
||||
}.get()
|
||||
println(profile.serverURI.resolve(actualKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +107,7 @@ class PutCommand : RbcsCommand() {
|
||||
}
|
||||
actualKey = key ?: UUID.randomUUID().toString()
|
||||
}
|
||||
inputStream.use {
|
||||
client.put(actualKey, it.readAllBytes(), CacheValueMetadata(contentDisposition, mimeType))
|
||||
}.get()
|
||||
println(profile.serverURI.resolve(actualKey))
|
||||
execute(profile, actualKey, inputStream, mimeType, contentDisposition)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user