From 0ee4f9c19b8c7d3aaf57eec2187ad3e208bf00fd Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Fri, 14 Oct 2016 14:16:20 +0100 Subject: [PATCH] Added DriverNodeInfo to allow access to the host and port for the api address for use in integration tests. --- .../src/main/kotlin/com/r3corda/node/driver/Driver.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/com/r3corda/node/driver/Driver.kt b/node/src/main/kotlin/com/r3corda/node/driver/Driver.kt index f19c168a5a..03d06134f0 100644 --- a/node/src/main/kotlin/com/r3corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/com/r3corda/node/driver/Driver.kt @@ -5,12 +5,16 @@ import com.fasterxml.jackson.databind.module.SimpleModule import com.google.common.net.HostAndPort import com.r3corda.core.ThreadBox import com.r3corda.core.crypto.Party +import com.r3corda.core.crypto.generateKeyPair import com.r3corda.core.node.NodeInfo +import com.r3corda.core.node.services.NetworkMapCache import com.r3corda.core.node.services.ServiceInfo import com.r3corda.node.services.config.ConfigHelper import com.r3corda.node.services.config.FullNodeConfiguration +import com.r3corda.node.services.messaging.ArtemisMessagingComponent import com.r3corda.node.services.messaging.ArtemisMessagingServer import com.r3corda.node.services.messaging.NodeMessagingClient +import com.r3corda.node.services.network.InMemoryNetworkMapCache import com.r3corda.node.services.network.NetworkMapService import com.r3corda.node.utilities.JsonSupport import com.typesafe.config.Config @@ -25,6 +29,7 @@ import java.nio.file.Paths import java.text.SimpleDateFormat import java.util.* import java.util.concurrent.* +import kotlin.concurrent.thread /** * This file defines a small "Driver" DSL for starting up nodes. @@ -52,7 +57,7 @@ interface DriverDSLExposedInterface { * @param advertisedServices The set of services to be advertised by the node. Defaults to empty set. * @return The [NodeInfo] of the started up node retrieved from the network map service. */ - fun startNode(providedName: String? = null, advertisedServices: Set = setOf()): Future + fun startNode(providedName: String? = null, advertisedServices: Set = setOf()): Future fun waitForAllNodesToFinish() } @@ -62,6 +67,8 @@ interface DriverDSLInternalInterface : DriverDSLExposedInterface { fun shutdown() } +data class DriverNodeInfo(val nodeInfo: NodeInfo, val messagingAddress: HostAndPort, val apiAddress: HostAndPort) + sealed class PortAllocation { abstract fun nextPort(): Int fun nextHostAndPort(): HostAndPort = HostAndPort.fromParts("localhost", nextPort()) @@ -276,7 +283,7 @@ class DriverDSL( } } - override fun startNode(providedName: String?, advertisedServices: Set): Future { + override fun startNode(providedName: String?, advertisedServices: Set): Future { val messagingAddress = portAllocation.nextHostAndPort() val apiAddress = portAllocation.nextHostAndPort() val debugPort = if (isDebug) debugPortAllocation.nextPort() else null