Skip to content

Commit

Permalink
IRS Demo - split IRS Demo into two separate applications to showcase … (
Browse files Browse the repository at this point in the history
corda#1638)

* IRS Demo - split IRS Demo into two separate applications to showcase the separation and usage of RPC client
  • Loading branch information
m4ksio authored Oct 25, 2017
1 parent ba75146 commit 44a7d87
Show file tree
Hide file tree
Showing 1,035 changed files with 623 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tags

.gradle
local.properties
.gradletasknamecache

# General build files
**/build/*
Expand Down
8 changes: 3 additions & 5 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
27 changes: 15 additions & 12 deletions samples/irs-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ This demo brings up three nodes: Bank A, Bank B and a node that simultaneously r
interest rates oracle. The two banks agree on an interest rate swap, and then do regular fixings of the deal as the
time on a simulated clock passes.

To run from the command line in Unix:
Functionality is split into two parts - CordApp which provides actual distributed ledger backend and Spring Boot
webapp which provides REST API and web frontend. Application communicate using Corda RPC protocol.

1. Run ``./gradlew samples:irs-demo:deployNodes`` to install configs and a command line tool under
To run from the command line in Unix:
1. Run ``./gradlew samples:irs-demo:cordapp:deployNodes`` to install configs and a command line tool under
``samples/irs-demo/build``
2. Run ``./gradlew samples:irs-demo:installDist``
3. Move to the ``samples/irs-demo/build`` directory
4. Run ``./nodes/runnodes`` to open up three new terminals with the three nodes (you may have to install xterm)
2. Run ``./gradlew samples:irs-demo:web:deployWebapps`` to install configs and tools for running webservers
3. Move to the ``samples/irs-demo/`` directory
4. Run ``./cordapp/build/nodes/runnodes`` to open up three new terminals with the three nodes (you may have to install xterm)
5. Run ``./web/build/webapps/runwebapps`` to open three more terminals for associated webserver

To run from the command line in Windows:

1. Run ``gradlew.bat samples:irs-demo:deployNodes`` to install configs and a command line tool under
1. Run ``gradlew.bat samples:irs-demo:cordapp:deployNodes`` to install configs and a command line tool under
``samples\irs-demo\build``
2. Run ``gradlew.bat samples:irs-demo:installDist``
3. Run ``cd samples\irs-demo\build`` to change current working directory
4. Run ``nodes\runnodes`` to open up several 6 terminals, 2 for each node. First terminal is a web-server associated
with every node and second one is Corda interactive shell for the node
2. Run ``gradlew.bat samples:irs-demo:web:deployWebapps`` to install configs and tools for running webservers
3. Run ``cd samples\irs-demo`` to change current working directory
4. Run ``cordapp\build\nodes\runnodes`` to open up several 3 terminals for each nodes
5. Run ``web\build\webapps\webapps`` to open up several 3 terminals for each nodes' webservers

This demo also has a web app. To use this, run nodes and then navigate to http://localhost:10007/web/irsdemo and
http://localhost:10010/web/irsdemo to see each node's view of the ledger.
This demo also has a web app. To use this, run nodes and then navigate to http://localhost:10007/ and
http://localhost:10010/ to see each node's view of the ledger.

To use the web app, click the "Create Deal" button, fill in the form, then click the "Submit" button. You can then use
the time controls at the top left of the home page to run the fixings. Click any individual trade in the blotter to
Expand Down
107 changes: 30 additions & 77 deletions samples/irs-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
buildscript {
ext {
springBootVersion = '1.5.7.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

// Spring Boot plugin adds a numerous hardcoded dependencies in the version much lower then Corda expects
// causing the problems in runtime. Those can be changed by manipulating above properties
// See https://github.com/spring-gradle-plugins/dependency-management-plugin/blob/master/README.md#changing-the-value-of-a-version-property
ext['artemis.version'] = "$artemis_version"
ext['hibernate.version'] = "$hibernate_version"

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.cordapp'
Expand All @@ -23,101 +42,35 @@ sourceSets {
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
demoArtifacts.extendsFrom testRuntime
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

// The irs demo CorDapp depends upon Cash CorDapp features
cordapp project(':finance')

// Corda integration dependencies
cordaCompile project(path: ":node:capsule", configuration: 'runtimeArtifacts')
cordaCompile project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
cordaCompile project(':core')
cordaCompile project(':webserver')

// Javax is required for webapis
compile "org.glassfish.jersey.core:jersey-server:${jersey_version}"

// Cordapp dependencies
// Specify your cordapp's dependencies below, including dependent cordapps
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile project(path: ":samples:irs-demo:cordapp", configuration: "demoArtifacts")
compile project(":samples:irs-demo:web")
compile('org.springframework.boot:spring-boot-starter-web') {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}

testCompile project(':node-driver')
testCompile "junit:junit:$junit_version"
testCompile "org.assertj:assertj-core:${assertj_version}"
}

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
name "O=Notary Service,L=Zurich,C=CH"
notary = [validating : true]
p2pPort 10002
rpcPort 10003
webPort 10004
cordapps = ["$project.group:finance:$corda_release_version"]
useTestClock true
}
node {
name "O=Bank A,L=London,C=GB"
p2pPort 10005
rpcPort 10006
webPort 10007
cordapps = ["$project.group:finance:$corda_release_version"]
useTestClock true
}
node {
name "O=Bank B,L=New York,C=US"
p2pPort 10008
rpcPort 10009
webPort 10010
cordapps = ["$project.group:finance:$corda_release_version"]
useTestClock true
}
bootRepackage {
enabled = false
}

task integrationTest(type: Test, dependsOn: []) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}

// This fixes the "line too long" error when running this demo with windows CLI
// TODO: Automatically apply to all projects via a plugin
tasks.withType(CreateStartScripts).each { task ->
task.doLast {
String text = task.windowsScript.text
// Replaces the per file classpath (which are all jars in "lib") with a wildcard on lib
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" })
task.windowsScript.write text
}
}

idea {
module {
downloadJavadoc = true // defaults to false
downloadSources = true
}
}

publishing {
publications {
jarAndSources(MavenPublication) {
from components.java
artifactId 'irsdemo'

artifact sourceJar
artifact javadocJar
}
}
}

jar {
from sourceSets.test.output
manifest {
attributes(
'Automatic-Module-Name': 'net.corda.samples.demos.irs'
)
}
}
}
115 changes: 115 additions & 0 deletions samples/irs-demo/cordapp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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.cordformation'
apply plugin: 'net.corda.plugins.cordapp'
apply plugin: 'maven-publish'
apply plugin: 'application'

mainClassName = 'net.corda.irs.IRSDemo'

sourceSets {
integrationTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/kotlin')
}
}
}

configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
demoArtifacts.extendsFrom integrationTestRuntime
}

dependencies {
// The irs demo CorDapp depends upon Cash CorDapp features
cordapp project(':finance')

// Corda integration dependencies
cordaCompile project(path: ":node:capsule", configuration: 'runtimeArtifacts')
cordaCompile project(':core')

// Cordapp dependencies
// Specify your cordapp's dependencies below, including dependent cordapps
compile group: 'commons-io', name: 'commons-io', version: '2.5'

testCompile project(':node-driver')
testCompile "junit:junit:$junit_version"
testCompile "org.assertj:assertj-core:${assertj_version}"
}

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {

ext.rpcUsers = [
['username' : "user",
'password' : "password",
'permissions' : [
"StartFlow.net.corda.irs.flows.AutoOfferFlow\$Requester",
"StartFlow.net.corda.irs.flows.UpdateBusinessDayFlow\$Broadcast",
"StartFlow.net.corda.irs.api.NodeInterestRates\$UploadFixesFlow"
]]
]

directory "./build/nodes"
node {
name "O=Notary Service,L=Zurich,C=CH"
notary = [validating : true]
p2pPort 10002
rpcPort 10003
cordapps = ["net.corda:finance:$corda_release_version"]
rpcUsers = ext.rpcUsers
useTestClock true
}
node {
name "O=Bank A,L=London,C=GB"
p2pPort 10005
rpcPort 10006
cordapps = ["net.corda:finance:$corda_release_version"]
rpcUsers = ext.rpcUsers
useTestClock true
}
node {
name "O=Bank B,L=New York,C=US"
p2pPort 10008
rpcPort 10009
cordapps = ["net.corda:finance:$corda_release_version"]
rpcUsers = ext.rpcUsers
useTestClock true
}
}

task integrationTest(type: Test, dependsOn: []) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}

// This fixes the "line too long" error when running this demo with windows CLI
// TODO: Automatically apply to all projects via a plugin
tasks.withType(CreateStartScripts).each { task ->
task.doLast {
String text = task.windowsScript.text
// Replaces the per file classpath (which are all jars in "lib") with a wildcard on lib
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" })
task.windowsScript.write text
}
}

idea {
module {
downloadJavadoc = true // defaults to false
downloadSources = true
}
}

jar {
from sourceSets.test.output
}

artifacts {
demoArtifacts jar
}
Loading

0 comments on commit 44a7d87

Please sign in to comment.