From cc1563dcd5b152f40b926e3d952062e92310fa75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Thu, 5 Oct 2023 11:14:01 +0100 Subject: [PATCH 1/6] CORE-17437: State Manager Configuration Section Promote State Manager configuration to its own section and remove it from under the Messaging configuration. --- .../schema/configuration/BootConfig.java | 2 +- .../schema/configuration/ConfigKeys.java | 1 + .../schema/configuration/MessagingConfig.java | 27 ------------ .../configuration/StateManagerConfig.java | 31 +++++++++++++ .../messaging/1.0/corda.messaging.json | 31 ------------- .../stateManager/1.0/corda.stateManager.json | 44 +++++++++++++++++++ .../1.0/state-manager-db-properties.json | 2 +- .../impl/SchemaProviderConfigImplTest.kt | 4 +- .../db.changelog-master.xml | 2 +- .../state-manager-migration-v5.1.xml | 0 10 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java create mode 100644 data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json rename data/config-schema/src/main/resources/net/corda/schema/configuration/{messaging => stateManager}/1.0/state-manager-db-properties.json (97%) rename data/db-schema/src/main/resources/net/corda/db/schema/{statemanager => state-manager}/db.changelog-master.xml (78%) rename data/db-schema/src/main/resources/net/corda/db/schema/{statemanager => state-manager}/migration/state-manager-migration-v5.1.xml (100%) diff --git a/data/config-schema/src/main/java/net/corda/schema/configuration/BootConfig.java b/data/config-schema/src/main/java/net/corda/schema/configuration/BootConfig.java index da3d210c13..ac957ee3e8 100644 --- a/data/config-schema/src/main/java/net/corda/schema/configuration/BootConfig.java +++ b/data/config-schema/src/main/java/net/corda/schema/configuration/BootConfig.java @@ -36,7 +36,7 @@ private BootConfig() { public static final String BOOT_SECRETS = "secrets"; - public static final String BOOT_STATE_MANAGER = "stateManager"; + public static final String BOOT_STATE_MANAGER = StateManagerConfig.STATE_MANAGER; public static final String BOOT_STATE_MANAGER_TYPE = BOOT_STATE_MANAGER + ".type"; public static final String BOOT_STATE_MANAGER_DB_USER = BOOT_STATE_MANAGER + ".database.user"; public static final String BOOT_STATE_MANAGER_DB_PASS = BOOT_STATE_MANAGER + ".database.pass"; diff --git a/data/config-schema/src/main/java/net/corda/schema/configuration/ConfigKeys.java b/data/config-schema/src/main/java/net/corda/schema/configuration/ConfigKeys.java index 7b7ec6b18a..a18dfda1b1 100644 --- a/data/config-schema/src/main/java/net/corda/schema/configuration/ConfigKeys.java +++ b/data/config-schema/src/main/java/net/corda/schema/configuration/ConfigKeys.java @@ -14,6 +14,7 @@ private ConfigKeys() { public static final String FLOW_CONFIG = "corda.flow"; public static final String MESSAGING_CONFIG = "corda.messaging"; public static final String EXTERNAL_MESSAGING_CONFIG = "corda.externalMessaging"; + public static final String STATE_MANAGER_CONFIG = "corda." + StateManagerConfig.STATE_MANAGER; public static final String UTXO_LEDGER_CONFIG = "corda.ledger.utxo"; public static final String P2P_LINK_MANAGER_CONFIG = "corda.p2p.linkManager"; public static final String P2P_GATEWAY_CONFIG = "corda.p2p.gateway"; diff --git a/data/config-schema/src/main/java/net/corda/schema/configuration/MessagingConfig.java b/data/config-schema/src/main/java/net/corda/schema/configuration/MessagingConfig.java index 0ab038f7f6..ff08267671 100644 --- a/data/config-schema/src/main/java/net/corda/schema/configuration/MessagingConfig.java +++ b/data/config-schema/src/main/java/net/corda/schema/configuration/MessagingConfig.java @@ -78,31 +78,4 @@ private Publisher() { * producers to stay under this limit when publishing messages. */ public static final String MAX_ALLOWED_MSG_SIZE = "maxAllowedMessageSize"; - - /** - * State Manager Configuration for connecting to the underlying persistent storage. - */ - public static final class StateManager { - private StateManager() { - } - - public static final String STATE_MANAGER = "stateManager"; - public static final String TYPE = STATE_MANAGER + ".type"; - - // Database Values - public static final String DB_PROPERTIES = STATE_MANAGER + ".database"; - public static final String JDBC_USER = DB_PROPERTIES + ".user"; - public static final String JDBC_PASS = DB_PROPERTIES + ".pass"; - - public static final String JDBC_URL = DB_PROPERTIES + ".jdbc.url"; - public static final String JDBC_DRIVER = DB_PROPERTIES + ".jdbc.driver"; - public static final String JDBC_DRIVER_DIRECTORY = DB_PROPERTIES + ".jdbc.directory"; - public static final String JDBC_PERSISTENCE_UNIT_NAME = DB_PROPERTIES + ".jdbc.persistenceUnitName"; - public static final String JDBC_POOL_MAX_SIZE = DB_PROPERTIES + ".pool.maxSize"; - public static final String JDBC_POOL_MIN_SIZE = DB_PROPERTIES + ".pool.minSize"; - public static final String JDBC_POOL_IDLE_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.idleTimeoutSeconds"; - public static final String JDBC_POOL_MAX_LIFETIME_SECONDS = DB_PROPERTIES + ".pool.maxLifetimeSeconds"; - public static final String JDBC_POOL_KEEP_ALIVE_TIME_SECONDS = DB_PROPERTIES + ".pool.keepAliveTimeSeconds"; - public static final String JDBC_POOL_VALIDATION_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.validationTimeoutSeconds"; - } } diff --git a/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java b/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java new file mode 100644 index 0000000000..1a1da04a57 --- /dev/null +++ b/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java @@ -0,0 +1,31 @@ +package net.corda.schema.configuration; + +/** + * Configuration keys to access public parts of the configuration under the {@code corda.stateManager} key. + */ +public final class StateManagerConfig { + private StateManagerConfig() { + } + + public static final String STATE_MANAGER = "stateManager"; + + public static final String TYPE = "type"; + + // Database Configuration Values + public static final class DataBase { + public static final String DB_PROPERTIES = "database"; + public static final String JDBC_USER = DB_PROPERTIES + ".user"; + public static final String JDBC_PASS = DB_PROPERTIES + ".pass"; + + public static final String JDBC_URL = DB_PROPERTIES + ".jdbc.url"; + public static final String JDBC_DRIVER = DB_PROPERTIES + ".jdbc.driver"; + public static final String JDBC_DRIVER_DIRECTORY = DB_PROPERTIES + ".jdbc.directory"; + public static final String JDBC_PERSISTENCE_UNIT_NAME = DB_PROPERTIES + ".jdbc.persistenceUnitName"; + public static final String JDBC_POOL_MAX_SIZE = DB_PROPERTIES + ".pool.maxSize"; + public static final String JDBC_POOL_MIN_SIZE = DB_PROPERTIES + ".pool.minSize"; + public static final String JDBC_POOL_IDLE_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.idleTimeoutSeconds"; + public static final String JDBC_POOL_MAX_LIFETIME_SECONDS = DB_PROPERTIES + ".pool.maxLifetimeSeconds"; + public static final String JDBC_POOL_KEEP_ALIVE_TIME_SECONDS = DB_PROPERTIES + ".pool.keepAliveTimeSeconds"; + public static final String JDBC_POOL_VALIDATION_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.validationTimeoutSeconds"; + } +} diff --git a/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/corda.messaging.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/corda.messaging.json index 3b3ebaa4d3..57eaf5e018 100644 --- a/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/corda.messaging.json +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/corda.messaging.json @@ -109,37 +109,6 @@ "default": 972800, "minimum": 512000, "maximum": 8388608 - }, - "stateManager": { - "description": "Connection details for the underlying persistent storage used by the out of process State Manager.", - "type": "object", - "properties": { - "type": { - "description": "The type of state manager implementation.", - "enum": [ - "DATABASE" - ] - }, - "additionalProperties": false - }, - "$comment": "Polymorphic state manager storage connection configuration. The valid section depends on which state manager implementation is in use.", - "allOf": [ - { - "if": { - "properties": { "type": { "const": "DATABASE" } }, - "required": ["type"] - }, - "then": { - "properties": { - "databaseProperties": { - "description": "Settings to connect to the state manager database.", - "$ref": "state-manager-db-properties.json" - } - }, - "required": ["type","databaseProperties"] - } - } - ] } }, "additionalProperties": false diff --git a/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json new file mode 100644 index 0000000000..c1a338556a --- /dev/null +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json @@ -0,0 +1,44 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://corda.r3.com/net/corda/schema/configuration/state.manager/1.0/corda.state.manager.json", + "title": "Corda State Manager Configuration Schema", + "description": "Configuration schema for the State Manager section. This configures the interactions of the workers with the underlying underlying persistent storage used by the out of process State Manager.", + "type": "object", + "properties": { + "type": { + "description": "The type of state manager implementation.", + "enum": [ + "DATABASE" + ] + }, + "additionalProperties": false + }, + "$comment": "Polymorphic state manager storage connection configuration. The valid section depends on which state manager implementation is in use.", + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "DATABASE" + } + }, + "required": [ + "type" + ] + }, + "then": { + "properties": { + "databaseProperties": { + "description": "Settings to connect to the State Manager Database.", + "$ref": "state-manager-db-properties.json" + } + }, + "required": [ + "type", + "databaseProperties" + ] + } + } + ], + "additionalProperties": false +} diff --git a/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/state-manager-db-properties.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json similarity index 97% rename from data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/state-manager-db-properties.json rename to data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json index fdba9a5407..ed0415e889 100644 --- a/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/state-manager-db-properties.json +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://corda.r3.com/net/corda/schema/configuration/db/1.0/corda.db.json", + "$id": "https://corda.r3.com/net/corda/schema/configuration/stdb/1.0/corda.db.json", "title": "State Manager Database Configuration Schema", "description": "Configuration schema for the database section. Note that this configuration cannot be updated dynamically through the REST endpoint.", "type": "object", diff --git a/data/config-schema/src/test/kotlin/net/corda/schema/configuration/provider/impl/SchemaProviderConfigImplTest.kt b/data/config-schema/src/test/kotlin/net/corda/schema/configuration/provider/impl/SchemaProviderConfigImplTest.kt index eedb5e0d56..ec693d023c 100644 --- a/data/config-schema/src/test/kotlin/net/corda/schema/configuration/provider/impl/SchemaProviderConfigImplTest.kt +++ b/data/config-schema/src/test/kotlin/net/corda/schema/configuration/provider/impl/SchemaProviderConfigImplTest.kt @@ -12,6 +12,7 @@ import net.corda.schema.configuration.ConfigKeys.RECONCILIATION_CONFIG import net.corda.schema.configuration.ConfigKeys.REST_CONFIG import net.corda.schema.configuration.ConfigKeys.SANDBOX_CONFIG import net.corda.schema.configuration.ConfigKeys.SECRETS_CONFIG +import net.corda.schema.configuration.ConfigKeys.STATE_MANAGER_CONFIG import net.corda.schema.configuration.ConfigKeys.UTXO_LEDGER_CONFIG import net.corda.schema.configuration.provider.ConfigSchemaException import net.corda.v5.base.versioning.Version @@ -42,6 +43,7 @@ class SchemaProviderConfigImplTest { SANDBOX_CONFIG, RECONCILIATION_CONFIG, MEMBERSHIP_CONFIG, + STATE_MANAGER_CONFIG ) private val VERSIONS = listOf("1.0") @@ -99,4 +101,4 @@ class SchemaProviderConfigImplTest { provider.getSchemaFile(BAD_SCHEMA_FILE) } } -} \ No newline at end of file +} diff --git a/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml b/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml similarity index 78% rename from data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml rename to data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml index 661f940b69..74d1220305 100644 --- a/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml +++ b/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml @@ -2,5 +2,5 @@ - + diff --git a/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/migration/state-manager-migration-v5.1.xml b/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/migration/state-manager-migration-v5.1.xml similarity index 100% rename from data/db-schema/src/main/resources/net/corda/db/schema/statemanager/migration/state-manager-migration-v5.1.xml rename to data/db-schema/src/main/resources/net/corda/db/schema/state-manager/migration/state-manager-migration-v5.1.xml From 8772b84313576ae4260e79a58c30055edc9e231e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Mon, 9 Oct 2023 11:15:30 +0100 Subject: [PATCH 2/6] Review Feedback --- .../configuration/StateManagerConfig.java | 3 +-- .../stateManager/1.0/corda.stateManager.json | 6 +++--- ...ies.json => stateManager-db-properties.json} | 17 ++++++----------- 3 files changed, 10 insertions(+), 16 deletions(-) rename data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/{state-manager-db-properties.json => stateManager-db-properties.json} (94%) diff --git a/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java b/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java index 1a1da04a57..c09fc6336d 100644 --- a/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java +++ b/data/config-schema/src/main/java/net/corda/schema/configuration/StateManagerConfig.java @@ -12,7 +12,7 @@ private StateManagerConfig() { public static final String TYPE = "type"; // Database Configuration Values - public static final class DataBase { + public static final class Database { public static final String DB_PROPERTIES = "database"; public static final String JDBC_USER = DB_PROPERTIES + ".user"; public static final String JDBC_PASS = DB_PROPERTIES + ".pass"; @@ -20,7 +20,6 @@ public static final class DataBase { public static final String JDBC_URL = DB_PROPERTIES + ".jdbc.url"; public static final String JDBC_DRIVER = DB_PROPERTIES + ".jdbc.driver"; public static final String JDBC_DRIVER_DIRECTORY = DB_PROPERTIES + ".jdbc.directory"; - public static final String JDBC_PERSISTENCE_UNIT_NAME = DB_PROPERTIES + ".jdbc.persistenceUnitName"; public static final String JDBC_POOL_MAX_SIZE = DB_PROPERTIES + ".pool.maxSize"; public static final String JDBC_POOL_MIN_SIZE = DB_PROPERTIES + ".pool.minSize"; public static final String JDBC_POOL_IDLE_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.idleTimeoutSeconds"; diff --git a/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json index c1a338556a..ecca652728 100644 --- a/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json @@ -1,8 +1,8 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://corda.r3.com/net/corda/schema/configuration/state.manager/1.0/corda.state.manager.json", + "$id": "https://corda.r3.com/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json", "title": "Corda State Manager Configuration Schema", - "description": "Configuration schema for the State Manager section. This configures the interactions of the workers with the underlying underlying persistent storage used by the out of process State Manager.", + "description": "Configuration schema for the State Manager section. This configures the interactions of the workers with the underlying persistent storage used by the out of process State Manager.", "type": "object", "properties": { "type": { @@ -30,7 +30,7 @@ "properties": { "databaseProperties": { "description": "Settings to connect to the State Manager Database.", - "$ref": "state-manager-db-properties.json" + "$ref": "stateManager-db-properties.json" } }, "required": [ diff --git a/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/stateManager-db-properties.json similarity index 94% rename from data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json rename to data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/stateManager-db-properties.json index ed0415e889..f0a89d0738 100644 --- a/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/state-manager-db-properties.json +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/stateManager/1.0/stateManager-db-properties.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://corda.r3.com/net/corda/schema/configuration/stdb/1.0/corda.db.json", + "$id": "https://corda.r3.com/net/corda/schema/configuration/stateManager/1.0/stateManager-db-properties.json", "title": "State Manager Database Configuration Schema", "description": "Configuration schema for the database section. Note that this configuration cannot be updated dynamically through the REST endpoint.", "type": "object", @@ -23,6 +23,11 @@ "type": "object", "default": {}, "properties": { + "url": { + "description": "The JDBC URL.", + "type": "string", + "default": "jdbc:postgresql://state-manager-db:5432/state_manager" + }, "driver": { "description": "The JDBC driver.", "type": "string", @@ -32,16 +37,6 @@ "description": "The directory that contains the JDBC drivers.", "type": "string", "default": "/opt/jdbc-driver" - }, - "url": { - "description": "The JDBC URL.", - "type": "string", - "default": "jdbc:postgresql://state-manager-db:5432/state_manager" - }, - "persistenceUnitName": { - "description": "The persistent unit name.", - "type": "string", - "default": "corda-state-manager" } }, "additionalProperties": false From b7972487ee286fa8a0eedde50978f05180658f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Mon, 9 Oct 2023 11:47:35 +0100 Subject: [PATCH 3/6] Trigger CI From e3dc655a71ada101421658763ec65ac30ffeab77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Mon, 9 Oct 2023 13:24:27 +0100 Subject: [PATCH 4/6] Revert directory rename (not supported by cli) --- .../{state-manager => statemanager}/db.changelog-master.xml | 2 +- .../migration/state-manager-migration-v5.1.xml | 0 gradle.properties | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename data/db-schema/src/main/resources/net/corda/db/schema/{state-manager => statemanager}/db.changelog-master.xml (78%) rename data/db-schema/src/main/resources/net/corda/db/schema/{state-manager => statemanager}/migration/state-manager-migration-v5.1.xml (100%) diff --git a/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml b/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml similarity index 78% rename from data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml rename to data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml index 74d1220305..661f940b69 100644 --- a/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/db.changelog-master.xml +++ b/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml @@ -2,5 +2,5 @@ - + diff --git a/data/db-schema/src/main/resources/net/corda/db/schema/state-manager/migration/state-manager-migration-v5.1.xml b/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/migration/state-manager-migration-v5.1.xml similarity index 100% rename from data/db-schema/src/main/resources/net/corda/db/schema/state-manager/migration/state-manager-migration-v5.1.xml rename to data/db-schema/src/main/resources/net/corda/db/schema/statemanager/migration/state-manager-migration-v5.1.xml diff --git a/gradle.properties b/gradle.properties index 9553f8d66b..9dbf75b334 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ cordaProductVersion = 5.1.0 # NOTE: update this each time this module contains a breaking change ## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to ## a per module property in which case module versions can change independently. -cordaApiRevision = 30 +cordaApiRevision = 31 # Main kotlinVersion = 1.8.21 From e0e59a58127f5f08320da9444fbe5c7a7cb2884d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Mon, 9 Oct 2023 15:21:57 +0100 Subject: [PATCH 5/6] Trigger CI From 26b962f27fc0cd3434303ef5e22dd171439886db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Ramos=20Cassella?= Date: Mon, 9 Oct 2023 15:22:39 +0100 Subject: [PATCH 6/6] Trigger CI