mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
Node: get artemisAddress and webAddress from the config rather than constructor parameters
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package com.r3corda.node.internal
|
||||
|
||||
import com.codahale.metrics.JmxReporter
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.r3corda.core.messaging.SingleMessageRecipient
|
||||
import com.r3corda.core.node.ServiceHub
|
||||
import com.r3corda.core.node.services.ServiceInfo
|
||||
@ -58,10 +57,8 @@ class ConfigurationException(message: String) : Exception(message)
|
||||
* @param clock The clock used within the node and by all protocols etc.
|
||||
* @param messagingServerAddr The address of the Artemis broker instance. If not provided the node will run one locally.
|
||||
*/
|
||||
class Node(val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
|
||||
override val configuration: FullNodeConfiguration, networkMapAddress: SingleMessageRecipient?,
|
||||
advertisedServices: Set<ServiceInfo>, clock: Clock = NodeClock(),
|
||||
val messagingServerAddr: HostAndPort? = null) : AbstractNode(configuration, networkMapAddress, advertisedServices, clock) {
|
||||
class Node(override val configuration: FullNodeConfiguration, networkMapAddress: SingleMessageRecipient?,
|
||||
advertisedServices: Set<ServiceInfo>, clock: Clock = NodeClock()) : AbstractNode(configuration, networkMapAddress, advertisedServices, clock) {
|
||||
companion object {
|
||||
/** The port that is used by default if none is specified. As you know, 31337 is the most elite number. */
|
||||
@JvmField
|
||||
@ -119,9 +116,9 @@ class Node(val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
|
||||
private var shutdownThread: Thread? = null
|
||||
|
||||
override fun makeMessagingService(): MessagingServiceInternal {
|
||||
val serverAddr = messagingServerAddr ?: {
|
||||
messageBroker = ArtemisMessagingServer(configuration, p2pAddr, services.networkMapCache)
|
||||
p2pAddr
|
||||
val serverAddr = configuration.messagingServerAddress ?: {
|
||||
messageBroker = ArtemisMessagingServer(configuration, configuration.artemisAddress, services.networkMapCache)
|
||||
configuration.artemisAddress
|
||||
}()
|
||||
val myIdentityOrNullIfNetworkMapService = if (networkMapService != null) services.storageService.myLegalIdentityKey.public else null
|
||||
return NodeMessagingClient(configuration, serverAddr, myIdentityOrNullIfNetworkMapService, serverThread,
|
||||
@ -177,13 +174,13 @@ class Node(val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
|
||||
sslContextFactory.setExcludeCipherSuites(".*NULL.*", ".*RC4.*", ".*MD5.*", ".*DES.*", ".*DSS.*")
|
||||
sslContextFactory.setIncludeCipherSuites(".*AES.*GCM.*")
|
||||
val sslConnector = ServerConnector(server, SslConnectionFactory(sslContextFactory, "http/1.1"), HttpConnectionFactory(httpsConfiguration))
|
||||
sslConnector.port = webServerAddr.port
|
||||
sslConnector.port = configuration.webAddress.port
|
||||
server.connectors = arrayOf<Connector>(sslConnector)
|
||||
} else {
|
||||
val httpConfiguration = HttpConfiguration()
|
||||
httpConfiguration.outputBufferSize = 32768
|
||||
val httpConnector = ServerConnector(server, HttpConnectionFactory(httpConfiguration))
|
||||
httpConnector.port = webServerAddr.port
|
||||
httpConnector.port = configuration.webAddress.port
|
||||
server.connectors = arrayOf<Connector>(httpConnector)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.r3corda.core.div
|
||||
import com.r3corda.core.messaging.SingleMessageRecipient
|
||||
import com.r3corda.core.node.services.ServiceInfo
|
||||
import com.r3corda.node.internal.Node
|
||||
import com.r3corda.node.serialization.NodeClock
|
||||
import com.r3corda.node.services.messaging.NodeMessagingClient
|
||||
import com.r3corda.node.services.network.NetworkMapService
|
||||
import com.typesafe.config.Config
|
||||
@ -18,7 +17,6 @@ import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.time.Clock
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.util.*
|
||||
@ -133,13 +131,12 @@ class FullNodeConfiguration(conf: Config) : NodeConfiguration {
|
||||
override val trustStorePassword: String by conf
|
||||
override val dataSourceProperties: Properties by conf
|
||||
override val devMode: Boolean by conf.getOrElse { false }
|
||||
val networkMapAddress: HostAndPort? = if (conf.hasPath("networkMapAddress")) HostAndPort.fromString(conf.getString("networkMapAddress")) else null
|
||||
val useHTTPS: Boolean by conf
|
||||
val artemisAddress: HostAndPort by conf
|
||||
val webAddress: HostAndPort by conf
|
||||
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 extraAdvertisedServiceIds: String by conf
|
||||
val clock: Clock = NodeClock()
|
||||
|
||||
fun createNode(): Node {
|
||||
val advertisedServices = mutableSetOf<ServiceInfo>()
|
||||
@ -150,14 +147,7 @@ class FullNodeConfiguration(conf: Config) : NodeConfiguration {
|
||||
}
|
||||
if (networkMapAddress == null) advertisedServices.add(ServiceInfo(NetworkMapService.Type))
|
||||
val networkMapMessageAddress: SingleMessageRecipient? = if (networkMapAddress == null) null else NodeMessagingClient.makeNetworkMapAddress(networkMapAddress)
|
||||
return Node(artemisAddress,
|
||||
webAddress,
|
||||
this,
|
||||
networkMapMessageAddress,
|
||||
advertisedServices,
|
||||
clock,
|
||||
messagingServerAddress
|
||||
)
|
||||
return Node(this, networkMapMessageAddress, advertisedServices)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user