mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
Added basic node configuration validation. (#2433)
This commit is contained in:
committed by
GitHub
parent
69c989478a
commit
3b5d89883d
@ -90,6 +90,11 @@ open class NodeStartup(val args: Array<String>) {
|
||||
logger.error("Exception during node configuration", e)
|
||||
return false
|
||||
}
|
||||
val errors = conf.validate()
|
||||
if (errors.isNotEmpty()) {
|
||||
logger.error("Invalid node configuration. Errors where:${System.lineSeparator()}${errors.joinToString(System.lineSeparator())}")
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
banJavaSerialisation(conf)
|
||||
|
@ -50,6 +50,8 @@ interface NodeConfiguration : NodeSSLConfiguration {
|
||||
val attachmentContentCacheSizeBytes: Long get() = defaultAttachmentContentCacheSize
|
||||
val attachmentCacheBound: Long get() = defaultAttachmentCacheBound
|
||||
|
||||
fun validate(): List<String>
|
||||
|
||||
companion object {
|
||||
// default to at least 8MB and a bit extra for larger heap sizes
|
||||
val defaultTransactionCacheSize: Long = 8.MB + getAdditionalCacheMemory()
|
||||
@ -163,6 +165,22 @@ data class NodeConfigurationImpl(
|
||||
}.asOptions(fallbackSslOptions)
|
||||
}
|
||||
|
||||
override fun validate(): List<String> {
|
||||
val errors = mutableListOf<String>()
|
||||
errors + validateRpcOptions(rpcOptions)
|
||||
return errors
|
||||
}
|
||||
|
||||
private fun validateRpcOptions(options: NodeRpcOptions): List<String> {
|
||||
val errors = mutableListOf<String>()
|
||||
if (!options.useSsl) {
|
||||
if (options.adminAddress == null) {
|
||||
errors + "'rpcSettings.adminAddress': missing. Property is mandatory when 'rpcSettings.useSsl' is false (default)."
|
||||
}
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
||||
override val exportJMXto: String get() = "http"
|
||||
override val transactionCacheSizeBytes: Long
|
||||
get() = transactionCacheSizeMegaBytes?.MB ?: super.transactionCacheSizeBytes
|
||||
|
Reference in New Issue
Block a user