Skip to content
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

icewind: re-use existing JNDI DataSource(s) #289

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion icewind/VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor[.patch]
# build version tag: timestamp
VER=0.9.4
VER=0.9.5
TAGS="${VER} ${VER}-$(date --utc +"%Y%m%dT%H%M%S")"
unset VER
20 changes: 16 additions & 4 deletions icewind/src/main/java/org/opencadc/icewind/DeletionHarvester.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import java.util.ListIterator;
import java.util.Map;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.log4j.Logger;

/**
Expand Down Expand Up @@ -139,12 +140,23 @@ private void init() {
this.repoClient = new RepoClient(src.getResourceID(), 1);

// destination
final String destDS = "jdbc/DeletionHarvester";

Map<String, Object> destConfig = getConfigDAO(dest);
ConnectionConfig destConnectionConfig = new ConnectionConfig(null, null,
dest.getUsername(), dest.getPassword(), HarvesterResource.POSTGRESQL_DRIVER, dest.getJdbcUrl());
final String destDS = "jdbc/destObsHarvest";
try {
DBUtil.createJNDIDataSource(destDS, destConnectionConfig);
DataSource cur = null;
try {
cur = DBUtil.findJNDIDataSource(destDS);
} catch (NamingException notInitialized) {
log.debug("JNDI not initialized yet... OK");
}
if (cur == null) {
ConnectionConfig destConnectionConfig = new ConnectionConfig(null, null,
dest.getUsername(), dest.getPassword(), HarvesterResource.POSTGRESQL_DRIVER, dest.getJdbcUrl());
DBUtil.createJNDIDataSource(destDS, destConnectionConfig);
} else {
log.debug("found DataSource: " + destDS + " -- re-using");
}
} catch (NamingException e) {
throw new IllegalStateException(String.format("Error creating destination JNDI datasource for %s reason: %s",
dest, e.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,25 @@ private void init(int nthreads) {
this.srcObservationService = new RepoClient(src.getResourceID(), nthreads);

// dest is always a database
final String destDS = "jdbc/ObservationHarvester";
Map<String, Object> destConfig = getConfigDAO(dest);
ConnectionConfig destConnectionConfig = new ConnectionConfig(null, null,
dest.getUsername(), dest.getPassword(), HarvesterResource.POSTGRESQL_DRIVER, dest.getJdbcUrl());
final String destDS = "jdbc/obsHarvestDest";
try {
DBUtil.createJNDIDataSource(destDS, destConnectionConfig);
DataSource cur = null;
try {
cur = DBUtil.findJNDIDataSource(destDS);
} catch (NamingException notInitialized) {
log.debug("JNDI not initialized yet... OK");
}
if (cur == null) {
ConnectionConfig destConnectionConfig = new ConnectionConfig(null, null,
dest.getUsername(), dest.getPassword(), HarvesterResource.POSTGRESQL_DRIVER, dest.getJdbcUrl());
DBUtil.createJNDIDataSource(destDS, destConnectionConfig);
} else {
log.debug("found DataSource: " + destDS + " -- re-using");
}
} catch (NamingException e) {
throw new IllegalStateException(String.format("Error creating destination JNDI datasource for %s reason: %s",
dest, e.getMessage()));
dest, e.getMessage()), e);
}
destConfig.put("jndiDataSourceName", destDS);
destConfig.put("basePublisherID", basePublisherID.toASCIIString());
Expand Down
Loading