Distributed notary setup fixes (#606)

* MySQL notary is clustered notary

* Fix registration tool app class

* Allow config file without parent

* Fix `MySQLNotaryServiceTest`
This commit is contained in:
Thomas Schroeter 2018-03-27 13:03:46 +01:00 committed by GitHub
parent 47e2f5e8c9
commit f6e14b8d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

View File

@ -39,7 +39,7 @@ configurations {
task buildRegistrationTool(type: FatCapsule, dependsOn: 'jar') { task buildRegistrationTool(type: FatCapsule, dependsOn: 'jar') {
group = "build" group = "build"
applicationClass 'com.r3.corda.networkmanage.registration.RegistrationToolKt' applicationClass 'com.r3.corda.networkmanage.registration.MainKt'
archiveName "registration-tool-${version}.jar" archiveName "registration-tool-${version}.jar"
capsuleManifest { capsuleManifest {
applicationVersion = corda_release_version applicationVersion = corda_release_version

View File

@ -22,6 +22,7 @@ import net.corda.nodeapi.internal.config.SSLConfiguration
import net.corda.nodeapi.internal.config.parseAs import net.corda.nodeapi.internal.config.parseAs
import java.net.URL import java.net.URL
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.Paths
fun RegistrationOption.runRegistration() { fun RegistrationOption.runRegistration() {
val config = ConfigFactory.parseFile(configFile.toFile(), ConfigParseOptions.defaults().setAllowMissing(false)) val config = ConfigFactory.parseFile(configFile.toFile(), ConfigParseOptions.defaults().setAllowMissing(false))
@ -31,7 +32,9 @@ fun RegistrationOption.runRegistration() {
val sslConfig = object : SSLConfiguration { val sslConfig = object : SSLConfiguration {
override val keyStorePassword: String by lazy { config.keyStorePassword ?: readPassword("Node Keystore password:") } override val keyStorePassword: String by lazy { config.keyStorePassword ?: readPassword("Node Keystore password:") }
override val trustStorePassword: String by lazy { config.trustStorePassword ?: readPassword("Node TrustStore password:") } override val trustStorePassword: String by lazy { config.trustStorePassword ?: readPassword("Node TrustStore password:") }
override val certificatesDirectory: Path = configFile.parent / "certificates" val parent = configFile.parent
override val certificatesDirectory: Path = if (parent != null) parent / "certificates"
else Paths.get("certificates")
} }
NetworkRegistrationHelper(sslConfig, NetworkRegistrationHelper(sslConfig,

View File

@ -51,6 +51,7 @@ import kotlin.test.assertFailsWith
class MySQLNotaryServiceTests : IntegrationTest() { class MySQLNotaryServiceTests : IntegrationTest() {
companion object { companion object {
val notaryName = CordaX500Name("MySQL Notary Service", "Zurich", "CH") val notaryName = CordaX500Name("MySQL Notary Service", "Zurich", "CH")
val notaryNodeName = CordaX500Name("Notary Replica 1", "Zurich", "CH")
@ClassRule @ClassRule
@JvmField @JvmField
val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2") val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2")
@ -64,11 +65,10 @@ class MySQLNotaryServiceTests : IntegrationTest() {
@Before @Before
fun before() { fun before() {
mockNet = InternalMockNetwork(cordappPackages = listOf("net.corda.testing.contracts")) mockNet = InternalMockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
notaryParty = DevIdentityGenerator.installKeyStoreWithNodeIdentity(mockNet.baseDirectory(mockNet.nextNodeId), notaryName) notaryParty = DevIdentityGenerator.generateDistributedNotarySingularIdentity(listOf(mockNet.baseDirectory(mockNet.nextNodeId)), notaryName)
val networkParameters = NetworkParametersCopier(testNetworkParameters(listOf(NotaryInfo(notaryParty, false)))) val networkParameters = NetworkParametersCopier(testNetworkParameters(listOf(NotaryInfo(notaryParty, false))))
val notaryNodeUnstarted = createNotaryNode() val notaryNodeUnstarted = createNotaryNode()
val nodeUnstarted = mockNet.createUnstartedNode() val nodeUnstarted = mockNet.createUnstartedNode()
val startedNodes = listOf(notaryNodeUnstarted, nodeUnstarted).map { n -> val startedNodes = listOf(notaryNodeUnstarted, nodeUnstarted).map { n ->
networkParameters.install(mockNet.baseDirectory(n.id)) networkParameters.install(mockNet.baseDirectory(n.id))
n.start() n.start()
@ -144,7 +144,7 @@ class MySQLNotaryServiceTests : IntegrationTest() {
} }
return mockNet.createUnstartedNode( return mockNet.createUnstartedNode(
InternalMockNodeParameters( InternalMockNodeParameters(
legalName = notaryName, legalName = notaryNodeName,
entropyRoot = BigInteger.valueOf(60L), entropyRoot = BigInteger.valueOf(60L),
configOverrides = { configOverrides = {
val notaryConfig = NotaryConfig(validating = false, mysql = MySQLConfiguration(dataStoreProperties)) val notaryConfig = NotaryConfig(validating = false, mysql = MySQLConfiguration(dataStoreProperties))

View File

@ -112,7 +112,7 @@ data class NotaryConfig(val validating: Boolean,
"raft, bftSMaRt, custom, and mysql configs cannot be specified together" "raft, bftSMaRt, custom, and mysql configs cannot be specified together"
} }
} }
val isClusterConfig: Boolean get() = raft != null || bftSMaRt != null val isClusterConfig: Boolean get() = raft != null || bftSMaRt != null || mysql != null
} }
data class MySQLConfiguration( data class MySQLConfiguration(
@ -399,4 +399,4 @@ data class RelayConfiguration(val relayHost: String,
val username: String, val username: String,
val privateKeyFile: Path, val privateKeyFile: Path,
val publicKeyFile: Path, val publicKeyFile: Path,
val sshPort: Int = 22) val sshPort: Int = 22)