Minor: fix startup time calculation, fix demos to print things to stdout instead of log.info

This commit is contained in:
Mike Hearn
2016-11-21 19:35:01 +01:00
parent 4c8e80f668
commit a70136f775
3 changed files with 9 additions and 10 deletions

View File

@ -32,6 +32,8 @@ fun printBasicNodeInfo(description: String, info: String? = null) {
} }
fun main(args: Array<String>) { fun main(args: Array<String>) {
val startTime = System.currentTimeMillis()
val parser = OptionParser() val parser = OptionParser()
// The intent of allowing a command line configurable directory and config path is to allow deployment flexibility. // The intent of allowing a command line configurable directory and config path is to allow deployment flexibility.
// Other general configuration should live inside the config file unless we regularly need temporary overrides on the command line // Other general configuration should live inside the config file unless we regularly need temporary overrides on the command line
@ -92,13 +94,12 @@ fun main(args: Array<String>) {
dirFile.mkdirs() dirFile.mkdirs()
val node = conf.createNode() val node = conf.createNode()
val startTime = System.currentTimeMillis()
node.start() node.start()
printPluginsAndServices(node) printPluginsAndServices(node)
node.networkMapRegistrationFuture.then { node.networkMapRegistrationFuture.then {
val elapsed = (System.currentTimeMillis() - startTime) / 10 / 1000.0 val elapsed = (System.currentTimeMillis() - startTime) / 10 / 100.0
printBasicNodeInfo("Node started up and registered in $elapsed sec") printBasicNodeInfo("Node started up and registered in $elapsed sec")
if (renderBasicInfoToConsole) if (renderBasicInfoToConsole)

View File

@ -8,7 +8,6 @@ import net.corda.core.success
import net.corda.core.utilities.ApiUtils import net.corda.core.utilities.ApiUtils
import net.corda.core.utilities.Emoji import net.corda.core.utilities.Emoji
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.protocols.CashCommand
import net.corda.protocols.FinalityProtocol import net.corda.protocols.FinalityProtocol
import net.corda.testing.ALICE_KEY import net.corda.testing.ALICE_KEY
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture
@ -51,7 +50,7 @@ class AttachmentDemoApi(val services: ServiceHub) {
// Send the transaction to the other recipient // Send the transaction to the other recipient
val tx = ptx.toSignedTransaction() val tx = ptx.toSignedTransaction()
services.invokeProtocolAsync<Unit>(FinalityProtocol::class.java, tx, setOf(it)).resultFuture.success { services.invokeProtocolAsync<Unit>(FinalityProtocol::class.java, tx, setOf(it)).resultFuture.success {
logger.info("Successfully sent attachment with the FinalityProtocol") println("Successfully sent attachment with the FinalityProtocol")
}.failure { }.failure {
logger.error("Failed to send attachment with the FinalityProtocol") logger.error("Failed to send attachment with the FinalityProtocol")
} }
@ -76,7 +75,7 @@ class AttachmentDemoApi(val services: ServiceHub) {
val attachment = services.storageService.attachments.openAttachment(tx.attachments.first()) val attachment = services.storageService.attachments.openAttachment(tx.attachments.first())
assertEquals(PROSPECTUS_HASH, attachment?.id) assertEquals(PROSPECTUS_HASH, attachment?.id)
logger.info("File received - we're happy!\n\nFinal transaction is:\n\n${Emoji.renderIfSupported(event.tx)}") println("File received - we're happy!\n\nFinal transaction is:\n\n${Emoji.renderIfSupported(event.tx)}")
Response.ok().entity("Final transaction is: ${Emoji.renderIfSupported(event.tx)}").build() Response.ok().entity("Final transaction is: ${Emoji.renderIfSupported(event.tx)}").build()
} else { } else {
Response.serverError().entity("No attachments passed").build() Response.serverError().entity("No attachments passed").build()

View File

@ -12,7 +12,6 @@ import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.Emoji import net.corda.core.utilities.Emoji
import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.ProgressTracker
import net.corda.node.services.api.ServiceHubInternal
import net.corda.node.services.persistence.NodeAttachmentService import net.corda.node.services.persistence.NodeAttachmentService
import net.corda.protocols.TwoPartyTradeProtocol import net.corda.protocols.TwoPartyTradeProtocol
import java.nio.file.Path import java.nio.file.Path
@ -54,7 +53,7 @@ class BuyerProtocol(val otherParty: Party,
// TODO: This should be moved into the protocol itself. // TODO: This should be moved into the protocol itself.
serviceHub.recordTransactions(listOf(tradeTX)) serviceHub.recordTransactions(listOf(tradeTX))
logger.info("Purchase complete - we are a happy customer! Final transaction is: " + println("Purchase complete - we are a happy customer! Final transaction is: " +
"\n\n${Emoji.renderIfSupported(tradeTX.tx)}") "\n\n${Emoji.renderIfSupported(tradeTX.tx)}")
logIssuanceAttachment(tradeTX) logIssuanceAttachment(tradeTX)
@ -63,7 +62,7 @@ class BuyerProtocol(val otherParty: Party,
private fun logBalance() { private fun logBalance() {
val balances = serviceHub.vaultService.cashBalances.entries.map { "${it.key.currencyCode} ${it.value}" } val balances = serviceHub.vaultService.cashBalances.entries.map { "${it.key.currencyCode} ${it.value}" }
logger.info("Remaining balance: ${balances.joinToString()}") println("Remaining balance: ${balances.joinToString()}")
} }
private fun logIssuanceAttachment(tradeTX: SignedTransaction) { private fun logIssuanceAttachment(tradeTX: SignedTransaction) {
@ -75,7 +74,7 @@ class BuyerProtocol(val otherParty: Party,
cpIssuance.attachments.first().let { cpIssuance.attachments.first().let {
val p = attachmentsPath.toAbsolutePath().resolve("$it.jar") val p = attachmentsPath.toAbsolutePath().resolve("$it.jar")
logger.info(""" println("""
The issuance of the commercial paper came with an attachment. You can find it expanded in this directory: The issuance of the commercial paper came with an attachment. You can find it expanded in this directory:
$p $p