mirror of
https://github.com/corda/corda.git
synced 2025-06-06 01:11:45 +00:00
ENT-2553 Serialisation warnings in notary healthcheck (#1497)
* Visibility settings and annotations to stop warnings when running notary healthcheck. * Add progress trackers so the warnings about unstarted progress trackers disappear.
This commit is contained in:
parent
c2ff705861
commit
d6c76c69aa
@ -3,6 +3,7 @@ package net.corda.notaryhealthcheck.cordapp
|
|||||||
import net.corda.core.contracts.*
|
import net.corda.core.contracts.*
|
||||||
import net.corda.core.flows.FlowLogicRefFactory
|
import net.corda.core.flows.FlowLogicRefFactory
|
||||||
import net.corda.core.identity.AbstractParty
|
import net.corda.core.identity.AbstractParty
|
||||||
|
import net.corda.notaryhealthcheck.contract.SchedulingContract
|
||||||
import net.corda.notaryhealthcheck.utils.Monitorable
|
import net.corda.notaryhealthcheck.utils.Monitorable
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import kotlin.reflect.jvm.jvmName
|
import kotlin.reflect.jvm.jvmName
|
||||||
@ -20,15 +21,16 @@ import kotlin.reflect.jvm.jvmName
|
|||||||
* @param waitTimeSeconds How long to wait for the next check (i.e. time to add to the current time for the next states startTime)
|
* @param waitTimeSeconds How long to wait for the next check (i.e. time to add to the current time for the next states startTime)
|
||||||
* @param waitForOutstandingFlowsSeconds How long to wait before running another notary check if the previous one is still outstanding.
|
* @param waitForOutstandingFlowsSeconds How long to wait before running another notary check if the previous one is still outstanding.
|
||||||
*/
|
*/
|
||||||
|
@BelongsToContract(SchedulingContract::class)
|
||||||
class ScheduledCheckState(
|
class ScheduledCheckState(
|
||||||
override val participants: List<AbstractParty>,
|
override val participants: List<AbstractParty>,
|
||||||
override val linearId: UniqueIdentifier,
|
override val linearId: UniqueIdentifier,
|
||||||
val statesToCheck: List<UniqueIdentifier>,
|
val statesToCheck: List<UniqueIdentifier>,
|
||||||
val target: Monitorable,
|
val target: Monitorable,
|
||||||
private val startTime: Instant,
|
val startTime: Instant,
|
||||||
val lastSuccessTime: Instant,
|
val lastSuccessTime: Instant,
|
||||||
private val waitTimeSeconds: Int,
|
val waitTimeSeconds: Int,
|
||||||
private val waitForOutstandingFlowsSeconds: Int) : SchedulableState, LinearState {
|
val waitForOutstandingFlowsSeconds: Int) : SchedulableState, LinearState {
|
||||||
override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
|
override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
|
||||||
val logicRef = flowLogicRefFactory.create(ScheduledCheckFlow::class.jvmName, thisStateRef, waitTimeSeconds, waitForOutstandingFlowsSeconds)
|
val logicRef = flowLogicRefFactory.create(ScheduledCheckFlow::class.jvmName, thisStateRef, waitTimeSeconds, waitForOutstandingFlowsSeconds)
|
||||||
return ScheduledActivity(logicRef, startTime)
|
return ScheduledActivity(logicRef, startTime)
|
||||||
@ -39,18 +41,21 @@ class ScheduledCheckState(
|
|||||||
* State to mark a running notary health check. The ScheduleCheckFlow evolves a ScheduleCheckState into this when it
|
* State to mark a running notary health check. The ScheduleCheckFlow evolves a ScheduleCheckState into this when it
|
||||||
* runs the healthcheck flow for its target.
|
* runs the healthcheck flow for its target.
|
||||||
*/
|
*/
|
||||||
|
@BelongsToContract(SchedulingContract::class)
|
||||||
class RunningCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>, val startTime: Instant) : LinearState
|
class RunningCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>, val startTime: Instant) : LinearState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State to mark a successful health check. The ScheduleCheckFlow evolves a RunningCheckState into this if the healthcheck
|
* State to mark a successful health check. The ScheduleCheckFlow evolves a RunningCheckState into this if the healthcheck
|
||||||
* flow returns successfully.
|
* flow returns successfully.
|
||||||
*/
|
*/
|
||||||
|
@BelongsToContract(SchedulingContract::class)
|
||||||
class SuccessfulCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>, val finishTime: Instant) : LinearState
|
class SuccessfulCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>, val finishTime: Instant) : LinearState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State to mark a failed health check. The ScheduleCheckFlow evolves a RunningCheckState into this if the healthcheck
|
* State to mark a failed health check. The ScheduleCheckFlow evolves a RunningCheckState into this if the healthcheck
|
||||||
* flow fails
|
* flow fails
|
||||||
*/
|
*/
|
||||||
|
@BelongsToContract(SchedulingContract::class)
|
||||||
class FailedCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>) : LinearState
|
class FailedCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>) : LinearState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,5 +63,6 @@ class FailedCheckState(override val linearId: UniqueIdentifier, override val par
|
|||||||
* if there was still one or more healthcheck flows outstanding and the last one had been started less than waitForOutstandingFlowsSeconds
|
* if there was still one or more healthcheck flows outstanding and the last one had been started less than waitForOutstandingFlowsSeconds
|
||||||
* ago.
|
* ago.
|
||||||
*/
|
*/
|
||||||
|
@BelongsToContract(SchedulingContract::class)
|
||||||
class AbandonnedCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>) : LinearState
|
class AbandonnedCheckState(override val linearId: UniqueIdentifier, override val participants: List<AbstractParty>) : LinearState
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import net.corda.core.transactions.ContractUpgradeWireTransaction
|
|||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.transactions.WireTransaction
|
import net.corda.core.transactions.WireTransaction
|
||||||
|
import net.corda.core.utilities.ProgressTracker
|
||||||
import net.corda.core.utilities.UntrustworthyData
|
import net.corda.core.utilities.UntrustworthyData
|
||||||
import net.corda.notaryhealthcheck.contract.NullContract
|
import net.corda.notaryhealthcheck.contract.NullContract
|
||||||
import net.corda.notaryhealthcheck.utils.Monitorable
|
import net.corda.notaryhealthcheck.utils.Monitorable
|
||||||
@ -23,14 +24,25 @@ class HealthCheckFlow(monitorable: Monitorable) : FlowLogic<List<TransactionSign
|
|||||||
private val party = monitorable.party
|
private val party = monitorable.party
|
||||||
|
|
||||||
data class NullCommand(val data: Byte = 0) : CommandData // Param must be public for AMQP serialization.
|
data class NullCommand(val data: Byte = 0) : CommandData // Param must be public for AMQP serialization.
|
||||||
|
|
||||||
|
@BelongsToContract(NullContract::class)
|
||||||
data class State(override val participants: List<AbstractParty>) : ContractState
|
data class State(override val participants: List<AbstractParty>) : ContractState
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
object PREPARING : ProgressTracker.Step("Preparing")
|
||||||
|
object CHECKING : ProgressTracker.Step("Checking")
|
||||||
|
}
|
||||||
|
|
||||||
|
override val progressTracker = ProgressTracker(PREPARING, CHECKING)
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): List<TransactionSignature> {
|
override fun call(): List<TransactionSignature> {
|
||||||
|
progressTracker.currentStep = PREPARING
|
||||||
val stx = serviceHub.signInitialTransaction(TransactionBuilder(notary).apply {
|
val stx = serviceHub.signInitialTransaction(TransactionBuilder(notary).apply {
|
||||||
addOutputState(State(listOf(ourIdentity)), NullContract::class.java.name, AlwaysAcceptAttachmentConstraint)
|
addOutputState(State(listOf(ourIdentity)), NullContract::class.java.name, AlwaysAcceptAttachmentConstraint)
|
||||||
addCommand(NullCommand(), listOf(ourIdentity.owningKey))
|
addCommand(NullCommand(), listOf(ourIdentity.owningKey))
|
||||||
})
|
})
|
||||||
|
progressTracker.currentStep = CHECKING
|
||||||
return subFlow(NotaryClientFlow(stx, party, notary))
|
return subFlow(NotaryClientFlow(stx, party, notary))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,11 +65,14 @@ class HealthCheckFlow(monitorable: Monitorable) : FlowLogic<List<TransactionSign
|
|||||||
override fun call(): List<TransactionSignature> {
|
override fun call(): List<TransactionSignature> {
|
||||||
val session = initiateFlow(party)
|
val session = initiateFlow(party)
|
||||||
val requestSignature = NotarisationRequest(stx.inputs, stx.id).generateSignature(serviceHub)
|
val requestSignature = NotarisationRequest(stx.inputs, stx.id).generateSignature(serviceHub)
|
||||||
return validateResponse(if (serviceHub.networkMapCache.isValidatingNotary(notaryParty)) {
|
progressTracker.currentStep = REQUESTING
|
||||||
|
val result = if (serviceHub.networkMapCache.isValidatingNotary(notaryParty)) {
|
||||||
sendAndReceiveValidating(session, requestSignature)
|
sendAndReceiveValidating(session, requestSignature)
|
||||||
} else {
|
} else {
|
||||||
sendAndReceiveNonValidating(notaryParty, session, requestSignature)
|
sendAndReceiveNonValidating(notaryParty, session, requestSignature)
|
||||||
}, notaryParty)
|
}
|
||||||
|
progressTracker.currentStep = VALIDATING
|
||||||
|
return validateResponse(result, notaryParty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user