mirror of
https://github.com/corda/corda.git
synced 2025-03-24 04:55:32 +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.AlertType.ERROR
|
||||
import javafx.stage.Stage
|
||||
import tornadofx.*
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import tornadofx.*
|
||||
|
||||
class JVMConfig : Controller() {
|
||||
|
||||
val userHome: Path = Paths.get(System.getProperty("user.home")).toAbsolutePath()
|
||||
val dataHome: Path = userHome.resolve("demobench")
|
||||
val capsuleHome: Path = dataHome.resolve(".capsule")
|
||||
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
|
||||
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 {
|
||||
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
|
||||
|
@ -47,10 +47,9 @@ class NodeConfig(
|
||||
.withValue("myLegalName", valueFor(legalName.toString()))
|
||||
.withValue("p2pAddress", addressValueFor(p2pPort))
|
||||
.withValue("extraAdvertisedServiceIds", valueFor(extraServices))
|
||||
.withFallback(optional("networkMapService", networkMap, {
|
||||
c, n ->
|
||||
.withFallback(optional("networkMapService", networkMap, { c, n ->
|
||||
c.withValue("address", addressValueFor(n.p2pPort))
|
||||
.withValue("legalName", valueFor(n.legalName.toString()))
|
||||
.withValue("legalName", valueFor(n.legalName.toString()))
|
||||
}))
|
||||
.withValue("webAddress", addressValueFor(webPort))
|
||||
.withValue("rpcAddress", addressValueFor(rpcPort))
|
||||
|
@ -116,7 +116,10 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
|
||||
confFile.writeText(config.toText())
|
||||
|
||||
// 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}")
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
|
@ -19,7 +19,8 @@ object SuggestedDetails {
|
||||
"Bank of Big Apples" to "New York",
|
||||
"Bank of Baguettes" to "Paris",
|
||||
"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
|
||||
|
@ -4,7 +4,6 @@ import tornadofx.*
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.logging.Level
|
||||
|
||||
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.
|
||||
*/
|
||||
private fun loadConf(url: URL?): List<String> {
|
||||
if (url == null) {
|
||||
return emptyList()
|
||||
return if (url == null) {
|
||||
emptyList()
|
||||
} else {
|
||||
try {
|
||||
val set = TreeSet<String>()
|
||||
val set = sortedSetOf<String>()
|
||||
InputStreamReader(url.openStream()).useLines { sq ->
|
||||
sq.forEach { line ->
|
||||
val service = line.trim()
|
||||
@ -30,12 +29,11 @@ class ServiceController(resourceName: String = "/services.conf") : Controller()
|
||||
log.info("Supports: $service")
|
||||
}
|
||||
}
|
||||
return set.toList()
|
||||
set.toList()
|
||||
} catch (e: IOException) {
|
||||
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)
|
||||
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()
|
||||
if (!UIUtil.isWindows) {
|
||||
@ -64,8 +64,7 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
||||
onExit(exitValue)
|
||||
}
|
||||
|
||||
val session = terminal.createTerminalSession(connector)
|
||||
session.start()
|
||||
terminal.createTerminalSession(connector).apply { start() }
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
|
Loading…
x
Reference in New Issue
Block a user