Compare commits
12 commits
master
...
expermenti
Author | SHA1 | Date | |
---|---|---|---|
7852030f8f | |||
d9a98148b7 | |||
848e0ba170 | |||
e85b77569b | |||
dcd05dc6a1 | |||
80402f3c52 | |||
0caa1f00a6 | |||
3558b5ad50 | |||
3d4843debd | |||
ac3fe5df73 | |||
b763dbb4fa | |||
69d45575af |
158
build.gradle
158
build.gradle
|
@ -1,79 +1,79 @@
|
|||
plugins {
|
||||
id "java"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.3.72"
|
||||
id "application"
|
||||
id "com.github.johnrengelman.shadow" version "5.2.0"
|
||||
id "com.diffplug.gradle.spotless" version "4.4.0"
|
||||
id "dev.afanasev.sekret" version "0.0.3"
|
||||
}
|
||||
|
||||
group = "com.mangadex"
|
||||
version = "git describe --tags --dirty".execute().text.trim()
|
||||
mainClassName = "mdnet.base.Main"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
configurations {
|
||||
runtime.exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-core"
|
||||
runtime.exclude group: "com.sun.mail", module: "javax.mail"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group: "dev.afanasev", name: "sekret-annotation", version: "0.0.3"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
|
||||
implementation group: "commons-io", name: "commons-io", version: "2.7"
|
||||
|
||||
implementation group: "org.http4k", name: "http4k-core", version: "$http_4k_version"
|
||||
implementation group: "org.http4k", name: "http4k-format-jackson", version: "$http_4k_version"
|
||||
implementation group: "com.fasterxml.jackson.datatype", name: "jackson-datatype-jsr310", version: "2.11.1"
|
||||
implementation group: "org.http4k", name: "http4k-client-apache", version: "$http_4k_version"
|
||||
implementation group: "org.http4k", name: "http4k-server-netty", version: "$http_4k_version"
|
||||
runtimeOnly group: "io.netty", name: "netty-tcnative-boringssl-static", version: "2.0.30.Final"
|
||||
|
||||
implementation group: "ch.qos.logback", name: "logback-classic", version: "1.3.0-alpha4"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-core", version: "$exposed_version"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-dao", version: "$exposed_version"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-jdbc", version: "$exposed_version"
|
||||
|
||||
implementation group: "org.xerial", name: "sqlite-jdbc", version: "3.30.1"
|
||||
|
||||
implementation "com.goterl.lazycode:lazysodium-java:4.3.0"
|
||||
implementation "net.java.dev.jna:jna:5.5.0"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
spotless {
|
||||
lineEndings 'UNIX'
|
||||
java {
|
||||
targetExclude("build/generated/**/*")
|
||||
eclipse()
|
||||
removeUnusedImports()
|
||||
trimTrailingWhitespace()
|
||||
endWithNewline()
|
||||
}
|
||||
kotlin {
|
||||
ktlint()
|
||||
trimTrailingWhitespace()
|
||||
endWithNewline()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("generateVersion", Copy) {
|
||||
def templateContext = [version: version]
|
||||
inputs.properties templateContext
|
||||
from "src/template/java"
|
||||
into "$buildDir/generated/java"
|
||||
expand templateContext
|
||||
}
|
||||
|
||||
sourceSets.main.java.srcDir generateVersion.outputs.files
|
||||
plugins {
|
||||
id "java"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.3.72"
|
||||
id "application"
|
||||
id "com.github.johnrengelman.shadow" version "5.2.0"
|
||||
id "com.diffplug.gradle.spotless" version "4.4.0"
|
||||
id "dev.afanasev.sekret" version "0.0.3"
|
||||
}
|
||||
|
||||
group = "com.mangadex"
|
||||
version = "git describe --tags --dirty".execute().text.trim()
|
||||
mainClassName = "mdnet.base.Main"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
configurations {
|
||||
runtime.exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-core"
|
||||
runtime.exclude group: "com.sun.mail", module: "javax.mail"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group: "dev.afanasev", name: "sekret-annotation", version: "0.0.3"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
|
||||
implementation group: "commons-io", name: "commons-io", version: "2.7"
|
||||
|
||||
implementation group: "org.http4k", name: "http4k-core", version: "$http_4k_version"
|
||||
implementation group: "org.http4k", name: "http4k-format-jackson", version: "$http_4k_version"
|
||||
implementation group: "com.fasterxml.jackson.datatype", name: "jackson-datatype-jsr310", version: "2.11.1"
|
||||
implementation group: "org.http4k", name: "http4k-client-apache", version: "$http_4k_version"
|
||||
implementation group: "org.http4k", name: "http4k-server-netty", version: "$http_4k_version"
|
||||
runtimeOnly group: "io.netty", name: "netty-tcnative-boringssl-static", version: "2.0.30.Final"
|
||||
|
||||
implementation group: "ch.qos.logback", name: "logback-classic", version: "1.3.0-alpha4"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-core", version: "$exposed_version"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-dao", version: "$exposed_version"
|
||||
implementation group: "org.jetbrains.exposed", name: "exposed-jdbc", version: "$exposed_version"
|
||||
|
||||
implementation group: "org.xerial", name: "sqlite-jdbc", version: "3.30.1"
|
||||
|
||||
implementation "com.goterl.lazycode:lazysodium-java:4.2.6"
|
||||
implementation "net.java.dev.jna:jna:5.5.0"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
spotless {
|
||||
lineEndings 'UNIX'
|
||||
java {
|
||||
targetExclude("build/generated/**/*")
|
||||
eclipse()
|
||||
removeUnusedImports()
|
||||
trimTrailingWhitespace()
|
||||
endWithNewline()
|
||||
}
|
||||
kotlin {
|
||||
ktlint()
|
||||
trimTrailingWhitespace()
|
||||
endWithNewline()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("generateVersion", Copy) {
|
||||
def templateContext = [version: version]
|
||||
inputs.properties templateContext
|
||||
from "src/template/java"
|
||||
into "$buildDir/generated/java"
|
||||
expand templateContext
|
||||
}
|
||||
|
||||
sourceSets.main.java.srcDir generateVersion.outputs.files
|
||||
|
|
|
@ -13,5 +13,9 @@
|
|||
"web_settings": { //delete this block to disable webui
|
||||
"ui_hostname": "127.0.0.1", // "127.0.0.1" is the default and binds to localhost only
|
||||
"ui_port": 8080
|
||||
},
|
||||
"experimental": {
|
||||
"max_buffer_size_for_cache_hit": 0 // Size is n * 8kiB. 0 uses the JDK default (which is likely 8kiB).
|
||||
// May improve diskIO at the cost of memory pressure. Testing needed
|
||||
}
|
||||
}
|
||||
|
|
|
@ -476,6 +476,11 @@ class MangaDexClient(private val clientSettingsFile: String) {
|
|||
throw ClientSettingsException("Config Error: Invalid UI port number")
|
||||
}
|
||||
}
|
||||
if (settings.experimental != null) {
|
||||
if (settings.experimental.maxBufferSizeForCacheHit < 0)
|
||||
throw ClientSettingsException("Config Error: Max cache buffer multiple must be >= 0")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun readClientSettings(): ClientSettings {
|
||||
|
|
|
@ -63,7 +63,7 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
|
|||
.setMaxConnPerRoute(3000)
|
||||
.build())
|
||||
|
||||
val imageServer = ImageServer(cache, database, statistics, serverSettings, client)
|
||||
val imageServer = ImageServer(cache, database, statistics, serverSettings, clientSettings, client)
|
||||
|
||||
return timeRequest()
|
||||
.then(catchAllHideDetails())
|
||||
|
|
|
@ -48,6 +48,7 @@ import mdnet.base.data.ImageDatum
|
|||
import mdnet.base.data.Statistics
|
||||
import mdnet.base.data.Token
|
||||
import mdnet.base.info
|
||||
import mdnet.base.settings.ClientSettings
|
||||
import mdnet.base.settings.ServerSettings
|
||||
import mdnet.base.trace
|
||||
import mdnet.base.warn
|
||||
|
@ -66,6 +67,7 @@ class ImageServer(
|
|||
private val database: Database,
|
||||
private val statistics: AtomicReference<Statistics>,
|
||||
private val serverSettings: ServerSettings,
|
||||
private val clientSettings: ClientSettings,
|
||||
private val client: HttpHandler
|
||||
) {
|
||||
init {
|
||||
|
@ -74,6 +76,9 @@ class ImageServer(
|
|||
}
|
||||
}
|
||||
private val executor = Executors.newCachedThreadPool()
|
||||
private val maxBufferSizeForCacheHit: Int? = clientSettings.experimental?.maxBufferSizeForCacheHit
|
||||
?.takeUnless { it == 0 }
|
||||
?.times(8 * 1024)
|
||||
|
||||
fun handler(dataSaver: Boolean, tokenized: Boolean = false): HttpHandler {
|
||||
return baseHandler().then { request ->
|
||||
|
@ -191,11 +196,16 @@ class ImageServer(
|
|||
}
|
||||
|
||||
LOGGER.info { "Request for $sanitizedUri hit cache" }
|
||||
val cacheStream = snapshot.getInputStream(0)
|
||||
val bufferSize = maxBufferSizeForCacheHit?.coerceAtMost(snapshot.getLength(0).toInt())
|
||||
val bufferedStream = bufferSize?.let {
|
||||
BufferedInputStream(cacheStream, bufferSize)
|
||||
} ?: BufferedInputStream(cacheStream) // Todo: Move into builder. It's untidy having the null propagate all the way here but I'm tired and tomorrow is a fast day.
|
||||
|
||||
respondWithImage(
|
||||
CipherInputStream(BufferedInputStream(snapshot.getInputStream(0)), cipher),
|
||||
snapshot.getLength(0).toString(), imageDatum.contentType, imageDatum.lastModified,
|
||||
true
|
||||
CipherInputStream(bufferedStream, cipher),
|
||||
snapshot.getLength(0).toString(), imageDatum.contentType, imageDatum.lastModified,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ data class ClientSettings(
|
|||
val threads: Int = 4,
|
||||
val gracefulShutdownWaitSeconds: Int = 60,
|
||||
val webSettings: WebSettings? = null,
|
||||
val devSettings: DevSettings? = null
|
||||
val devSettings: DevSettings? = null,
|
||||
val experimental: Experimental? = null
|
||||
)
|
||||
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
|
@ -48,3 +49,8 @@ data class WebSettings(
|
|||
data class DevSettings(
|
||||
val isDev: Boolean = false
|
||||
)
|
||||
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
data class Experimental(
|
||||
val maxBufferSizeForCacheHit: Int = 0
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue