mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
Use buyer/seller instead of alpha/beta and allow nodes to both be named localhost. Update docs.
This commit is contained in:
parent
75a542f79d
commit
f705eee312
@ -1,9 +1,9 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Node: alpha" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||
<configuration default="false" name="Node: buyer" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="core.node.TraderDemoKt" />
|
||||
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--dir=alpha --service-fake-trades --network-address=alpha" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--dir=buyer --service-fake-trades --network-address=localhost" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
@ -1,9 +1,9 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Node: beta" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||
<configuration default="false" name="Node: seller" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="core.node.TraderDemoKt" />
|
||||
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--dir=beta --fake-trade-with=alpha --network-address=beta:31338 --timestamper-identity-file=alpha/identity-public --timestamper-address=alpha:31338" />
|
||||
<option name="PROGRAM_PARAMETERS" value="--dir=seller --fake-trade-with=localhost --network-address=localhost:31338 --timestamper-identity-file=buyer/identity-public --timestamper-address=localhost" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
@ -106,12 +106,12 @@ mainClassName = 'core.node.TraderDemoKt'
|
||||
task runDemoBuyer(type: JavaExec, dependsOn: ':classes') {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
main = 'core.node.TraderDemoKt'
|
||||
args = ['--dir=alpha', '--service-fake-trades', '--network-address=alpha']
|
||||
args = ['--dir=buyer', '--service-fake-trades', '--network-address=localhost']
|
||||
}
|
||||
|
||||
task runDemoSeller(type: JavaExec, dependsOn: ':classes') {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
main = 'core.node.TraderDemoKt'
|
||||
args = ['--dir=beta', '--fake-trade-with=alpha', '--network-address=beta:31338',
|
||||
'--timestamper-identity-file=alpha/identity-public', '--timestamper-address=alpha']
|
||||
args = ['--dir=seller', '--fake-trade-with=localhost', '--network-address=localhost:31338',
|
||||
'--timestamper-identity-file=buyer/identity-public', '--timestamper-address=localhost']
|
||||
}
|
||||
|
@ -4,21 +4,15 @@ Running the trading demo
|
||||
The repository contains a program that implements a demo of two nodes running the two-party trading protocol, which you
|
||||
can learn about in :doc:`protocol-state-machines`.
|
||||
|
||||
The node has only currently been tested on MacOS X. If you have success on other platforms, please let us know.
|
||||
|
||||
To run the demo, firstly edit your /etc/hosts file or Windows equivalent to add two aliases for localhost: alpha and
|
||||
beta. This is necessary for now because parts of the code use the DNS hostname to identify nodes and thus defining two
|
||||
nodes both called localhost won't work. We might fix this in future to include the port number everywhere, so making
|
||||
this easier.
|
||||
|
||||
You should now be able to run ``ping alpha`` and ``ping beta`` and not see errors.
|
||||
The node has only currently been tested on MacOS X and Ubuntu Linux. If you have success on other platforms, please
|
||||
let us know.
|
||||
|
||||
Now, open two terminals, and in the first run:::
|
||||
|
||||
./gradlew runDemoBuyer
|
||||
|
||||
It will create a directory named "alpha" and ask you to edit the configuration file inside. Open up ``alpha/config``
|
||||
in your favourite text editor and give the node a legal identity of "Alpha Corp, Inc" or whatever else you feel like.
|
||||
It will create a directory named "buyer" and ask you to edit the configuration file inside. Open up ``buyer/config``
|
||||
in your favourite text editor and give the node a legal identity of "Big Buyer Corp, Inc" or whatever else you feel like.
|
||||
The actual text string is not important. Now run the gradle command again, and it should start up and wait for
|
||||
a seller to connect.
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
package core.node
|
||||
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.google.common.util.concurrent.MoreExecutors
|
||||
import core.RunOnCallerThread
|
||||
import core.ThreadBox
|
||||
import core.messaging.*
|
||||
import core.utilities.loggerFor
|
||||
@ -90,7 +90,7 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
|
||||
return mutex.locked {
|
||||
sendClients.getOrPut(addr) {
|
||||
maybeSetupConnection(addr.hostAndPort)
|
||||
val qName = addr.hostAndPort.hostText
|
||||
val qName = addr.hostAndPort.toString()
|
||||
session.createProducer(qName)
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
|
||||
|
||||
// Create a queue on which to receive messages and set up the handler.
|
||||
session = clientFactory.createSession()
|
||||
session.createQueue(myHostPort.hostText, "inbound", false)
|
||||
session.createQueue(myHostPort.toString(), "inbound", false)
|
||||
inboundConsumer = session.createConsumer("inbound").setMessageHandler { message: ClientMessage ->
|
||||
// This code runs for every inbound message.
|
||||
if (!message.containsProperty(TOPIC_PROPERTY)) {
|
||||
@ -155,7 +155,7 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
|
||||
override fun serialise(): ByteArray = bits
|
||||
}
|
||||
for (handler in deliverTo) {
|
||||
(handler.executor ?: MoreExecutors.directExecutor()).execute {
|
||||
(handler.executor ?: RunOnCallerThread).execute {
|
||||
try {
|
||||
handler.callback(msg, handler)
|
||||
} catch(e: Exception) {
|
||||
@ -220,7 +220,7 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort)
|
||||
private enum class ConnectionDirection { INBOUND, OUTBOUND }
|
||||
|
||||
private fun maybeSetupConnection(hostAndPort: HostAndPort) {
|
||||
val name = hostAndPort.hostText
|
||||
val name = hostAndPort.toString()
|
||||
|
||||
// To make ourselves talk to a remote server, we need a "bridge". Bridges are things inside Artemis that know how
|
||||
// to handle remote machines going away temporarily, retry connections, etc. They're the bit that handles
|
||||
|
@ -184,7 +184,9 @@ fun makeFakeCommercialPaper(ownedBy: PublicKey): StateAndRef<CommercialPaper.Sta
|
||||
|
||||
private fun loadConfigFile(configFile: Path): NodeConfiguration {
|
||||
fun askAdminToEditConfig(configFile: Path?) {
|
||||
println()
|
||||
println("This is the first run, so you should edit the config file in $configFile and then start the node again.")
|
||||
println()
|
||||
System.exit(1)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user