diff --git a/icewind/VERSION b/icewind/VERSION index 0372533c..d24693fe 100644 --- a/icewind/VERSION +++ b/icewind/VERSION @@ -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 diff --git a/icewind/src/main/java/org/opencadc/icewind/DeletionHarvester.java b/icewind/src/main/java/org/opencadc/icewind/DeletionHarvester.java index 47baf37d..f69468cc 100644 --- a/icewind/src/main/java/org/opencadc/icewind/DeletionHarvester.java +++ b/icewind/src/main/java/org/opencadc/icewind/DeletionHarvester.java @@ -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; /** @@ -139,12 +140,23 @@ private void init() { this.repoClient = new RepoClient(src.getResourceID(), 1); // destination + final String destDS = "jdbc/DeletionHarvester"; + Map 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())); diff --git a/icewind/src/main/java/org/opencadc/icewind/ObservationHarvester.java b/icewind/src/main/java/org/opencadc/icewind/ObservationHarvester.java index c08fc414..8ac17ff2 100644 --- a/icewind/src/main/java/org/opencadc/icewind/ObservationHarvester.java +++ b/icewind/src/main/java/org/opencadc/icewind/ObservationHarvester.java @@ -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 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());