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 ff08267671..de19bbdbbd 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,4 +78,31 @@ 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/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 57eaf5e018..72f0be5bb6 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,6 +109,37 @@ "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/messaging/1.0/state-manager-db-properties.json b/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/state-manager-db-properties.json new file mode 100644 index 0000000000..a9d1bb7617 --- /dev/null +++ b/data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/state-manager-db-properties.json @@ -0,0 +1,106 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://corda.r3.com/net/corda/schema/configuration/db/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", + "properties": { + "database": { + "description": "Database settings.", + "type": "object", + "default": {}, + "properties": { + "user": { + "description": "The database user.", + "type": "string" + }, + "pass": { + "description": "The database password.", + "type": "string" + }, + "jdbc": { + "description": "JDBC settings.", + "type": "object", + "default": {}, + "properties": { + "driver": { + "description": "The JDBC driver.", + "type": "string", + "default": "org.postgresql.Driver" + }, + "directory": { + "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 + }, + "pool": { + "description": "Database pool settings.", + "type": "object", + "default": {}, + "properties": { + "max_size": { + "description": "The maximum database pool size.", + "type": "integer", + "minimum": 1, + "default": 10 + }, + "min_size": { + "description": "The minimum database pool size. If left null will default to the `max_size` value.", + "default": null, + "anyOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "type": "null" + } + ] + }, + "idleTimeoutSeconds": { + "description": "The maximum time (in seconds) a connection can stay idle in the pool. A value of 0 means that idle connections are never removed from the pool.", + "type": "integer", + "minimum": 0, + "default": 120 + }, + "maxLifetimeSeconds": { + "description": "The maximum time (in seconds) a connection can stay in the pool, regardless if it has been idle or has been recently used. If a connection is in-use and has reached \"maxLifetime\" timeout, it will be removed from the pool only when it becomes idle.", + "type": "integer", + "minimum": 1, + "default": 1800 + }, + "keepAliveTimeSeconds": { + "description": "The interval time (in seconds) in which connections will be tested for aliveness. Connections which are no longer alive are removed from the pool. A value of 0 means this check is disabled.", + "type": "integer", + "minimum": 0, + "default": 0 + }, + "validationTimeoutSeconds": { + "description": "The maximum time (in seconds) that the pool will wait for a connection to be validated as alive.", + "type": "integer", + "minimum": 1, + "default": 5 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "default": {} + }, + "additionalProperties": false +} diff --git a/data/db-schema/src/main/java/net/corda/db/schema/DbSchema.java b/data/db-schema/src/main/java/net/corda/db/schema/DbSchema.java index 782d9b9754..a0956525a2 100644 --- a/data/db-schema/src/main/java/net/corda/db/schema/DbSchema.java +++ b/data/db-schema/src/main/java/net/corda/db/schema/DbSchema.java @@ -61,4 +61,6 @@ private DbSchema() { public static final String UNIQUENESS_STATE_DETAILS_TABLE = "uniqueness_state_details"; public static final String UNIQUENESS_TX_DETAILS_TABLE = "uniqueness_tx_details"; public static final String UNIQUENESS_REJECTED_TX_TABLE = "uniqueness_rejected_txs"; + + public static final String STATE_MANAGER_TABLE = "state"; } 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/statemanager/db.changelog-master.xml new file mode 100644 index 0000000000..661f940b69 --- /dev/null +++ b/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/db.changelog-master.xml @@ -0,0 +1,6 @@ + + + + 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/statemanager/migration/state-manager-migration-v5.1.xml new file mode 100644 index 0000000000..77380c0cff --- /dev/null +++ b/data/db-schema/src/main/resources/net/corda/db/schema/statemanager/migration/state-manager-migration-v5.1.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +