This is an automated email from the ASF dual-hosted git repository. joscorbe pushed a commit to branch OAK-11835 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 37ca3706543b556abaa5d0d9ede41bad51f7f450 Author: Jose Cordero <corde...@adobe.com> AuthorDate: Fri Aug 1 17:12:32 2025 +0200 OAK-11835: Added OSGi configuration for all Mongo Connection Pool parameters --- .../oak/plugins/document/Configuration.java | 68 ++++++++++++++++ .../DocumentNodeStoreServiceConfiguration.java | 92 ++++++++++++++++++++-- 2 files changed, 153 insertions(+), 7 deletions(-) diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java index 92e7f619e2..38f37a67a6 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java @@ -87,6 +87,74 @@ import static org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreServic "overridden via framework property 'oak.mongo.leaseSocketTimeout'") int mongoLeaseSocketTimeout() default DocumentNodeStoreService.DEFAULT_MONGO_LEASE_SO_TIMEOUT_MILLIS; + @AttributeDefinition( + name = "MongoDB Max Pool Size", + description = "The maximum number of connections in the MongoDB connection pool. " + + "Note that this value can be overridden via framework property 'oak.mongo.maxPoolSize'") + int mongoMaxPoolSize() default 100; + + @AttributeDefinition( + name = "MongoDB Min Pool Size", + description = "The minimum number of connections in the MongoDB connection pool. " + + "Note that this value can be overridden via framework property 'oak.mongo.minPoolSize'") + int mongoMinPoolSize() default 0; + + @AttributeDefinition( + name = "MongoDB Max Connecting", + description = "Maximum number of connections the MongoDB pool may be establishing concurrently. " + + "Note that this value can be overridden via framework property 'oak.mongo.maxConnecting'") + int mongoMaxConnecting() default 2; + + @AttributeDefinition( + name = "MongoDB Max Idle Time (ms)", + description = "The maximum idle time in milliseconds of a MongoDB pooled connection. " + + "A value of 0 means no limit. " + + "Note that this value can be overridden via framework property 'oak.mongo.maxIdleTimeMS'") + int mongoMaxIdleTimeMS() default 0; + + @AttributeDefinition( + name = "MongoDB Max Life Time (ms)", + description = "The maximum lifetime in milliseconds of a MongoDB pooled connection. " + + "A value of 0 means no limit. " + + "Note that this value can be overridden via framework property 'oak.mongo.maxLifeTimeMS'") + int mongoMaxLifeTimeMS() default 0; + + @AttributeDefinition( + name = "MongoDB Connect Timeout (ms)", + description = "The connection timeout in milliseconds for establishing connections to MongoDB. " + + "Note that this value can be overridden via framework property 'oak.mongo.connectTimeoutMS'") + int mongoConnectTimeoutMS() default 10000; + + @AttributeDefinition( + name = "MongoDB Heartbeat Frequency (ms)", + description = "The frequency in milliseconds of the driver checking the state of MongoDB servers. " + + "Note that this value can be overridden via framework property 'oak.mongo.heartbeatFrequencyMS'") + int mongoHeartbeatFrequencyMS() default 10000; + + @AttributeDefinition( + name = "MongoDB Server Selection Timeout (ms)", + description = "How long the driver will wait for server selection to succeed before throwing an exception, in milliseconds. " + + "Note that this value can be overridden via framework property 'oak.mongo.serverSelectionTimeoutMS'") + int mongoServerSelectionTimeoutMS() default 30000; + + @AttributeDefinition( + name = "MongoDB Wait Queue Timeout (ms)", + description = "The maximum time in milliseconds that a thread can wait for a connection to become available (deprecated but still supported). " + + "Note that this value can be overridden via framework property 'oak.mongo.waitQueueTimeoutMS'") + int mongoWaitQueueTimeoutMS() default 120000; + + @AttributeDefinition( + name = "MongoDB Socket Read Timeout (ms)", + description = "The socket read timeout in milliseconds. A value of 0 means no timeout. " + + "Note that this value can be overridden via framework property 'oak.mongo.readTimeoutMS'") + int mongoReadTimeoutMS() default 0; + + @AttributeDefinition( + name = "MongoDB Min Heartbeat Frequency (ms)", + description = "The minimum heartbeat frequency in milliseconds for MongoDB server monitoring. " + + "Note that this value can be overridden via framework property 'oak.mongo.minHeartbeatFrequencyMS'") + int mongoMinHeartbeatFrequencyMS() default 500; + @AttributeDefinition( name = "Cache Size (in MB)", description = "Cache size in MB. This is distributed among various caches used in DocumentNodeStore") diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfiguration.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfiguration.java index 98618299bf..e94441aac2 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfiguration.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceConfiguration.java @@ -77,6 +77,61 @@ final class DocumentNodeStoreServiceConfiguration { */ private static final String FWK_PROP_MONGO_LEASE_SO_TIMEOUT = "oak.mongo.leaseSocketTimeout"; + /** + * Name of framework property to configure MongoDB connection pool max size. + */ + private static final String FWK_PROP_MONGO_MAX_POOL_SIZE = "oak.mongo.maxPoolSize"; + + /** + * Name of framework property to configure MongoDB connection pool min size. + */ + private static final String FWK_PROP_MONGO_MIN_POOL_SIZE = "oak.mongo.minPoolSize"; + + /** + * Name of framework property to configure MongoDB max connecting. + */ + private static final String FWK_PROP_MONGO_MAX_CONNECTING = "oak.mongo.maxConnecting"; + + /** + * Name of framework property to configure MongoDB max idle time. + */ + private static final String FWK_PROP_MONGO_MAX_IDLE_TIME_MS = "oak.mongo.maxIdleTimeMS"; + + /** + * Name of framework property to configure MongoDB max life time. + */ + private static final String FWK_PROP_MONGO_MAX_LIFE_TIME_MS = "oak.mongo.maxLifeTimeMS"; + + /** + * Name of framework property to configure MongoDB connect timeout. + */ + private static final String FWK_PROP_MONGO_CONNECT_TIMEOUT_MS = "oak.mongo.connectTimeoutMS"; + + /** + * Name of framework property to configure MongoDB heartbeat frequency. + */ + private static final String FWK_PROP_MONGO_HEARTBEAT_FREQUENCY_MS = "oak.mongo.heartbeatFrequencyMS"; + + /** + * Name of framework property to configure MongoDB server selection timeout. + */ + private static final String FWK_PROP_MONGO_SERVER_SELECTION_TIMEOUT_MS = "oak.mongo.serverSelectionTimeoutMS"; + + /** + * Name of framework property to configure MongoDB wait queue timeout. + */ + private static final String FWK_PROP_MONGO_WAIT_QUEUE_TIMEOUT_MS = "oak.mongo.waitQueueTimeoutMS"; + + /** + * Name of framework property to configure MongoDB socket read timeout. + */ + private static final String FWK_PROP_MONGO_READ_TIMEOUT_MS = "oak.mongo.readTimeoutMS"; + + /** + * Name of framework property to configure MongoDB min heartbeat frequency. + */ + private static final String FWK_PROP_MONGO_MIN_HEARTBEAT_FREQUENCY_MS = "oak.mongo.minHeartbeatFrequencyMS"; + /** * Name of the framework property to configure the update limit. */ @@ -88,19 +143,42 @@ final class DocumentNodeStoreServiceConfiguration { static final String PROP_SO_KEEP_ALIVE = "socketKeepAlive"; static final String PROP_LEASE_SO_TIMEOUT = "leaseSocketTimeout"; static final String PROP_UPDATE_LIMIT = "updateLimit"; + static final String PROP_MONGO_MAX_POOL_SIZE = "mongoMaxPoolSize"; + static final String PROP_MONGO_MIN_POOL_SIZE = "mongoMinPoolSize"; + static final String PROP_MONGO_MAX_CONNECTING = "mongoMaxConnecting"; + static final String PROP_MONGO_MAX_IDLE_TIME_MS = "mongoMaxIdleTimeMS"; + static final String PROP_MONGO_MAX_LIFE_TIME_MS = "mongoMaxLifeTimeMS"; + static final String PROP_MONGO_CONNECT_TIMEOUT_MS = "mongoConnectTimeoutMS"; + static final String PROP_MONGO_HEARTBEAT_FREQUENCY_MS = "mongoHeartbeatFrequencyMS"; + static final String PROP_MONGO_SERVER_SELECTION_TIMEOUT_MS = "mongoServerSelectionTimeoutMS"; + static final String PROP_MONGO_WAIT_QUEUE_TIMEOUT_MS = "mongoWaitQueueTimeoutMS"; + static final String PROP_MONGO_READ_TIMEOUT_MS = "mongoReadTimeoutMS"; + static final String PROP_MONGO_MIN_HEARTBEAT_FREQUENCY_MS = "mongoMinHeartbeatFrequencyMS"; /** * Special mapping of property names to framework properties. All other * property names are mapped to framework properties by prefixing them with * {@link #DEFAULT_FWK_PREFIX}. */ - private static final Map<String, String> FWK_PROP_MAPPING = Map.of( - PROP_DB, FWK_PROP_DB, - PROP_URI, FWK_PROP_URI, - PROP_HOME, PROP_HOME, - PROP_SO_KEEP_ALIVE, FWK_PROP_SO_KEEP_ALIVE, - PROP_LEASE_SO_TIMEOUT, FWK_PROP_MONGO_LEASE_SO_TIMEOUT, - PROP_UPDATE_LIMIT, FWK_PROP_UPDATE_LIMIT); + private static final Map<String, String> FWK_PROP_MAPPING = Map.ofEntries( + Map.entry(PROP_DB, FWK_PROP_DB), + Map.entry(PROP_URI, FWK_PROP_URI), + Map.entry(PROP_HOME, PROP_HOME), + Map.entry(PROP_SO_KEEP_ALIVE, FWK_PROP_SO_KEEP_ALIVE), + Map.entry(PROP_LEASE_SO_TIMEOUT, FWK_PROP_MONGO_LEASE_SO_TIMEOUT), + Map.entry(PROP_UPDATE_LIMIT, FWK_PROP_UPDATE_LIMIT), + Map.entry(PROP_MONGO_MAX_POOL_SIZE, FWK_PROP_MONGO_MAX_POOL_SIZE), + Map.entry(PROP_MONGO_MIN_POOL_SIZE, FWK_PROP_MONGO_MIN_POOL_SIZE), + Map.entry(PROP_MONGO_MAX_CONNECTING, FWK_PROP_MONGO_MAX_CONNECTING), + Map.entry(PROP_MONGO_MAX_IDLE_TIME_MS, FWK_PROP_MONGO_MAX_IDLE_TIME_MS), + Map.entry(PROP_MONGO_MAX_LIFE_TIME_MS, FWK_PROP_MONGO_MAX_LIFE_TIME_MS), + Map.entry(PROP_MONGO_CONNECT_TIMEOUT_MS, FWK_PROP_MONGO_CONNECT_TIMEOUT_MS), + Map.entry(PROP_MONGO_HEARTBEAT_FREQUENCY_MS, FWK_PROP_MONGO_HEARTBEAT_FREQUENCY_MS), + Map.entry(PROP_MONGO_SERVER_SELECTION_TIMEOUT_MS, FWK_PROP_MONGO_SERVER_SELECTION_TIMEOUT_MS), + Map.entry(PROP_MONGO_WAIT_QUEUE_TIMEOUT_MS, FWK_PROP_MONGO_WAIT_QUEUE_TIMEOUT_MS), + Map.entry(PROP_MONGO_READ_TIMEOUT_MS, FWK_PROP_MONGO_READ_TIMEOUT_MS), + Map.entry(PROP_MONGO_MIN_HEARTBEAT_FREQUENCY_MS, FWK_PROP_MONGO_MIN_HEARTBEAT_FREQUENCY_MS) + ); private DocumentNodeStoreServiceConfiguration() { }