mirror of
https://github.com/corda/corda.git
synced 2025-01-18 18:56:28 +00:00
NOTICK fix demobench (#6455)
* Add schema migration step to node start-up * Allow to set hibernate for app schema, including error pop-up when it goes bang.
This commit is contained in:
parent
057a8d8ae9
commit
adeea5c0de
@ -1,11 +1,17 @@
|
||||
package net.corda.demobench.model
|
||||
|
||||
import javafx.application.Application.Parameters
|
||||
import javafx.application.Platform
|
||||
import javafx.beans.binding.IntegerExpression
|
||||
import javafx.beans.property.SimpleBooleanProperty
|
||||
import javafx.scene.control.Alert
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.*
|
||||
import net.corda.core.internal.copyToDirectory
|
||||
import net.corda.core.internal.createDirectories
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.internal.noneOrSingle
|
||||
import net.corda.core.internal.writeText
|
||||
import net.corda.core.node.NetworkParameters
|
||||
import net.corda.core.node.NotaryInfo
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
@ -52,6 +58,7 @@ class NodeController(
|
||||
}
|
||||
|
||||
val djvmEnabled = SimpleBooleanProperty(djvmEnabled)
|
||||
val allowHibernateToManageAppSchema = SimpleBooleanProperty(false)
|
||||
|
||||
private val jvm by inject<JVMConfig>()
|
||||
private val cordappController by inject<CordappController>()
|
||||
@ -61,6 +68,8 @@ class NodeController(
|
||||
private val cordaPath: Path = jvm.applicationDir.resolve("corda").resolve("corda.jar")
|
||||
private val command = jvm.commandFor(cordaPath).toTypedArray()
|
||||
|
||||
private val schemaSetupArgs = arrayOf("run-migration-scripts", "--core-schemas", "--app-schemas")
|
||||
|
||||
private val nodes = LinkedHashMap<String, NodeConfigWrapper>()
|
||||
private var notaryIdentity: Party? = null
|
||||
private var networkParametersCopier: NetworkParametersCopier? = null
|
||||
@ -155,6 +164,23 @@ class NodeController(
|
||||
jvm.setCapsuleCacheDir(this)
|
||||
}
|
||||
(networkParametersCopier ?: makeNetworkParametersCopier(config)).install(config.nodeDir)
|
||||
@Suppress("SpreadOperator")
|
||||
val schemaSetupCommand = jvm.commandFor(cordaPath, *schemaSetupArgs).let {
|
||||
if (allowHibernateToManageAppSchema.value) {
|
||||
it + "--allow-hibernate-to-manage-app-schema"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.toTypedArray()
|
||||
if (pty.runSetupProcess(schemaSetupCommand, cordaEnv, config.nodeDir.toString()) != 0) {
|
||||
Platform.runLater {
|
||||
Alert(
|
||||
Alert.AlertType.ERROR,
|
||||
"Failed to set up database schema for node [${config.nodeConfig.myLegalName}]\n" +
|
||||
"Please check logfiles!").showAndWait()
|
||||
}
|
||||
return false
|
||||
}
|
||||
pty.run(command, cordaEnv, config.nodeDir.toString())
|
||||
log.info("Launched node: ${config.nodeConfig.myLegalName}")
|
||||
return true
|
||||
|
@ -63,6 +63,11 @@ class R3Pty(val name: CordaX500Name, settings: SettingsProvider, dimension: Dime
|
||||
terminal.createTerminalSession(connector).apply { start() }
|
||||
}
|
||||
|
||||
fun runSetupProcess(args: Array<String>, envs: Map<String, String>, workingDir: String?): Int {
|
||||
val process = PtyProcess.exec(args, envs, workingDir)
|
||||
return process.waitFor()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@Throws(InterruptedException::class)
|
||||
fun waitFor(): Int = terminal.ttyConnector?.waitFor() ?: -1
|
||||
|
@ -155,6 +155,9 @@ class NodeTabView : Fragment() {
|
||||
checkbox("Deterministic Contract Verification", nodeController.djvmEnabled).apply {
|
||||
styleClass += "djvm"
|
||||
}
|
||||
checkbox("Allow Hibernate to manage app schema", nodeController.allowHibernateToManageAppSchema).apply {
|
||||
styleClass += "hibernate"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user