Fixed Demobench. (#2548)

This commit is contained in:
Michele Sollecito 2018-02-16 13:16:26 +00:00 committed by GitHub
parent fe7c129ae7
commit 9711ea88c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,9 @@
package net.corda.demobench.model
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory.empty
import com.typesafe.config.ConfigRenderOptions
import com.typesafe.config.ConfigValueFactory
import net.corda.core.identity.CordaX500Name
import net.corda.core.internal.copyToDirectory
import net.corda.core.internal.createDirectories
@ -19,6 +22,7 @@ data class NodeConfig(
val myLegalName: CordaX500Name,
val p2pAddress: NetworkHostAndPort,
val rpcAddress: NetworkHostAndPort,
val rpcAdminAddress: NetworkHostAndPort,
/** This is not used by the node but by the webserver which looks at node.conf. */
val webAddress: NetworkHostAndPort,
val notary: NotaryService?,
@ -38,7 +42,17 @@ data class NodeConfig(
@Suppress("unused")
private val useTestClock = true
fun toText(): String = toConfig().root().render(renderOptions)
private fun asConfig(): Config {
val config = toConfig()
val rpcSettings = empty()
.withValue("address", ConfigValueFactory.fromAnyRef(rpcAddress.toString()))
.withValue("adminAddress", ConfigValueFactory.fromAnyRef(rpcAdminAddress.toString()))
.root()
return config.withoutPath("rpcAddress").withoutPath("rpcAdminAddress").withValue("rpcSettings", rpcSettings)
}
fun toText(): String = asConfig().root().render(renderOptions)
}
/**

View File

@ -75,6 +75,7 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
),
p2pAddress = nodeData.p2pPort.toLocalAddress(),
rpcAddress = nodeData.rpcPort.toLocalAddress(),
rpcAdminAddress = nodeData.rpcAdminPort.toLocalAddress(),
webAddress = nodeData.webPort.toLocalAddress(),
notary = notary,
h2port = nodeData.h2Port.value,

View File

@ -35,6 +35,7 @@ class NodeData {
val nearestCity = SimpleObjectProperty(CityDatabase["London"]!!)
val p2pPort = SimpleIntegerProperty()
val rpcPort = SimpleIntegerProperty()
val rpcAdminPort = SimpleIntegerProperty()
val webPort = SimpleIntegerProperty()
val h2Port = SimpleIntegerProperty()
val extraServices = SimpleListProperty(observableArrayList<ExtraService>())
@ -45,6 +46,7 @@ class NodeDataModel : ItemViewModel<NodeData>(NodeData()) {
val nearestCity = bind { item?.nearestCity }
val p2pPort = bind { item?.p2pPort }
val rpcPort = bind { item?.rpcPort }
val rpcAdminPort = bind { item?.rpcAdminPort }
val webPort = bind { item?.webPort }
val h2Port = bind { item?.h2Port }
}

View File

@ -188,6 +188,7 @@ class NodeTabView : Fragment() {
model.p2pPort.value = nodeController.nextPort
model.rpcPort.value = nodeController.nextPort
model.rpcAdminPort.value = nodeController.nextPort
model.webPort.value = nodeController.nextPort
model.h2Port.value = nodeController.nextPort

View File

@ -28,6 +28,7 @@ class NodeConfigTest {
legalName = myLegalName,
p2pPort = 10001,
rpcPort = 40002,
rpcAdminPort = 40003,
webPort = 20001,
h2port = 30001,
notary = NotaryService(validating = false),
@ -55,6 +56,7 @@ class NodeConfigTest {
legalName = myLegalName,
p2pPort = 10001,
rpcPort = 40002,
rpcAdminPort = 40003,
webPort = 20001,
h2port = 30001,
notary = NotaryService(validating = false),
@ -77,6 +79,7 @@ class NodeConfigTest {
legalName: CordaX500Name = CordaX500Name(organisation = "Unknown", locality = "Nowhere", country = "GB"),
p2pPort: Int = -1,
rpcPort: Int = -1,
rpcAdminPort: Int = -1,
webPort: Int = -1,
h2port: Int = -1,
notary: NotaryService?,
@ -86,6 +89,7 @@ class NodeConfigTest {
myLegalName = legalName,
p2pAddress = localPort(p2pPort),
rpcAddress = localPort(rpcPort),
rpcAdminAddress = localPort(rpcAdminPort),
webAddress = localPort(webPort),
h2port = h2port,
notary = notary,

View File

@ -150,6 +150,7 @@ class NodeControllerTest {
organisation: String = "Unknown",
p2pPort: Int = 0,
rpcPort: Int = 0,
rpcAdminPort: Int = 0,
webPort: Int = 0,
h2port: Int = 0,
notary: NotaryService? = null,
@ -163,6 +164,7 @@ class NodeControllerTest {
),
p2pAddress = localPort(p2pPort),
rpcAddress = localPort(rpcPort),
rpcAdminAddress = localPort(rpcAdminPort),
webAddress = localPort(webPort),
h2port = h2port,
notary = notary,