Skip to content

Commit edc6b36

Browse files
authored
CORE-17437: State Manager Configuration Section (#1277)
Promote State Manager configuration to its own section and remove it from under the Messaging configuration.
1 parent 397b29e commit edc6b36

File tree

9 files changed

+86
-72
lines changed

9 files changed

+86
-72
lines changed

data/config-schema/src/main/java/net/corda/schema/configuration/BootConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private BootConfig() {
3636

3737
public static final String BOOT_SECRETS = "secrets";
3838

39-
public static final String BOOT_STATE_MANAGER = "stateManager";
39+
public static final String BOOT_STATE_MANAGER = StateManagerConfig.STATE_MANAGER;
4040
public static final String BOOT_STATE_MANAGER_TYPE = BOOT_STATE_MANAGER + ".type";
4141
public static final String BOOT_STATE_MANAGER_DB_USER = BOOT_STATE_MANAGER + ".database.user";
4242
public static final String BOOT_STATE_MANAGER_DB_PASS = BOOT_STATE_MANAGER + ".database.pass";

data/config-schema/src/main/java/net/corda/schema/configuration/ConfigKeys.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ private ConfigKeys() {
1414
public static final String FLOW_CONFIG = "corda.flow";
1515
public static final String MESSAGING_CONFIG = "corda.messaging";
1616
public static final String EXTERNAL_MESSAGING_CONFIG = "corda.externalMessaging";
17+
public static final String STATE_MANAGER_CONFIG = "corda." + StateManagerConfig.STATE_MANAGER;
1718
public static final String UTXO_LEDGER_CONFIG = "corda.ledger.utxo";
1819
public static final String P2P_LINK_MANAGER_CONFIG = "corda.p2p.linkManager";
1920
public static final String P2P_GATEWAY_CONFIG = "corda.p2p.gateway";

data/config-schema/src/main/java/net/corda/schema/configuration/MessagingConfig.java

-27
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,4 @@ private Publisher() {
7878
* producers to stay under this limit when publishing messages.
7979
*/
8080
public static final String MAX_ALLOWED_MSG_SIZE = "maxAllowedMessageSize";
81-
82-
/**
83-
* State Manager Configuration for connecting to the underlying persistent storage.
84-
*/
85-
public static final class StateManager {
86-
private StateManager() {
87-
}
88-
89-
public static final String STATE_MANAGER = "stateManager";
90-
public static final String TYPE = STATE_MANAGER + ".type";
91-
92-
// Database Values
93-
public static final String DB_PROPERTIES = STATE_MANAGER + ".database";
94-
public static final String JDBC_USER = DB_PROPERTIES + ".user";
95-
public static final String JDBC_PASS = DB_PROPERTIES + ".pass";
96-
97-
public static final String JDBC_URL = DB_PROPERTIES + ".jdbc.url";
98-
public static final String JDBC_DRIVER = DB_PROPERTIES + ".jdbc.driver";
99-
public static final String JDBC_DRIVER_DIRECTORY = DB_PROPERTIES + ".jdbc.directory";
100-
public static final String JDBC_PERSISTENCE_UNIT_NAME = DB_PROPERTIES + ".jdbc.persistenceUnitName";
101-
public static final String JDBC_POOL_MAX_SIZE = DB_PROPERTIES + ".pool.maxSize";
102-
public static final String JDBC_POOL_MIN_SIZE = DB_PROPERTIES + ".pool.minSize";
103-
public static final String JDBC_POOL_IDLE_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.idleTimeoutSeconds";
104-
public static final String JDBC_POOL_MAX_LIFETIME_SECONDS = DB_PROPERTIES + ".pool.maxLifetimeSeconds";
105-
public static final String JDBC_POOL_KEEP_ALIVE_TIME_SECONDS = DB_PROPERTIES + ".pool.keepAliveTimeSeconds";
106-
public static final String JDBC_POOL_VALIDATION_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.validationTimeoutSeconds";
107-
}
10881
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.corda.schema.configuration;
2+
3+
/**
4+
* Configuration keys to access public parts of the configuration under the {@code corda.stateManager} key.
5+
*/
6+
public final class StateManagerConfig {
7+
private StateManagerConfig() {
8+
}
9+
10+
public static final String STATE_MANAGER = "stateManager";
11+
12+
public static final String TYPE = "type";
13+
14+
// Database Configuration Values
15+
public static final class Database {
16+
public static final String DB_PROPERTIES = "database";
17+
public static final String JDBC_USER = DB_PROPERTIES + ".user";
18+
public static final String JDBC_PASS = DB_PROPERTIES + ".pass";
19+
20+
public static final String JDBC_URL = DB_PROPERTIES + ".jdbc.url";
21+
public static final String JDBC_DRIVER = DB_PROPERTIES + ".jdbc.driver";
22+
public static final String JDBC_DRIVER_DIRECTORY = DB_PROPERTIES + ".jdbc.directory";
23+
public static final String JDBC_POOL_MAX_SIZE = DB_PROPERTIES + ".pool.maxSize";
24+
public static final String JDBC_POOL_MIN_SIZE = DB_PROPERTIES + ".pool.minSize";
25+
public static final String JDBC_POOL_IDLE_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.idleTimeoutSeconds";
26+
public static final String JDBC_POOL_MAX_LIFETIME_SECONDS = DB_PROPERTIES + ".pool.maxLifetimeSeconds";
27+
public static final String JDBC_POOL_KEEP_ALIVE_TIME_SECONDS = DB_PROPERTIES + ".pool.keepAliveTimeSeconds";
28+
public static final String JDBC_POOL_VALIDATION_TIMEOUT_SECONDS = DB_PROPERTIES + ".pool.validationTimeoutSeconds";
29+
}
30+
}

data/config-schema/src/main/resources/net/corda/schema/configuration/messaging/1.0/corda.messaging.json

-31
Original file line numberDiff line numberDiff line change
@@ -109,37 +109,6 @@
109109
"default": 972800,
110110
"minimum": 512000,
111111
"maximum": 8388608
112-
},
113-
"stateManager": {
114-
"description": "Connection details for the underlying persistent storage used by the out of process State Manager.",
115-
"type": "object",
116-
"properties": {
117-
"type": {
118-
"description": "The type of state manager implementation.",
119-
"enum": [
120-
"DATABASE"
121-
]
122-
},
123-
"additionalProperties": false
124-
},
125-
"$comment": "Polymorphic state manager storage connection configuration. The valid section depends on which state manager implementation is in use.",
126-
"allOf": [
127-
{
128-
"if": {
129-
"properties": { "type": { "const": "DATABASE" } },
130-
"required": ["type"]
131-
},
132-
"then": {
133-
"properties": {
134-
"databaseProperties": {
135-
"description": "Settings to connect to the state manager database.",
136-
"$ref": "state-manager-db-properties.json"
137-
}
138-
},
139-
"required": ["type","databaseProperties"]
140-
}
141-
}
142-
]
143112
}
144113
},
145114
"additionalProperties": false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://corda.r3.com/net/corda/schema/configuration/stateManager/1.0/corda.stateManager.json",
4+
"title": "Corda State Manager Configuration Schema",
5+
"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.",
6+
"type": "object",
7+
"properties": {
8+
"type": {
9+
"description": "The type of state manager implementation.",
10+
"enum": [
11+
"DATABASE"
12+
]
13+
},
14+
"additionalProperties": false
15+
},
16+
"$comment": "Polymorphic state manager storage connection configuration. The valid section depends on which state manager implementation is in use.",
17+
"allOf": [
18+
{
19+
"if": {
20+
"properties": {
21+
"type": {
22+
"const": "DATABASE"
23+
}
24+
},
25+
"required": [
26+
"type"
27+
]
28+
},
29+
"then": {
30+
"properties": {
31+
"databaseProperties": {
32+
"description": "Settings to connect to the State Manager Database.",
33+
"$ref": "stateManager-db-properties.json"
34+
}
35+
},
36+
"required": [
37+
"type",
38+
"databaseProperties"
39+
]
40+
}
41+
}
42+
],
43+
"additionalProperties": false
44+
}
+6-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3-
"$id": "https://corda.r3.com/net/corda/schema/configuration/db/1.0/corda.db.json",
3+
"$id": "https://corda.r3.com/net/corda/schema/configuration/stateManager/1.0/stateManager-db-properties.json",
44
"title": "State Manager Database Configuration Schema",
55
"description": "Configuration schema for the database section. Note that this configuration cannot be updated dynamically through the REST endpoint.",
66
"type": "object",
@@ -23,6 +23,11 @@
2323
"type": "object",
2424
"default": {},
2525
"properties": {
26+
"url": {
27+
"description": "The JDBC URL.",
28+
"type": "string",
29+
"default": "jdbc:postgresql://state-manager-db:5432/state_manager"
30+
},
2631
"driver": {
2732
"description": "The JDBC driver.",
2833
"type": "string",
@@ -32,16 +37,6 @@
3237
"description": "The directory that contains the JDBC drivers.",
3338
"type": "string",
3439
"default": "/opt/jdbc-driver"
35-
},
36-
"url": {
37-
"description": "The JDBC URL.",
38-
"type": "string",
39-
"default": "jdbc:postgresql://state-manager-db:5432/state_manager"
40-
},
41-
"persistenceUnitName": {
42-
"description": "The persistent unit name.",
43-
"type": "string",
44-
"default": "corda-state-manager"
4540
}
4641
},
4742
"additionalProperties": false

data/config-schema/src/test/kotlin/net/corda/schema/configuration/provider/impl/SchemaProviderConfigImplTest.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import net.corda.schema.configuration.ConfigKeys.RECONCILIATION_CONFIG
1212
import net.corda.schema.configuration.ConfigKeys.REST_CONFIG
1313
import net.corda.schema.configuration.ConfigKeys.SANDBOX_CONFIG
1414
import net.corda.schema.configuration.ConfigKeys.SECRETS_CONFIG
15+
import net.corda.schema.configuration.ConfigKeys.STATE_MANAGER_CONFIG
1516
import net.corda.schema.configuration.ConfigKeys.UTXO_LEDGER_CONFIG
1617
import net.corda.schema.configuration.provider.ConfigSchemaException
1718
import net.corda.v5.base.versioning.Version
@@ -42,6 +43,7 @@ class SchemaProviderConfigImplTest {
4243
SANDBOX_CONFIG,
4344
RECONCILIATION_CONFIG,
4445
MEMBERSHIP_CONFIG,
46+
STATE_MANAGER_CONFIG
4547
)
4648
private val VERSIONS = listOf("1.0")
4749

@@ -99,4 +101,4 @@ class SchemaProviderConfigImplTest {
99101
provider.getSchemaFile(BAD_SCHEMA_FILE)
100102
}
101103
}
102-
}
104+
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cordaProductVersion = 5.1.0
99
# NOTE: update this each time this module contains a breaking change
1010
## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to
1111
## a per module property in which case module versions can change independently.
12-
cordaApiRevision = 30
12+
cordaApiRevision = 31
1313

1414
# Main
1515
kotlinVersion = 1.8.21

0 commit comments

Comments
 (0)