diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt index 34b7f4e6de..18483c2d02 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/InterestRateSwapAPI.kt @@ -8,7 +8,6 @@ import net.corda.core.messaging.startFlow import net.corda.core.utilities.loggerFor import net.corda.irs.contract.InterestRateSwap import net.corda.irs.flows.AutoOfferFlow -import net.corda.irs.flows.ExitServerFlow import net.corda.irs.flows.UpdateBusinessDayFlow import java.net.URI import java.time.LocalDate @@ -34,9 +33,6 @@ import javax.ws.rs.core.Response * simulate any associated business processing (currently fixing). * * TODO: replace simulated date advancement with business event based implementation - * - * PUT /api/irs/restart - (empty payload) cause the node to restart for API user emergency use in case any servers become unresponsive, - * or if the demodate or population of deals should be reset (will only work while persistence is disabled). */ @Path("irs") class InterestRateSwapAPI(val rpc: CordaRPCOps) { @@ -112,12 +108,4 @@ class InterestRateSwapAPI(val rpc: CordaRPCOps) { fun fetchDemoDate(): LocalDate { return LocalDateTime.ofInstant(rpc.currentNodeTime(), ZoneId.systemDefault()).toLocalDate() } - - @PUT - @Path("restart") - @Consumes(MediaType.APPLICATION_JSON) - fun exitServer(): Response { - rpc.startFlow(ExitServerFlow::Broadcast, 83).returnValue.getOrThrow() - return Response.ok().build() - } } diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt deleted file mode 100644 index a56e262bdd..0000000000 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt +++ /dev/null @@ -1,76 +0,0 @@ -package net.corda.irs.flows - -import co.paralleluniverse.fibers.Suspendable -import co.paralleluniverse.strands.Strand -import net.corda.core.crypto.Party -import net.corda.core.flows.FlowLogic -import net.corda.core.node.CordaPluginRegistry -import net.corda.core.node.NodeInfo -import net.corda.core.node.PluginServiceHub -import net.corda.core.utilities.unwrap -import net.corda.testing.node.MockNetworkMapCache -import java.util.concurrent.TimeUnit -import java.util.function.Function - -object ExitServerFlow { - - // Will only be enabled if you install the Handler - @Volatile private var enabled = false - - // This is not really a HandshakeMessage but needs to be so that the send uses the default session ID. This will - // resolve itself when the flow session stuff is done. - data class ExitMessage(val exitCode: Int) - - class Plugin : CordaPluginRegistry() { - override val servicePlugins = listOf(Function(::Service)) - } - - class Service(services: PluginServiceHub) { - init { - services.registerFlowInitiator(Broadcast::class.java, ::ExitServerHandler) - enabled = true - } - } - - - private class ExitServerHandler(val otherParty: Party) : FlowLogic() { - override fun call() { - // Just to validate we got the message - if (enabled) { - val message = receive(otherParty).unwrap { it } - System.exit(message.exitCode) - } - } - } - - - /** - * This takes a Java Integer rather than Kotlin Int as that is what we end up with in the calling map and currently - * we do not support coercing numeric types in the reflective search for matching constructors. - */ - class Broadcast(val exitCode: Int) : FlowLogic() { - - @Suspendable - override fun call(): Boolean { - if (enabled) { - for (recipient in serviceHub.networkMapCache.partyNodes) { - doNextRecipient(recipient) - } - // Sleep a little in case any async message delivery to other nodes needs to happen - Strand.sleep(1, TimeUnit.SECONDS) - System.exit(exitCode) - } - return enabled - } - - @Suspendable - private fun doNextRecipient(recipient: NodeInfo) { - if (recipient.address is MockNetworkMapCache.MockAddress) { - // Ignore - } else { - send(recipient.legalIdentity, ExitMessage(exitCode)) - } - } - } - -} diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt index 3b7a710076..d87bbcd93c 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt @@ -6,7 +6,6 @@ import net.corda.core.node.CordaPluginRegistry import net.corda.irs.api.InterestRateSwapAPI import net.corda.irs.contract.InterestRateSwap import net.corda.irs.flows.AutoOfferFlow -import net.corda.irs.flows.ExitServerFlow import net.corda.irs.flows.FixingFlow import net.corda.irs.flows.UpdateBusinessDayFlow import java.time.Duration @@ -22,7 +21,6 @@ class IRSPlugin : CordaPluginRegistry() { override val requiredFlows: Map> = mapOf( AutoOfferFlow.Requester::class.java.name to setOf(InterestRateSwap.State::class.java.name), UpdateBusinessDayFlow.Broadcast::class.java.name to setOf(LocalDate::class.java.name), - ExitServerFlow.Broadcast::class.java.name to setOf(kotlin.Int::class.java.name), FixingFlow.FixingRoleDecider::class.java.name to setOf(StateRef::class.java.name, Duration::class.java.name), FixingFlow.Floater::class.java.name to setOf(Party::class.java.name, FixingFlow.FixingSession::class.java.name)) } diff --git a/samples/irs-demo/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry b/samples/irs-demo/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry index 27d759838b..b7e05a9569 100644 --- a/samples/irs-demo/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry +++ b/samples/irs-demo/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry @@ -2,5 +2,4 @@ net.corda.irs.plugin.IRSPlugin net.corda.irs.api.NodeInterestRates$Plugin net.corda.irs.flows.AutoOfferFlow$Plugin -net.corda.irs.flows.ExitServerFlow$Plugin net.corda.irs.flows.UpdateBusinessDayFlow$Plugin