Skip to content

Commit

Permalink
CORE-17437: State Manager Configuration Section (#1277)
Browse files Browse the repository at this point in the history
Promote State Manager configuration to its own section and remove it
from under the Messaging configuration.
  • Loading branch information
jujoramos authored Oct 9, 2023
1 parent 397b29e commit edc6b36
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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_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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$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 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": "stateManager-db-properties.json"
}
},
"required": [
"type",
"databaseProperties"
]
}
}
],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -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/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",
Expand All @@ -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",
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,6 +43,7 @@ class SchemaProviderConfigImplTest {
SANDBOX_CONFIG,
RECONCILIATION_CONFIG,
MEMBERSHIP_CONFIG,
STATE_MANAGER_CONFIG
)
private val VERSIONS = listOf("1.0")

Expand Down Expand Up @@ -99,4 +101,4 @@ class SchemaProviderConfigImplTest {
provider.getSchemaFile(BAD_SCHEMA_FILE)
}
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit edc6b36

Please sign in to comment.