mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
Unpack DemoBench's capsules within $HOME/demobench directory. (#738)
* Unpack the capsules into a subdirectory of $HOME/demobench. * Minor tidy up. * Add a new suggested bank.
This commit is contained in:
parent
ca36b4676d
commit
1aae41214f
@ -3,14 +3,15 @@ package net.corda.demobench.model
|
|||||||
import javafx.scene.control.Alert
|
import javafx.scene.control.Alert
|
||||||
import javafx.scene.control.Alert.AlertType.ERROR
|
import javafx.scene.control.Alert.AlertType.ERROR
|
||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
import tornadofx.*
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import tornadofx.*
|
||||||
|
|
||||||
class JVMConfig : Controller() {
|
class JVMConfig : Controller() {
|
||||||
|
|
||||||
val userHome: Path = Paths.get(System.getProperty("user.home")).toAbsolutePath()
|
val userHome: Path = Paths.get(System.getProperty("user.home")).toAbsolutePath()
|
||||||
val dataHome: Path = userHome.resolve("demobench")
|
val dataHome: Path = userHome.resolve("demobench")
|
||||||
|
val capsuleHome: Path = dataHome.resolve(".capsule")
|
||||||
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
|
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
|
||||||
val applicationDir: Path = Paths.get(System.getProperty("user.dir")).toAbsolutePath()
|
val applicationDir: Path = Paths.get(System.getProperty("user.dir")).toAbsolutePath()
|
||||||
|
|
||||||
@ -23,9 +24,12 @@ class JVMConfig : Controller() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun processFor(jarPath: Path, vararg args: String): ProcessBuilder {
|
fun processFor(jarPath: Path, vararg args: String): ProcessBuilder {
|
||||||
return ProcessBuilder(commandFor(jarPath, *args))
|
return ProcessBuilder(commandFor(jarPath, *args)).apply { setCapsuleCacheDir(environment()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setCapsuleCacheDir(env: MutableMap<String, String>): MutableMap<String, String> = env.apply {
|
||||||
|
put("CAPSULE_CACHE_DIR", capsuleHome.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias atRuntime = (Path, String) -> Unit
|
typealias atRuntime = (Path, String) -> Unit
|
||||||
|
@ -47,10 +47,9 @@ class NodeConfig(
|
|||||||
.withValue("myLegalName", valueFor(legalName.toString()))
|
.withValue("myLegalName", valueFor(legalName.toString()))
|
||||||
.withValue("p2pAddress", addressValueFor(p2pPort))
|
.withValue("p2pAddress", addressValueFor(p2pPort))
|
||||||
.withValue("extraAdvertisedServiceIds", valueFor(extraServices))
|
.withValue("extraAdvertisedServiceIds", valueFor(extraServices))
|
||||||
.withFallback(optional("networkMapService", networkMap, {
|
.withFallback(optional("networkMapService", networkMap, { c, n ->
|
||||||
c, n ->
|
|
||||||
c.withValue("address", addressValueFor(n.p2pPort))
|
c.withValue("address", addressValueFor(n.p2pPort))
|
||||||
.withValue("legalName", valueFor(n.legalName.toString()))
|
.withValue("legalName", valueFor(n.legalName.toString()))
|
||||||
}))
|
}))
|
||||||
.withValue("webAddress", addressValueFor(webPort))
|
.withValue("webAddress", addressValueFor(webPort))
|
||||||
.withValue("rpcAddress", addressValueFor(rpcPort))
|
.withValue("rpcAddress", addressValueFor(rpcPort))
|
||||||
|
@ -116,7 +116,10 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
|
|||||||
confFile.writeText(config.toText())
|
confFile.writeText(config.toText())
|
||||||
|
|
||||||
// Execute the Corda node
|
// Execute the Corda node
|
||||||
pty.run(command, System.getenv(), nodeDir.toString())
|
val cordaEnv = System.getenv().toMutableMap().apply {
|
||||||
|
jvm.setCapsuleCacheDir(this)
|
||||||
|
}
|
||||||
|
pty.run(command, cordaEnv, nodeDir.toString())
|
||||||
log.info("Launched node: ${config.legalName}")
|
log.info("Launched node: ${config.legalName}")
|
||||||
return true
|
return true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -19,7 +19,8 @@ object SuggestedDetails {
|
|||||||
"Bank of Big Apples" to "New York",
|
"Bank of Big Apples" to "New York",
|
||||||
"Bank of Baguettes" to "Paris",
|
"Bank of Baguettes" to "Paris",
|
||||||
"Bank of Fondue" to "Geneve",
|
"Bank of Fondue" to "Geneve",
|
||||||
"Bank of Maple Syrup" to "Toronto"
|
"Bank of Maple Syrup" to "Toronto",
|
||||||
|
"Bank of Golden Gates" to "San Francisco"
|
||||||
)
|
)
|
||||||
|
|
||||||
private var cursor = 0
|
private var cursor = 0
|
||||||
|
@ -4,7 +4,6 @@ import tornadofx.*
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.*
|
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
class ServiceController(resourceName: String = "/services.conf") : Controller() {
|
class ServiceController(resourceName: String = "/services.conf") : Controller() {
|
||||||
@ -17,11 +16,11 @@ class ServiceController(resourceName: String = "/services.conf") : Controller()
|
|||||||
* Load our list of known extra Corda services.
|
* Load our list of known extra Corda services.
|
||||||
*/
|
*/
|
||||||
private fun loadConf(url: URL?): List<String> {
|
private fun loadConf(url: URL?): List<String> {
|
||||||
if (url == null) {
|
return if (url == null) {
|
||||||
return emptyList()
|
emptyList()
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
val set = TreeSet<String>()
|
val set = sortedSetOf<String>()
|
||||||
InputStreamReader(url.openStream()).useLines { sq ->
|
InputStreamReader(url.openStream()).useLines { sq ->
|
||||||
sq.forEach { line ->
|
sq.forEach { line ->
|
||||||
val service = line.trim()
|
val service = line.trim()
|
||||||
@ -30,12 +29,11 @@ class ServiceController(resourceName: String = "/services.conf") : Controller()
|
|||||||
log.info("Supports: $service")
|
log.info("Supports: $service")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set.toList()
|
set.toList()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
log.log(Level.SEVERE, "Failed to load $url: ${e.message}", e)
|
log.log(Level.SEVERE, "Failed to load $url: ${e.message}", e)
|
||||||
return emptyList()
|
emptyList<String>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
|||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun run(args: Array<String>, envs: Map<String, String>, workingDir: String?) {
|
fun run(args: Array<String>, envs: Map<String, String>, workingDir: String?) {
|
||||||
check(!terminal.isSessionRunning, { "${terminal.sessionName} is already running" })
|
check(!terminal.isSessionRunning) { "${terminal.sessionName} is already running" }
|
||||||
|
|
||||||
val environment = envs.toMutableMap()
|
val environment = envs.toMutableMap()
|
||||||
if (!UIUtil.isWindows) {
|
if (!UIUtil.isWindows) {
|
||||||
@ -64,8 +64,7 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
|||||||
onExit(exitValue)
|
onExit(exitValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
val session = terminal.createTerminalSession(connector)
|
terminal.createTerminalSession(connector).apply { start() }
|
||||||
session.start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user