diff --git a/services/base-jdbc/src/main/java/org/eclipse/hono/service/base/jdbc/config/JdbcProperties.java b/services/base-jdbc/src/main/java/org/eclipse/hono/service/base/jdbc/config/JdbcProperties.java index 3ac07bd988..08561b4569 100644 --- a/services/base-jdbc/src/main/java/org/eclipse/hono/service/base/jdbc/config/JdbcProperties.java +++ b/services/base-jdbc/src/main/java/org/eclipse/hono/service/base/jdbc/config/JdbcProperties.java @@ -32,6 +32,10 @@ public class JdbcProperties { private static final Logger log = LoggerFactory.getLogger(JdbcProperties.class); + private static final Integer MAXIMUM_POOL_SIZE_DEFAULT = 15; + private static final Integer MINIMUM_POOL_SIZE_DEFAULT = 3; + private static final Integer INITIAL_POOL_SIZE_DEFAULT = 3; + private static final Integer MAXIMUM_IDLE_TIME_DEFAULT = 3600; private String url; private String driverClass; @@ -59,10 +63,10 @@ public JdbcProperties() { public JdbcProperties(final JdbcOptions options) { Objects.requireNonNull(options); setDriverClass(options.driverClass()); - options.maximumPoolSize().ifPresent(this::setMaximumPoolSize); - options.minimumPoolSize().ifPresent(this::setMinimumPoolSize); - options.initialPoolSize().ifPresent(this::setInitialPoolSize); - options.maximumIdleTime().ifPresent(this::setMaximumIdleTime); + options.maximumPoolSize().ifPresentOrElse(this::setMaximumPoolSize, () -> setMaximumPoolSize(MAXIMUM_POOL_SIZE_DEFAULT)); + options.minimumPoolSize().ifPresentOrElse(this::setMinimumPoolSize, () -> setMinimumPoolSize(MINIMUM_POOL_SIZE_DEFAULT)); + options.initialPoolSize().ifPresentOrElse(this::setInitialPoolSize, () -> setInitialPoolSize(INITIAL_POOL_SIZE_DEFAULT)); + options.maximumIdleTime().ifPresentOrElse(this::setMaximumIdleTime, () -> setMaximumIdleTime(MAXIMUM_IDLE_TIME_DEFAULT)); options.password().ifPresent(this::setPassword); options.tableName().ifPresent(this::setTableName); setUrl(options.url()); diff --git a/site/documentation/content/admin-guide/jdbc-device-registry-config.md b/site/documentation/content/admin-guide/jdbc-device-registry-config.md index 83dc57fd4d..7ac4dcbb6a 100644 --- a/site/documentation/content/admin-guide/jdbc-device-registry-config.md +++ b/site/documentation/content/admin-guide/jdbc-device-registry-config.md @@ -65,19 +65,19 @@ and availability. | `HONO_REGISTRY_JDBC_ADAPTER_DRIVERCLASS`
`hono.registry.jdbc.adapter.driverClass` | no | The default driver registered for the JDBC URL. | The class name of the JDBC driver.| | `HONO_REGISTRY_JDBC_ADAPTER_USERNAME`
`hono.registry.jdbc.adapter.username` | no | - | The username used to access the database. | | `HONO_REGISTRY_JDBC_ADAPTER_PASSWORD`
`hono.registry.jdbc.adapter.password` | no | - | The password used to access the database. | -| `HONO_REGISTRY_JDBC_ADAPTER_MAXIMUMPOOLSIZE`
`hono.registry.jdbc.adapter.maximumPoolSize` | no | Depends on the connection pool implementation. `15` for C3P0. | The maximum size of the connection pool. | -| `HONO_REGISTRY_JDBC_ADAPTER_MINIMUMPOOLSIZE`
`hono.registry.jdbc.adapter.minimumPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | The minimum size of the connection pool. | -| `HONO_REGISTRY_JDBC_ADAPTER_INITIALPOOLSIZE`
`hono.registry.jdbc.adapter.initialPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | -| `HONO_REGISTRY_JDBC_ADAPTER_MAXIMUMIDLETIME`
`hono.registry.jdbc.adapter.maximumIdleTime` | no | Depends on the connection pool implementation. `0` for C3P0. | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | +| `HONO_REGISTRY_JDBC_ADAPTER_MAXIMUMPOOLSIZE`
`hono.registry.jdbc.adapter.maximumPoolSize` | no | `15` | The maximum size of the connection pool. | +| `HONO_REGISTRY_JDBC_ADAPTER_MINIMUMPOOLSIZE`
`hono.registry.jdbc.adapter.minimumPoolSize` | no | `3` | The minimum size of the connection pool. | +| `HONO_REGISTRY_JDBC_ADAPTER_INITIALPOOLSIZE`
`hono.registry.jdbc.adapter.initialPoolSize` | no | `3` | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | +| `HONO_REGISTRY_JDBC_ADAPTER_MAXIMUMIDLETIME`
`hono.registry.jdbc.adapter.maximumIdleTime` | no | `3600` | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | | `HONO_REGISTRY_JDBC_ADAPTER_TABLENAME`
`hono.registry.jdbc.adapter.tableName` | no | - | The name of the table the datastore uses. If the datastore requires multiple tables, this is the prefix. | | `HONO_REGISTRY_JDBC_MANAGEMENT_URL`
`hono.registry.jdbc.management.url` | yes | - | The JDBC URL to the database. | | `HONO_REGISTRY_JDBC_MANAGEMENT_DRIVERCLASS`
`hono.registry.jdbc.management.driverClass` | no | The default driver registered for the JDBC URL. | The class name of the JDBC driver. | | `HONO_REGISTRY_JDBC_MANAGEMENT_USERNAME`
`hono.registry.jdbc.management.username` | no | - | The username used to access the database. | | `HONO_REGISTRY_JDBC_MANAGEMENT_PASSWORD`
`hono.registry.jdbc.management.password` | no | - | The password used to access the database. | -| `HONO_REGISTRY_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE`
`hono.registry.jdbc.management.maximumPoolSize` | no | Depends on the connection pool implementation. `15` for C3P0. | The maximum size of the connection pool. | -| `HONO_REGISTRY_JDBC_MANAGEMENT_MINIMUMPOOLSIZE`
`hono.registry.jdbc.management.minimumPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | The minimum size of the connection pool. | -| `HONO_REGISTRY_JDBC_MANAGEMENT_INITIALPOOLSIZE`
`hono.registry.jdbc.management.initialPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | -| `HONO_REGISTRY_JDBC_MANAGEMENT_MAXIMUMIDLETIME`
`hono.registry.jdbc.management.maximumIdleTime` | no | Depends on the connection pool implementation. `0` for C3P0. | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | +| `HONO_REGISTRY_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE`
`hono.registry.jdbc.management.maximumPoolSize` | no | `15` | The maximum size of the connection pool. | +| `HONO_REGISTRY_JDBC_MANAGEMENT_MINIMUMPOOLSIZE`
`hono.registry.jdbc.management.minimumPoolSize` | no | `3` | The minimum size of the connection pool. | +| `HONO_REGISTRY_JDBC_MANAGEMENT_INITIALPOOLSIZE`
`hono.registry.jdbc.management.initialPoolSize` | no | `3` | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | +| `HONO_REGISTRY_JDBC_MANAGEMENT_MAXIMUMIDLETIME`
`hono.registry.jdbc.management.maximumIdleTime` | no | `3600` | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | | `HONO_REGISTRY_JDBC_MANAGEMENT_TABLENAME`
`hono.registry.jdbc.management.tableName` | no | - | The name of the table the datastore uses. If the datastore requires multiple tables, this is the prefix. | | `HONO_REGISTRY_SVC_CREDENTIALSTTL`
`hono.registry.svc.credentialsTtl` | no | `1m` | The TTL for credentials responses. | | `HONO_REGISTRY_SVC_HASHALGORITHMSWHITELIST`
`hono.registry.svc.hashAlgorithmsWhitelist` | no | `empty` | An array of supported hashing algorithms to be used with the `hashed-password` type of credentials. When not set, all values will be accepted. | @@ -89,19 +89,19 @@ and availability. | `HONO_TENANT_JDBC_ADAPTER_DRIVERCLASS`
`hono.tenant.jdbc.adapter.driverClass` | no | The default driver registered for the JDBC URL. | The class name of the JDBC driver.| | `HONO_TENANT_JDBC_ADAPTER_USERNAME`
`hono.tenant.jdbc.adapter.username` | no | - | The username used to access the database. | | `HONO_TENANT_JDBC_ADAPTER_PASSWORD`
`hono.tenant.jdbc.adapter.password` | no | - | The password used to access the database. | -| `HONO_TENANT_JDBC_ADAPTER_MAXIMUMPOOLSIZE`
`hono.tenant.jdbc.adapter.maximumPoolSize` | no | Depends on the connection pool implementation. `15` for C3P0. | The maximum size of the connection pool. | -| `HONO_TENANT_JDBC_ADAPTER_MINIMUMPOOLSIZE`
`hono.tenant.jdbc.adapter.minimumPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | The minimum size of the connection pool. | -| `HONO_TENANT_JDBC_ADAPTER_INITIALPOOLSIZE`
`hono.tenant.jdbc.adapter.initialPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | -| `HONO_TENANT_JDBC_ADAPTER_MAXIMUMIDLETIME`
`hono.tenant.jdbc.adapter.maximumIdleTime` | no | Depends on the connection pool implementation. `0` for C3P0. | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | +| `HONO_TENANT_JDBC_ADAPTER_MAXIMUMPOOLSIZE`
`hono.tenant.jdbc.adapter.maximumPoolSize` | no | `15` | The maximum size of the connection pool. | +| `HONO_TENANT_JDBC_ADAPTER_MINIMUMPOOLSIZE`
`hono.tenant.jdbc.adapter.minimumPoolSize` | no | `3` | The minimum size of the connection pool. | +| `HONO_TENANT_JDBC_ADAPTER_INITIALPOOLSIZE`
`hono.tenant.jdbc.adapter.initialPoolSize` | no | `3` | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | +| `HONO_TENANT_JDBC_ADAPTER_MAXIMUMIDLETIME`
`hono.tenant.jdbc.adapter.maximumIdleTime` | no | `3600` | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | | `HONO_TENANT_JDBC_ADAPTER_TABLENAME`
`hono.tenant.jdbc.adapter.tableName` | no | - | The name of the table the datastore uses. If the datastore requires multiple tables, this is the prefix. | | `HONO_TENANT_JDBC_MANAGEMENT_URL`
`hono.tenant.jdbc.management.url` | yes | - | The JDBC URL to the database. | | `HONO_TENANT_JDBC_MANAGEMENT_DRIVERCLASS`
`hono.tenant.jdbc.management.driverClass` | no | The default driver registered for the JDBC URL. | The class name of the JDBC driver. | | `HONO_TENANT_JDBC_MANAGEMENT_USERNAME`
`hono.tenant.jdbc.management.username` | no | - | The username used to access the database. | | `HONO_TENANT_JDBC_MANAGEMENT_PASSWORD`
`hono.tenant.jdbc.management.password` | no | - | The password used to access the database. | -| `HONO_TENANT_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE`
`hono.tenant.jdbc.management.maximumPoolSize` | no | Depends on the connection pool implementation. `15` for C3P0. | The maximum size of the connection pool. | -| `HONO_TENANT_JDBC_MANAGEMENT_MINIMUMPOOLSIZE`
`hono.tenant.jdbc.management.minimumPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | The minimum size of the connection pool. | -| `HONO_TENANT_JDBC_MANAGEMENT_INITIALPOOLSIZE`
`hono.tenant.jdbc.management.initialPoolSize` | no | Depends on the connection pool implementation. `3` for C3P0. | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | -| `HONO_TENANT_JDBC_MANAGEMENT_MAXIMUMIDLETIME`
`hono.tenant.jdbc.management.maximumIdleTime` | no | Depends on the connection pool implementation. `0` for C3P0. | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | +| `HONO_TENANT_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE`
`hono.tenant.jdbc.management.maximumPoolSize` | no | `15` | The maximum size of the connection pool. | +| `HONO_TENANT_JDBC_MANAGEMENT_MINIMUMPOOLSIZE`
`hono.tenant.jdbc.management.minimumPoolSize` | no | `3` | The minimum size of the connection pool. | +| `HONO_TENANT_JDBC_MANAGEMENT_INITIALPOOLSIZE`
`hono.tenant.jdbc.management.initialPoolSize` | no | `3` | Number of connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize. | +| `HONO_TENANT_JDBC_MANAGEMENT_MAXIMUMIDLETIME`
`hono.tenant.jdbc.management.maximumIdleTime` | no | `3600` | Seconds a connection can remain pooled but unused before being discarded. Zero means idle connections never expire. | | `HONO_TENANT_JDBC_MANAGEMENT_TABLENAME`
`hono.tenant.jdbc.management.tableName` | no | - | The name of the table the datastore uses. If the datastore requires multiple tables, this is the prefix. | | `HONO_TENANT_SVC_TENANTTTL`
`hono.tenant.service.tenantTtl` | no | `1m` | The TTL for tenant responses. |