mirror of
https://github.com/corda/corda.git
synced 2025-06-03 16:10:58 +00:00
NOTICK Reformat DriverDSLImpl.kt (#6685)
Reformat DriverDSLImpl to standard IntelliJ style
This commit is contained in:
parent
b895a976a7
commit
b1e2d6a48c
@ -1,4 +1,5 @@
|
|||||||
@file:Suppress("TooManyFunctions", "Deprecation")
|
@file:Suppress("TooManyFunctions", "Deprecation")
|
||||||
|
|
||||||
package net.corda.testing.node.internal
|
package net.corda.testing.node.internal
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.instrument.JavaAgent
|
import co.paralleluniverse.fibers.instrument.JavaAgent
|
||||||
@ -147,7 +148,7 @@ class DriverDSLImpl(
|
|||||||
val cordappsForAllNodes: Collection<TestCordappInternal>?,
|
val cordappsForAllNodes: Collection<TestCordappInternal>?,
|
||||||
val djvmBootstrapSource: Path?,
|
val djvmBootstrapSource: Path?,
|
||||||
val djvmCordaSource: List<Path>,
|
val djvmCordaSource: List<Path>,
|
||||||
val environmentVariables : Map<String, String>,
|
val environmentVariables: Map<String, String>,
|
||||||
val allowHibernateToManageAppSchema: Boolean = true
|
val allowHibernateToManageAppSchema: Boolean = true
|
||||||
) : InternalDriverDSL {
|
) : InternalDriverDSL {
|
||||||
|
|
||||||
@ -156,8 +157,10 @@ class DriverDSLImpl(
|
|||||||
private var _shutdownManager: ShutdownManager? = null
|
private var _shutdownManager: ShutdownManager? = null
|
||||||
override val shutdownManager get() = _shutdownManager!!
|
override val shutdownManager get() = _shutdownManager!!
|
||||||
private lateinit var extraCustomCordapps: Set<CustomCordapp>
|
private lateinit var extraCustomCordapps: Set<CustomCordapp>
|
||||||
|
|
||||||
// Map from a nodes legal name to an observable emitting the number of nodes in its network map.
|
// Map from a nodes legal name to an observable emitting the number of nodes in its network map.
|
||||||
private val networkVisibilityController = NetworkVisibilityController()
|
private val networkVisibilityController = NetworkVisibilityController()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Future which completes when the network map infrastructure is available, whether a local one or one from the CZ.
|
* Future which completes when the network map infrastructure is available, whether a local one or one from the CZ.
|
||||||
* This future acts as a gate to prevent nodes from starting too early. The value of the future is a [LocalNetworkMap]
|
* This future acts as a gate to prevent nodes from starting too early. The value of the future is a [LocalNetworkMap]
|
||||||
@ -274,7 +277,7 @@ class DriverDSLImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return registrationFuture.flatMap { conf ->
|
return registrationFuture.flatMap { conf ->
|
||||||
networkMapAvailability.flatMap {networkMap ->
|
networkMapAvailability.flatMap { networkMap ->
|
||||||
// But starting the node proper does require the network map
|
// But starting the node proper does require the network map
|
||||||
startRegisteredNode(conf, networkMap, parameters, bytemanPort)
|
startRegisteredNode(conf, networkMap, parameters, bytemanPort)
|
||||||
}
|
}
|
||||||
@ -424,13 +427,13 @@ class DriverDSLImpl(
|
|||||||
_shutdownManager = ShutdownManager(executorService)
|
_shutdownManager = ShutdownManager(executorService)
|
||||||
|
|
||||||
val callerPackage = getCallerPackage().toMutableList()
|
val callerPackage = getCallerPackage().toMutableList()
|
||||||
if(callerPackage.firstOrNull()?.startsWith("net.corda.node") == true) callerPackage.add("net.corda.testing")
|
if (callerPackage.firstOrNull()?.startsWith("net.corda.node") == true) callerPackage.add("net.corda.testing")
|
||||||
extraCustomCordapps = cordappsForPackages(extraCordappPackagesToScan + callerPackage)
|
extraCustomCordapps = cordappsForPackages(extraCordappPackagesToScan + callerPackage)
|
||||||
|
|
||||||
val notaryInfosFuture = if (compatibilityZone == null) {
|
val notaryInfosFuture = if (compatibilityZone == null) {
|
||||||
// If no CZ is specified then the driver does the generation of the network parameters and the copying of the
|
// If no CZ is specified then the driver does the generation of the network parameters and the copying of the
|
||||||
// node info files.
|
// node info files.
|
||||||
startNotaryIdentityGeneration().map { notaryInfos -> Pair(notaryInfos, LocalNetworkMap(notaryInfos.map{it.second})) }
|
startNotaryIdentityGeneration().map { notaryInfos -> Pair(notaryInfos, LocalNetworkMap(notaryInfos.map { it.second })) }
|
||||||
} else {
|
} else {
|
||||||
// Otherwise it's the CZ's job to distribute thse via the HTTP network map, as that is what the nodes will be expecting.
|
// Otherwise it's the CZ's job to distribute thse via the HTTP network map, as that is what the nodes will be expecting.
|
||||||
val notaryInfosFuture = if (compatibilityZone.rootCert == null) {
|
val notaryInfosFuture = if (compatibilityZone.rootCert == null) {
|
||||||
@ -441,7 +444,7 @@ class DriverDSLImpl(
|
|||||||
startAllNotaryRegistrations(compatibilityZone.rootCert, compatibilityZone)
|
startAllNotaryRegistrations(compatibilityZone.rootCert, compatibilityZone)
|
||||||
}
|
}
|
||||||
notaryInfosFuture.map { notaryInfos ->
|
notaryInfosFuture.map { notaryInfos ->
|
||||||
compatibilityZone.publishNotaries(notaryInfos.map{it.second})
|
compatibilityZone.publishNotaries(notaryInfos.map { it.second })
|
||||||
Pair(notaryInfos, null)
|
Pair(notaryInfos, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,14 +452,15 @@ class DriverDSLImpl(
|
|||||||
networkMapAvailability = notaryInfosFuture.map { it.second }
|
networkMapAvailability = notaryInfosFuture.map { it.second }
|
||||||
|
|
||||||
_notaries = notaryInfosFuture.map { (notaryInfos, localNetworkMap) ->
|
_notaries = notaryInfosFuture.map { (notaryInfos, localNetworkMap) ->
|
||||||
val listOfFutureNodeHandles = startNotaries(notaryInfos.map{it.first}, localNetworkMap, notaryCustomOverrides)
|
val listOfFutureNodeHandles = startNotaries(notaryInfos.map { it.first }, localNetworkMap, notaryCustomOverrides)
|
||||||
notaryInfos.zip(listOfFutureNodeHandles) { (_, notaryInfo), nodeHandlesFuture ->
|
notaryInfos.zip(listOfFutureNodeHandles) { (_, notaryInfo), nodeHandlesFuture ->
|
||||||
NotaryHandle(notaryInfo.identity, notaryInfo.validating, nodeHandlesFuture)
|
NotaryHandle(notaryInfo.identity, notaryInfo.validating, nodeHandlesFuture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_notaries.map { notary -> notary.map { handle -> handle.nodeHandles } }.getOrThrow(notaryHandleTimeout).forEach { future -> future.getOrThrow(notaryHandleTimeout) }
|
_notaries.map { notary -> notary.map { handle -> handle.nodeHandles } }.getOrThrow(notaryHandleTimeout)
|
||||||
} catch(e: NodeListenProcessDeathException) {
|
.forEach { future -> future.getOrThrow(notaryHandleTimeout) }
|
||||||
|
} catch (e: NodeListenProcessDeathException) {
|
||||||
val message = if (e.causeFromStdError.isNotBlank()) {
|
val message = if (e.causeFromStdError.isNotBlank()) {
|
||||||
"Unable to start notaries. Failed with the following error: ${e.causeFromStdError}"
|
"Unable to start notaries. Failed with the following error: ${e.causeFromStdError}"
|
||||||
} else {
|
} else {
|
||||||
@ -491,7 +495,7 @@ class DriverDSLImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startNotaryIdentityGeneration(): CordaFuture<List<Pair<NodeConfig,NotaryInfo>>> {
|
private fun startNotaryIdentityGeneration(): CordaFuture<List<Pair<NodeConfig, NotaryInfo>>> {
|
||||||
return executorService.fork {
|
return executorService.fork {
|
||||||
notarySpecs.map { spec ->
|
notarySpecs.map { spec ->
|
||||||
val notaryConfig = mapOf("notary" to mapOf("validating" to spec.validating))
|
val notaryConfig = mapOf("notary" to mapOf("validating" to spec.validating))
|
||||||
@ -541,10 +545,11 @@ class DriverDSLImpl(
|
|||||||
spec: NotarySpec,
|
spec: NotarySpec,
|
||||||
rootCert: X509Certificate,
|
rootCert: X509Certificate,
|
||||||
compatibilityZone: CompatibilityZoneParams
|
compatibilityZone: CompatibilityZoneParams
|
||||||
): CordaFuture<Pair<NodeConfig,NotaryInfo>> {
|
): CordaFuture<Pair<NodeConfig, NotaryInfo>> {
|
||||||
val parameters = NodeParameters(rpcUsers = spec.rpcUsers, verifierType = spec.verifierType, customOverrides = notaryCustomOverrides, maximumHeapSize = spec.maximumHeapSize)
|
val parameters = NodeParameters(rpcUsers = spec.rpcUsers, verifierType = spec.verifierType, customOverrides = notaryCustomOverrides, maximumHeapSize = spec.maximumHeapSize)
|
||||||
return createSchema(createConfig(spec.name, parameters), false).flatMap { config ->
|
return createSchema(createConfig(spec.name, parameters), false).flatMap { config ->
|
||||||
startNodeRegistration(config, rootCert, compatibilityZone.config())}.flatMap { config ->
|
startNodeRegistration(config, rootCert, compatibilityZone.config())
|
||||||
|
}.flatMap { config ->
|
||||||
// Node registration only gives us the node CA cert, not the identity cert. That is only created on first
|
// Node registration only gives us the node CA cert, not the identity cert. That is only created on first
|
||||||
// startup or when the node is told to just generate its node info file. We do that here.
|
// startup or when the node is told to just generate its node info file. We do that here.
|
||||||
if (startNodesInProcess) {
|
if (startNodesInProcess) {
|
||||||
@ -566,7 +571,6 @@ class DriverDSLImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateNodeNames(spec: NotarySpec): List<CordaX500Name> {
|
private fun generateNodeNames(spec: NotarySpec): List<CordaX500Name> {
|
||||||
@ -808,6 +812,7 @@ class DriverDSLImpl(
|
|||||||
*/
|
*/
|
||||||
inner class LocalNetworkMap(notaryInfos: List<NotaryInfo>) {
|
inner class LocalNetworkMap(notaryInfos: List<NotaryInfo>) {
|
||||||
val networkParametersCopier = NetworkParametersCopier(networkParameters.copy(notaries = notaryInfos))
|
val networkParametersCopier = NetworkParametersCopier(networkParameters.copy(notaries = notaryInfos))
|
||||||
|
|
||||||
// TODO: this object will copy NodeInfo files from started nodes to other nodes additional-node-infos/
|
// TODO: this object will copy NodeInfo files from started nodes to other nodes additional-node-infos/
|
||||||
// This uses the FileSystem and adds a delay (~5 seconds) given by the time we wait before polling the file system.
|
// This uses the FileSystem and adds a delay (~5 seconds) given by the time we wait before polling the file system.
|
||||||
// Investigate whether we can avoid that.
|
// Investigate whether we can avoid that.
|
||||||
@ -836,6 +841,7 @@ class DriverDSLImpl(
|
|||||||
private val notaryHandleTimeout = Duration.ofMinutes(1)
|
private val notaryHandleTimeout = Duration.ofMinutes(1)
|
||||||
private val defaultRpcUserList = listOf(InternalUser("default", "default", setOf("ALL")).toConfig().root().unwrapped())
|
private val defaultRpcUserList = listOf(InternalUser("default", "default", setOf("ALL")).toConfig().root().unwrapped())
|
||||||
private val names = arrayOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME)
|
private val names = arrayOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sub-set of permissions that grant most of the essential operations used in the unit/integration tests as well as
|
* A sub-set of permissions that grant most of the essential operations used in the unit/integration tests as well as
|
||||||
* in demo application like NodeExplorer.
|
* in demo application like NodeExplorer.
|
||||||
@ -942,7 +948,7 @@ class DriverDSLImpl(
|
|||||||
maximumHeapSize: String,
|
maximumHeapSize: String,
|
||||||
logLevelOverride: String?,
|
logLevelOverride: String?,
|
||||||
identifier: String,
|
identifier: String,
|
||||||
environmentVariables : Map<String,String>,
|
environmentVariables: Map<String, String>,
|
||||||
extraCmdLineFlag: Array<String> = emptyArray()
|
extraCmdLineFlag: Array<String> = emptyArray()
|
||||||
): Process {
|
): Process {
|
||||||
log.info("Starting out-of-process Node ${config.corda.myLegalName.organisation}, " +
|
log.info("Starting out-of-process Node ${config.corda.myLegalName.organisation}, " +
|
||||||
@ -983,7 +989,6 @@ class DriverDSLImpl(
|
|||||||
else -> "DEBUG"
|
else -> "DEBUG"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val arguments = mutableListOf(
|
val arguments = mutableListOf(
|
||||||
"--base-directory=${config.corda.baseDirectory}",
|
"--base-directory=${config.corda.baseDirectory}",
|
||||||
"--logging-level=$loggingLevel",
|
"--logging-level=$loggingLevel",
|
||||||
@ -1050,7 +1055,8 @@ class DriverDSLImpl(
|
|||||||
|| (manifest[TARGET_PLATFORM_VERSION] != null && manifest[MIN_PLATFORM_VERSION] != null)
|
|| (manifest[TARGET_PLATFORM_VERSION] != null && manifest[MIN_PLATFORM_VERSION] != null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val Path.isExcludedJar: Boolean get() {
|
private val Path.isExcludedJar: Boolean
|
||||||
|
get() {
|
||||||
return JarInputStream(Files.newInputStream(this).buffered()).use { jar ->
|
return JarInputStream(Files.newInputStream(this).buffered()).use { jar ->
|
||||||
val manifest = jar.manifest ?: return false
|
val manifest = jar.manifest ?: return false
|
||||||
isCordapp(manifest) || isTestArtifact(manifest)
|
isCordapp(manifest) || isTestArtifact(manifest)
|
||||||
@ -1328,7 +1334,7 @@ sealed class CompatibilityZoneParams(
|
|||||||
) {
|
) {
|
||||||
abstract fun networkMapURL(): URL
|
abstract fun networkMapURL(): URL
|
||||||
abstract fun doormanURL(): URL
|
abstract fun doormanURL(): URL
|
||||||
abstract fun config() : NetworkServicesConfig
|
abstract fun config(): NetworkServicesConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1336,18 +1342,18 @@ sealed class CompatibilityZoneParams(
|
|||||||
*/
|
*/
|
||||||
class SharedCompatibilityZoneParams(
|
class SharedCompatibilityZoneParams(
|
||||||
private val url: URL,
|
private val url: URL,
|
||||||
private val pnm : UUID?,
|
private val pnm: UUID?,
|
||||||
publishNotaries: (List<NotaryInfo>) -> Unit,
|
publishNotaries: (List<NotaryInfo>) -> Unit,
|
||||||
rootCert: X509Certificate? = null
|
rootCert: X509Certificate? = null
|
||||||
) : CompatibilityZoneParams(publishNotaries, rootCert) {
|
) : CompatibilityZoneParams(publishNotaries, rootCert) {
|
||||||
|
|
||||||
val config : NetworkServicesConfig by lazy {
|
val config: NetworkServicesConfig by lazy {
|
||||||
NetworkServicesConfig(url, url, pnm, false)
|
NetworkServicesConfig(url, url, pnm, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doormanURL() = url
|
override fun doormanURL() = url
|
||||||
override fun networkMapURL() = url
|
override fun networkMapURL() = url
|
||||||
override fun config() : NetworkServicesConfig = config
|
override fun config(): NetworkServicesConfig = config
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1356,17 +1362,17 @@ class SharedCompatibilityZoneParams(
|
|||||||
class SplitCompatibilityZoneParams(
|
class SplitCompatibilityZoneParams(
|
||||||
private val doormanURL: URL,
|
private val doormanURL: URL,
|
||||||
private val networkMapURL: URL,
|
private val networkMapURL: URL,
|
||||||
private val pnm : UUID?,
|
private val pnm: UUID?,
|
||||||
publishNotaries: (List<NotaryInfo>) -> Unit,
|
publishNotaries: (List<NotaryInfo>) -> Unit,
|
||||||
rootCert: X509Certificate? = null
|
rootCert: X509Certificate? = null
|
||||||
) : CompatibilityZoneParams(publishNotaries, rootCert) {
|
) : CompatibilityZoneParams(publishNotaries, rootCert) {
|
||||||
val config : NetworkServicesConfig by lazy {
|
val config: NetworkServicesConfig by lazy {
|
||||||
NetworkServicesConfig(doormanURL, networkMapURL, pnm, false)
|
NetworkServicesConfig(doormanURL, networkMapURL, pnm, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doormanURL() = doormanURL
|
override fun doormanURL() = doormanURL
|
||||||
override fun networkMapURL() = networkMapURL
|
override fun networkMapURL() = networkMapURL
|
||||||
override fun config() : NetworkServicesConfig = config
|
override fun config(): NetworkServicesConfig = config
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user