mirror of
https://github.com/corda/corda.git
synced 2025-06-14 13:18:18 +00:00
Network bootstrapper check for duplicate node names (#3182)
This commit is contained in:
committed by
Shams Asari
parent
24b43117dc
commit
ae5bacb4b4
@ -1,11 +1,11 @@
|
|||||||
# List of Contributors
|
# List of Contributors
|
||||||
|
|
||||||
We'd like to thank the following people for contributing to Corda, either by
|
We'd like to thank the following people for contributing to Corda, either by
|
||||||
contributing to the design of Corda during the architecture review sessions of the
|
contributing to the design of Corda during the architecture review sessions of the
|
||||||
R3 Architecture Working Group and during design reviews since Corda has been
|
R3 Architecture Working Group and during design reviews since Corda has been
|
||||||
open-sourced, or by contributing code via pull requests. Some people have
|
open-sourced, or by contributing code via pull requests. Some people have
|
||||||
moved to a different organisation since their contribution. Please forgive any
|
moved to a different organisation since their contribution. Please forgive any
|
||||||
omissions, and create a pull request, or email <james@r3.com>, if you wish to
|
omissions, and create a pull request, or email <james@r3.com>, if you wish to
|
||||||
see changes to this list.
|
see changes to this list.
|
||||||
|
|
||||||
* acetheultimate
|
* acetheultimate
|
||||||
@ -164,6 +164,7 @@ see changes to this list.
|
|||||||
* Simon Taylor (Barclays)
|
* Simon Taylor (Barclays)
|
||||||
* Sofus Mortensen (Digital Asset Holdings)
|
* Sofus Mortensen (Digital Asset Holdings)
|
||||||
* stevenroose
|
* stevenroose
|
||||||
|
* Stanly Johnson (Servntire Global)
|
||||||
* Szymon Sztuka (R3)
|
* Szymon Sztuka (R3)
|
||||||
* tb-pq
|
* tb-pq
|
||||||
* Thiago Rafael Ferreira (Scorpius IT Solutions)
|
* Thiago Rafael Ferreira (Scorpius IT Solutions)
|
||||||
@ -175,7 +176,7 @@ see changes to this list.
|
|||||||
* tomconte
|
* tomconte
|
||||||
* Tommy Lillehagen (R3)
|
* Tommy Lillehagen (R3)
|
||||||
* tomtau
|
* tomtau
|
||||||
* Tudor Malene (R3)
|
* Tudor Malene (R3)
|
||||||
* Tushar Singh Bora
|
* Tushar Singh Bora
|
||||||
* varunkm
|
* varunkm
|
||||||
* verymahler
|
* verymahler
|
||||||
|
@ -37,6 +37,10 @@ import java.time.Instant
|
|||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
import kotlin.streams.toList
|
import kotlin.streams.toList
|
||||||
|
import kotlin.collections.HashSet
|
||||||
|
import kotlin.collections.component1
|
||||||
|
import kotlin.collections.component2
|
||||||
|
import kotlin.collections.set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to bootstrap a local network of Corda nodes on the same filesystem.
|
* Class to bootstrap a local network of Corda nodes on the same filesystem.
|
||||||
@ -74,6 +78,8 @@ class NetworkBootstrapper {
|
|||||||
try {
|
try {
|
||||||
println("Waiting for all nodes to generate their node-info files...")
|
println("Waiting for all nodes to generate their node-info files...")
|
||||||
val nodeInfoFiles = gatherNodeInfoFiles(processes, nodeDirs)
|
val nodeInfoFiles = gatherNodeInfoFiles(processes, nodeDirs)
|
||||||
|
println("Checking for duplicate nodes")
|
||||||
|
checkForDuplicateLegalNames(nodeInfoFiles)
|
||||||
println("Distributing all node-info files to all nodes")
|
println("Distributing all node-info files to all nodes")
|
||||||
distributeNodeInfos(nodeDirs, nodeInfoFiles)
|
distributeNodeInfos(nodeDirs, nodeInfoFiles)
|
||||||
print("Loading existing network parameters... ")
|
print("Loading existing network parameters... ")
|
||||||
@ -160,6 +166,22 @@ class NetworkBootstrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*the function checks for duplicate myLegalName in the all the *_node.conf files
|
||||||
|
All the myLegalName values are added to a HashSet - this helps detect duplicate values.
|
||||||
|
If a duplicate name is found the process is aborted with an error message
|
||||||
|
*/
|
||||||
|
private fun checkForDuplicateLegalNames(nodeInfoFiles: List<Path>) {
|
||||||
|
val legalNames = HashSet<String>()
|
||||||
|
for (nodeInfoFile in nodeInfoFiles) {
|
||||||
|
val nodeConfig = ConfigFactory.parseFile((nodeInfoFile.parent / "node.conf").toFile())
|
||||||
|
val legalName = nodeConfig.getString("myLegalName")
|
||||||
|
if(!legalNames.add(legalName)){
|
||||||
|
println("Duplicate Node Found - ensure every node has a unique legal name");
|
||||||
|
throw IllegalArgumentException("Duplicate Node Found - $legalName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun gatherNotaryInfos(nodeInfoFiles: List<Path>): List<NotaryInfo> {
|
private fun gatherNotaryInfos(nodeInfoFiles: List<Path>): List<NotaryInfo> {
|
||||||
return nodeInfoFiles.mapNotNull { nodeInfoFile ->
|
return nodeInfoFiles.mapNotNull { nodeInfoFile ->
|
||||||
// The config contains the notary type
|
// The config contains the notary type
|
||||||
|
Reference in New Issue
Block a user