Merge remote-tracking branch 'open/master' into os-merge-aefd90f

# Conflicts:
#	CONTRIBUTORS.md
This commit is contained in:
Shams Asari
2018-07-09 12:33:47 +01:00
14 changed files with 49 additions and 75 deletions

View File

@ -34,7 +34,6 @@ import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.millis
import net.corda.node.NodeRegistrationOption
import net.corda.node.VersionInfo
import net.corda.node.internal.ConfigurationException
import net.corda.node.internal.Node
import net.corda.node.internal.StartedNode
import net.corda.node.services.Permissions
@ -846,7 +845,7 @@ class DriverDSLImpl(
it += extraCmdLineFlag
}.toList()
return ProcessUtilities.startCordaProcess(
return ProcessUtilities.startJavaProcess(
className = "net.corda.node.Corda", // cannot directly get class for this, so just use string
arguments = arguments,
jdwpPort = debugPort,
@ -859,13 +858,12 @@ class DriverDSLImpl(
private fun startWebserver(handle: NodeHandleInternal, debugPort: Int?, maximumHeapSize: String): Process {
val className = "net.corda.webserver.WebServer"
writeConfig(handle.baseDirectory, "web-server.conf", handle.toWebServerConfig())
return ProcessUtilities.startCordaProcess(
return ProcessUtilities.startJavaProcess(
className = className, // cannot directly get class for this, so just use string
arguments = listOf("--base-directory", handle.baseDirectory.toString()),
jdwpPort = debugPort,
extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") +
inheritFromParentProcess().map { "-D${it.first}=${it.second}" },
workingDirectory = null,
maximumHeapSize = maximumHeapSize
)
}

View File

@ -11,40 +11,32 @@
package net.corda.testing.node.internal
import net.corda.core.internal.div
import java.io.File
import java.nio.file.Path
object ProcessUtilities {
inline fun <reified C : Any> startJavaProcess(
arguments: List<String>,
classpath: String = defaultClassPath,
classPath: List<String> = defaultClassPath,
workingDirectory: Path? = null,
jdwpPort: Int? = null,
extraJvmArguments: List<String> = emptyList()
extraJvmArguments: List<String> = emptyList(),
maximumHeapSize: String? = null
): Process {
return startJavaProcessImpl(C::class.java.name, arguments, classpath, jdwpPort, extraJvmArguments, null, null)
return startJavaProcess(C::class.java.name, arguments, classPath, workingDirectory, jdwpPort, extraJvmArguments, maximumHeapSize)
}
fun startCordaProcess(
fun startJavaProcess(
className: String,
arguments: List<String>,
jdwpPort: Int?,
extraJvmArguments: List<String>,
workingDirectory: Path?,
maximumHeapSize: String
): Process {
return startJavaProcessImpl(className, arguments, defaultClassPath, jdwpPort, extraJvmArguments, workingDirectory, maximumHeapSize)
}
fun startJavaProcessImpl(
className: String,
arguments: List<String>,
classpath: String,
jdwpPort: Int?,
extraJvmArguments: List<String>,
workingDirectory: Path?,
maximumHeapSize: String?
classPath: List<String> = defaultClassPath,
workingDirectory: Path? = null,
jdwpPort: Int? = null,
extraJvmArguments: List<String> = emptyList(),
maximumHeapSize: String? = null
): Process {
val command = mutableListOf<String>().apply {
add((System.getProperty("java.home") / "bin" / "java").toString())
add(javaPath)
(jdwpPort != null) && add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$jdwpPort")
if (maximumHeapSize != null) add("-Xmx$maximumHeapSize")
add("-XX:+UseG1GC")
@ -54,7 +46,7 @@ object ProcessUtilities {
}
return ProcessBuilder(command).apply {
inheritIO()
environment()["CLASSPATH"] = classpath
environment()["CLASSPATH"] = classPath.joinToString(File.pathSeparator)
if (workingDirectory != null) {
redirectError((workingDirectory / "$className.stderr.log").toFile())
redirectOutput((workingDirectory / "$className.stdout.log").toFile())
@ -63,5 +55,7 @@ object ProcessUtilities {
}.start()
}
val defaultClassPath: String get() = System.getProperty("java.class.path")
private val javaPath = (System.getProperty("java.home") / "bin" / "java").toString()
val defaultClassPath: List<String> = System.getProperty("java.class.path").split(File.pathSeparator)
}