Simplify the FullNodeConfiguration now that an explicit identity for the NetworkMapService isn't a problem.

Use consistent if style

Don't include NetworkMapAddress in config if hosting locally
This commit is contained in:
Matthew Nesbit 2016-09-07 13:58:56 +01:00
parent c7b164897b
commit 1f2a6d256e
5 changed files with 35 additions and 69 deletions

View File

@ -1,15 +1,11 @@
basedir : "./nodea", basedir : "./nodea"
myLegalName : "Bank A", myLegalName : "Bank A"
nearestCity : "London", nearestCity : "London"
keyStorePassword : "cordacadevpass", keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass", trustStorePassword : "trustpass"
artemisAddress : "localhost:31337", artemisAddress : "localhost:31337"
webAddress : "localhost:31339", webAddress : "localhost:31339"
hostNotaryServiceLocally: false, hostNotaryServiceLocally: false
extraAdvertisedServiceIds: "corda.interest_rates", extraAdvertisedServiceIds: "corda.interest_rates"
mapService : { networkMapAddress : "localhost:12345"
hostServiceLocally : false,
address : "localhost:12345",
identity : "Notary Service"
}
useHTTPS : false useHTTPS : false

View File

@ -1,15 +1,11 @@
basedir : "./nodeb", basedir : "./nodeb"
myLegalName : "Bank B", myLegalName : "Bank B"
nearestCity : "London", nearestCity : "London"
keyStorePassword : "cordacadevpass", keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass", trustStorePassword : "trustpass"
artemisAddress : "localhost:31338", artemisAddress : "localhost:31338"
webAddress : "localhost:31340", webAddress : "localhost:31340"
hostNotaryServiceLocally: false, hostNotaryServiceLocally: false
extraAdvertisedServiceIds: "corda.interest_rates", extraAdvertisedServiceIds: "corda.interest_rates"
mapService : { networkMapAddress : "localhost:12345"
hostServiceLocally : false,
address : "localhost:12345",
identity : "Notary Service"
}
useHTTPS : false useHTTPS : false

View File

@ -1,15 +1,10 @@
basedir : "./nameserver", basedir : "./nameserver"
myLegalName : "Notary Service", myLegalName : "Notary Service"
nearestCity : "London", nearestCity : "London"
keyStorePassword : "cordacadevpass", keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass", trustStorePassword : "trustpass"
artemisAddress : "localhost:12345", artemisAddress : "localhost:12345"
webAddress : "localhost:12346", webAddress : "localhost:12346"
hostNotaryServiceLocally: true, hostNotaryServiceLocally: true
extraAdvertisedServiceIds: "", extraAdvertisedServiceIds: ""
mapService : {
hostServiceLocally : true,
address : ${artemisAddress},
identity : ${myLegalName}
}
useHTTPS : false useHTTPS : false

View File

@ -40,11 +40,7 @@ General node configuration file for hosting the IRSDemo services.
webAddress : "localhost:31339" webAddress : "localhost:31339"
hostNotaryServiceLocally: false hostNotaryServiceLocally: false
extraAdvertisedServiceIds: "corda.interest_rates" extraAdvertisedServiceIds: "corda.interest_rates"
mapService : { networkMapAddress : "localhost:12345"
hostServiceLocally : false
address : "localhost:12345"
identity : "Notary Service"
}
useHTTPS : false useHTTPS : false
NetworkMapService plus Simple Notary configuration file. NetworkMapService plus Simple Notary configuration file.
@ -60,11 +56,6 @@ NetworkMapService plus Simple Notary configuration file.
webAddress : "localhost:12346" webAddress : "localhost:12346"
hostNotaryServiceLocally: true hostNotaryServiceLocally: true
extraAdvertisedServiceIds: "" extraAdvertisedServiceIds: ""
mapService : {
hostServiceLocally : true
address : ${artemisAddress}
identity : ${myLegalName}
}
useHTTPS : false useHTTPS : false
Configuration File Fields Configuration File Fields
@ -103,11 +94,7 @@ Configuration File Fields
:extraAdvertisedServiceIds: A list of ServiceType id strings to be advertised to the NetworkMapService and thus be available when other nodes query the NetworkMapCache for supporting nodes. This can also include plugin services loaded from .jar files in the :extraAdvertisedServiceIds: A list of ServiceType id strings to be advertised to the NetworkMapService and thus be available when other nodes query the NetworkMapCache for supporting nodes. This can also include plugin services loaded from .jar files in the
:mapService.hostServiceLocally: If true the node is declaring itself as the NetworkMapService host. Otherwise the configuration below is the remote connection details for the node to connect to the NetworkMapService. :networkMapAddress: If `null`, or missing the node is declaring itself as the NetworkMapService host. Otherwise the configuration value is the remote HostAndPort string for the ArtemisMQ service on the hosting node.
:mapService.address: If the node is hosting the NetworkMapService this should be exactly equal to the artemisAddress (hence $ substitution above). Otherwise this value is the remote HostAndPort string for the ArtemisMQ service on the hosting node.
:mapService.identity: If the node is hosting the NetworkMapService this should be exactly equal to the myLegalName (hence $ substitution above). Otherwise this value must match the myLegalName of the hosting node.
:useHTTPS: If false the node's web server will be plain HTTP. If true the node will use the same certificate and private key from the ``<workspace>/certificates/sslkeystore.jks`` file as the ArtemisMQ port for HTTPS. If HTTPS is enabled then unencrypted HTTP traffic to the node's **webAddress** port is not supported. :useHTTPS: If false the node's web server will be plain HTTP. If true the node will use the same certificate and private key from the ``<workspace>/certificates/sslkeystore.jks`` file as the ArtemisMQ port for HTTPS. If HTTPS is enabled then unencrypted HTTP traffic to the node's **webAddress** port is not supported.

View File

@ -90,12 +90,6 @@ class NodeConfigurationFromConfig(val config: Config = ConfigFactory.load()) : N
override val dataSourceProperties: Properties by config override val dataSourceProperties: Properties by config
} }
class NameServiceConfig(conf: Config) {
val hostServiceLocally: Boolean by conf
val address: HostAndPort by conf
val identity: String by conf
}
class FullNodeConfiguration(conf: Config) : NodeConfiguration { class FullNodeConfiguration(conf: Config) : NodeConfiguration {
val basedir: Path by conf val basedir: Path by conf
override val myLegalName: String by conf override val myLegalName: String by conf
@ -108,28 +102,26 @@ class FullNodeConfiguration(conf: Config) : NodeConfiguration {
val artemisAddress: HostAndPort by conf val artemisAddress: HostAndPort by conf
val webAddress: HostAndPort by conf val webAddress: HostAndPort by conf
val messagingServerAddress: HostAndPort? = if (conf.hasPath("messagingServerAddress")) HostAndPort.fromString(conf.getString("messagingServerAddress")) else null val messagingServerAddress: HostAndPort? = if (conf.hasPath("messagingServerAddress")) HostAndPort.fromString(conf.getString("messagingServerAddress")) else null
val networkMapAddress: HostAndPort? = if (conf.hasPath("networkMapAddress")) HostAndPort.fromString(conf.getString("networkMapAddress")) else null
val hostNotaryServiceLocally: Boolean by conf val hostNotaryServiceLocally: Boolean by conf
val extraAdvertisedServiceIds: String by conf val extraAdvertisedServiceIds: String by conf
val mapService: NameServiceConfig = NameServiceConfig(conf.getConfig("mapService"))
val clock: Clock = NodeClock() val clock: Clock = NodeClock()
fun createNode(): Node { fun createNode(): Node {
val networkMapTarget = ArtemisMessagingClient.makeNetworkMapAddress(mapService.address)
val advertisedServices = mutableSetOf<ServiceType>() val advertisedServices = mutableSetOf<ServiceType>()
if (mapService.hostServiceLocally) advertisedServices.add(NetworkMapService.Type)
if (hostNotaryServiceLocally) advertisedServices.add(SimpleNotaryService.Type) if (hostNotaryServiceLocally) advertisedServices.add(SimpleNotaryService.Type)
if (!extraAdvertisedServiceIds.isNullOrEmpty()) { if (!extraAdvertisedServiceIds.isNullOrEmpty()) {
for (serviceId in extraAdvertisedServiceIds.split(",")) { for (serviceId in extraAdvertisedServiceIds.split(",")) {
advertisedServices.add(object : ServiceType(serviceId) {}) advertisedServices.add(object : ServiceType(serviceId) {})
} }
} }
if (networkMapAddress == null) advertisedServices.add(NetworkMapService.Type)
val networkMapAddress: SingleMessageRecipient? = if (mapService.hostServiceLocally) null else networkMapTarget val networkMapMessageAddress: SingleMessageRecipient? = if (networkMapAddress == null) null else ArtemisMessagingClient.makeNetworkMapAddress(networkMapAddress)
return Node(basedir.toAbsolutePath().normalize(), return Node(basedir.toAbsolutePath().normalize(),
artemisAddress, artemisAddress,
webAddress, webAddress,
this, this,
networkMapAddress, networkMapMessageAddress,
advertisedServices, advertisedServices,
clock, clock,
messagingServerAddress messagingServerAddress