From 5e0202acd0999f82a2e65fbdffec602598523a38 Mon Sep 17 00:00:00 2001 From: Andras Slemmer Date: Thu, 19 Apr 2018 10:54:17 +0100 Subject: [PATCH 1/6] Add killFlow --- .../main/kotlin/net/corda/core/messaging/CordaRPCOps.kt | 7 +++++++ .../main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt | 3 +++ .../net/corda/node/internal/RpcAuthorisationProxy.kt | 5 +++++ .../net/corda/node/internal/RpcExceptionHandlingProxy.kt | 3 +++ 4 files changed, 18 insertions(+) diff --git a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt index 51c287af17..047ceb2efe 100644 --- a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt +++ b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt @@ -260,6 +260,13 @@ interface CordaRPCOps : RPCOps { @RPCReturnsObservables fun startTrackedFlowDynamic(logicType: Class>, vararg args: Any?): FlowProgressHandle + /** + * Attempts to kill a flow. This is not a clean termination and should be reserved for exceptional cases such as stuck fibers. + * + * @return whether the flow existed and was killed. + */ + fun killFlow(id: StateMachineRunId): Boolean + /** Returns Node's NodeInfo, assuming this will not change while the node is running. */ fun nodeInfo(): NodeInfo diff --git a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt index 7a4a8a94e5..398de94bbd 100644 --- a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt +++ b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt @@ -9,6 +9,7 @@ import net.corda.core.crypto.SecureHash import net.corda.core.flows.FlowInitiator import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC +import net.corda.core.flows.StateMachineRunId import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -109,6 +110,8 @@ internal class CordaRPCOpsImpl( return snapshot } + override fun killFlow(id: StateMachineRunId) = smm.killFlow(id) + override fun stateMachinesFeed(): DataFeed, StateMachineUpdate> { return database.transaction { val (allStateMachines, changes) = smm.track() diff --git a/node/src/main/kotlin/net/corda/node/internal/RpcAuthorisationProxy.kt b/node/src/main/kotlin/net/corda/node/internal/RpcAuthorisationProxy.kt index ece6c31561..0f66d391f3 100644 --- a/node/src/main/kotlin/net/corda/node/internal/RpcAuthorisationProxy.kt +++ b/node/src/main/kotlin/net/corda/node/internal/RpcAuthorisationProxy.kt @@ -4,6 +4,7 @@ import net.corda.client.rpc.PermissionException import net.corda.core.contracts.ContractState import net.corda.core.crypto.SecureHash import net.corda.core.flows.FlowLogic +import net.corda.core.flows.StateMachineRunId import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party @@ -73,6 +74,10 @@ class RpcAuthorisationProxy(private val implementation: CordaRPCOps, private val implementation.startTrackedFlowDynamic(logicType, *args) } + override fun killFlow(id: StateMachineRunId): Boolean = guard("killFlow") { + return implementation.killFlow(id) + } + override fun nodeInfo(): NodeInfo = guard("nodeInfo", implementation::nodeInfo) override fun notaryIdentities(): List = guard("notaryIdentities", implementation::notaryIdentities) diff --git a/node/src/main/kotlin/net/corda/node/internal/RpcExceptionHandlingProxy.kt b/node/src/main/kotlin/net/corda/node/internal/RpcExceptionHandlingProxy.kt index f8434b9b52..b533808c81 100644 --- a/node/src/main/kotlin/net/corda/node/internal/RpcExceptionHandlingProxy.kt +++ b/node/src/main/kotlin/net/corda/node/internal/RpcExceptionHandlingProxy.kt @@ -5,6 +5,7 @@ import net.corda.core.contracts.ContractState import net.corda.core.crypto.SecureHash import net.corda.core.doOnError import net.corda.core.flows.FlowLogic +import net.corda.core.flows.StateMachineRunId import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.internal.concurrent.doOnError @@ -88,6 +89,8 @@ class RpcExceptionHandlingProxy(private val delegate: SecureCordaRPCOps) : Corda override fun acceptNewNetworkParameters(parametersHash: SecureHash) = wrap { delegate.acceptNewNetworkParameters(parametersHash) } + override fun killFlow(id: StateMachineRunId) = wrap { delegate.killFlow(id) } + override fun nodeInfo() = wrap(delegate::nodeInfo) override fun notaryIdentities() = wrap(delegate::notaryIdentities) From a276a2555ed049213c9479f1527ce9302cc16dcc Mon Sep 17 00:00:00 2001 From: Andras Slemmer Date: Thu, 19 Apr 2018 10:58:48 +0100 Subject: [PATCH 2/6] Add killFlow tests --- .../net/corda/node/CordaRPCOpsImplTest.kt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt index ef83ab852c..683ddbcc0b 100644 --- a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt @@ -1,5 +1,6 @@ package net.corda.node +import co.paralleluniverse.fibers.Fiber import co.paralleluniverse.fibers.Suspendable import net.corda.client.rpc.PermissionException import net.corda.core.context.AuthServiceId @@ -19,6 +20,7 @@ import net.corda.core.node.services.queryBy import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow +import net.corda.core.utilities.unwrap import net.corda.finance.DOLLARS import net.corda.finance.GBP import net.corda.finance.USD @@ -43,6 +45,7 @@ import net.corda.testing.node.internal.InternalMockNetwork.MockNode import net.corda.testing.node.internal.InternalMockNodeParameters import net.corda.testing.node.testActor import org.apache.commons.io.IOUtils +import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatExceptionOfType import org.junit.After import org.junit.Assert.assertArrayEquals @@ -293,6 +296,71 @@ class CordaRPCOpsImplTest { } } + @Test + fun `kill a stuck flow through RPC`() { + + withPermissions(startFlow(), invokeRpc(CordaRPCOps::killFlow), invokeRpc(CordaRPCOps::stateMachinesFeed), invokeRpc(CordaRPCOps::stateMachinesSnapshot)) { + + val flow = rpc.startFlow(::NewJoinerFlow) + + val killed = rpc.killFlow(flow.id) + + assertThat(killed).isTrue() + assertThat(rpc.stateMachinesSnapshot().map { info -> info.id }).doesNotContain(flow.id) + } + } + + @Test + fun `kill a waiting flow through RPC`() { + + withPermissions(startFlow(), invokeRpc(CordaRPCOps::killFlow), invokeRpc(CordaRPCOps::stateMachinesFeed), invokeRpc(CordaRPCOps::stateMachinesSnapshot)) { + + val flow = rpc.startFlow(::HopefulFlow, alice) + + val killed = rpc.killFlow(flow.id) + + assertThat(killed).isTrue() + assertThat(rpc.stateMachinesSnapshot().map { info -> info.id }).doesNotContain(flow.id) + } + } + + @Test + fun `kill a nonexistent flow through RPC`() { + + withPermissions(invokeRpc(CordaRPCOps::killFlow)) { + + val nonexistentFlowId = StateMachineRunId.createRandom() + + val killed = rpc.killFlow(nonexistentFlowId) + + assertThat(killed).isFalse() + } + } + + @StartableByRPC + class NewJoinerFlow : FlowLogic() { + + @Suspendable + override fun call(): String { + + logger.info("When can I join you say? Almost there buddy...") + Fiber.currentFiber().join() + return "You'll never get me!" + } + } + + @StartableByRPC + class HopefulFlow(private val party: Party) : FlowLogic() { + + @Suspendable + override fun call(): String { + + logger.info("Waiting for a miracle...") + val miracle = initiateFlow(party).receive().unwrap { it } + return miracle + } + } + class NonRPCFlow : FlowLogic() { @Suspendable override fun call() = Unit From 26c6ba61187680b8bc73e65cbffe9ec420c4bd7d Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 15 May 2018 13:25:28 +0100 Subject: [PATCH 3/6] CORDA-1461 Fix smoke tests (#3150) --- .../net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java | 3 ++- .../src/main/kotlin/net/corda/smoketesting/NodeConfig.kt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java b/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java index 30edeeb897..32e2747072 100644 --- a/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java +++ b/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java @@ -48,7 +48,8 @@ public class StandaloneCordaRPCJavaClientTest { port.getAndIncrement(), port.getAndIncrement(), true, - Collections.singletonList(rpcUser) + Collections.singletonList(rpcUser), + true ); @Before diff --git a/testing/smoke-test-utils/src/main/kotlin/net/corda/smoketesting/NodeConfig.kt b/testing/smoke-test-utils/src/main/kotlin/net/corda/smoketesting/NodeConfig.kt index 145846962b..120faa5314 100644 --- a/testing/smoke-test-utils/src/main/kotlin/net/corda/smoketesting/NodeConfig.kt +++ b/testing/smoke-test-utils/src/main/kotlin/net/corda/smoketesting/NodeConfig.kt @@ -15,7 +15,8 @@ class NodeConfig( val rpcPort: Int, val rpcAdminPort: Int, val isNotary: Boolean, - val users: List + val users: List, + val devMode: Boolean = true ) { companion object { val renderOptions: ConfigRenderOptions = ConfigRenderOptions.defaults().setOriginComments(false) @@ -38,6 +39,7 @@ class NodeConfig( .root()) .withValue("rpcUsers", valueFor(users.map { it.toConfig().root().unwrapped() }.toList())) .withValue("useTestClock", valueFor(true)) + .withValue("devMode", valueFor(devMode)) return if (isNotary) { config.withValue("notary", ConfigValueFactory.fromMap(mapOf("validating" to true))) } else { From 2c16de8ec49089f96b637ed431fd8a0dafdcf2ec Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 11 May 2018 17:15:06 +0200 Subject: [PATCH 4/6] Docs: reorganise the left hand table of contents. It now has an app dev section, an operations section, and a "participate" section. --- docs/source/_static/css/custom.css | 7 +++++++ docs/source/index.rst | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css index ebf9a0e17d..db3532e97b 100644 --- a/docs/source/_static/css/custom.css +++ b/docs/source/_static/css/custom.css @@ -24,6 +24,13 @@ input { letter-spacing: 0.3px } +p.caption { + margin-top: 2em; +} +span.caption-text { + font-size: larger; +} + p { font-size: 100%; /* Get rid of RTD rule that assumes nobody changes their browser font size */ } diff --git a/docs/source/index.rst b/docs/source/index.rst index bd85109131..05499f86f9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -30,17 +30,28 @@ We look forward to seeing what you can do with Corda! .. _`download the PDF`: _static/corda-developer-site.pdf .. toctree:: + :caption: App development :maxdepth: 1 quickstart-index.rst key-concepts.rst building-a-cordapp-index.rst - corda-nodes-index.rst - corda-networks-index.rst tutorials-index.rst tools-index.rst node-internals-index.rst component-library-index.rst - release-process-index.rst troubleshooting.rst + +.. toctree:: + :caption: Operations + :maxdepth: 2 + + corda-nodes-index.rst + corda-networks-index.rst + +.. toctree:: + :caption: Participate + :maxdepth: 2 + + release-process-index.rst other-index.rst From 0dd06571942a2211965353d35ff2a2325552263c Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 11 May 2018 17:31:42 +0200 Subject: [PATCH 5/6] Docs: add support for Markdown to Sphinx --- docs/requirements.txt | 6 ++++-- docs/source/conf.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 9c409bc241..91cd59da01 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,9 +1,10 @@ -## The following requirements were added by pip freeze: alabaster==0.7.8 Babel==2.3.4 certifi==2018.4.16 chardet==3.0.4 +CommonMark==0.5.5 docutils==0.12 +future==0.16.0 idna==2.6 imagesize==0.7.1 Jinja2==2.8 @@ -14,9 +15,10 @@ Pillow==5.1.0 Pygments==2.2.0 pyparsing==2.2.0 pytz==2016.4 +recommonmark==0.4.0 reportlab==3.4.0 requests==2.18.4 -rst2pdf==0.93 +rst2pdf==0.93.dev0 six==1.10.0 snowballstemmer==1.2.1 Sphinx==1.7.4 diff --git a/docs/source/conf.py b/docs/source/conf.py index 5684a4962e..e24dd0efca 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -41,8 +41,10 @@ templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ['.rst', '.md'] +source_parsers = { + '.md': 'recommonmark.parser.CommonMarkParser', +} # The encoding of source files. #source_encoding = 'utf-8-sig' From 8cac69d2522ae37b2bb976347b5aad853c04795a Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 11 May 2018 17:32:19 +0200 Subject: [PATCH 6/6] Docs: re-organise the toctree a bit more and introduce a design section It includes (for now) just the design template. --- docs/source/aws-vm.rst | 6 +++--- docs/source/azure-vm.rst | 4 ++-- docs/source/corda-networks-index.rst | 4 ++-- docs/source/corda-nodes-index.rst | 4 ++-- docs/source/design/README.md | 2 +- ...nReviewProcess.md => design-review-process.md} | 12 ++++++------ docs/source/design/designTemplate/design.md | 2 +- docs/source/index.rst | 15 +++++++++++++-- docs/source/other-index.rst | 9 --------- docs/source/tools-index.rst | 3 --- 10 files changed, 30 insertions(+), 31 deletions(-) rename docs/source/design/{designReviewProcess.md => design-review-process.md} (98%) delete mode 100644 docs/source/other-index.rst diff --git a/docs/source/aws-vm.rst b/docs/source/aws-vm.rst index b0f518480e..571620463c 100644 --- a/docs/source/aws-vm.rst +++ b/docs/source/aws-vm.rst @@ -1,5 +1,5 @@ -Building a Corda VM from the AWS Marketplace -============================================ +AWS Marketplace +=============== To help you design, build and test applications on Corda, called CorDapps, a Corda network AMI can be deployed from the `AWS Marketplace `__. Instructions on running Corda nodes can be found `here `_. @@ -12,7 +12,7 @@ Pre-requisites Deploying a Corda Network ---------------------------- +------------------------- Browse to the `AWS Marketplace `__ and search for Corda. diff --git a/docs/source/azure-vm.rst b/docs/source/azure-vm.rst index e346c24c2b..8661422006 100644 --- a/docs/source/azure-vm.rst +++ b/docs/source/azure-vm.rst @@ -1,5 +1,5 @@ -Building a Corda Network on Azure Marketplace -============================================= +Azure Marketplace +================= To help you design, build and test applications on Corda, called CorDapps, a Corda network can be deployed on the `Microsoft Azure Marketplace `_ diff --git a/docs/source/corda-networks-index.rst b/docs/source/corda-networks-index.rst index 270726948e..cc3e81321e 100644 --- a/docs/source/corda-networks-index.rst +++ b/docs/source/corda-networks-index.rst @@ -1,5 +1,5 @@ -Corda networks -============== +Networks +======== .. toctree:: :maxdepth: 1 diff --git a/docs/source/corda-nodes-index.rst b/docs/source/corda-nodes-index.rst index 6bf9c361b9..da92cdf876 100644 --- a/docs/source/corda-nodes-index.rst +++ b/docs/source/corda-nodes-index.rst @@ -1,5 +1,5 @@ -Corda nodes -=========== +Nodes +===== .. toctree:: :maxdepth: 1 diff --git a/docs/source/design/README.md b/docs/source/design/README.md index 94161e68bc..64e212f3f7 100644 --- a/docs/source/design/README.md +++ b/docs/source/design/README.md @@ -10,7 +10,7 @@ These should be written in [Markdown](https://github.com/adam-p/markdown-here/wi ## Design Review Process -Please see the [design review process](./designReviewProcess.md). +Please see the [design review process](design-review-process.md). * Feature request submission * High level design diff --git a/docs/source/design/designReviewProcess.md b/docs/source/design/design-review-process.md similarity index 98% rename from docs/source/design/designReviewProcess.md rename to docs/source/design/design-review-process.md index 57cc17b5b3..c5c658d6b4 100644 --- a/docs/source/design/designReviewProcess.md +++ b/docs/source/design/design-review-process.md @@ -1,9 +1,8 @@ - -# Overview +# Design review process The Corda Design Review process defines a means of editing, storing, collaborating, reviewing and approving Corda documentation in a consistent, structured, easily accessible and open manner. -# Background +## Background Historically, Corda design documentation has been produced in an ad hoc fashion to include: * Multiple sources and formats of storage @@ -20,7 +19,7 @@ Historically, Corda design documentation has been produced in an ad hoc fashion * Lack of proposed implementation plan (time, resources, effort). * Often missing stakeholder collaboration and review in the feedback cycle. -# Process +## Process This process specifies: @@ -53,7 +52,8 @@ The following diagram illustrates the process flow: ![Design Review Process](./designReviewProcess.png) -# Review Groups +## Review Groups + Design documents should include all relevant stakeholders in their distribution (mostly as PR reviewers in github). This will often vary and depend on the origin of the Feature Request, particularly for high level business requirements. Technical Design Documents will tend to include a small set of stakeholders (Design Approval Board, Platform Development, DevOps). Final approval authority lays with at least one member of the Design Approval Board (DAB) or nominated delegate(s). Design Approval Board (DAB) @@ -91,7 +91,7 @@ Other review groups inlcude: * Customers * Key collaborators -# Applicability and Timing +## Applicability and Timing This process should be applied to any major feature request gathered by the product management team or lead technologists that has been entered in the product backlog as a requirement, and has been prioritized for imminent execution. diff --git a/docs/source/design/designTemplate/design.md b/docs/source/design/designTemplate/design.md index 37c8ed3660..601e2f7074 100644 --- a/docs/source/design/designTemplate/design.md +++ b/docs/source/design/designTemplate/design.md @@ -2,7 +2,7 @@ # Design Template -Please read the [Design Review Process](../designReviewProcess.md) before completing a design. +Please read the [Design Review Process](../design-review-process.md) before completing a design. This design template should be used for capturing new Corda feature requests that have been raised as JIRA requirements stories by the product management team. The design may be completed in two stages depending on the complexity and scope of the new feature. diff --git a/docs/source/index.rst b/docs/source/index.rst index 05499f86f9..44694f4e09 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -30,7 +30,7 @@ We look forward to seeing what you can do with Corda! .. _`download the PDF`: _static/corda-developer-site.pdf .. toctree:: - :caption: App development + :caption: Development :maxdepth: 1 quickstart-index.rst @@ -48,10 +48,21 @@ We look forward to seeing what you can do with Corda! corda-nodes-index.rst corda-networks-index.rst + azure-vm.rst + aws-vm.rst + loadtesting.rst + +.. toctree:: + :caption: Design docs + :maxdepth: 2 + + design/design-review-process.md .. toctree:: :caption: Participate :maxdepth: 2 release-process-index.rst - other-index.rst + corda-repo-layout.rst + building-the-docs.rst + json.rst diff --git a/docs/source/other-index.rst b/docs/source/other-index.rst deleted file mode 100644 index f6d60548e7..0000000000 --- a/docs/source/other-index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Other -===== - -.. toctree:: - :maxdepth: 1 - - corda-repo-layout - building-the-docs - json diff --git a/docs/source/tools-index.rst b/docs/source/tools-index.rst index 3955a0cbe1..55b398dd35 100644 --- a/docs/source/tools-index.rst +++ b/docs/source/tools-index.rst @@ -7,6 +7,3 @@ Tools network-simulator demobench node-explorer - azure-vm - aws-vm - loadtesting \ No newline at end of file