Skip to content

Commit a5fd529

Browse files
authored
feat(config): add s3 config validation (#2255)
1 parent 09d701e commit a5fd529

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/src/main/scala/kafka/server/KafkaConfig.scala

+17
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,23 @@ class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _])
761761
}
762762
}
763763

764+
// configuration sanity checks
765+
val memoryType = if (s3StreamAllocatorPolicy.isDirect) "Direct buffer" else "Heap buffer"
766+
val memoryLimit = if (s3StreamAllocatorPolicy.isDirect) {
767+
PlatformDependent.maxDirectMemory()
768+
} else {
769+
Runtime.getRuntime.maxMemory()
770+
}
771+
if (s3BlockCacheSize > memoryLimit) {
772+
throw new ConfigException(s"${AutoMQConfig.S3_BLOCK_CACHE_SIZE_CONFIG} of ${s3BlockCacheSize} exceeds ${memoryType} limit of ${memoryLimit}")
773+
}
774+
if (s3WALCacheSize > memoryLimit) {
775+
throw new ConfigException(s"${AutoMQConfig.S3_WAL_CACHE_SIZE_CONFIG} of ${s3WALCacheSize} exceeds ${memoryType} limit of ${memoryLimit}")
776+
}
777+
if (s3WALUploadThreshold > s3WALCacheSize) {
778+
throw new ConfigException(s"${AutoMQConfig.S3_WAL_UPLOAD_THRESHOLD_CONFIG} of ${s3WALUploadThreshold} exceeds ${AutoMQConfig.S3_WAL_CACHE_SIZE_CONFIG} of ${s3WALCacheSize}")
779+
}
780+
764781
(s3WALCacheSize, s3BlockCacheSize, s3WALUploadThreshold)
765782
}
766783

0 commit comments

Comments
 (0)