Skip to content

Commit

Permalink
feat: Add support for JDBC connection pools introduced in Horizon 32.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
indigo423 committed Oct 16, 2023
1 parent 2390b30 commit 7ad1e89
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 16 deletions.
37 changes: 29 additions & 8 deletions bootstrap-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,17 @@ setCredentials() {
echo -n "Generate OpenNMS database config ... "
if [[ -f "${OPENNMS_HOME}"/etc/opennms-datasources.xml ]]; then
printf '<?xml version="1.0" encoding="UTF-8"?>
<datasource-configuration>
<connection-pool factory="org.opennms.core.db.C3P0ConnectionFactory"
idleTimeout="600"
loginTimeout="3"
minPool="50"
maxPool="50"
maxSize="50" />
<datasource-configuration xmlns:this="http://xmlns.opennms.org/xsd/config/opennms-datasources"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.opennms.org/xsd/config/opennms-datasources
http://www.opennms.org/xsd/config/opennms-datasources.xsd ">
<connection-pool factory="org.opennms.core.db.HikariCPConnectionFactory"
idleTimeout="600"
loginTimeout="3"
minPool="25"
maxPool="50"
maxSize="50" />
<jdbc-data-source name="opennms"
database-name="%s"
Expand All @@ -269,7 +273,24 @@ setCredentials() {
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}" />
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>
<jdbc-data-source name="opennms-monitor"
database-name="postgres"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/postgres"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>
</datasource-configuration>' "${DB_NAME}" "${DB_NAME}" \
| sudo -u opennms tee "${OPENNMS_HOME}"/etc/opennms-datasources.xml 1>>/dev/null 2>>"${ERROR_LOG}"
checkError "${?}"
Expand Down
37 changes: 29 additions & 8 deletions bootstrap-yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,17 @@ setCredentials() {
echo -n "Generate OpenNMS database config ... "
if [[ -f "${OPENNMS_HOME}"/etc/opennms-datasources.xml ]]; then
printf '<?xml version="1.0" encoding="UTF-8"?>
<datasource-configuration>
<connection-pool factory="org.opennms.core.db.C3P0ConnectionFactory"
idleTimeout="600"
loginTimeout="3"
minPool="50"
maxPool="50"
maxSize="50" />
<datasource-configuration xmlns:this="http://xmlns.opennms.org/xsd/config/opennms-datasources"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.opennms.org/xsd/config/opennms-datasources
http://www.opennms.org/xsd/config/opennms-datasources.xsd ">
<connection-pool factory="org.opennms.core.db.HikariCPConnectionFactory"
idleTimeout="600"
loginTimeout="3"
minPool="25"
maxPool="50"
maxSize="50" />
<jdbc-data-source name="opennms"
database-name="%s"
Expand All @@ -255,7 +259,24 @@ setCredentials() {
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}" />
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>
<jdbc-data-source name="opennms-monitor"
database-name="postgres"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/postgres"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>
</datasource-configuration>' "${DB_NAME}" "${DB_NAME}" \
| sudo -u opennms tee "${OPENNMS_HOME}"/etc/opennms-datasources.xml 1>>/dev/null 2>>"${ERROR_LOG}"
checkError "${?}"
Expand Down

0 comments on commit 7ad1e89

Please sign in to comment.