mirror of
https://github.com/corda/corda.git
synced 2025-06-22 09:08:49 +00:00
Merged in nodedircreate (pull request #139)
Todo resolution: Moved node directory creation into the abstract node.
This commit is contained in:
@ -163,6 +163,14 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Run any tasks that are needed to ensure the node is in a correct state before running start()
|
||||
*/
|
||||
open fun setup(): AbstractNode {
|
||||
createNodeDir()
|
||||
return this
|
||||
}
|
||||
|
||||
private fun buildAdvertisedServices() {
|
||||
val serviceTypes = info.advertisedServices
|
||||
if (NetworkMapService.Type in serviceTypes) makeNetworkMapService()
|
||||
@ -327,4 +335,10 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
}
|
||||
return NodeAttachmentService(attachmentsDir, services.monitoringService.metrics)
|
||||
}
|
||||
|
||||
protected fun createNodeDir() {
|
||||
if (!Files.exists(dir)) {
|
||||
Files.createDirectories(dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.glassfish.jersey.servlet.ServletContainer
|
||||
import java.io.RandomAccessFile
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.nio.channels.FileLock
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.time.Clock
|
||||
import javax.management.ObjectName
|
||||
@ -152,6 +153,11 @@ class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setup(): Node {
|
||||
super.setup()
|
||||
return this
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
webServer.stop()
|
||||
super.stop()
|
||||
@ -177,6 +183,7 @@ class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration
|
||||
println("Shut that other node down and try again. It may have process ID ${file.readText()}")
|
||||
System.exit(1)
|
||||
}
|
||||
|
||||
nodeFileLock = l
|
||||
val ourProcessID: String = ManagementFactory.getRuntimeMXBean().name.split("@")[0]
|
||||
f.setLength(0)
|
||||
|
@ -122,7 +122,7 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false,
|
||||
override val nearestCity: String = "Atlantis"
|
||||
}
|
||||
val node = nodeFactory.create(path, config, this, networkMapAddress, advertisedServices.toSet(), id, keyPair)
|
||||
if (start) node.start()
|
||||
if (start) node.setup().start()
|
||||
_nodes.add(node)
|
||||
return node
|
||||
}
|
||||
|
Reference in New Issue
Block a user