Merging forward updates from release/os/4.10 to release/os/4.11 - 2024-10-23

This commit is contained in:
r3-build 2024-10-23 07:59:33 +00:00
commit 3fb3917695
2 changed files with 29 additions and 16 deletions

View File

@ -310,12 +310,14 @@ abstract class FlowLogic<out T> {
@Suspendable
@JvmOverloads
open fun receiveAllMap(sessions: Map<FlowSession, Class<out Any>>, maySkipCheckpoint: Boolean = false): Map<FlowSession, UntrustworthyData<Any>> {
enforceNoPrimitiveInReceive(sessions.values)
val replies = stateMachine.suspend(
ioRequest = FlowIORequest.Receive(sessions.keys.toNonEmptySet()),
maySkipCheckpoint = maySkipCheckpoint
)
return replies.mapValues { (session, payload) -> payload.checkPayloadIs(sessions[session]!!) }
serviceHub.telemetryServiceInternal.span("${this::class.java.name}#receiveAllMap") {
enforceNoPrimitiveInReceive(sessions.values)
val replies = stateMachine.suspend(
ioRequest = FlowIORequest.Receive(sessions.keys.toNonEmptySet()),
maySkipCheckpoint = maySkipCheckpoint
)
return replies.mapValues { (session, payload) -> payload.checkPayloadIs(sessions[session]!!) }
}
}
/**
@ -332,9 +334,11 @@ abstract class FlowLogic<out T> {
@Suspendable
@JvmOverloads
open fun <R : Any> receiveAll(receiveType: Class<R>, sessions: List<FlowSession>, maySkipCheckpoint: Boolean = false): List<UntrustworthyData<R>> {
enforceNoPrimitiveInReceive(listOf(receiveType))
enforceNoDuplicates(sessions)
return castMapValuesToKnownType(receiveAllMap(associateSessionsToReceiveType(receiveType, sessions)))
serviceHub.telemetryServiceInternal.span("${this::class.java.name}#receiveAll") {
enforceNoPrimitiveInReceive(listOf(receiveType))
enforceNoDuplicates(sessions)
return castMapValuesToKnownType(receiveAllMap(associateSessionsToReceiveType(receiveType, sessions)))
}
}
/**
@ -351,8 +355,10 @@ abstract class FlowLogic<out T> {
@Suspendable
@JvmOverloads
fun sendAll(payload: Any, sessions: Set<FlowSession>, maySkipCheckpoint: Boolean = false) {
val sessionToPayload = sessions.map { it to payload }.toMap()
return sendAllMap(sessionToPayload, maySkipCheckpoint)
serviceHub.telemetryServiceInternal.span("${this::class.java.name}#sendAll") {
val sessionToPayload = sessions.map { it to payload }.toMap()
return sendAllMap(sessionToPayload, maySkipCheckpoint)
}
}
/**
@ -368,10 +374,12 @@ abstract class FlowLogic<out T> {
@Suspendable
@JvmOverloads
fun sendAllMap(payloadsPerSession: Map<FlowSession, Any>, maySkipCheckpoint: Boolean = false) {
val request = FlowIORequest.Send(
sessionToMessage = stateMachine.serialize(payloadsPerSession)
)
stateMachine.suspend(request, maySkipCheckpoint)
serviceHub.telemetryServiceInternal.span("${this::class.java.name}#sendAllMap") {
val request = FlowIORequest.Send(
sessionToMessage = stateMachine.serialize(payloadsPerSession)
)
stateMachine.suspend(request, maySkipCheckpoint)
}
}
/**

View File

@ -1,6 +1,7 @@
package net.corda.core.internal.telemetry
import net.corda.core.CordaInternal
import net.corda.core.DeleteForDJVM
import net.corda.core.flows.FlowLogic
import net.corda.core.internal.uncheckedCast
import net.corda.core.node.ServiceHub
@ -34,6 +35,7 @@ enum class TelemetryStatusCode {
ERROR
}
@DeleteForDJVM
@CordaSerializable
data class TelemetryId(private val telemetryService: TelemetryServiceImpl) {
val id: UUID = UUID.randomUUID()
@ -57,12 +59,14 @@ data class ComponentTelemetryIds(val componentTelemetryIds: Map<String, UUID>)
interface TelemetryEvent
@DeleteForDJVM
class StartSpanForFlowEvent(val name: String,
val attributes: Map<String, String>,
val telemetryId: UUID, val flowLogic: FlowLogic<*>?,
val telemetryDataItem: TelemetryDataItem?): TelemetryEvent
@DeleteForDJVM
class EndSpanForFlowEvent(val telemetryId: UUID): TelemetryEvent
@DeleteForDJVM
class StartSpanEvent(val name: String, val attributes: Map<String, String>, val telemetryId: UUID, val flowLogic: FlowLogic<*>?): TelemetryEvent
class EndSpanEvent(val telemetryId: UUID): TelemetryEvent
class SetStatusEvent(val telemetryId: UUID, val telemetryStatusCode: TelemetryStatusCode, val message: String): TelemetryEvent
@ -88,6 +92,7 @@ interface TelemetryComponentId {
}
@Suppress("TooManyFunctions")
@DeleteForDJVM
class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService {
companion object {