diff --git a/edexOsgi/build.edex/esb/conf/log4j-ingest.xml b/edexOsgi/build.edex/esb/conf/log4j-ingest.xml index 7c776b833a..8640e52fe9 100644 --- a/edexOsgi/build.edex/esb/conf/log4j-ingest.xml +++ b/edexOsgi/build.edex/esb/conf/log4j-ingest.xml @@ -169,7 +169,7 @@ - + @@ -177,6 +177,8 @@ + + @@ -277,11 +279,6 @@ - - - - - diff --git a/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF index a48d919f74..6e7afe265b 100644 --- a/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.text/META-INF/MANIFEST.MF @@ -13,11 +13,11 @@ Require-Bundle: com.raytheon.edex.textdb, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.edex.decodertools;bundle-version="1.0.0", com.raytheon.uf.common.status;bundle-version="1.11.17", - com.raytheon.uf.common.site;bundle-version="1.12.1174" + com.raytheon.uf.common.site;bundle-version="1.12.1174", + com.raytheon.uf.edex.archive Export-Package: com.raytheon.edex.plugin.text, com.raytheon.edex.plugin.text.dao Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.common.dataplugin.text, com.raytheon.uf.common.dataplugin.text.db, - com.raytheon.uf.common.dataplugin.text.request, - com.raytheon.uf.edex.maintenance.archive + com.raytheon.uf.common.dataplugin.text.request diff --git a/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java index e5631a13d1..b795ffb25e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/maintenance/archiver/TextArchiveFileNameFormatter.java @@ -34,12 +34,12 @@ import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.archive.IPluginArchiveFileNameFormatter; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.raytheon.uf.edex.maintenance.archive.IPluginArchiveFileNameFormatter; /** - * TODO Add Description + * Properly stores StdTextProducts by time. * *
  * 
@@ -48,7 +48,7 @@ import com.raytheon.uf.edex.maintenance.archive.IPluginArchiveFileNameFormatter;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 20, 2012            dgilling     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter      Moved IPluginArchiveFileNameFormatter.
  * 
* * @author dgilling @@ -70,6 +70,7 @@ public class TextArchiveFileNameFormatter implements * com.raytheon.uf.edex.database.plugin.PluginDao, java.util.Map, * java.util.Calendar, java.util.Calendar) */ + @SuppressWarnings("rawtypes") @Override public Map> getPdosByFile( String pluginName, PluginDao dao, diff --git a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java index 7c7c470ed5..3c82b24d5e 100644 --- a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java +++ b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/ArchiveConfigManager.java @@ -188,7 +188,7 @@ public class ArchiveConfigManager { public Collection getArchives() { String fileName = ArchiveConstants.selectFileName(Type.Retention, null); SelectConfig selections = loadSelection(fileName); - if (selections != null && !selections.isEmpty()) { + if ((selections != null) && !selections.isEmpty()) { try { for (ArchiveSelect archiveSelect : selections.getArchiveList()) { ArchiveConfig archiveConfig = archiveMap.get(archiveSelect @@ -407,7 +407,8 @@ public class ArchiveConfigManager { private Calendar calculateExpiration(ArchiveConfig archive, CategoryConfig category) { Calendar expireCal = TimeUtil.newGmtCalendar(); - int retHours = category == null || category.getRetentionHours() == 0 ? archive + int retHours = (category == null) + || (category.getRetentionHours() == 0) ? archive .getRetentionHours() : category.getRetentionHours(); if (retHours != 0) { expireCal.add(Calendar.HOUR, (-1) * retHours); @@ -453,7 +454,7 @@ public class ArchiveConfigManager { for (LocalizationFile lFile : files) { try { ArchiveConfig archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile); - if (archiveConfig != null && archiveConfig.isValid()) { + if ((archiveConfig != null) && archiveConfig.isValid()) { archiveNameToLocalizationFileMap.put( archiveConfig.getName(), lFile); archiveMap.put(archiveConfig.getName(), archiveConfig); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java index a87c33c165..581bc4e7ca 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/StdTextProduct.java @@ -58,6 +58,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * 04/06/2010 4734 mhuang Moved from edex server * 17May2010 2187 cjeanbap Change class to be Abstract * 27 May 2012 #647 dgilling Implement getIdentifier/setIdentifier. + * Nov 05, 2013 2499 rjpeter Fix generics. * * * @author jkorman @@ -67,8 +68,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize -public abstract class StdTextProduct extends PersistableDataObject implements - ISerializableObject { +public abstract class StdTextProduct extends + PersistableDataObject implements ISerializableObject { private static final long serialVersionUID = 1L; @@ -185,10 +186,8 @@ public abstract class StdTextProduct extends PersistableDataObject implements * (java.lang.Object) */ @Override - public void setIdentifier(Object identifier) { - if (identifier instanceof StdTextProductId) { - setProdId((StdTextProductId) identifier); - } + public void setIdentifier(StdTextProductId identifier) { + setProdId(identifier); } public String getBbbid() { @@ -227,7 +226,7 @@ public abstract class StdTextProduct extends PersistableDataObject implements Matcher m = ControlCharacterPattern.matcher(this.product); String result = this.product; - for (int i = 0; m.find(); ++i) { + for (; m.find();) { String nonAscii = m.group(); char[] charArr = nonAscii.toCharArray(); if (charArr.length == 1) { @@ -342,10 +341,12 @@ public abstract class StdTextProduct extends PersistableDataObject implements public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((bbbid == null) ? 0 : bbbid.hashCode()); - result = prime * result + ((refTime == null) ? 0 : refTime.hashCode()); - result = prime * result + ((prodId == null) ? 0 : prodId.hashCode()); - result = prime * result + ((product == null) ? 0 : product.hashCode()); + result = (prime * result) + ((bbbid == null) ? 0 : bbbid.hashCode()); + result = (prime * result) + + ((refTime == null) ? 0 : refTime.hashCode()); + result = (prime * result) + ((prodId == null) ? 0 : prodId.hashCode()); + result = (prime * result) + + ((product == null) ? 0 : product.hashCode()); return result; } diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index cf0d55bb7e..6a45fc1d52 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -52,6 +52,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint; * Mar 20, 2013 1774 randerso Add SECONDS_PER_DAY, changed SECONDS_PER_HOUR to int. * Apr 24, 2013 1628 mschenke Added GMT TimeZone Object constant * Jun 05, 2013 DR 16279 D. Friedman Add timeOfDayToAbsoluteTime + * Nov 05, 2013 2499 rjpeter Added prettyDuration. * * * @author njensen @@ -165,6 +166,13 @@ public final class TimeUtil { static final ITimer NULL_CLOCK = new NullClock(); + private static final long[] DURATION_INTERVALS = { MILLIS_PER_YEAR, + MILLIS_PER_WEEK, MILLIS_PER_DAY, MILLIS_PER_HOUR, + MILLIS_PER_MINUTE, MILLIS_PER_SECOND }; + + private static final String[] DURATION_QUALIFIERS = { "y", "w", "d", "h", + "m", "s" }; + /** * The strategy to retrieve the "current time" value from. */ @@ -415,20 +423,24 @@ public final class TimeUtil { } } - /** Converts a time-of-day (in seconds) to an absolute time given an - * absolute reference time. The resulting time is within a day of the - * reference time. - * @param timeOfDaySeconds The time of day in seconds past midnight - * @param referenceTime The reference time (should have GMT time zone) + /** + * Converts a time-of-day (in seconds) to an absolute time given an absolute + * reference time. The resulting time is within a day of the reference time. + * + * @param timeOfDaySeconds + * The time of day in seconds past midnight + * @param referenceTime + * The reference time (should have GMT time zone) * @return */ - public static Calendar timeOfDayToAbsoluteTime(int timeOfDaySeconds, Calendar referenceTime) { + public static Calendar timeOfDayToAbsoluteTime(int timeOfDaySeconds, + Calendar referenceTime) { Calendar targetDay = (Calendar) referenceTime.clone(); - int refTimeTodSeconds = referenceTime.get(Calendar.HOUR_OF_DAY) * SECONDS_PER_HOUR - + referenceTime.get(Calendar.MINUTE) * SECONDS_PER_MINUTE + int refTimeTodSeconds = (referenceTime.get(Calendar.HOUR_OF_DAY) * SECONDS_PER_HOUR) + + (referenceTime.get(Calendar.MINUTE) * SECONDS_PER_MINUTE) + referenceTime.get(Calendar.SECOND); int absTodDiff = Math.abs(refTimeTodSeconds - timeOfDaySeconds); - if (absTodDiff < SECONDS_PER_DAY - absTodDiff) { + if (absTodDiff < (SECONDS_PER_DAY - absTodDiff)) { // nothing; use current targetDay } else if (refTimeTodSeconds < timeOfDaySeconds) { targetDay.add(Calendar.DAY_OF_MONTH, -1); @@ -442,6 +454,43 @@ public final class TimeUtil { return targetDay; } + /** + * Formats millis keeping the two most significant digits. + * + * 1y16w 2d15h 3m5s + * + * @param durationInMillis + * @return + */ + public static String prettyDuration(long durationInMillis) { + StringBuilder timeString = new StringBuilder(); + // handle s/ms separately + for (int i = 0; i < (DURATION_INTERVALS.length - 1); i++) { + long interval = DURATION_INTERVALS[i]; + if (durationInMillis > interval) { + timeString.append(durationInMillis / interval).append( + DURATION_QUALIFIERS[i]); + durationInMillis %= interval; + timeString.append(durationInMillis / DURATION_INTERVALS[i + 1]) + .append(DURATION_QUALIFIERS[i + 1]); + + return timeString.toString(); + } + } + + // seconds/ms + if (durationInMillis > MILLIS_PER_SECOND) { + timeString.append(durationInMillis / MILLIS_PER_SECOND).append('.'); + durationInMillis %= MILLIS_PER_SECOND; + int tenth = (int) (durationInMillis / 100); + timeString.append(tenth).append('s'); + } else { + timeString.append(durationInMillis).append("ms"); + } + + return timeString.toString(); + } + /** * Disabled constructor. */ diff --git a/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF index dd531b7090..038586a1a9 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.archive/META-INF/MANIFEST.MF @@ -5,13 +5,19 @@ Bundle-SymbolicName: com.raytheon.uf.edex.archive Bundle-Version: 1.0.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: com.raytheon.uf.edex.archive.purge +Export-Package: com.raytheon.uf.edex.archive, + com.raytheon.uf.edex.archive.purge Import-Package: com.raytheon.uf.common.archive.config, com.raytheon.uf.common.archive.request Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174", - com.raytheon.uf.edex.auth;bundle-version="1.12.1174", + com.raytheon.uf.edex.database, + com.raytheon.uf.common.dataplugin, + com.raytheon.uf.common.datastorage, + com.raytheon.uf.common.localization;bundle-version="1.12.1174", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.time, com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.localization;bundle-version="1.12.1174" + com.raytheon.uf.edex.auth;bundle-version="1.12.1174", + com.raytheon.uf.edex.core diff --git a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml new file mode 100644 index 0000000000..aa18209389 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archive-spring.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml b/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml deleted file mode 100644 index 8dd6192d7d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.archive/res/spring/archivepurger-spring.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - java.lang.Throwable - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties b/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties index 9b9705e607..5cdaa2a6c6 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties +++ b/edexOsgi/com.raytheon.uf.edex.archive/resources/com.raytheon.uf.edex.archive.cron.properties @@ -1,6 +1,11 @@ +# enable archive +archive.enable=true # runs database and hdf5 archive for archive server to pull data from archive.cron=0+40+*+*+*+? -# purge archives -archive.purge.cron=0+5+*+*+*+? # enable archive purge -archive.purge.enable=false +archive.purge.enable=true +# purge archives +archive.purge.cron=0+5+0/3+*+*+? + +# to disable a specific archive, use property archive.disable=pluginName,pluginName... +#archive.disable=grid,text,acars \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java new file mode 100644 index 0000000000..73449c929f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DataArchiver.java @@ -0,0 +1,138 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.archive; + +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; + +/** + * Handles archiving of data. Has two interfaces for registering data archive. + * Data archived based on archiving for each plugin and general data archive + * programs. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 16, 2011            rjpeter     Initial creation
+ * Nov 05, 2013 2499       rjpeter     Repackaged, updated to use System properties.
+ * 
+ * + * @author rjpeter + * @version 1.0 + */ +public class DataArchiver { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(DataArchiver.class); + + // enables/disables archiving as a whole + private final static String ENABLE_PROPERTY = "archive.enable"; + + // allows for disabling of specific plugins if desired + private final static String DISABLE_PROPERTY = "archive.disable"; + + private final boolean ARCHIVING_ENABLED; + + private final Set DISABLED_PLUGINS; + + private final List pluginArchivers = new LinkedList(); + + private final List dataArchivers = new LinkedList(); + + private String archivePath = null; + + public DataArchiver(String archivePath) { + this.archivePath = archivePath; + ARCHIVING_ENABLED = Boolean.getBoolean(ENABLE_PROPERTY); + String disabledPluginList = System.getProperty(DISABLE_PROPERTY); + if (disabledPluginList != null) { + String[] plugins = disabledPluginList.split(","); + DISABLED_PLUGINS = new HashSet(plugins.length); + for (String plugin : plugins) { + DISABLED_PLUGINS.add(plugin.trim()); + } + } else { + DISABLED_PLUGINS = Collections.emptySet(); + } + } + + public void archivePlugins() { + Thread.currentThread().setName("Archiver"); + if (ARCHIVING_ENABLED) { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + statusHandler.info("Archival of plugin data started"); + + // get list of plugins, ordered by plugin + Set availablePlugins = new TreeSet(PluginRegistry + .getInstance().getRegisteredObjects()); + + for (String pluginName : availablePlugins) { + if (DISABLED_PLUGINS.contains(pluginName)) { + statusHandler.info(pluginName + ": Archiving disabled"); + } else { + for (IPluginArchiver pluginArchiver : pluginArchivers) { + pluginArchiver.archivePlugin(pluginName, archivePath); + } + } + } + + timer.stop(); + statusHandler + .info("Archival of plugin data completed. Time to run: " + + TimeUtil.prettyDuration(timer.getElapsedTime())); + } else { + statusHandler.info("Archival of plugin data disabled, exiting"); + } + } + + public Object registerPluginArchiver(IPluginArchiver archiver) { + if (!pluginArchivers.contains(archiver)) { + pluginArchivers.add(archiver); + } else { + statusHandler.warn("Plugin archiver already registered: " + + archiver); + } + + return this; + } + + public Object registerDataArchiver(IDataArchiver archiver) { + if (!dataArchivers.contains(archiver)) { + dataArchivers.add(archiver); + } else { + statusHandler.warn("Data archiver already registered: " + archiver); + } + + return this; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java similarity index 88% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java index 20f51f2798..e3d7ddb493 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DatabaseArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DatabaseArchiver.java @@ -17,10 +17,8 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -55,6 +53,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; import com.raytheon.uf.edex.database.DataAccessLayerException; @@ -64,7 +63,6 @@ import com.raytheon.uf.edex.database.cluster.ClusterTask; import com.raytheon.uf.edex.database.cluster.handler.CurrentTimeClusterLockHandler; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; /** * This class handles moving processed data to the archiver directory. @@ -78,7 +76,7 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; * Nov 17, 2011 rjpeter Initial creation * Jan 18, 2013 1469 bkowal Removed the hdf5 data directory. * Oct 23, 2013 2478 rferrel Make date format thread safe. - * + * Nov 05, 2013 2499 rjpeter Repackaged, removed config files, always compresses. * * * @author rjpeter @@ -125,8 +123,7 @@ public class DatabaseArchiver implements IPluginArchiver { } @Override - public void archivePlugin(String pluginName, String archivePath, - DataArchiveConfig conf) { + public void archivePlugin(String pluginName, String archivePath) { PluginProperties props = PluginRegistry.getInstance() .getRegisteredObject(pluginName); if ((props != null) && (props.getRecord() != null) @@ -135,7 +132,7 @@ public class DatabaseArchiver implements IPluginArchiver { if (recordClass != null) { try { recordClass.asSubclass(PluginDataObject.class); - archivePluginData(pluginName, archivePath, conf); + archivePluginData(pluginName, archivePath); } catch (ClassCastException e) { // not an error, using asSubClass to filter non // PluginDataObjects @@ -145,8 +142,7 @@ public class DatabaseArchiver implements IPluginArchiver { } @SuppressWarnings("rawtypes") - public boolean archivePluginData(String pluginName, String archivePath, - DataArchiveConfig conf) { + public boolean archivePluginData(String pluginName, String archivePath) { SimpleDateFormat dateFormat = TL_DATE_FORMAT.get(); // set archive time Calendar runTime = Calendar.getInstance(); @@ -184,7 +180,7 @@ public class DatabaseArchiver implements IPluginArchiver { Set datastoreFilesToArchive = new HashSet(); startTime = determineStartTime(pluginName, ct.getExtraInfo(), - runTime, dao, conf); + runTime, dao); Calendar endTime = determineEndTime(startTime, runTime); Map> pdoMap = new HashMap>(); @@ -201,7 +197,7 @@ public class DatabaseArchiver implements IPluginArchiver { if ((pdosToSave != null) && !pdosToSave.isEmpty()) { recordCount += savePdoMap(pluginName, archivePath, - pdosToSave, conf.getCompressionEnabled()); + pdosToSave); for (Map.Entry> entry : pdosToSave .entrySet()) { List pdoList = entry.getValue(); @@ -217,8 +213,7 @@ public class DatabaseArchiver implements IPluginArchiver { } if ((pdoMap != null) && !pdoMap.isEmpty()) { - recordCount += savePdoMap(pluginName, archivePath, pdoMap, - conf.getCompressionEnabled()); + recordCount += savePdoMap(pluginName, archivePath, pdoMap); // don't forget to archive the HDF5 for the records that weren't // saved off by the prior while block for (Map.Entry> entry : pdoMap @@ -257,15 +252,11 @@ public class DatabaseArchiver implements IPluginArchiver { try { // data must be older than 30 minutes, and no older than - // hours - // to keep hours need to lookup plugin and see if - // compression - // matches, or embed in configuration the compression - // level on - // archive, but would still need to lookup plugin - ds.copy(outputDir, compRequired, "lastArchived", - 1800000, - conf.getHoursToKeep() * 60000 + 1800000); + // hours to keep hours need to lookup plugin and see if + // compression matches, or embed in configuration the + // compression level on archive, but would still need to + // lookup plugin + ds.copy(outputDir, compRequired, "lastArchived", 0, 0); } catch (StorageException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage()); @@ -280,10 +271,12 @@ public class DatabaseArchiver implements IPluginArchiver { } if (recordCount > 0) { - statusHandler.info(pluginName + ": successfully archived " - + recordCount + " records in " - + (System.currentTimeMillis() - timimgStartMillis) - + " ms"); + statusHandler.info(pluginName + + ": successfully archived " + + recordCount + + " records in " + + TimeUtil.prettyDuration(System.currentTimeMillis() + - timimgStartMillis)); } else { statusHandler .info(pluginName + ": Found no records to archive"); @@ -309,9 +302,8 @@ public class DatabaseArchiver implements IPluginArchiver { @SuppressWarnings("rawtypes") protected int savePdoMap(String pluginName, String archivePath, - Map> pdoMap, - boolean compressMetadata) throws SerializationException, - IOException { + Map> pdoMap) + throws SerializationException, IOException { int recordsSaved = 0; for (Map.Entry> entry : pdoMap @@ -324,7 +316,7 @@ public class DatabaseArchiver implements IPluginArchiver { path = path.substring(0, path.length() - 3); } - path += (compressMetadata ? ".bin.gz" : ".bin"); + path += ".bin.gz"; File file = new File(path); List pdosToSerialize = entry.getValue(); @@ -337,10 +329,7 @@ public class DatabaseArchiver implements IPluginArchiver { try { // created gzip'd stream - is = (compressMetadata ? new GZIPInputStream( - new FileInputStream(file), 8192) - : new BufferedInputStream( - new FileInputStream(file), 8192)); + is = new GZIPInputStream(new FileInputStream(file), 8192); // transform back for list append @SuppressWarnings("unchecked") @@ -397,10 +386,7 @@ public class DatabaseArchiver implements IPluginArchiver { } // created gzip'd stream - os = (compressMetadata ? new GZIPOutputStream( - new FileOutputStream(file), 8192) - : new BufferedOutputStream(new FileOutputStream(file), - 8192)); + os = new GZIPOutputStream(new FileOutputStream(file), 8192); // Thrift serialize pdo list SerializationUtil.transformToThriftUsingStream(pdosToSerialize, @@ -427,13 +413,11 @@ public class DatabaseArchiver implements IPluginArchiver { * @param extraInfo * @param runTime * @param dao - * @param conf * @return startTime * @throws DataAccessLayerException */ protected Calendar determineStartTime(String pluginName, String extraInfo, - Calendar runTime, PluginDao dao, DataArchiveConfig conf) - throws DataAccessLayerException { + Calendar runTime, PluginDao dao) throws DataAccessLayerException { Calendar startTime = null; SimpleDateFormat dateFormat = TL_DATE_FORMAT.get(); @@ -474,14 +458,7 @@ public class DatabaseArchiver implements IPluginArchiver { } } - // earliest time based on default retention - Calendar earliestTime = Calendar.getInstance(TimeZone - .getTimeZone("GMT")); - earliestTime - .add(Calendar.HOUR, (-1 * conf.getHoursToKeep().intValue())); - - return (startTime.compareTo(earliestTime) < 0) ? earliestTime - : startTime; + return startTime; } /** diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.java similarity index 98% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.java index 2cdec811dc..1246c23c10 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DefaultPluginArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/DefaultPluginArchiveFileNameFormatter.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; import java.io.File; import java.util.Calendar; @@ -51,7 +51,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao; * Mar 12, 2013 1783 rferrel Replace ArrayList with LinkedList to * remove excess capacity and reduce * time to resize a growing list. - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author dgilling diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java similarity index 90% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java index a922e0d4ee..59a035ffae 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IDataArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IDataArchiver.java @@ -17,10 +17,10 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; /** - * TODO Add Description + * Data Archiver interface * *
  * 
@@ -29,7 +29,7 @@ package com.raytheon.uf.edex.maintenance.archive;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Dec 16, 2011            rjpeter     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter     Repackaged
  * 
* * @author rjpeter diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.java similarity index 93% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.java index 92d2d47b83..b0e106df98 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiveFileNameFormatter.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiveFileNameFormatter.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; +package com.raytheon.uf.edex.archive; import java.util.Calendar; import java.util.List; @@ -28,7 +28,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; /** - * TODO Add Description + * Interface for archive file name formatters. * *
  * 
@@ -37,7 +37,7 @@ import com.raytheon.uf.edex.database.plugin.PluginDao;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 20, 2012            dgilling     Initial creation
- * 
+ * Nov 05, 2013 2499       rjpeter     Repackaged
  * 
* * @author dgilling @@ -64,6 +64,7 @@ public interface IPluginArchiveFileNameFormatter { * If the DAO is unable to retrieve the records from the * database. */ + @SuppressWarnings("rawtypes") public abstract Map> getPdosByFile( String pluginName, PluginDao dao, Map> pdoMap, diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java similarity index 87% rename from edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java rename to edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java index 1abd3d7f62..879818b5a6 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/IPluginArchiver.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/IPluginArchiver.java @@ -17,9 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.maintenance.archive; - -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; +package com.raytheon.uf.edex.archive; /** * Interface for archiving data based on plugins. @@ -31,7 +29,7 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 16, 2011 rjpeter Initial creation - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author rjpeter @@ -39,6 +37,5 @@ import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; */ public interface IPluginArchiver { - public void archivePlugin(String pluginName, String archivePath, - DataArchiveConfig config); + public void archivePlugin(String pluginName, String archivePath); } diff --git a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java index 3802050faa..6af9a95018 100644 --- a/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java +++ b/edexOsgi/com.raytheon.uf.edex.archive/src/com/raytheon/uf/edex/archive/purge/ArchivePurger.java @@ -26,6 +26,8 @@ import com.raytheon.uf.common.archive.config.ArchiveConfigManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; /** * Purge task to purge archived data based on configured expiration. @@ -41,7 +43,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Aug 28, 2013 2299 rferrel manager.purgeExpiredFromArchive now returns * number of files purged. * Sep 03, 2013 2224 rferrel Add check to enable/disable purger. - * + * Nov 05, 2013 2499 rjpeter Repackaged * * * @author bgonzale @@ -58,12 +60,17 @@ public class ArchivePurger { * Purge expired elements from the archives. */ public static void purge() { + Thread.currentThread().setName("Purge-Archive"); String enableString = System.getProperty(ENABLE_PROPERTY, "false"); if (Boolean.parseBoolean(enableString)) { - statusHandler.info("::Archive Purged started."); + ITimer timer = TimeUtil.getTimer(); + timer.start(); + statusHandler.info("Archive Purge started."); ArchiveConfigManager manager = ArchiveConfigManager.getInstance(); Collection archives = manager.getArchives(); for (ArchiveConfig archive : archives) { + ITimer archiveTimer = TimeUtil.getTimer(); + archiveTimer.start(); int purgeCount = manager.purgeExpiredFromArchive(archive); if (statusHandler.isPriorityEnabled(Priority.INFO)) { StringBuilder sb = new StringBuilder(archive.getName()); @@ -73,11 +80,17 @@ public class ArchivePurger { if (purgeCount != 1) { sb.append("s"); } - sb.append("."); + sb.append(" in ") + .append(TimeUtil.prettyDuration(archiveTimer + .getElapsedTime())).append("."); statusHandler.info(sb.toString()); } } - statusHandler.info("::Archive Purged finished."); + statusHandler.info("Archive Purge finished. Time to run: " + + TimeUtil.prettyDuration(timer.getElapsedTime())); + } else { + statusHandler.info("Archive Purge disabled, exiting"); } + } } diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF index 7be9583144..cb074f7ac8 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/MANIFEST.MF @@ -5,22 +5,11 @@ Bundle-SymbolicName: com.raytheon.uf.edex.maintenance Bundle-Version: 1.0.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.raytheon.uf.common.dataplugin, - com.raytheon.uf.common.dataplugin.persist, - com.raytheon.uf.common.dataquery.db, +Require-Bundle: com.raytheon.uf.common.dataplugin, com.raytheon.uf.common.datastorage, - com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization, com.raytheon.uf.common.status, - com.raytheon.uf.common.time, com.raytheon.uf.common.util, - com.raytheon.uf.common.util.registry, - com.raytheon.uf.edex.core.dataplugin, - com.raytheon.uf.edex.core.props, - com.raytheon.uf.edex.database, - com.raytheon.uf.edex.database.cluster, - com.raytheon.uf.edex.database.cluster.handler, - com.raytheon.uf.edex.database.plugin, - com.raytheon.uf.edex.pointdata, - org.springframework.orm.hibernate3.support -Export-Package: com.raytheon.uf.edex.maintenance.archive + com.raytheon.uf.edex.core, + com.raytheon.uf.edex.pointdata + diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 708c60ff8c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.maintenance/component-deploy.xml deleted file mode 100644 index 2fa640c974..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/component-deploy.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml b/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml index d2d8f16110..a4e1376efa 100644 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml +++ b/edexOsgi/com.raytheon.uf.edex.maintenance/res/spring/maintenance-ingest.xml @@ -8,32 +8,10 @@ - - - - - + - - - - - - - - - - - - - - - + @@ -47,23 +25,5 @@ - - - - - - - - java.lang.Throwable - - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java deleted file mode 100644 index 991d6a98e2..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.SerializationUtil; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; - -/** - * Handles archiving of data. Has two interfaces for registering data archive. - * Data archived based on archiving for each plugin and general data archive - * programs. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 16, 2011            rjpeter     Initial creation
- * 
- * 
- * - * @author rjpeter - * @version 1.0 - */ -public class DataArchiver { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(DataArchiver.class); - - private List pluginArchivers = new ArrayList(); - - private List dataArchivers = new ArrayList(); - - private String archivePath = null; - - private String defaultPlugin = "default"; - - private String configDir = "archiver"; - - public DataArchiver(String archivePath) { - this.archivePath = archivePath; - } - - public void archivePlugins() { - statusHandler.info("Archival of plugin data starting"); - - // get list of plugins, ordered by plugin - Set availablePlugins = new TreeSet(PluginRegistry - .getInstance().getRegisteredObjects()); - - Map configs = getDataArchiveConfigs(); - DataArchiveConfig defaultConf = configs.get(defaultPlugin); - File baseArchive = new File(archivePath); - - for (String pluginName : availablePlugins) { - DataArchiveConfig conf = configs.get(pluginName); - if (conf == null) { - conf = defaultConf; - } - - if (Boolean.TRUE.equals(conf.getArchivingEnabled())) { - for (IPluginArchiver pluginArchiver : pluginArchivers) { - pluginArchiver.archivePlugin(pluginName, archivePath, conf); - } - } - } - - statusHandler.info("Archival of plugin data complete"); - } - - public Object registerPluginArchiver(IPluginArchiver archiver) { - if (!pluginArchivers.contains(archiver)) { - pluginArchivers.add(archiver); - } else { - statusHandler.warn("Plugin archiver already registered: " - + archiver); - } - - return this; - } - - public Object registerDataArchiver(IDataArchiver archiver) { - if (!dataArchivers.contains(archiver)) { - dataArchivers.add(archiver); - } else { - statusHandler.warn("Data archiver already registered: " + archiver); - } - - return this; - } - - private Map getDataArchiveConfigs() { - Map configs = new HashMap(); - IPathManager pathMgr = PathManagerFactory.getPathManager(); - // process in reverse order so BASE is processed before CONFIGURED - // before SITE - List contexts = Arrays.asList(pathMgr - .getLocalSearchHierarchy(LocalizationType.COMMON_STATIC)); - Collections.reverse(contexts); - String[] extensions = new String[] { "xml" }; - for (LocalizationContext ctx : contexts) { - statusHandler.info("Loading context: " + ctx); - LocalizationFile[] lfs = pathMgr.listFiles(ctx, configDir, - extensions, false, true); - if (lfs != null && lfs.length > 0) { - for (LocalizationFile lf : lfs) { - String fileName = lf.getName(); - try { - File f = lf.getFile(true); - fileName = f.getAbsolutePath(); - Object obj = SerializationUtil - .jaxbUnmarshalFromXmlFile(f); - if (obj instanceof DataArchiveConfig) { - DataArchiveConfig conf = (DataArchiveConfig) obj; - String plugin = conf.getPluginName(); - if (plugin != null) { - plugin = plugin.trim(); - if (!plugin.isEmpty()) { - configs.put(plugin, conf); - } else { - throw new Exception( - "Configuration file does not specify pluginName"); - } - } else { - throw new Exception( - "Configuration file does not specify pluginName"); - } - } else { - throw new Exception( - "File in wrong format, expected " - + DataArchiveConfig.class - + ", found " + obj.getClass()); - } - } catch (Throwable e) { - statusHandler.error( - "Failed to load archive configuration file: " - + fileName, e); - } - } - } - } - - DataArchiveConfig defaultConf = configs.get(defaultPlugin); - if (defaultConf == null) { - // default plugin didn't load from disk, force a default config - statusHandler - .warn("Failed to find default configuration, using internal defaults"); - defaultConf = new DataArchiveConfig(); - defaultConf.setPluginName(defaultPlugin); - configs.put(defaultPlugin, defaultConf); - } - - if (!defaultConf.isArchivingEnabledSet()) { - defaultConf.setArchivingEnabled(Boolean.TRUE); - } - - if (!defaultConf.isCompressionEnabledSet()) { - defaultConf.setCompressionEnabled(Boolean.TRUE); - } - - if (!defaultConf.isHoursToKeepSet()) { - defaultConf.setHoursToKeep(6); - } - - // override unset fields with default - for (DataArchiveConfig pluginConf : configs.values()) { - if (pluginConf.getPluginName().equals(defaultPlugin)) { - // skip default conf - continue; - } - - if (!pluginConf.isArchivingEnabledSet()) { - pluginConf.setArchivingEnabled(defaultConf - .getArchivingEnabled()); - } - - if (!pluginConf.isCompressionEnabledSet()) { - pluginConf.setCompressionEnabled(defaultConf - .getArchivingEnabled()); - } - - if (!pluginConf.isHoursToKeepSet()) { - pluginConf.setHoursToKeep(defaultConf.getHoursToKeep()); - } - } - - try { - statusHandler.info("DefaultConfiguration:\n" - + SerializationUtil.marshalToXml(defaultConf)); - } catch (Exception e) { - statusHandler.handle(Priority.WARN, "Failed to deserialize config", - e); - } - return configs; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java deleted file mode 100644 index ba7ea799da..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive; - -import java.io.File; - -import com.raytheon.uf.common.datastorage.DataStoreFactory; -import com.raytheon.uf.common.datastorage.IDataStore; -import com.raytheon.uf.common.datastorage.StorageException; -import com.raytheon.uf.common.datastorage.StorageProperties.Compression; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig; - -/** - * Uses the repack feature of IDataStore to archive data by repacking it to a - * specified compression at the hdf5 dataset level and moving the resulting file - * to the archive dir. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 8, 2011            njensen     Initial creation
- * Jan 14, 2013 1469      bkowal      Removed the hdf5 data directory.
- * Jul 23, 2013 2216      rferrel     Removed the time stamp filter in hdf5 copy.
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class DataStoreArchiver { - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(DataStoreArchiver.class); - - private Compression compression = Compression.NONE; - - public DataStoreArchiver(String compression) { - this.compression = Compression.valueOf(compression); - } - - public void archiveFiles(String[] hdf5Files, String archiveDir, - DataArchiveConfig conf) { - for (String hdf5File : hdf5Files) { - IDataStore ds = DataStoreFactory.getDataStore(new File(hdf5File)); - String outputDir = archiveDir; // + dirs of hdf5 file - - try { - // Do not perform time stamp check. - ds.copy(outputDir, compression, null, 0, 0); - } catch (StorageException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage()); - } - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java deleted file mode 100644 index 406e9536a6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.maintenance.archive.config; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Data archive configuration. Configuration should be pulled from common_static - * localization. Configuration with a pluginName of default will all to all - * plugins. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jan 14, 2012            rjpeter     Initial creation
- * 
- * 
- * - * @author rjpeter - * @version 1.0 - */ -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -public class DataArchiveConfig { - @XmlElement - private String pluginName; - - @XmlElement - private Integer hoursToKeep; - - @XmlElement - private Boolean archivingEnabled; - - @XmlElement - private Boolean compressionEnabled; - - /** - * @return the pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * @param pluginName - * the pluginName to set - */ - public void setPluginName(String pluginName) { - this.pluginName = pluginName; - } - - /** - * @return the hoursToKeep - */ - public Integer getHoursToKeep() { - return hoursToKeep; - } - - /** - * @param hoursToKeep - * the hoursToKeep to set - */ - public void setHoursToKeep(Integer hoursToKeep) { - this.hoursToKeep = hoursToKeep; - } - - /** - * @return the archivingEnabled - */ - public Boolean getArchivingEnabled() { - return archivingEnabled; - } - - /** - * @param archivingEnabled - * the archivingEnabled to set - */ - public void setArchivingEnabled(Boolean archivingEnabled) { - this.archivingEnabled = archivingEnabled; - } - - /** - * @param compressionEnabled - * the compressionEnabled to set - */ - public void setCompressionEnabled(Boolean compressionEnabled) { - this.compressionEnabled = compressionEnabled; - } - - /** - * @return the compressionEnabled - */ - public Boolean getCompressionEnabled() { - return compressionEnabled; - } - - public boolean isArchivingEnabledSet() { - return archivingEnabled != null; - } - - public boolean isHoursToKeepSet() { - return hoursToKeep != null; - } - - public boolean isCompressionEnabledSet() { - return (compressionEnabled != null); - } -}