From d683df5753aa11df31624b773cceec72aa5c152b Mon Sep 17 00:00:00 2001 From: Tommy Lillehagen Date: Mon, 2 Jul 2018 18:32:38 +0100 Subject: [PATCH 1/4] CORDA-1711 - Remove dependency on PathUtilsKt in net.corda.core.internal (#3493) --- .../net/corda/finance/flows/CashConfigDataFlow.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/finance/src/main/kotlin/net/corda/finance/flows/CashConfigDataFlow.kt b/finance/src/main/kotlin/net/corda/finance/flows/CashConfigDataFlow.kt index 0edd0987e9..ac890bd517 100644 --- a/finance/src/main/kotlin/net/corda/finance/flows/CashConfigDataFlow.kt +++ b/finance/src/main/kotlin/net/corda/finance/flows/CashConfigDataFlow.kt @@ -5,8 +5,6 @@ import com.typesafe.config.ConfigFactory import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC import net.corda.core.internal.declaredField -import net.corda.core.internal.div -import net.corda.core.internal.read import net.corda.core.node.AppServiceHub import net.corda.core.node.services.CordaService import net.corda.core.serialization.CordaSerializable @@ -17,6 +15,11 @@ import net.corda.finance.GBP import net.corda.finance.USD import net.corda.finance.flows.ConfigHolder.Companion.supportedCurrencies import java.io.IOException +import java.io.InputStream +import java.nio.file.Files +import java.nio.file.OpenOption +import java.nio.file.Path +import java.nio.file.Paths import java.util.* // TODO Until apps have access to their own config, we'll hack things by first getting the baseDirectory, read the node.conf @@ -25,6 +28,12 @@ import java.util.* class ConfigHolder(services: AppServiceHub) : SingletonSerializeAsToken() { companion object { val supportedCurrencies = listOf(USD, GBP, CHF, EUR) + + // TODO: In future releases, the Finance app should be fully decoupled from internal APIs in Core. + private operator fun Path.div(other: String): Path = resolve(other) + private operator fun String.div(other: String): Path = Paths.get(this) / other + private fun Path.inputStream(vararg options: OpenOption): InputStream = Files.newInputStream(this, *options) + private inline fun Path.read(vararg options: OpenOption, block: (InputStream) -> R): R = inputStream(*options).use(block) } val issuableCurrencies: List From 95d1b1f84e83c758ffa29b61a7aa2c02c0eb6737 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 3 Jul 2018 09:16:48 +0100 Subject: [PATCH 2/4] ENT-2001 use versionInfo when registering node with the doorman (#3435) * ENT-2001 use versionInfo when registering node with the doorman * ENT-2001 address code review changes --- .../src/main/kotlin/net/corda/node/internal/NodeStartup.kt | 6 +++--- .../registration/HTTPNetworkRegistrationService.kt | 7 +++---- .../registration/NetworkRegistrationHelperTest.kt | 1 + .../net/corda/testing/node/internal/DriverDSLImpl.kt | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index f9a045445b..790de59c8d 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -130,7 +130,7 @@ open class NodeStartup(val args: Array) { preNetworkRegistration(conf) if (cmdlineOptions.nodeRegistrationOption != null) { // Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig] - registerWithNetwork(conf, cmdlineOptions.nodeRegistrationOption) + registerWithNetwork(conf, versionInfo, cmdlineOptions.nodeRegistrationOption) return true } logStartupInfo(versionInfo, cmdlineOptions, conf) @@ -300,7 +300,7 @@ open class NodeStartup(val args: Array) { logger.info("Starting as node on ${conf.p2pAddress}") } - protected open fun registerWithNetwork(conf: NodeConfiguration, nodeRegistrationConfig: NodeRegistrationOption) { + protected open fun registerWithNetwork(conf: NodeConfiguration, versionInfo: VersionInfo, nodeRegistrationConfig: NodeRegistrationOption) { val compatibilityZoneURL = conf.networkServices?.doormanURL ?: throw RuntimeException( "compatibilityZoneURL or networkServices must be configured!") @@ -310,7 +310,7 @@ open class NodeStartup(val args: Array) { println("* Registering as a new participant with Corda network *") println("* *") println("******************************************************************") - NodeRegistrationHelper(conf, HTTPNetworkRegistrationService(compatibilityZoneURL), nodeRegistrationConfig).buildKeystore() + NodeRegistrationHelper(conf, HTTPNetworkRegistrationService(compatibilityZoneURL, versionInfo), nodeRegistrationConfig).buildKeystore() // Minimal changes to make registration tool create node identity. // TODO: Move node identity generation logic from node to registration helper. diff --git a/node/src/main/kotlin/net/corda/node/utilities/registration/HTTPNetworkRegistrationService.kt b/node/src/main/kotlin/net/corda/node/utilities/registration/HTTPNetworkRegistrationService.kt index 14a37ab0a0..ff37ecafad 100644 --- a/node/src/main/kotlin/net/corda/node/utilities/registration/HTTPNetworkRegistrationService.kt +++ b/node/src/main/kotlin/net/corda/node/utilities/registration/HTTPNetworkRegistrationService.kt @@ -5,6 +5,7 @@ import net.corda.core.internal.openHttpConnection import net.corda.core.internal.post import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.seconds +import net.corda.node.VersionInfo import net.corda.nodeapi.internal.crypto.X509CertificateFactory import okhttp3.CacheControl import okhttp3.Headers @@ -18,12 +19,10 @@ import java.util.* import java.util.zip.ZipInputStream import javax.naming.ServiceUnavailableException -class HTTPNetworkRegistrationService(compatibilityZoneURL: URL) : NetworkRegistrationService { +class HTTPNetworkRegistrationService(compatibilityZoneURL: URL, val versionInfo: VersionInfo) : NetworkRegistrationService { private val registrationURL = URL("$compatibilityZoneURL/certificate") companion object { - // TODO: Propagate version information from gradle - const val CLIENT_VERSION = "1.0" private val TRANSIENT_ERROR_STATUS_CODES = setOf(HTTP_BAD_GATEWAY, HTTP_UNAVAILABLE, HTTP_GATEWAY_TIMEOUT) } @@ -53,7 +52,7 @@ class HTTPNetworkRegistrationService(compatibilityZoneURL: URL) : NetworkRegistr } override fun submitRequest(request: PKCS10CertificationRequest): String { - return String(registrationURL.post(OpaqueBytes(request.encoded), "Client-Version" to CLIENT_VERSION)) + return String(registrationURL.post(OpaqueBytes(request.encoded), "Client-Version" to "${versionInfo.platformVersion}")) } } diff --git a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt index 1bf49ca960..425ee24312 100644 --- a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt +++ b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt @@ -15,6 +15,7 @@ import net.corda.core.internal.div import net.corda.core.internal.x500Name import net.corda.core.utilities.seconds import net.corda.node.NodeRegistrationOption +import net.corda.node.VersionInfo import net.corda.node.services.config.NodeConfiguration import net.corda.nodeapi.internal.DevIdentityGenerator import net.corda.nodeapi.internal.crypto.CertificateAndKeyPair diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index 28719e5128..c5261b496d 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -23,6 +23,7 @@ import net.corda.core.utilities.contextLogger import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.millis import net.corda.node.NodeRegistrationOption +import net.corda.node.VersionInfo import net.corda.node.internal.ConfigurationException import net.corda.node.internal.Node import net.corda.node.internal.StartedNode @@ -253,6 +254,7 @@ class DriverDSLImpl( "devMode" to false) )) + val versionInfo = VersionInfo(1, "1", "1", "1") config.corda.certificatesDirectory.createDirectories() // Create network root truststore. val rootTruststorePath = config.corda.certificatesDirectory / "network-root-truststore.jks" @@ -266,7 +268,7 @@ class DriverDSLImpl( executorService.fork { NodeRegistrationHelper( config.corda, - HTTPNetworkRegistrationService(compatibilityZoneURL), + HTTPNetworkRegistrationService(compatibilityZoneURL, versionInfo), NodeRegistrationOption(rootTruststorePath, rootTruststorePassword) ).buildKeystore() config From 20b89e06fa3808f5799b5c0d00fbc86c10298b29 Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Tue, 3 Jul 2018 09:41:48 +0100 Subject: [PATCH 3/4] Link is HTTP, not HTTPS (#3497) --- docs/source/node-administration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/node-administration.rst b/docs/source/node-administration.rst index 35b32545ad..690a339732 100644 --- a/docs/source/node-administration.rst +++ b/docs/source/node-administration.rst @@ -75,7 +75,7 @@ formats for accessing MBeans, and provides client libraries to work with that pr Here are a few ways to build dashboards and extract monitoring data for a node: -* `hawtio `_ is a web based console that connects directly to JVM's that have been instrumented with a +* `hawtio `_ is a web based console that connects directly to JVM's that have been instrumented with a jolokia agent. This tool provides a nice JMX dashboard very similar to the traditional JVisualVM / JConsole MBbeans original. * `JMX2Graphite `_ is a tool that can be pointed to /monitoring/json and will scrape the statistics found there, then insert them into the Graphite monitoring tool on a regular basis. It runs @@ -180,4 +180,4 @@ If the above holds, Corda components will benefit from the following: * Guaranteed eventual processing of acknowledged client messages, provided that the backlog of persistent queues is not lost irremediably. * A timely recovery from deletion or corruption of configuration files (e.g., ``node.conf``, ``node-info`` files, etc.), database drivers, CorDapps binaries and configuration, and certificate directories, provided backups are available to restore from. -.. warning:: Private keys used to sign transactions should be preserved with the utmost care. The recommendation is to keep at least two separate copies on a storage not connected to the Internet. \ No newline at end of file +.. warning:: Private keys used to sign transactions should be preserved with the utmost care. The recommendation is to keep at least two separate copies on a storage not connected to the Internet. From a5f43110f01c1bb116bb13274f1046204ee76e5f Mon Sep 17 00:00:00 2001 From: Christian Sailer Date: Tue, 3 Jul 2018 12:56:58 +0100 Subject: [PATCH 4/4] CORDA-1710 Swap order of Java and Kotlin examples in HTML docs (#3488) * Swap order of Java and Kotlin examples in HTML docs * Nicer comment * Put the hiding of kotlin examples back in the css file (so they start out hidden rather than being hidden when the JS runs - this could potentially make a difference with a large page over a slow connection) --- docs/source/_static/codesets.js | 8 +++++--- docs/source/_static/css/custom.css | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/source/_static/codesets.js b/docs/source/_static/codesets.js index af6444d502..c8dba38ee0 100644 --- a/docs/source/_static/codesets.js +++ b/docs/source/_static/codesets.js @@ -1,8 +1,8 @@ $(document).ready(function() { $(".codeset").each(function(index, el) { - var c = $("
KotlinJava
"); - var kotlinButton = c.children()[0]; - var javaButton = c.children()[1]; + var c = $("
JavaKotlin
"); + var javaButton = c.children()[0]; + var kotlinButton = c.children()[1]; kotlinButton.onclick = function() { $(el).children(".highlight-java")[0].style.display = "none"; $(el).children(".highlight-kotlin")[0].style.display = "block"; @@ -19,6 +19,8 @@ $(document).ready(function() { if ($(el).children(".highlight-java").length == 0) { // No Java for this example. javaButton.style.display = "none"; + // In this case, display Kotlin by default + $(el).children(".highlight-kotlin")[0].style.display = "block"; } c.insertBefore(el); }); diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css index db3532e97b..613bbdec06 100644 --- a/docs/source/_static/css/custom.css +++ b/docs/source/_static/css/custom.css @@ -122,7 +122,7 @@ a:visited { background: #263673; } -.codeset > .highlight-java { +.codeset > .highlight-kotlin { display: none; }