diff --git a/.ci/api-current.txt b/.ci/api-current.txt index 2b5b9d7bda..9b0c4dcb3c 100644 --- a/.ci/api-current.txt +++ b/.ci/api-current.txt @@ -6527,27 +6527,22 @@ public static final class net.corda.client.rpc.CordaRPCClient$Companion extends @NotNull public final net.corda.client.rpc.CordaRPCClient createWithSsl(net.corda.core.utilities.NetworkHostAndPort, net.corda.core.messaging.ClientRpcSslOptions, net.corda.client.rpc.CordaRPCClientConfiguration) ## -public interface net.corda.client.rpc.CordaRPCClientConfiguration - public abstract int getCacheConcurrencyLevel() +public class net.corda.client.rpc.CordaRPCClientConfiguration extends java.lang.Object + public (java.time.Duration) @NotNull - public abstract java.time.Duration getConnectionMaxRetryInterval() + public final java.time.Duration component1() @NotNull - public abstract java.time.Duration getConnectionRetryInterval() - public abstract double getConnectionRetryIntervalMultiplier() + public final net.corda.client.rpc.CordaRPCClientConfiguration copy(java.time.Duration) + public boolean equals(Object) @NotNull - public abstract java.time.Duration getDeduplicationCacheExpiry() - public abstract int getMaxFileSize() - public abstract int getMaxReconnectAttempts() - public abstract int getMinimumServerProtocolVersion() - public abstract int getObservationExecutorPoolSize() - @NotNull - public abstract java.time.Duration getReapInterval() - public abstract boolean getTrackRpcCallSites() + public java.time.Duration getConnectionMaxRetryInterval() + public int hashCode() + public String toString() public static final net.corda.client.rpc.CordaRPCClientConfiguration$Companion Companion + @NotNull + public static final net.corda.client.rpc.CordaRPCClientConfiguration DEFAULT ## public static final class net.corda.client.rpc.CordaRPCClientConfiguration$Companion extends java.lang.Object - @NotNull - public final net.corda.client.rpc.CordaRPCClientConfiguration default() ## @DoNotImplement public final class net.corda.client.rpc.CordaRPCConnection extends java.lang.Object implements net.corda.client.rpc.RPCConnection diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt index 0ab4ed96df..b7d2d0b944 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt @@ -81,7 +81,7 @@ class NodeMonitorModel { // Only execute using "runLater()" if JavaFX been initialized. // It may not be initialized in the unit test. // Also if we are already in the JavaFX thread - perform direct invocation without postponing it. - if(initialized.value.get() && !Platform.isFxApplicationThread()) { + if (initialized.value.get() && !Platform.isFxApplicationThread()) { Platform.runLater(op) } else { op() @@ -108,7 +108,7 @@ class NodeMonitorModel { // Proxy may change during re-connect, ensure that subject wiring accurately reacts to this activity. proxyObservable.addListener { _, _, wrapper -> - if(wrapper != null) { + if (wrapper != null) { val proxy = wrapper.cordaRPCOps // Vault snapshot (force single page load with MAX_PAGE_SIZE) + updates val (statesSnapshot, vaultUpdates) = proxy.vaultTrackBy(QueryCriteria.VaultQueryCriteria(Vault.StateStatus.ALL), @@ -144,7 +144,8 @@ class NodeMonitorModel { } val futureProgressTrackerUpdates = stateMachineUpdatesSubject.map { stateMachineUpdate -> if (stateMachineUpdate is StateMachineUpdate.Added) { - ProgressTrackingEvent.createStreamFromStateMachineInfo(stateMachineUpdate.stateMachineInfo) ?: Observable.empty() + ProgressTrackingEvent.createStreamFromStateMachineInfo(stateMachineUpdate.stateMachineInfo) + ?: Observable.empty() } else { Observable.empty() } @@ -193,29 +194,28 @@ class NodeMonitorModel { logger.info("Connecting to: $nodeHostAndPort") val client = CordaRPCClient( nodeHostAndPort, - object : CordaRPCClientConfiguration { - override val connectionMaxRetryInterval = retryInterval - } + CordaRPCClientConfiguration.DEFAULT.copy( + connectionMaxRetryInterval = retryInterval + ) ) val _connection = client.start(username, password) // Check connection is truly operational before returning it. val nodeInfo = _connection.proxy.nodeInfo() require(nodeInfo.legalIdentitiesAndCerts.isNotEmpty()) _connection - } catch(secEx: ActiveMQException) { + } catch (secEx: ActiveMQException) { // Happens when: // * incorrect credentials provided; // * incorrect endpoint specified; // - no point to retry connecting. throw secEx - } - catch(th: Throwable) { + } catch (th: Throwable) { // Deliberately not logging full stack trace as it will be full of internal stacktraces. logger.info("Exception upon establishing connection: " + th.message) null } - if(connection != null) { + if (connection != null) { logger.info("Connection successfully established with: $nodeHostAndPort") return connection } diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt index 4a1115dc0c..36926ac661 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/CordaRPCClientTest.kt @@ -70,9 +70,9 @@ class CordaRPCClientTest : NodeBasedTest(listOf("net.corda.finance.contracts", C override fun setUp() { super.setUp() node = startNode(ALICE_NAME, rpcUsers = listOf(rpcUser)) - client = CordaRPCClient(node.internals.configuration.rpcOptions.address!!, object : CordaRPCClientConfiguration { - override val maxReconnectAttempts = 5 - }) + client = CordaRPCClient(node.internals.configuration.rpcOptions.address!!, CordaRPCClientConfiguration.DEFAULT.copy( + maxReconnectAttempts = 5 + )) identity = node.info.identityFromX500Name(ALICE_NAME) } diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt index d80bd46c7d..41c1a8f6c0 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt @@ -11,7 +11,6 @@ package net.corda.client.rpc import net.corda.client.rpc.internal.RPCClient -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl import net.corda.core.context.Trace import net.corda.core.crypto.random63BitValue import net.corda.core.internal.concurrent.fork @@ -116,7 +115,7 @@ class RPCStabilityTests { Try.on { startRpcClient( server.get().broker.hostAndPort!!, - configuration = CordaRPCClientConfigurationImpl.default.copy(minimumServerProtocolVersion = 1) + configuration = CordaRPCClientConfiguration.DEFAULT.copy(minimumServerProtocolVersion = 1) ).get() } } @@ -139,7 +138,7 @@ class RPCStabilityTests { rpcDriver { fun startAndCloseServer(broker: RpcBrokerHandle) { startRpcServerWithBrokerRunning( - configuration = RPCServerConfiguration.default, + configuration = RPCServerConfiguration.DEFAULT, ops = DummyOps, brokerHandle = broker ).rpcServer.close() @@ -160,7 +159,7 @@ class RPCStabilityTests { @Test fun `rpc client close doesnt leak broker resources`() { rpcDriver { - val server = startRpcServer(configuration = RPCServerConfiguration.default, ops = DummyOps).get() + val server = startRpcServer(configuration = RPCServerConfiguration.DEFAULT, ops = DummyOps).get() RPCClient(server.broker.hostAndPort!!).start(RPCOps::class.java, rpcTestUser.username, rpcTestUser.password).close() val initial = server.broker.getStats() repeat(100) { @@ -251,7 +250,7 @@ class RPCStabilityTests { val serverPort = startRpcServer(ops = ops).getOrThrow().broker.hostAndPort!! serverFollower.unfollow() // Set retry interval to 1s to reduce test duration - val clientConfiguration = CordaRPCClientConfigurationImpl.default.copy(connectionRetryInterval = 1.seconds) + val clientConfiguration = CordaRPCClientConfiguration.DEFAULT.copy(connectionRetryInterval = 1.seconds) val clientFollower = shutdownManager.follower() val client = startRpcClient(serverPort, configuration = clientConfiguration).getOrThrow() clientFollower.unfollow() @@ -276,7 +275,7 @@ class RPCStabilityTests { val serverPort = startRpcServer(ops = ops).getOrThrow().broker.hostAndPort!! serverFollower.unfollow() // Set retry interval to 1s to reduce test duration - val clientConfiguration = CordaRPCClientConfigurationImpl.default.copy(connectionRetryInterval = 1.seconds, maxReconnectAttempts = 5) + val clientConfiguration = CordaRPCClientConfiguration.DEFAULT.copy(connectionRetryInterval = 1.seconds, maxReconnectAttempts = 5) val clientFollower = shutdownManager.follower() val client = startRpcClient(serverPort, configuration = clientConfiguration).getOrThrow() clientFollower.unfollow() @@ -308,7 +307,7 @@ class RPCStabilityTests { val serverPort = startRpcServer(ops = ops).getOrThrow().broker.hostAndPort!! serverFollower.unfollow() - val clientConfiguration = CordaRPCClientConfigurationImpl.default.copy(connectionRetryInterval = 500.millis, maxReconnectAttempts = 1) + val clientConfiguration = CordaRPCClientConfiguration.DEFAULT.copy(connectionRetryInterval = 500.millis, maxReconnectAttempts = 1) val clientFollower = shutdownManager.follower() val client = startRpcClient(serverPort, configuration = clientConfiguration).getOrThrow() clientFollower.unfollow() @@ -463,7 +462,7 @@ class RPCStabilityTests { } } val server = startRpcServer( - configuration = RPCServerConfiguration.default.copy( + configuration = RPCServerConfiguration.DEFAULT.copy( reapInterval = 100.millis ), ops = trackSubscriberOpsImpl diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt index 564b373c4d..76ff61a512 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt @@ -10,7 +10,6 @@ package net.corda.client.rpc -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl import net.corda.client.rpc.internal.RPCClient import net.corda.client.rpc.internal.serialization.amqp.AMQPClientSerializationScheme import net.corda.core.context.Actor @@ -20,6 +19,9 @@ import net.corda.core.serialization.internal.effectiveSerializationEnv import net.corda.core.utilities.NetworkHostAndPort import net.corda.nodeapi.ArtemisTcpTransport.Companion.rpcConnectorTcpTransport import net.corda.core.messaging.ClientRpcSslOptions +import net.corda.core.utilities.days +import net.corda.core.utilities.minutes +import net.corda.core.utilities.seconds import net.corda.nodeapi.internal.config.SSLConfiguration import net.corda.serialization.internal.AMQP_RPC_CLIENT_CONTEXT import java.time.Duration @@ -34,46 +36,163 @@ class CordaRPCConnection internal constructor(connection: RPCConnection + */ + open val maxReconnectAttempts: Int = unlimitedReconnectAttempts, + + /** + * Maximum file size, in bytes. + */ + open val maxFileSize: Int = 10485760, + // 10 MiB maximum allowed file size for attachments, including message headers. + // TODO: acquire this value from Network Map when supported. + + /** + * The cache expiry of a deduplication watermark per client. + */ + open val deduplicationCacheExpiry: Duration = 1.days + +) { companion object { - fun default(): CordaRPCClientConfiguration = CordaRPCClientConfigurationImpl.default + + private const val unlimitedReconnectAttempts = -1 + + @JvmField + val DEFAULT: CordaRPCClientConfiguration = CordaRPCClientConfiguration() + } + + /** + * Create a new copy of a configuration object with zero or more parameters modified. + */ + @JvmOverloads + fun copy( + connectionMaxRetryInterval: Duration = this.connectionMaxRetryInterval, + minimumServerProtocolVersion: Int = this.minimumServerProtocolVersion, + trackRpcCallSites: Boolean = this.trackRpcCallSites, + reapInterval: Duration = this.reapInterval, + observationExecutorPoolSize: Int = this.observationExecutorPoolSize, + cacheConcurrencyLevel: Int = this.cacheConcurrencyLevel, + connectionRetryInterval: Duration = this.connectionRetryInterval, + connectionRetryIntervalMultiplier: Double = this.connectionRetryIntervalMultiplier, + maxReconnectAttempts: Int = this.maxReconnectAttempts, + maxFileSize: Int = this.maxFileSize, + deduplicationCacheExpiry: Duration = this.deduplicationCacheExpiry + ): CordaRPCClientConfiguration { + return CordaRPCClientConfiguration( + connectionMaxRetryInterval, + minimumServerProtocolVersion, + trackRpcCallSites, + reapInterval, + observationExecutorPoolSize, + cacheConcurrencyLevel, + connectionRetryInterval, + connectionRetryIntervalMultiplier, + maxReconnectAttempts, + maxFileSize, + deduplicationCacheExpiry + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as CordaRPCClientConfiguration + if (connectionMaxRetryInterval != other.connectionMaxRetryInterval) return false + if (minimumServerProtocolVersion != other.minimumServerProtocolVersion) return false + if (trackRpcCallSites != other.trackRpcCallSites) return false + if (reapInterval != other.reapInterval) return false + if (observationExecutorPoolSize != other.observationExecutorPoolSize) return false + if (cacheConcurrencyLevel != other.cacheConcurrencyLevel) return false + if (connectionRetryInterval != other.connectionRetryInterval) return false + if (connectionRetryIntervalMultiplier != other.connectionRetryIntervalMultiplier) return false + if (maxReconnectAttempts != other.maxReconnectAttempts) return false + if (maxFileSize != other.maxFileSize) return false + if (deduplicationCacheExpiry != other.deduplicationCacheExpiry) return false + + return true + } + + override fun hashCode(): Int { + var result = minimumServerProtocolVersion + result = 31 * result + connectionMaxRetryInterval.hashCode() + result = 31 * result + trackRpcCallSites.hashCode() + result = 31 * result + reapInterval.hashCode() + result = 31 * result + observationExecutorPoolSize + result = 31 * result + cacheConcurrencyLevel + result = 31 * result + connectionRetryInterval.hashCode() + result = 31 * result + connectionRetryIntervalMultiplier.hashCode() + result = 31 * result + maxReconnectAttempts + result = 31 * result + maxFileSize + result = 31 * result + deduplicationCacheExpiry.hashCode() + return result + } + + override fun toString(): String { + return "CordaRPCClientConfiguration(" + + "connectionMaxRetryInterval=$connectionMaxRetryInterval, " + + "minimumServerProtocolVersion=$minimumServerProtocolVersion, trackRpcCallSites=$trackRpcCallSites, " + + "reapInterval=$reapInterval, observationExecutorPoolSize=$observationExecutorPoolSize, " + + "cacheConcurrencyLevel=$cacheConcurrencyLevel, connectionRetryInterval=$connectionRetryInterval, " + + "connectionRetryIntervalMultiplier=$connectionRetryIntervalMultiplier, " + + "maxReconnectAttempts=$maxReconnectAttempts, maxFileSize=$maxFileSize, " + + "deduplicationCacheExpiry=$deduplicationCacheExpiry)" + } + + // Left is for backwards compatibility with version 3.1 + operator fun component1() = connectionMaxRetryInterval + } /** @@ -115,7 +234,7 @@ interface CordaRPCClientConfiguration { */ class CordaRPCClient private constructor( private val hostAndPort: NetworkHostAndPort, - private val configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + private val configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, private val sslConfiguration: ClientRpcSslOptions? = null, private val nodeSslConfiguration: SSLConfiguration? = null, private val classLoader: ClassLoader? = null, @@ -124,7 +243,7 @@ class CordaRPCClient private constructor( ) { @JvmOverloads constructor(hostAndPort: NetworkHostAndPort, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default()) + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT) : this(hostAndPort, configuration, null) /** @@ -134,13 +253,13 @@ class CordaRPCClient private constructor( * @param configuration An optional configuration used to tweak client behaviour. */ @JvmOverloads - constructor(haAddressPool: List, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default()) : this(haAddressPool.first(), configuration, null, null, null, haAddressPool) + constructor(haAddressPool: List, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT) : this(haAddressPool.first(), configuration, null, null, null, haAddressPool) companion object { fun createWithSsl( hostAndPort: NetworkHostAndPort, sslConfiguration: ClientRpcSslOptions, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default() + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ): CordaRPCClient { return CordaRPCClient(hostAndPort, configuration, sslConfiguration) } @@ -148,14 +267,14 @@ class CordaRPCClient private constructor( fun createWithSsl( haAddressPool: List, sslConfiguration: ClientRpcSslOptions, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default() + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ): CordaRPCClient { return CordaRPCClient(haAddressPool.first(), configuration, sslConfiguration, haAddressPool = haAddressPool) } internal fun createWithSslAndClassLoader( hostAndPort: NetworkHostAndPort, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: ClientRpcSslOptions? = null, classLoader: ClassLoader? = null ): CordaRPCClient { @@ -164,7 +283,7 @@ class CordaRPCClient private constructor( internal fun createWithInternalSslAndClassLoader( hostAndPort: NetworkHostAndPort, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: SSLConfiguration?, classLoader: ClassLoader? = null ): CordaRPCClient { @@ -173,7 +292,7 @@ class CordaRPCClient private constructor( internal fun createWithSslAndClassLoader( haAddressPool: List, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: ClientRpcSslOptions? = null, classLoader: ClassLoader? = null ): CordaRPCClient { diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/CordaRPCClientUtils.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/CordaRPCClientUtils.kt index a7b8006071..cc2e38be87 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/CordaRPCClientUtils.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/CordaRPCClientUtils.kt @@ -22,21 +22,21 @@ import rx.Observable /** Utility which exposes the internal Corda RPC constructor to other internal Corda components */ fun createCordaRPCClientWithSslAndClassLoader( hostAndPort: NetworkHostAndPort, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: ClientRpcSslOptions? = null, classLoader: ClassLoader? = null ) = CordaRPCClient.createWithSslAndClassLoader(hostAndPort, configuration, sslConfiguration, classLoader) fun createCordaRPCClientWithInternalSslAndClassLoader( hostAndPort: NetworkHostAndPort, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: SSLConfiguration? = null, classLoader: ClassLoader? = null ) = CordaRPCClient.createWithInternalSslAndClassLoader(hostAndPort, configuration, sslConfiguration, classLoader) fun createCordaRPCClientWithSslAndClassLoader( haAddressPool: List, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.default(), + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: ClientRpcSslOptions? = null, classLoader: ClassLoader? = null ) = CordaRPCClient.createWithSslAndClassLoader(haAddressPool, configuration, sslConfiguration, classLoader) diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt index 37673b7e5e..794c16c045 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClient.kt @@ -33,69 +33,34 @@ import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.TransportConfiguration import org.apache.activemq.artemis.api.core.client.ActiveMQClient import java.lang.reflect.Proxy -import java.time.Duration - -/** - * This configuration may be used to tweak the internals of the RPC client. - */ -data class CordaRPCClientConfigurationImpl( - override val minimumServerProtocolVersion: Int, - override val trackRpcCallSites: Boolean, - override val reapInterval: Duration, - override val observationExecutorPoolSize: Int, - override val connectionRetryInterval: Duration, - override val connectionRetryIntervalMultiplier: Double, - override val connectionMaxRetryInterval: Duration, - override val maxReconnectAttempts: Int, - override val maxFileSize: Int, - override val deduplicationCacheExpiry: Duration -) : CordaRPCClientConfiguration { - companion object { - private const val unlimitedReconnectAttempts = -1 - @JvmStatic - val default = CordaRPCClientConfigurationImpl( - minimumServerProtocolVersion = 0, - trackRpcCallSites = false, - reapInterval = 1.seconds, - observationExecutorPoolSize = 4, - connectionRetryInterval = 5.seconds, - connectionRetryIntervalMultiplier = 1.5, - connectionMaxRetryInterval = 3.minutes, - maxReconnectAttempts = unlimitedReconnectAttempts, - /** 10 MiB maximum allowed file size for attachments, including message headers. TODO: acquire this value from Network Map when supported. */ - maxFileSize = 10485760, - deduplicationCacheExpiry = 1.days - ) - } -} /** * This runs on the client JVM */ class RPCClient( val transport: TransportConfiguration, - val rpcConfiguration: CordaRPCClientConfiguration = CordaRPCClientConfigurationImpl.default, + val rpcConfiguration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, val serializationContext: SerializationContext = SerializationDefaults.RPC_CLIENT_CONTEXT, val haPoolTransportConfigurations: List = emptyList() ) { constructor( hostAndPort: NetworkHostAndPort, sslConfiguration: ClientRpcSslOptions? = null, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfigurationImpl.default, + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, serializationContext: SerializationContext = SerializationDefaults.RPC_CLIENT_CONTEXT ) : this(rpcConnectorTcpTransport(hostAndPort, sslConfiguration), configuration, serializationContext) constructor( hostAndPort: NetworkHostAndPort, sslConfiguration: SSLConfiguration, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfigurationImpl.default, + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, serializationContext: SerializationContext = SerializationDefaults.RPC_CLIENT_CONTEXT ) : this(rpcInternalClientTcpTransport(hostAndPort, sslConfiguration), configuration, serializationContext) constructor( haAddressPool: List, sslConfiguration: ClientRpcSslOptions? = null, - configuration: CordaRPCClientConfiguration = CordaRPCClientConfigurationImpl.default, + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, serializationContext: SerializationContext = SerializationDefaults.RPC_CLIENT_CONTEXT ) : this(rpcConnectorTcpTransport(haAddressPool.first(), sslConfiguration), configuration, serializationContext, rpcConnectorTcpTransportsFromList(haAddressPool, sslConfiguration)) diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/AbstractRPCTest.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/AbstractRPCTest.kt index d4c4025e72..c2c8fba105 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/AbstractRPCTest.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/AbstractRPCTest.kt @@ -10,7 +10,6 @@ package net.corda.client.rpc -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl import net.corda.core.internal.concurrent.flatMap import net.corda.core.internal.concurrent.map import net.corda.core.messaging.RPCOps @@ -54,8 +53,8 @@ open class AbstractRPCTest { inline fun RPCDriverDSL.testProxy( ops: I, rpcUser: User = rpcTestUser, - clientConfiguration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default, - serverConfiguration: RPCServerConfiguration = RPCServerConfiguration.default + clientConfiguration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, + serverConfiguration: RPCServerConfiguration = RPCServerConfiguration.DEFAULT ): TestProxy { return when (mode) { RPCTestMode.InVm -> diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCConcurrencyTests.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCConcurrencyTests.kt index 72f2cb29a1..4d63625780 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCConcurrencyTests.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCConcurrencyTests.kt @@ -10,7 +10,6 @@ package net.corda.client.rpc -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl import net.corda.core.crypto.random63BitValue import net.corda.core.internal.concurrent.fork import net.corda.core.internal.concurrent.transpose @@ -100,10 +99,10 @@ class RPCConcurrencyTests : AbstractRPCTest() { private fun RPCDriverDSL.testProxy(): TestProxy { return testProxy( TestOpsImpl(pool), - clientConfiguration = CordaRPCClientConfigurationImpl.default.copy( + clientConfiguration = CordaRPCClientConfiguration.DEFAULT.copy( reapInterval = 100.millis ), - serverConfiguration = RPCServerConfiguration.default.copy( + serverConfiguration = RPCServerConfiguration.DEFAULT.copy( rpcThreadPoolSize = 4 ) ) diff --git a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt index 0ceb8740e5..fc372c7b6b 100644 --- a/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt +++ b/client/rpc/src/test/kotlin/net/corda/client/rpc/RPCPerformanceTests.kt @@ -11,7 +11,6 @@ package net.corda.client.rpc import com.google.common.base.Stopwatch -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl import net.corda.core.internal.concurrent.doneFuture import net.corda.core.messaging.RPCOps import net.corda.core.utilities.minutes @@ -53,7 +52,7 @@ class RPCPerformanceTests : AbstractRPCTest() { } private fun RPCDriverDSL.testProxy( - clientConfiguration: CordaRPCClientConfigurationImpl, + clientConfiguration: CordaRPCClientConfiguration, serverConfiguration: RPCServerConfiguration ): TestProxy { return testProxy( @@ -66,8 +65,8 @@ class RPCPerformanceTests : AbstractRPCTest() { private fun warmup() { rpcDriver { val proxy = testProxy( - CordaRPCClientConfigurationImpl.default, - RPCServerConfiguration.default + CordaRPCClientConfiguration.DEFAULT, + RPCServerConfiguration.DEFAULT ) val executor = Executors.newFixedThreadPool(4) val N = 10000 @@ -96,10 +95,10 @@ class RPCPerformanceTests : AbstractRPCTest() { measure(inputOutputSizes, (1..5)) { inputOutputSize, _ -> rpcDriver { val proxy = testProxy( - CordaRPCClientConfigurationImpl.default.copy( + CordaRPCClientConfiguration.DEFAULT.copy( observationExecutorPoolSize = 2 ), - RPCServerConfiguration.default.copy( + RPCServerConfiguration.DEFAULT.copy( rpcThreadPoolSize = 8 ) ) @@ -135,10 +134,10 @@ class RPCPerformanceTests : AbstractRPCTest() { rpcDriver { val metricRegistry = startReporter(shutdownManager) val proxy = testProxy( - CordaRPCClientConfigurationImpl.default.copy( + CordaRPCClientConfiguration.DEFAULT.copy( reapInterval = 1.seconds ), - RPCServerConfiguration.default.copy( + RPCServerConfiguration.DEFAULT.copy( rpcThreadPoolSize = 8 ) ) @@ -168,8 +167,8 @@ class RPCPerformanceTests : AbstractRPCTest() { // TODO this hangs with more parallelism rpcDriver { val proxy = testProxy( - CordaRPCClientConfigurationImpl.default, - RPCServerConfiguration.default + CordaRPCClientConfiguration.DEFAULT, + RPCServerConfiguration.DEFAULT ) val numberOfMessages = 1000 val bigSize = 10_000_000 diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index d564e95efc..d5293646e9 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -8,6 +8,11 @@ Unreleased ========== * Introduced a hierarchy of ``DatabaseMigrationException``s, allowing ``NodeStartup`` to gracefully inform users of problems related to database migrations before exiting with a non-zero code. +* H2 database changes: + * The node's H2 database now listens on ``localhost`` by default. + * The database server address must also be enabled in the node configuration. + * A new ``h2Settings`` configuration block supercedes the ``h2Port`` option. + * Improved documentation PDF quality. Building the documentation now requires ``LaTex`` to be installed on the OS. * Add ``devModeOptions.allowCompatibilityZone`` to re-enable the use of a compatibility zone and ``devMode`` @@ -48,6 +53,8 @@ Unreleased * The node's configuration is only printed on startup if ``devMode`` is ``true``, avoiding the risk of printing passwords in a production setup. +* ``NodeStartup`` will now only print node's configuration if ``devMode`` is ``true``, avoiding the risk of printing passwords in a production setup. + * SLF4J's MDC will now only be printed to the console if not empty. No more log lines ending with "{}". * ``WireTransaction.Companion.createComponentGroups`` has been marked as ``@CordaInternal``. It was never intended to be diff --git a/docs/source/generating-a-node.rst b/docs/source/generating-a-node.rst index 59a9b1e1e5..ea189a1870 100644 --- a/docs/source/generating-a-node.rst +++ b/docs/source/generating-a-node.rst @@ -143,8 +143,26 @@ The webserver JAR will be copied into the node's ``build`` folder with the name The Dockerform task ------------------- -The ``Dockerform`` is a sister task of ``Cordform``. It has nearly the same syntax and produces very -similar results - enhanced by an extra file to enable easy spin up of nodes using ``docker-compose``. +The ``Dockerform`` is a sister task of ``Cordform`` that provides an extra file allowing you to easily spin up +nodes using ``docker-compose``. It supports the following configuration options for each node: + +* ``name`` +* ``notary`` +* ``cordapps`` +* ``rpcUsers`` +* ``useTestClock`` + +There is no need to specify the nodes' ports, as every node has a separate container, so no ports conflict will occur. +Every node will expose port ``10003`` for RPC connections. + +The nodes' webservers will not be started. Instead, you should interact with each node via its shell over SSH +(see the :doc:`node configuration options `). You have to enable the shell by adding the +following line to each node's ``node.conf`` file: + + ``sshd { port = 2222 }`` + +Where ``2222`` is the port you want to open to SSH into the shell. + Below you can find the example task from the `IRS Demo `_ included in the samples directory of main Corda GitHub repository: .. sourcecode:: groovy @@ -194,13 +212,6 @@ Below you can find the example task from the `IRS Demo `_, unzip the zip, and navigate in a terminal window to the unzipped folder * Change directories to the bin folder: ``cd h2/bin`` @@ -25,6 +32,10 @@ stored states, transactions and attachments as follows: You will be presented with a web interface that shows the contents of your node's storage and vault, and provides an interface for you to query them using SQL. +The default behaviour is to expose the H2 database on localhost. This can be overridden in the +node configuration using ``h2Settings.address`` and specifying the address of the network interface to listen on, +or simply using ``0.0.0.0:0`` to listen on all interfaces. + .. _standalone_database_config_examples_ref: Standalone database diff --git a/experimental/behave/src/main/kotlin/net/corda/behave/node/Node.kt b/experimental/behave/src/main/kotlin/net/corda/behave/node/Node.kt index 8d48eb85f2..f322d89d47 100644 --- a/experimental/behave/src/main/kotlin/net/corda/behave/node/Node.kt +++ b/experimental/behave/src/main/kotlin/net/corda/behave/node/Node.kt @@ -200,9 +200,9 @@ class Node( val user = config.users.first() val address = config.nodeInterface val targetHost = NetworkHostAndPort(address.host, address.rpcPort) - val config = object : CordaRPCClientConfiguration { - override val connectionMaxRetryInterval = 10.seconds - } + val config = CordaRPCClientConfiguration.DEFAULT.copy( + connectionMaxRetryInterval = 10.seconds + ) log.info("Establishing RPC connection to ${targetHost.host} on port ${targetHost.port} ...") CordaRPCClient(targetHost, config).use(user.username, user.password) { log.info("RPC connection to ${targetHost.host}:${targetHost.port} established") diff --git a/experimental/ha-testing/src/main/kotlin/net/corda/haTesting/AbstractScenarioRunner.kt b/experimental/ha-testing/src/main/kotlin/net/corda/haTesting/AbstractScenarioRunner.kt index 609f91eede..493839e7e0 100644 --- a/experimental/ha-testing/src/main/kotlin/net/corda/haTesting/AbstractScenarioRunner.kt +++ b/experimental/ha-testing/src/main/kotlin/net/corda/haTesting/AbstractScenarioRunner.kt @@ -24,9 +24,9 @@ abstract class AbstractScenarioRunner(options: OptionSet) { val retryInterval = 5.seconds val client = CordaRPCClient(endpoint, - object : CordaRPCClientConfiguration { - override val connectionMaxRetryInterval = retryInterval - } + CordaRPCClientConfiguration.DEFAULT.copy( + connectionMaxRetryInterval = retryInterval + ) ) val connection = client.start(user, password) return connection.proxy diff --git a/node/src/main/kotlin/net/corda/node/internal/Node.kt b/node/src/main/kotlin/net/corda/node/internal/Node.kt index 5ec33cd2d2..e53a54069a 100644 --- a/node/src/main/kotlin/net/corda/node/internal/Node.kt +++ b/node/src/main/kotlin/net/corda/node/internal/Node.kt @@ -224,7 +224,7 @@ open class Node(configuration: NodeConfiguration, printBasicNodeInfo("Advertised P2P messaging addresses", info.addresses.joinToString()) - val rpcServerConfiguration = RPCServerConfiguration.default.copy( + val rpcServerConfiguration = RPCServerConfiguration.DEFAULT.copy( rpcThreadPoolSize = configuration.enterpriseConfiguration.tuning.rpcThreadPoolSize ) rpcServerAddresses?.let { @@ -362,15 +362,19 @@ open class Node(configuration: NodeConfiguration, wellKnownPartyFromAnonymous: (AbstractParty) -> Party?): CordaPersistence { val databaseUrl = configuration.dataSourceProperties.getProperty("dataSource.url") val h2Prefix = "jdbc:h2:file:" + if (databaseUrl != null && databaseUrl.startsWith(h2Prefix)) { - val h2Port = databaseUrl.substringAfter(";AUTO_SERVER_PORT=", "").substringBefore(';') - if (h2Port.isNotBlank()) { + val effectiveH2Settings = configuration.effectiveH2Settings + + if(effectiveH2Settings != null && effectiveH2Settings.address != null) { val databaseName = databaseUrl.removePrefix(h2Prefix).substringBefore(';') val server = org.h2.tools.Server.createTcpServer( - "-tcpPort", h2Port, + "-tcpPort", effectiveH2Settings.address.port.toString(), "-tcpAllowOthers", "-tcpDaemon", "-key", "node", databaseName) + // override interface that createTcpServer listens on (which is always 0.0.0.0) + System.setProperty("h2.bindAddress", effectiveH2Settings.address.host) runOnStop += server::stop val url = server.start().url printBasicNodeInfo("Database connection url is", "jdbc:h2:$url/node") diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt index db90db75d7..b207671020 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt @@ -76,7 +76,7 @@ interface NodeConfiguration : NodeSSLConfiguration { val extraNetworkMapKeys: List val tlsCertCrlDistPoint: URL? val tlsCertCrlIssuer: String? - + val effectiveH2Settings: NodeH2Settings? fun validate(): List companion object { @@ -249,12 +249,14 @@ data class NodeConfigurationImpl( override val graphiteOptions: GraphiteOptions? = null, override val extraNetworkMapKeys: List = emptyList(), // do not use or remove (breaks DemoBench together with rejection of unknown configuration keys during parsing) - private val h2port: Int = 0, + private val h2port: Int? = null, + private val h2Settings: NodeH2Settings? = null, // do not use or remove (used by Capsule) private val jarDirs: List = emptyList() ) : NodeConfiguration { companion object { private val logger = loggerFor() + } override val rpcOptions: NodeRpcOptions = initialiseRpcOptions(rpcAddress, rpcSettings, BrokerRpcSslOptions(baseDirectory / "certificates" / "nodekeystore.jks", keyStorePassword)) @@ -274,6 +276,7 @@ data class NodeConfigurationImpl( }.asOptions(fallbackSslOptions) } + private fun validateTlsCertCrlConfig(): List { val errors = mutableListOf() if (tlsCertCrlIssuer != null) { @@ -298,6 +301,15 @@ data class NodeConfigurationImpl( errors += validateRpcOptions(rpcOptions) errors += validateTlsCertCrlConfig() errors += validateNetworkServices() + errors += validateH2Settings() + return errors + } + + private fun validateH2Settings(): List { + val errors = mutableListOf() + if (h2port != null && h2Settings != null) { + errors += "Cannot specify both 'h2port' and 'h2Settings' in configuration" + } return errors } @@ -345,6 +357,11 @@ data class NodeConfigurationImpl( override val attachmentContentCacheSizeBytes: Long get() = attachmentContentCacheSizeMegaBytes?.MB ?: super.attachmentContentCacheSizeBytes + override val effectiveH2Settings: NodeH2Settings? + get() = when { + h2port != null -> NodeH2Settings(address = NetworkHostAndPort(host="localhost", port=h2port)) + else -> h2Settings + } init { // This is a sanity feature do not remove. @@ -387,9 +404,12 @@ data class NodeConfigurationImpl( if (compatibilityZoneURL != null && networkServices == null) { networkServices = NetworkServicesConfig(compatibilityZoneURL, compatibilityZoneURL, true) } + require(h2port == null || h2Settings == null) { "Cannot specify both 'h2port' and 'h2Settings' in configuration" } } } + + data class NodeRpcSettings( val address: NetworkHostAndPort?, val adminAddress: NetworkHostAndPort?, @@ -412,6 +432,10 @@ data class NodeRpcSettings( } } +data class NodeH2Settings( + val address: NetworkHostAndPort? +) + enum class VerifierType { InMemory, OutOfProcess diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt index e9e9236b24..c8c5af0e21 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt @@ -81,7 +81,7 @@ data class RPCServerConfiguration( val deduplicationCacheExpiry: Duration ) { companion object { - val default = RPCServerConfiguration( + val DEFAULT = RPCServerConfiguration( rpcThreadPoolSize = 4, reapInterval = 1.seconds, deduplicationCacheExpiry = 1.days diff --git a/node/src/main/resources/reference.conf b/node/src/main/resources/reference.conf index f5c94d72e1..de036401ec 100644 --- a/node/src/main/resources/reference.conf +++ b/node/src/main/resources/reference.conf @@ -14,7 +14,7 @@ crlCheckSoftFail = true lazyBridgeStart = true dataSourceProperties = { dataSourceClassName = org.h2.jdbcx.JdbcDataSource - dataSource.url = "jdbc:h2:file:"${baseDirectory}"/persistence;DB_CLOSE_ON_EXIT=FALSE;WRITE_DELAY=0;LOCK_TIMEOUT=10000;AUTO_SERVER_PORT="${h2port} + dataSource.url = "jdbc:h2:file:"${baseDirectory}"/persistence;DB_CLOSE_ON_EXIT=FALSE;WRITE_DELAY=0;LOCK_TIMEOUT=10000" dataSource.user = sa dataSource.password = "" } @@ -22,7 +22,7 @@ database = { transactionIsolationLevel = "REPEATABLE_READ" exportHibernateJMXStatistics = "false" } -h2port = 0 + useTestClock = false verifierType = InMemory enterpriseConfiguration = { @@ -46,6 +46,6 @@ rpcSettings = { } flowTimeout { timeout = 30 seconds - maxRestartCount = 3 - backoffBase = 2.0 + maxRestartCount = 5 + backoffBase = 1.8 } diff --git a/node/src/test/kotlin/net/corda/node/services/rpc/ArtemisRpcTests.kt b/node/src/test/kotlin/net/corda/node/services/rpc/ArtemisRpcTests.kt index f690ee6ca5..903b3e6739 100644 --- a/node/src/test/kotlin/net/corda/node/services/rpc/ArtemisRpcTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/rpc/ArtemisRpcTests.kt @@ -115,7 +115,7 @@ class ArtemisRpcTests { } artemisBroker.use { broker -> broker.start() - InternalRPCMessagingClient(nodeSSlconfig, adminAddress, maxMessageSize, CordaX500Name("MegaCorp", "London", "GB"), RPCServerConfiguration.default).use { server -> + InternalRPCMessagingClient(nodeSSlconfig, adminAddress, maxMessageSize, CordaX500Name("MegaCorp", "London", "GB"), RPCServerConfiguration.DEFAULT).use { server -> server.start(TestRpcOpsImpl(), securityManager, broker.serverControl) val client = RPCClient(rpcConnectorTcpTransport(broker.addresses.primary, clientSslOptions)) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/RPCDriver.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/RPCDriver.kt index fde79971ab..894537d493 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/RPCDriver.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/RPCDriver.kt @@ -11,7 +11,7 @@ package net.corda.testing.node.internal import net.corda.client.mock.Generator -import net.corda.client.rpc.internal.CordaRPCClientConfigurationImpl +import net.corda.client.rpc.CordaRPCClientConfiguration import net.corda.client.rpc.internal.RPCClient import net.corda.client.rpc.internal.serialization.amqp.AMQPClientSerializationScheme import net.corda.core.concurrent.CordaFuture @@ -67,7 +67,7 @@ import net.corda.nodeapi.internal.config.User as InternalUser inline fun RPCDriverDSL.startInVmRpcClient( username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ) = startInVmRpcClient(I::class.java, username, password, configuration) inline fun RPCDriverDSL.startRandomRpcClient( @@ -80,14 +80,14 @@ inline fun RPCDriverDSL.startRpcClient( rpcAddress: NetworkHostAndPort, username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ) = startRpcClient(I::class.java, rpcAddress, username, password, configuration) inline fun RPCDriverDSL.startRpcClient( haAddressPool: List, username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ) = startRpcClient(I::class.java, haAddressPool, username, password, configuration) data class RpcBrokerHandle( @@ -249,7 +249,7 @@ data class RPCDriverDSL( nodeLegalName: CordaX500Name = fakeNodeLegalName, maxFileSize: Int = MAX_MESSAGE_SIZE, maxBufferedBytesPerClient: Long = 10L * MAX_MESSAGE_SIZE, - configuration: RPCServerConfiguration = RPCServerConfiguration.default, + configuration: RPCServerConfiguration = RPCServerConfiguration.DEFAULT, ops: I ): CordaFuture { return startInVmRpcBroker(rpcUser, maxFileSize, maxBufferedBytesPerClient).map { broker -> @@ -269,7 +269,7 @@ data class RPCDriverDSL( rpcOpsClass: Class, username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ): CordaFuture { return driverDSL.executorService.fork { val client = RPCClient(inVmClientTransportConfiguration, configuration) @@ -317,7 +317,7 @@ data class RPCDriverDSL( nodeLegalName: CordaX500Name = fakeNodeLegalName, maxFileSize: Int = MAX_MESSAGE_SIZE, maxBufferedBytesPerClient: Long = 10L * MAX_MESSAGE_SIZE, - configuration: RPCServerConfiguration = RPCServerConfiguration.default, + configuration: RPCServerConfiguration = RPCServerConfiguration.DEFAULT, customPort: NetworkHostAndPort? = null, ops: I ): CordaFuture { @@ -340,7 +340,7 @@ data class RPCDriverDSL( rpcAddress: NetworkHostAndPort, username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ): CordaFuture { return driverDSL.executorService.fork { val client = RPCClient(ArtemisTcpTransport.rpcConnectorTcpTransport(rpcAddress, null), configuration) @@ -366,7 +366,7 @@ data class RPCDriverDSL( haAddressPool: List, username: String = rpcTestUser.username, password: String = rpcTestUser.password, - configuration: CordaRPCClientConfigurationImpl = CordaRPCClientConfigurationImpl.default + configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT ): CordaFuture { return driverDSL.executorService.fork { val client = RPCClient(haAddressPool, null, configuration) @@ -472,7 +472,7 @@ data class RPCDriverDSL( fun startRpcServerWithBrokerRunning( rpcUser: User = rpcTestUser, nodeLegalName: CordaX500Name = fakeNodeLegalName, - configuration: RPCServerConfiguration = RPCServerConfiguration.default, + configuration: RPCServerConfiguration = RPCServerConfiguration.DEFAULT, ops: I, brokerHandle: RpcBrokerHandle ): RpcServerHandle { diff --git a/testing/qa/behave/tools/rpc-proxy/src/main/kotlin/net/corda/behave/service/proxy/RPCProxyWebService.kt b/testing/qa/behave/tools/rpc-proxy/src/main/kotlin/net/corda/behave/service/proxy/RPCProxyWebService.kt index d6c072430f..0ce061abab 100644 --- a/testing/qa/behave/tools/rpc-proxy/src/main/kotlin/net/corda/behave/service/proxy/RPCProxyWebService.kt +++ b/testing/qa/behave/tools/rpc-proxy/src/main/kotlin/net/corda/behave/service/proxy/RPCProxyWebService.kt @@ -134,9 +134,9 @@ class RPCProxyWebService(targetHostAndPort: NetworkHostAndPort) { private fun use(action: (CordaRPCOps) -> T): Response { val targetHost = NetworkHostAndPort("localhost", targetPort) - val config = object : CordaRPCClientConfiguration { - override val connectionMaxRetryInterval = 10.seconds - } + val config = CordaRPCClientConfiguration.DEFAULT.copy( + connectionMaxRetryInterval = 10.seconds + ) log.info("Establishing RPC connection to ${targetHost.host} on port ${targetHost.port} ...") return try { CordaRPCClient(targetHost, config).use("corda", DEFAULT_PASSWORD) { diff --git a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt index 8e48009d3d..75d5a37fa1 100644 --- a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt +++ b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt @@ -56,7 +56,6 @@ class NodeConfigTest { assertEquals(localPort(40002), fullConfig.rpcOptions.address) assertEquals(localPort(10001), fullConfig.p2pAddress) assertEquals(listOf(user("jenny")), fullConfig.rpcUsers) - assertThat(fullConfig.dataSourceProperties[DataSourceConfigTag.DATA_SOURCE_URL] as String).contains("AUTO_SERVER_PORT=30001") assertTrue(fullConfig.useTestClock) assertFalse(fullConfig.detectPublicIp) } diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt index 0c807c5ea5..09916ed81e 100644 --- a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt +++ b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt @@ -101,9 +101,9 @@ object InteractiveShell { fun startShell(configuration: ShellConfiguration, classLoader: ClassLoader? = null) { rpcOps = { username: String, credentials: String -> val client = createCordaRPCClientWithSslAndClassLoader(hostAndPort = configuration.hostAndPort, - configuration = object : CordaRPCClientConfiguration { - override val maxReconnectAttempts = 1 - }, + configuration = CordaRPCClientConfiguration.DEFAULT.copy( + maxReconnectAttempts = 1 + ), sslConfiguration = configuration.ssl, classLoader = classLoader) this.connection = client.start(username, credentials) @@ -119,9 +119,9 @@ object InteractiveShell { fun startShellInternal(configuration: ShellConfiguration, classLoader: ClassLoader? = null) { rpcOps = { username: String, credentials: String -> val client = createCordaRPCClientWithInternalSslAndClassLoader(hostAndPort = configuration.hostAndPort, - configuration = object : CordaRPCClientConfiguration { - override val maxReconnectAttempts = 1 - }, + configuration = CordaRPCClientConfiguration.DEFAULT.copy( + maxReconnectAttempts = 1 + ), sslConfiguration = configuration.nodeSslConfig, classLoader = classLoader) this.connection = client.start(username, credentials) @@ -312,7 +312,7 @@ object InteractiveShell { } catch (e: PermissionException) { output.println(e.message ?: "Access denied", Color.red) } catch (e: ExecutionException) { - // ignoring it as already logged by the progress handler subscriber + // ignoring it as already logged by the progress handler subscriber } finally { InputStreamDeserializer.closeAll() }