mirror of
https://github.com/corda/corda.git
synced 2025-02-04 02:01:13 +00:00
[CORDA-442] Removed the NetworkMap option from Cordform, changed all the examples… (#1827)
[CORDA-442] Removed the option for Cordformation to specify a networkMap. All the samples have been migrated to not specify a networkMap.
This commit is contained in:
parent
8c9045bd73
commit
3bee830604
@ -231,7 +231,6 @@ tasks.withType(Test) {
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Controller,OU=corda,L=London,C=GB"
|
||||
node {
|
||||
name "O=Controller,OU=corda,L=London,C=GB"
|
||||
notary = [validating : true]
|
||||
|
@ -12,8 +12,8 @@ UNRELEASED
|
||||
deploys nodes for development and testing, the latter turns a project into a cordapp project that generates JARs in
|
||||
the standard CorDapp format.
|
||||
|
||||
* ``Cordform`` and node identity generation
|
||||
* Cordform may not specify a value for ``NetworkMap``, when that happens, during the task execution the following happens:
|
||||
* ``Cordform`` and node identity generation:
|
||||
* Removed the parameter ``NetworkMap`` from Cordform. Now at the end of the deployment the following happens:
|
||||
1. Each node is started and its signed serialized NodeInfo is written to disk in the node base directory.
|
||||
2. Every serialized ``NodeInfo`` above is copied in every other node "additional-node-info" folder under the NodeInfo folder.
|
||||
|
||||
|
@ -11,13 +11,12 @@ Cordform is the local node deployment system for CorDapps. The nodes generated a
|
||||
debugging, and testing node configurations, but not for production or testnet deployment.
|
||||
|
||||
Here is an example Gradle task called ``deployNodes`` that uses the Cordform plugin to deploy three nodes, plus a
|
||||
notary/network map node:
|
||||
notary node:
|
||||
|
||||
.. sourcecode:: groovy
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Controller,OU=corda,L=London,C=UK"
|
||||
node {
|
||||
name "O=Controller,OU=corda,L=London,C=UK"
|
||||
notary = [validating : true]
|
||||
@ -52,9 +51,7 @@ notary/network map node:
|
||||
}
|
||||
}
|
||||
|
||||
You can extend ``deployNodes`` to generate any number of nodes you like. The only requirement is that you must specify
|
||||
one node as running the network map service, by putting their name in the ``networkMap`` field. In our example, the
|
||||
``Controller`` is set as the network map service.
|
||||
You can extend ``deployNodes`` to generate any number of nodes you like.
|
||||
|
||||
.. warning:: When adding nodes, make sure that there are no port clashes!
|
||||
|
||||
@ -87,7 +84,12 @@ run all the nodes at once. Each node in the ``nodes`` folder has the following s
|
||||
. nodeName
|
||||
├── corda.jar // The Corda runtime
|
||||
├── node.conf // The node's configuration
|
||||
└── plugins // Any installed CorDapps
|
||||
├── plugins // Any installed CorDapps
|
||||
└── additional-node-infos // Directory containing all the addresses and certificates of the other nodes.
|
||||
|
||||
.. note:: During the build process each node generates a NodeInfo file which is written in its own root directory,
|
||||
the plug-in proceeds and copies each node NodeInfo to every other node ``additional-node-infos`` directory.
|
||||
The NodeInfo file contains a node hostname and port, legal name and security certificate.
|
||||
|
||||
.. note:: Outside of development environments, do not store your node directories in the build folder.
|
||||
|
||||
|
@ -73,7 +73,6 @@ task integrationTest(type: Test) {
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Notary Service,OU=corda,L=London,C=GB"
|
||||
node {
|
||||
name "O=Notary Service,OU=corda,L=London,C=GB"
|
||||
notary = [validating : true]
|
||||
|
@ -25,7 +25,6 @@ Let's take a look at the nodes we're going to deploy. Open the project's ``build
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Controller,L=London,C=GB"
|
||||
node {
|
||||
name "O=Controller,L=London,C=GB"
|
||||
notary = [validating : true]
|
||||
@ -82,6 +81,7 @@ the three node folders. Each node folder has the following structure:
|
||||
|____corda-webserver.jar // The node's webserver
|
||||
|____dependencies
|
||||
|____node.conf // The node's configuration file
|
||||
|____additional-node-infos/ // Directory containing all the other nodes' addresses and identities
|
||||
|____plugins
|
||||
|____java/kotlin-source-0.1.jar // Our IOU CorDapp
|
||||
|
||||
|
@ -17,7 +17,7 @@ if:
|
||||
|
||||
We will deploy the CorDapp on 4 test nodes:
|
||||
|
||||
* **Controller**, which hosts the network map service and a validating notary service
|
||||
* **Controller**, which hosts a validating notary service
|
||||
* **PartyA**
|
||||
* **PartyB**
|
||||
* **PartyC**
|
||||
@ -276,7 +276,7 @@ IntelliJ
|
||||
|
||||
The node driver defined in ``/src/test/kotlin/com/example/Main.kt`` allows you to specify how many nodes you would like
|
||||
to run and the configuration settings for each node. For the example CorDapp, the driver starts up four nodes
|
||||
and adds an RPC user for all but the "Controller" node (which serves as the notary and network map service):
|
||||
and adds an RPC user for all but the "Controller" node (which serves as the notary):
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
@ -489,9 +489,6 @@ You must now edit the configuration file for each node, including the controller
|
||||
and make the following changes:
|
||||
|
||||
* Change the Artemis messaging address to the machine's IP address (e.g. ``p2pAddress="10.18.0.166:10006"``)
|
||||
* Change the network map service's address to the IP address of the machine where the controller node is running
|
||||
(e.g. ``networkMapService { address="10.18.0.166:10002" legalName="O=Controller,L=London,C=GB" ``). The controller
|
||||
will not have the ``networkMapService`` configuration entry
|
||||
|
||||
After starting each node, the nodes will be able to see one another and agree IOUs among themselves.
|
||||
|
||||
|
@ -7,11 +7,9 @@ import java.util.function.Consumer;
|
||||
public abstract class CordformDefinition {
|
||||
public final Path driverDirectory;
|
||||
public final ArrayList<Consumer<? super CordformNode>> nodeConfigurers = new ArrayList<>();
|
||||
public final String networkMapNodeName;
|
||||
|
||||
public CordformDefinition(Path driverDirectory, String networkMapNodeName) {
|
||||
public CordformDefinition(Path driverDirectory) {
|
||||
this.driverDirectory = driverDirectory;
|
||||
this.networkMapNodeName = networkMapNodeName;
|
||||
}
|
||||
|
||||
public void addNode(Consumer<? super CordformNode> configurer) {
|
||||
|
@ -3,9 +3,7 @@ package net.corda.plugins
|
||||
import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME
|
||||
import net.corda.cordform.CordformContext
|
||||
import net.corda.cordform.CordformDefinition
|
||||
import net.corda.cordform.CordformNode
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
@ -24,7 +22,6 @@ class Cordform extends DefaultTask {
|
||||
String definitionClass
|
||||
protected def directory = Paths.get("build", "nodes")
|
||||
private def nodes = new ArrayList<Node>()
|
||||
protected String networkMapNodeName
|
||||
|
||||
/**
|
||||
* Set the directory to install nodes into.
|
||||
@ -36,16 +33,6 @@ class Cordform extends DefaultTask {
|
||||
this.directory = Paths.get(directory)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the network map node.
|
||||
*
|
||||
* @warning Ensure the node name is one of the configured nodes.
|
||||
* @param nodeName The name of the node that will host the network map.
|
||||
*/
|
||||
void networkMap(String nodeName) {
|
||||
networkMapNodeName = nodeName
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a node configuration.
|
||||
*
|
||||
@ -110,12 +97,15 @@ class Cordform extends DefaultTask {
|
||||
*/
|
||||
@TaskAction
|
||||
void build() {
|
||||
String networkMapNodeName = initializeConfigurationAndGetNetworkMapNodeName()
|
||||
initializeConfiguration()
|
||||
installRunScript()
|
||||
finalizeConfiguration(networkMapNodeName)
|
||||
nodes.each {
|
||||
it.build()
|
||||
}
|
||||
generateNodeInfos()
|
||||
}
|
||||
|
||||
private initializeConfigurationAndGetNetworkMapNodeName() {
|
||||
private initializeConfiguration() {
|
||||
if (null != definitionClass) {
|
||||
def cd = loadCordformDefinition()
|
||||
cd.nodeConfigurers.each { nc ->
|
||||
@ -129,30 +119,10 @@ class Cordform extends DefaultTask {
|
||||
project.projectDir.toPath().resolve(getNodeByName(nodeName).nodeDir.toPath())
|
||||
}
|
||||
}
|
||||
return cd.networkMapNodeName.toString()
|
||||
} else {
|
||||
nodes.each {
|
||||
it.rootDir directory
|
||||
}
|
||||
return this.networkMapNodeName
|
||||
}
|
||||
}
|
||||
|
||||
private finalizeConfiguration(String networkMapNodeName) {
|
||||
Node networkMapNode = getNodeByName(networkMapNodeName)
|
||||
if (networkMapNode == null) {
|
||||
nodes.each {
|
||||
it.build()
|
||||
}
|
||||
generateNodeInfos()
|
||||
logger.info("Starting without networkMapNode, this an experimental feature")
|
||||
} else {
|
||||
nodes.each {
|
||||
if (it != networkMapNode) {
|
||||
it.networkMapAddress(networkMapNode.getP2PAddress(), networkMapNodeName)
|
||||
}
|
||||
it.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.attachmentdemo.AttachmentDemoFlow"]]]
|
||||
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Notary Service,L=Zurich,C=CH"
|
||||
node {
|
||||
name "O=Notary Service,L=Zurich,C=CH"
|
||||
notary = [validating : true]
|
||||
|
@ -50,8 +50,6 @@ dependencies {
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
// This name "Notary" is hard-coded into BankOfCordaClientApi so if you change it here, change it there too.
|
||||
// In this demo the node that runs a standalone notary also acts as the network map server.
|
||||
networkMap "O=Notary Service,L=Zurich,C=CH"
|
||||
node {
|
||||
name "O=Notary Service,L=Zurich,C=CH"
|
||||
notary = [validating : true]
|
||||
|
@ -51,7 +51,6 @@ dependencies {
|
||||
|
||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Notary Service,L=Zurich,C=CH"
|
||||
node {
|
||||
name "O=Notary Service,L=Zurich,C=CH"
|
||||
notary = [validating : true]
|
||||
|
@ -13,7 +13,11 @@ import net.corda.node.services.transactions.minCorrectReplicas
|
||||
import net.corda.node.utilities.ServiceIdentityGenerator
|
||||
import net.corda.testing.ALICE
|
||||
import net.corda.testing.BOB
|
||||
import net.corda.testing.internal.demorun.*
|
||||
import net.corda.testing.internal.demorun.name
|
||||
import net.corda.testing.internal.demorun.node
|
||||
import net.corda.testing.internal.demorun.notary
|
||||
import net.corda.testing.internal.demorun.rpcUsers
|
||||
import net.corda.testing.internal.demorun.runNodes
|
||||
|
||||
fun main(args: Array<String>) = BFTNotaryCordform.runNodes()
|
||||
|
||||
@ -22,7 +26,7 @@ private val notaryNames = createNotaryNames(clusterSize)
|
||||
|
||||
// This is not the intended final design for how to use CordformDefinition, please treat this as experimental and DO
|
||||
// NOT use this as a design to copy.
|
||||
object BFTNotaryCordform : CordformDefinition("build" / "notary-demo-nodes", notaryNames[0].toString()) {
|
||||
object BFTNotaryCordform : CordformDefinition("build" / "notary-demo-nodes") {
|
||||
private val clusterName = CordaX500Name(BFTNonValidatingNotaryService.id, "BFT", "Zurich", "CH")
|
||||
|
||||
init {
|
||||
|
@ -22,7 +22,7 @@ private val notaryNames = createNotaryNames(3)
|
||||
|
||||
// This is not the intended final design for how to use CordformDefinition, please treat this as experimental and DO
|
||||
// NOT use this as a design to copy.
|
||||
object RaftNotaryCordform : CordformDefinition("build" / "notary-demo-nodes", notaryNames[0].toString()) {
|
||||
object RaftNotaryCordform : CordformDefinition("build" / "notary-demo-nodes") {
|
||||
private val clusterName = CordaX500Name(RaftValidatingNotaryService.id, "Raft", "Zurich", "CH")
|
||||
|
||||
init {
|
||||
|
@ -11,7 +11,11 @@ import net.corda.notarydemo.flows.RPCStartableNotaryFlowClient
|
||||
import net.corda.testing.ALICE
|
||||
import net.corda.testing.BOB
|
||||
import net.corda.testing.DUMMY_NOTARY
|
||||
import net.corda.testing.internal.demorun.*
|
||||
import net.corda.testing.internal.demorun.name
|
||||
import net.corda.testing.internal.demorun.node
|
||||
import net.corda.testing.internal.demorun.notary
|
||||
import net.corda.testing.internal.demorun.rpcUsers
|
||||
import net.corda.testing.internal.demorun.runNodes
|
||||
|
||||
fun main(args: Array<String>) = SingleNotaryCordform.runNodes()
|
||||
|
||||
@ -19,7 +23,7 @@ val notaryDemoUser = User("demou", "demop", setOf(startFlowPermission<DummyIssue
|
||||
|
||||
// This is not the intended final design for how to use CordformDefinition, please treat this as experimental and DO
|
||||
// NOT use this as a design to copy.
|
||||
object SingleNotaryCordform : CordformDefinition("build" / "notary-demo-nodes", DUMMY_NOTARY.name.toString()) {
|
||||
object SingleNotaryCordform : CordformDefinition("build" / "notary-demo-nodes") {
|
||||
init {
|
||||
node {
|
||||
name(ALICE.name)
|
||||
|
@ -64,7 +64,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
ext.rpcUsers = [['username': "default", 'password': "default", 'permissions': [ 'ALL' ]]]
|
||||
|
||||
directory "./build/nodes"
|
||||
networkMap "O=Notary Service,L=Zurich,C=CH"
|
||||
node {
|
||||
name "O=Notary Service,L=Zurich,C=CH"
|
||||
notary = [validating : true]
|
||||
|
@ -51,8 +51,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
|
||||
|
||||
directory "./build/nodes"
|
||||
// This name "Notary" is hard-coded into TraderDemoClientApi so if you change it here, change it there too.
|
||||
// In this demo the node that runs a standalone notary also acts as the network map server.
|
||||
networkMap "O=Notary Service,L=Zurich,C=CH"
|
||||
node {
|
||||
name "O=Notary Service,L=Zurich,C=CH"
|
||||
notary = [validating : true]
|
||||
|
@ -4,8 +4,6 @@ package net.corda.testing.internal.demorun
|
||||
|
||||
import net.corda.cordform.CordformDefinition
|
||||
import net.corda.cordform.CordformNode
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.testing.driver.NetworkMapStartStrategy
|
||||
import net.corda.testing.driver.PortAllocation
|
||||
import net.corda.testing.driver.driver
|
||||
|
||||
@ -20,7 +18,6 @@ fun CordformDefinition.clean() {
|
||||
fun CordformDefinition.runNodes() = driver(
|
||||
isDebug = true,
|
||||
driverDirectory = driverDirectory,
|
||||
networkMapStartStrategy = NetworkMapStartStrategy.Nominated(CordaX500Name.parse(networkMapNodeName)),
|
||||
portAllocation = PortAllocation.Incremental(10001)
|
||||
) {
|
||||
setup(this)
|
||||
|
Loading…
x
Reference in New Issue
Block a user