From a70136f775b86085ae3231ace64b6b73218d160d Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 21 Nov 2016 19:35:01 +0100 Subject: [PATCH] Minor: fix startup time calculation, fix demos to print things to stdout instead of log.info --- node/src/main/kotlin/net/corda/node/Main.kt | 5 +++-- .../net/corda/attachmentdemo/api/AttachmentDemoApi.kt | 5 ++--- .../net/corda/traderdemo/protocol/BuyerProtocol.kt | 9 ++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/Main.kt b/node/src/main/kotlin/net/corda/node/Main.kt index 57c3298140..387e06e033 100644 --- a/node/src/main/kotlin/net/corda/node/Main.kt +++ b/node/src/main/kotlin/net/corda/node/Main.kt @@ -32,6 +32,8 @@ fun printBasicNodeInfo(description: String, info: String? = null) { } fun main(args: Array) { + val startTime = System.currentTimeMillis() + val parser = OptionParser() // 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 @@ -92,13 +94,12 @@ fun main(args: Array) { dirFile.mkdirs() val node = conf.createNode() - val startTime = System.currentTimeMillis() node.start() printPluginsAndServices(node) 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") if (renderBasicInfoToConsole) diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/api/AttachmentDemoApi.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/api/AttachmentDemoApi.kt index ed3ce058cc..d76253ed6d 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/api/AttachmentDemoApi.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/api/AttachmentDemoApi.kt @@ -8,7 +8,6 @@ import net.corda.core.success import net.corda.core.utilities.ApiUtils import net.corda.core.utilities.Emoji import net.corda.core.utilities.loggerFor -import net.corda.protocols.CashCommand import net.corda.protocols.FinalityProtocol import net.corda.testing.ALICE_KEY import java.util.concurrent.CompletableFuture @@ -51,7 +50,7 @@ class AttachmentDemoApi(val services: ServiceHub) { // Send the transaction to the other recipient val tx = ptx.toSignedTransaction() services.invokeProtocolAsync(FinalityProtocol::class.java, tx, setOf(it)).resultFuture.success { - logger.info("Successfully sent attachment with the FinalityProtocol") + println("Successfully sent attachment with the FinalityProtocol") }.failure { 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()) 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() } else { Response.serverError().entity("No attachments passed").build() diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/protocol/BuyerProtocol.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/protocol/BuyerProtocol.kt index a66a834af2..a750c1ae4d 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/protocol/BuyerProtocol.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/protocol/BuyerProtocol.kt @@ -12,13 +12,12 @@ import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.Emoji import net.corda.core.utilities.ProgressTracker -import net.corda.node.services.api.ServiceHubInternal import net.corda.node.services.persistence.NodeAttachmentService import net.corda.protocols.TwoPartyTradeProtocol import java.nio.file.Path import java.util.* -class BuyerProtocol(val otherParty: Party, +class BuyerProtocol(val otherParty: Party, private val attachmentsPath: Path, override val progressTracker: ProgressTracker = ProgressTracker(STARTING_BUY)) : ProtocolLogic() { @@ -54,7 +53,7 @@ class BuyerProtocol(val otherParty: Party, // TODO: This should be moved into the protocol itself. 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)}") logIssuanceAttachment(tradeTX) @@ -63,7 +62,7 @@ class BuyerProtocol(val otherParty: Party, private fun logBalance() { 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) { @@ -75,7 +74,7 @@ class BuyerProtocol(val otherParty: Party, cpIssuance.attachments.first().let { 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: $p