mirror of
https://github.com/corda/corda.git
synced 2024-12-23 23:02:29 +00:00
Code rewiew: turn dev mode options into a data class
This commit is contained in:
parent
5440594afd
commit
5b5a4bd2e4
@ -11,6 +11,8 @@ import java.net.URL
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
|
||||
data class DevModeOptions(val disableCheckpointChecker: Boolean?)
|
||||
|
||||
interface NodeConfiguration : NodeSSLConfiguration {
|
||||
// myLegalName should be only used in the initial network registration, we should use the name from the certificate instead of this.
|
||||
// TODO: Remove this so we don't accidentally use this identity in the code?
|
||||
@ -28,7 +30,7 @@ interface NodeConfiguration : NodeSSLConfiguration {
|
||||
val database: Properties?
|
||||
val rpcUsers: List<User>
|
||||
val devMode: Boolean
|
||||
val devModeOptions: Properties?
|
||||
val devModeOptions: DevModeOptions?
|
||||
val certificateSigningService: URL
|
||||
val certificateChainCheckPolicies: List<CertChainPolicyConfig>
|
||||
val verifierType: VerifierType
|
||||
@ -42,10 +44,6 @@ interface NodeConfiguration : NodeSSLConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
fun NodeConfiguration.isDevModeOptionsFlagSet(flag: String): Boolean {
|
||||
return this.devModeOptions?.get(flag).toString().toLowerCase() == "true"
|
||||
}
|
||||
|
||||
data class NotaryConfig(val validating: Boolean,
|
||||
val raft: RaftConfig? = null,
|
||||
val bftSMaRt: BFTSMaRtConfiguration? = null,
|
||||
@ -102,7 +100,7 @@ data class FullNodeConfiguration(
|
||||
override val notary: NotaryConfig?,
|
||||
override val certificateChainCheckPolicies: List<CertChainPolicyConfig>,
|
||||
override val devMode: Boolean = false,
|
||||
override val devModeOptions: Properties? = null,
|
||||
override val devModeOptions: DevModeOptions? = null,
|
||||
val useTestClock: Boolean = false,
|
||||
val detectPublicIp: Boolean = true,
|
||||
override val activeMQServer: ActiveMqServerConfiguration,
|
||||
|
@ -32,7 +32,6 @@ import net.corda.node.services.api.Checkpoint
|
||||
import net.corda.node.services.api.CheckpointStorage
|
||||
import net.corda.node.services.api.ServiceHubInternal
|
||||
import net.corda.node.services.config.NodeConfiguration
|
||||
import net.corda.node.services.config.isDevModeOptionsFlagSet
|
||||
import net.corda.node.services.messaging.ReceivedMessage
|
||||
import net.corda.node.services.messaging.TopicSession
|
||||
import net.corda.node.utilities.*
|
||||
@ -91,7 +90,7 @@ class StateMachineManagerImpl(
|
||||
private val mutex = ThreadBox(InnerState())
|
||||
// This thread (only enabled in dev mode) deserialises checkpoints in the background to shake out bugs in checkpoint restore.
|
||||
private val checkpointCheckerThread = if (serviceHub.configuration.devMode
|
||||
&& !serviceHub.configuration.isDevModeOptionsFlagSet(NodeConfiguration.DISABLE_CHECKPOINT_CHECKER))
|
||||
&& serviceHub.configuration.devModeOptions?.disableCheckpointChecker != true)
|
||||
newNamedSingleThreadExecutor("CheckpointChecker") else null
|
||||
|
||||
@Volatile private var unrestorableCheckpoints = false
|
||||
|
@ -70,10 +70,10 @@ class FullNodeConfigurationTest {
|
||||
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)),
|
||||
additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis())
|
||||
|
||||
fun configDebugOptions(devMode: Boolean, debugOptions: Properties?) {
|
||||
fun configDebugOptions(devMode: Boolean, debugOptions: DevModeOptions?) {
|
||||
testConfiguration.copy(devMode = devMode, devModeOptions = debugOptions)
|
||||
}
|
||||
val debugOptions = Properties()
|
||||
val debugOptions = DevModeOptions(null)
|
||||
configDebugOptions(true, debugOptions)
|
||||
configDebugOptions(true,null)
|
||||
assertThatThrownBy{configDebugOptions(false, debugOptions)}.hasMessageMatching( "Cannot use devModeOptions outside of dev mode" )
|
||||
@ -105,14 +105,13 @@ class FullNodeConfigurationTest {
|
||||
activeMQServer = ActiveMqServerConfiguration(BridgeConfiguration(0, 0, 0.0)),
|
||||
additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis())
|
||||
|
||||
fun configDebugOptions(devMode: Boolean, debugOptions: Properties?) : NodeConfiguration {
|
||||
return testConfiguration.copy(devMode = devMode, devModeOptions = debugOptions)
|
||||
fun configDebugOptions(devMode: Boolean, devModeOptions: DevModeOptions?) : NodeConfiguration {
|
||||
return testConfiguration.copy(devMode = devMode, devModeOptions = devModeOptions)
|
||||
}
|
||||
val debugOptions = Properties()
|
||||
assertFalse { configDebugOptions(true,null).isDevModeOptionsFlagSet("foo")}
|
||||
assertFalse { configDebugOptions(true,debugOptions).isDevModeOptionsFlagSet("foo")}
|
||||
debugOptions.setProperty("foo", "tRuE")
|
||||
assert( configDebugOptions(true, debugOptions).isDevModeOptionsFlagSet("foo"))
|
||||
assertFalse { configDebugOptions(true,null).devModeOptions?.disableCheckpointChecker == true}
|
||||
assertFalse { configDebugOptions(true,DevModeOptions(null)).devModeOptions?.disableCheckpointChecker == true}
|
||||
assertFalse { configDebugOptions(true,DevModeOptions(false)).devModeOptions?.disableCheckpointChecker == true}
|
||||
assert ( configDebugOptions(true,DevModeOptions(true)).devModeOptions?.disableCheckpointChecker == true)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user