mirror of
https://github.com/corda/corda.git
synced 2025-02-27 19:46:38 +00:00
ENT-1831 Delete notaryhealthcheck which is now in CC (#791)
This commit is contained in:
parent
647b821c1c
commit
2a37ce438a
@ -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")
|
||||
|
@ -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'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -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<String>) = 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
|
||||
)
|
||||
}
|
||||
}
|
@ -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<String>) {
|
||||
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.")
|
||||
}
|
@ -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<Unit>() {
|
||||
class DoNothingContract : Contract {
|
||||
override fun verify(tx: LedgerTransaction) {}
|
||||
}
|
||||
|
||||
data class DummyCommand(val dummy: Int = 0) : CommandData
|
||||
data class State(override val participants: List<AbstractParty>) : 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))
|
||||
}
|
||||
}
|
@ -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<TransactionSignature> {
|
||||
progressTracker.currentStep = REQUESTING
|
||||
val notaryParty = checkTransaction()
|
||||
|
||||
val parties = if (checkEntireCluster) {
|
||||
serviceHub.networkMapCache.notaryIdentities.filter { it.owningKey == notaryParty.owningKey }
|
||||
} else {
|
||||
listOf(notaryParty)
|
||||
}
|
||||
var signatures: List<TransactionSignature> = 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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user