From 2a37ce438a6978feeaae3c2d8692771d2dd0bae7 Mon Sep 17 00:00:00 2001 From: Andrzej Cichocki Date: Mon, 30 Apr 2018 17:23:59 +0100 Subject: [PATCH] ENT-1831 Delete notaryhealthcheck which is now in CC (#791) --- settings.gradle | 1 - tools/notaryhealthcheck/build.gradle | 72 ----------------- .../notaryhealthcheck/HealthCheckCordform.kt | 80 ------------------- .../net/corda/notaryhealthcheck/Main.kt | 38 --------- .../flows/HealthCheckFlow.kt | 42 ---------- .../flows/HealthCheckNotaryClientFlow.kt | 54 ------------- 6 files changed, 287 deletions(-) delete mode 100644 tools/notaryhealthcheck/build.gradle delete mode 100644 tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/HealthCheckCordform.kt delete mode 100644 tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/Main.kt delete mode 100644 tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckFlow.kt delete mode 100644 tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckNotaryClientFlow.kt diff --git a/settings.gradle b/settings.gradle index 93c5f6b9ca..e584008cef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,7 +57,6 @@ include 'tools:loadtest' include 'tools:graphs' include 'tools:bootstrapper' include 'tools:dbmigration' -include 'tools:notaryhealthcheck' include 'tools:shell' include 'example-code' project(':example-code').projectDir = file("$settingsDir/docs/source/example-code") diff --git a/tools/notaryhealthcheck/build.gradle b/tools/notaryhealthcheck/build.gradle deleted file mode 100644 index a26d20da7b..0000000000 --- a/tools/notaryhealthcheck/build.gradle +++ /dev/null @@ -1,72 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -import net.corda.plugins.Cordform - -apply plugin: 'java' -apply plugin: 'kotlin' -apply plugin: 'idea' -apply plugin: 'net.corda.plugins.quasar-utils' -apply plugin: 'net.corda.plugins.publish-utils' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'maven-publish' - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "junit:junit:$junit_version" - - // Corda integration dependencies - cordaCompile project(path: ":node:capsule", configuration: 'runtimeArtifacts') - cordaCompile project(':core') - cordaCompile project(':client:jfx') - cordaCompile project(':client:rpc') - cordaCompile project(':node-driver') - compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6' - compile "io.dropwizard.metrics:metrics-graphite:$metrics_version" - -} - -idea { - module { - downloadJavadoc = true // defaults to false - downloadSources = true - } -} - -publishing { - publications { - jarAndSources(MavenPublication) { - from components.java - artifactId 'notaryhealthcheck' - - artifact sourceJar - artifact javadocJar - } - } -} - -task runTest(type: JavaExec) { - classpath = sourceSets.main.runtimeClasspath - main = 'net.corda.notaryhealthcheck.MainKt' -} - -task deployNodes(type: Cordform, dependsOn: 'jar') { - definitionClass = 'net.corda.notaryhealthcheck.HealthCheckCordform' -} - -jar { - manifest { - attributes( - 'Automatic-Module-Name': 'net.corda.notaryhealthcheck' - ) - } -} - diff --git a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/HealthCheckCordform.kt b/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/HealthCheckCordform.kt deleted file mode 100644 index 7ee43f749e..0000000000 --- a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/HealthCheckCordform.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -package net.corda.notaryhealthcheck - -import net.corda.cordform.CordformContext -import net.corda.cordform.CordformDefinition -import net.corda.cordform.CordformNode -import net.corda.core.identity.CordaX500Name -import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.services.Permissions.Companion.all -import net.corda.node.services.config.NotaryConfig -import net.corda.node.services.config.RaftConfig -import net.corda.nodeapi.internal.DevIdentityGenerator -import net.corda.testing.node.User -import net.corda.testing.node.internal.demorun.* -import java.nio.file.Paths - -fun main(args: Array) = HealthCheckCordform().nodeRunner().deployAndRunNodes() - -class HealthCheckCordform : CordformDefinition() { - private fun createNotaryNames(clusterSize: Int) = (0 until clusterSize).map { CordaX500Name("Notary Service $it", "Zurich", "CH") } - private val notaryDemoUser = User("demou", "demop", setOf(all())) - private val notaryNames = createNotaryNames(3) - private val clusterName = CordaX500Name("Raft", "Zurich", "CH") - - init { - nodesDirectory = Paths.get("build", "nodes") - fun notaryNode(index: Int, nodePort: Int, clusterPort: Int? = null, configure: CordformNode.() -> Unit) = node { - name(notaryNames[index]) - val clusterAddresses = if (clusterPort != null) listOf(NetworkHostAndPort("localhost", clusterPort)) else emptyList() - notary(NotaryConfig(validating = true, raft = RaftConfig(NetworkHostAndPort("localhost", nodePort), clusterAddresses))) - configure() - } - notaryNode(0, 10008) { - p2pPort(10009) - rpcSettings { - port(10010) - adminPort(10110) - } - } - notaryNode(1, 10012, 10008) { - p2pPort(10013) - rpcSettings { - port(10014) - adminPort(10114) - } - } - notaryNode(2, 10016, 10008) { - p2pPort(10017) - rpcSettings { - port(10018) - adminPort(10118) - } - } - node { - name(CordaX500Name("R3 Notary Health Check", "London", "GB")) - p2pPort(10002) - rpcSettings { - port(10003) - adminPort(10103) - } - rpcUsers(notaryDemoUser) - } - } - - override fun setup(context: CordformContext) { - DevIdentityGenerator.generateDistributedNotarySingularIdentity( - notaryNames.map { context.baseDirectory(it.toString()) }, - clusterName - ) - } -} \ No newline at end of file diff --git a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/Main.kt b/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/Main.kt deleted file mode 100644 index fcd23a64c9..0000000000 --- a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/Main.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -package net.corda.notaryhealthcheck - -import net.corda.client.rpc.CordaRPCClient -import net.corda.core.messaging.CordaRPCOps -import net.corda.core.messaging.startFlow -import net.corda.core.utilities.NetworkHostAndPort -import net.corda.nodeapi.internal.config.User -import net.corda.node.services.Permissions -import net.corda.notaryhealthcheck.flows.HealthCheckFlow -import java.util.concurrent.TimeUnit - -fun main(args: Array) { - val addresses = listOf(NetworkHostAndPort("localhost", 10003)) - val notaryDemoUser = User("demou", "demop", setOf(Permissions.all())) - - addresses.parallelStream().forEach { - val c = CordaRPCClient(it).start(notaryDemoUser.username, notaryDemoUser.password) - healthCheck(c.proxy) - } - println("Health check complete.") -} - -fun healthCheck(rpc: CordaRPCOps) { - val notary = rpc.notaryIdentities().first() - print("Running health check for notary cluster ${notary.name}... ") - rpc.startFlow(::HealthCheckFlow, notary, true).returnValue.get(30, TimeUnit.SECONDS) - println("Done.") -} diff --git a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckFlow.kt b/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckFlow.kt deleted file mode 100644 index f10e340f11..0000000000 --- a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckFlow.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -package net.corda.notaryhealthcheck.flows - -import co.paralleluniverse.fibers.Suspendable -import net.corda.core.contracts.CommandData -import net.corda.core.contracts.Contract -import net.corda.core.contracts.ContractState -import net.corda.core.flows.FlowLogic -import net.corda.core.flows.StartableByRPC -import net.corda.core.identity.AbstractParty -import net.corda.core.identity.Party -import net.corda.core.transactions.LedgerTransaction -import net.corda.core.transactions.TransactionBuilder - -@StartableByRPC -open class HealthCheckFlow(val notaryParty: Party, val checkEntireCluster: Boolean = false) : FlowLogic() { - class DoNothingContract : Contract { - override fun verify(tx: LedgerTransaction) {} - } - - data class DummyCommand(val dummy: Int = 0) : CommandData - data class State(override val participants: List) : ContractState - - @Suspendable - override fun call() { - val state = State(listOf(ourIdentity)) - val stx = serviceHub.signInitialTransaction(TransactionBuilder(notaryParty).apply { - addOutputState(state, "net.corda.notaryhealthcheck.flows.HealthCheckFlow\$DoNothingContract") - addCommand(DummyCommand(), listOf(ourIdentity.owningKey)) - }) - subFlow(HealthCheckNotaryClientFlow(stx, checkEntireCluster = checkEntireCluster)) - } -} \ No newline at end of file diff --git a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckNotaryClientFlow.kt b/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckNotaryClientFlow.kt deleted file mode 100644 index 6c193ae5d3..0000000000 --- a/tools/notaryhealthcheck/src/main/kotlin/net/corda/notaryhealthcheck/flows/HealthCheckNotaryClientFlow.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * R3 Proprietary and Confidential - * - * Copyright (c) 2018 R3 Limited. All rights reserved. - * - * The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. - * - * Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. - */ - -package net.corda.notaryhealthcheck.flows - -import co.paralleluniverse.fibers.Suspendable -import net.corda.core.crypto.TransactionSignature -import net.corda.core.flows.NotarisationRequest -import net.corda.core.flows.NotaryError -import net.corda.core.flows.NotaryException -import net.corda.core.flows.NotaryFlow -import net.corda.core.internal.generateSignature -import net.corda.core.transactions.SignedTransaction - -/** - * Notarises the provided transaction. If [checkEntireCluster] is set to *true*, will repeat the notarisation request - * to each member of the notary cluster. - */ -class HealthCheckNotaryClientFlow( - stx: SignedTransaction, - /** - * If set to *true*, will issue a notarisation request to each replica in the notary cluster, - * rather than sending the request to one replica only. - */ - private val checkEntireCluster: Boolean = false -) : NotaryFlow.Client(stx) { - @Suspendable - @Throws(NotaryException::class) - override fun call(): List { - progressTracker.currentStep = REQUESTING - val notaryParty = checkTransaction() - - val parties = if (checkEntireCluster) { - serviceHub.networkMapCache.notaryIdentities.filter { it.owningKey == notaryParty.owningKey } - } else { - listOf(notaryParty) - } - var signatures: List = emptyList() - parties.forEach { nodeLegalIdentity -> - logger.info("Sending notarisation request to: $nodeLegalIdentity") - val response = notarise(nodeLegalIdentity) - signatures = validateResponse(response, notaryParty) - logger.info("Received a valid signature from $nodeLegalIdentity, signed by $notaryParty") - } - return signatures - } -} \ No newline at end of file