-
Notifications
You must be signed in to change notification settings - Fork 535
7418 datasourcedefinition #7422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9dfe7b8
b92e465
3c92120
d05cbaf
19c5e98
b646831
d0a1194
813e0fb
aa1cc0f
cb4d308
9155c07
06dbef1
b186508
2d0dc6e
1c0959b
ea0cf29
a41e177
1a921f6
83ea82f
c583909
f98c164
9168ad1
d7f3da1
7e3498e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| ## Release Highlights | ||
|
|
||
| ### Easier Configuration of Database Connections | ||
|
|
||
| Dataverse now being able to use up-to-date Java technologies, transforms | ||
| the way how to configure the connection to your PostgreSQL database. | ||
|
|
||
| In the past, the configuration of the connection has been quite static | ||
| and not very easy to update. This has been an issue especially for cloud | ||
| and container usage. | ||
|
|
||
| Using MicroProfile Config API (#7000, #7418), you can much more easily specify configuration | ||
| details. For an overview of supported options, please see the | ||
| [installation guide](https://guides.dataverse.org/en/5.3/installation/config.html#jvm-options). | ||
|
|
||
| Note that some settings have been moved from domain.xml to code such as min and max pool size. | ||
|
|
||
| ## Notes for Dataverse Installation Administrators | ||
|
|
||
| ### New JVM Options | ||
|
|
||
| - dataverse.db.name | ||
| - dataverse.db.user | ||
| - dataverse.db.password | ||
| - dataverse.db.host | ||
| - dataverse.db.port | ||
|
|
||
| <!-- ## Update to Payara Platform 5.2020.6 --> | ||
| <!-- ... --> | ||
|
|
||
| <!-- PLACEHOLDER REPLACEMENT TEXT FOR PAYARA UPGRADE NOTE #7417 --> | ||
| 🚨 THIS VERSION OF DATAVERSE **REQUIRES** UPGRADING TO PAYARA 5.2020.6. 🚨 | ||
|
|
||
| <!-- ... --> | ||
|
|
||
| ## Upgrading from earlier releases | ||
|
|
||
| ℹ️ You need to update the Payara Application Server before continuing here. See above. | ||
|
|
||
| 1. Undeploy the previous version. | ||
| ``` | ||
| <payara install path>/asadmin list-applications | ||
| <payara install path>/asadmin undeploy dataverse-<version> | ||
| ``` | ||
|
|
||
| (where `<payara install path>` is where Payara 5 is installed, for example: `/usr/local/payara5`) | ||
|
|
||
| 2. Update your database connection before updating. | ||
|
|
||
| Please configure your connection details, replacing all the `${DB_...}`. | ||
| (If you are using a PostgreSQL server on `localhost:5432`, you can omit `dataverse.db.host` and `dataverse.db.port`.) | ||
|
|
||
| ``` | ||
| <payara install path>/asadmin create-system-properties "dataverse.db.user=${DB_USER}" | ||
| <payara install path>/asadmin create-system-properties "dataverse.db.host=${DB_HOST}" | ||
| <payara install path>/asadmin create-system-properties "dataverse.db.port=${DB_PORT}" | ||
| <payara install path>/asadmin create-system-properties "dataverse.db.name=${DB_NAME}" | ||
| echo "AS_ADMIN_ALIASPASSWORD=${DB_PASS}" > /tmp/password.txt | ||
| <payara install path>/asadmin create-password-alias --passwordfile /tmp/password.txt dataverse.db.password | ||
| rm /tmp/password.txt | ||
| ``` | ||
|
|
||
| <!-- PLACE HOLDER FOR EJB TIMER DATABASE RESET NOTE #5345 --> | ||
|
|
||
| Now you are safe to delete the old password alias and DB pool: | ||
| ``` | ||
| <payara install path>/asadmin delete-jdbc-connection-pool --cascade=true dvnDbPool | ||
| <payara install path>/asadmin delete-password-alias db_password_alias | ||
| ``` | ||
|
|
||
| 3. Stop payara and remove the generated directory, start. | ||
| ``` | ||
| service payara stop | ||
| # remove the generated directory: | ||
| rm -rf <payara install path>/payara/domains/domain1/generated | ||
| service payara start | ||
| ``` | ||
|
|
||
| 3. Deploy this version. | ||
| ``` | ||
| <payara install path>/bin/asadmin deploy dataverse-5.3.war | ||
| ``` | ||
|
|
||
| 4. Restart Payara | ||
| ``` | ||
| service payara stop | ||
| service payara start | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| @TransactionManagement(value = TransactionManagementType.BEAN) | ||
| public class StartupFlywayMigrator { | ||
|
|
||
| @Resource(lookup = "jdbc/VDCNetDS") | ||
| @Resource(lookup = "java:app/jdbc/dataverse") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 9dfe7b8 it is explained why this changed:
|
||
| private DataSource dataSource; | ||
|
|
||
| @PostConstruct | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package edu.harvard.iq.dataverse.util; | ||
|
|
||
| import javax.annotation.Resource; | ||
| import javax.annotation.sql.DataSourceDefinition; | ||
| import javax.enterprise.inject.Produces; | ||
| import javax.inject.Singleton; | ||
| import javax.sql.DataSource; | ||
|
|
||
| // Find docs here: https://javaee.github.io/javaee-spec/javadocs/javax/annotation/sql/DataSourceDefinition.html | ||
| @Singleton | ||
| @DataSourceDefinition( | ||
| name = "java:app/jdbc/dataverse", | ||
| // The app server (Payara) deploys a managed pool for this data source for us. | ||
| // We don't need to deal with this on our own. | ||
| // | ||
| // HINT: PGSimpleDataSource would work too, but as we use a connection pool, go with a javax.sql.ConnectionPoolDataSource | ||
| // HINT: PGXADataSource is unnecessary (no distributed transactions used) and breaks ingest. | ||
| className = "org.postgresql.ds.PGConnectionPoolDataSource", | ||
| user = "${MPCONFIG=dataverse.db.user}", | ||
| password = "${MPCONFIG=dataverse.db.password}", | ||
| url = "jdbc:postgresql://${MPCONFIG=dataverse.db.host}:${MPCONFIG=dataverse.db.port}/${MPCONFIG=dataverse.db.name}", | ||
| // If we ever need to change these pool settings, we need to remove this class and create the resource | ||
| // from web.xml. We can use MicroProfile Config in there for these values, impossible to do in the annotation. | ||
| // | ||
| // See also https://blog.payara.fish/an-intro-to-connection-pools-in-payara-server-5 | ||
| // Payara DataSourceDefinitionDeployer default value = 8 | ||
| minPoolSize = 10, | ||
| // HINT: Payara DataSourceDefinitionDeployer default value = 32 | ||
| // HINT: Harvard Dataverse is fine for a while with 64 | ||
| maxPoolSize = 100, | ||
| // "The number of seconds that a physical connection should remain unused in the pool before the connection is closed for a connection pool. " | ||
| // Payara DataSourceDefinitionDeployer default value = 300 (seconds) | ||
| maxIdleTime = 300) | ||
| // It's possible to add additional properties like this... | ||
| // | ||
| //properties = { | ||
| // "fish.payara.log-jdbc-calls=true" | ||
| //}) | ||
| // | ||
| // ... but at this time we don't think we need any. The full list | ||
| // of properties can be found at https://docs.payara.fish/community/docs/5.2020.6/documentation/payara-server/jdbc/advanced-connection-pool-properties.html#full-list-of-properties | ||
| // | ||
| // All these properties cannot be configured via MPCONFIG as Payara doesn't support this (yet). To be enhanced. | ||
| // See also https://github.com/payara/Payara/issues/5024 | ||
| public class DataSourceProducer { | ||
|
|
||
| @Resource(lookup = "java:app/jdbc/dataverse") | ||
| DataSource ds; | ||
|
|
||
| @Produces | ||
| public DataSource getDatasource() { | ||
| return ds; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| dataverse.db.host=localhost | ||
| dataverse.db.port=5432 | ||
| dataverse.db.user=dataverse | ||
| dataverse.db.name=dataverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added so the following file would be included:
src/main/resources/META-INF/microprofile-config.properties