Skip to content

Commit

Permalink
[eclipse-hono#3542] Added minimumPoolSize, initialPoolSize and maximu…
Browse files Browse the repository at this point in the history
…mIdleTime as parameters to the JDBC configuration

Signed-off-by: Matthias Kaemmer <[email protected]>
  • Loading branch information
mattkaem committed Sep 25, 2023
1 parent a7ec5d6 commit d2e1e6a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ public interface JdbcOptions {
*/
OptionalInt maximumPoolSize();

/**
* Gets the minimum size of the DB connection pool.
*
* @return The minimum number of connections in the pool.
*/
OptionalInt minimumPoolSize();

/**
* Gets the initial size of the DB connection pool.
*
* @return The initial number of connections in the pool.
*/
OptionalInt initialPoolSize();

/**
* Gets the maximum idle time of connections in the DB connection pool.
*
* @return The maximum idle time of connections in the pool.
*/
OptionalInt maximumIdleTime();

/**
* Gets the name of the table that contains the data.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class JdbcProperties {
private String username;
private String password;
private Integer maximumPoolSize;
private Integer minimumPoolSize;
private Integer initialPoolSize;
private Integer maximumIdleTime;
private String tableName;

/**
Expand All @@ -57,6 +60,9 @@ 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.password().ifPresent(this::setPassword);
options.tableName().ifPresent(this::setTableName);
setUrl(options.url());
Expand Down Expand Up @@ -98,6 +104,27 @@ public Integer getMaximumPoolSize() {
return maximumPoolSize;
}

public void setMinimumPoolSize(final Integer minimumPoolSize) {
this.minimumPoolSize = minimumPoolSize;
}
public Integer getMinimumPoolSize() {
return minimumPoolSize;
}

public void setInitialPoolSize(final Integer initialPoolSize) {
this.initialPoolSize = initialPoolSize;
}
public Integer getInitialPoolSize() {
return initialPoolSize;
}

public void setMaximumIdleTime(final Integer maximumIdleTime) {
this.maximumIdleTime = maximumIdleTime;
}
public Integer getMaximumIdleTime() {
return maximumIdleTime;
}

public String getTableName() {
return tableName;
}
Expand Down Expand Up @@ -126,6 +153,15 @@ public static JDBCClient dataSource(final Vertx vertx, final JdbcProperties data
if (dataSourceProperties.getMaximumPoolSize() != null) {
config.put("max_pool_size", dataSourceProperties.getMaximumPoolSize());
}
if (dataSourceProperties.getMinimumPoolSize() != null) {
config.put("min_pool_size", dataSourceProperties.getMinimumPoolSize());
}
if (dataSourceProperties.getInitialPoolSize() != null) {
config.put("initial_pool_size", dataSourceProperties.getInitialPoolSize());
}
if (dataSourceProperties.getMaximumIdleTime() != null) {
config.put("max_idle_time", dataSourceProperties.getMaximumIdleTime());
}

log.info("Creating new SQL client: {} - table: {}", config, dataSourceProperties.getTableName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ and availability.
| `HONO_REGISTRY_JDBC_ADAPTER_USERNAME` <br> `hono.registry.jdbc.adapter.username` | no | - | The username used to access the database. |
| `HONO_REGISTRY_JDBC_ADAPTER_PASSWORD` <br> `hono.registry.jdbc.adapter.password` | no | - | The password used to access the database. |
| `HONO_REGISTRY_JDBC_ADAPTER_MAXIMUMPOOLSIZE` <br> `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` <br> `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` <br> `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` <br> `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_TABLENAME` <br> `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` <br> `hono.registry.jdbc.management.url` | yes | - | The JDBC URL to the database. |
| `HONO_REGISTRY_JDBC_MANAGEMENT_DRIVERCLASS` <br> `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` <br> `hono.registry.jdbc.management.username` | no | - | The username used to access the database. |
| `HONO_REGISTRY_JDBC_MANAGEMENT_PASSWORD` <br> `hono.registry.jdbc.management.password` | no | - | The password used to access the database. |
| `HONO_REGISTRY_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE` <br> `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` <br> `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` <br> `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` <br> `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_TABLENAME` <br> `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` <br> `hono.registry.svc.credentialsTtl` | no | `1m` | The TTL for credentials responses. |
| `HONO_REGISTRY_SVC_HASHALGORITHMSWHITELIST` <br> `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. |
Expand All @@ -84,12 +90,18 @@ and availability.
| `HONO_TENANT_JDBC_ADAPTER_USERNAME` <br> `hono.tenant.jdbc.adapter.username` | no | - | The username used to access the database. |
| `HONO_TENANT_JDBC_ADAPTER_PASSWORD` <br> `hono.tenant.jdbc.adapter.password` | no | - | The password used to access the database. |
| `HONO_TENANT_JDBC_ADAPTER_MAXIMUMPOOLSIZE` <br> `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` <br> `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` <br> `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` <br> `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_TABLENAME` <br> `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` <br> `hono.tenant.jdbc.management.url` | yes | - | The JDBC URL to the database. |
| `HONO_TENANT_JDBC_MANAGEMENT_DRIVERCLASS` <br> `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` <br> `hono.tenant.jdbc.management.username` | no | - | The username used to access the database. |
| `HONO_TENANT_JDBC_MANAGEMENT_PASSWORD` <br> `hono.tenant.jdbc.management.password` | no | - | The password used to access the database. |
| `HONO_TENANT_JDBC_MANAGEMENT_MAXIMUMPOOLSIZE` <br> `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` <br> `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` <br> `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` <br> `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_TABLENAME` <br> `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` <br> `hono.tenant.service.tenantTtl` | no | `1m` | The TTL for tenant responses. |

Expand Down

0 comments on commit d2e1e6a

Please sign in to comment.