Issue #1966 Initial setup.

Change-Id: I9b63433524fe419099e5646d028391377784d193

Former-commit-id: e36e62d3c146f10ef20a0d84abd26a96b9740827
This commit is contained in:
Roger Ferrel 2013-05-13 13:58:13 -05:00
parent 6c406d6a8e
commit 9f9f85f875
32 changed files with 1898 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.viz.archive</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Wed May 01 15:01:03 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Archive
Bundle-SymbolicName: com.raytheon.uf.viz.archive;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.archive.Activator
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.core.runtime,
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.archive;bundle-version="1.0.0",
com.raytheon.uf.common.time;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<?eclipse version="3.2"?>
<plugin>
<extension
point="com.raytheon.uf.viz.localization.localizationpath">
<path
application="Archive"
localizationType="COMMON_STATIC"
name="Archive"
value="archive"
recursive="false"
extensionFilter=".xml">
</path>
</extension>
</plugin>

View file

@ -0,0 +1,108 @@
/**
* 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.viz;
import com.raytheon.uf.common.time.util.TimeUtil;
/**
* Convenience class for taking retention hours and converting to days/hours.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 2, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class RetentionHours {
private int retentionHours;
/**
* Constructor with default 7 day retention.
*/
public RetentionHours() {
this(7 * TimeUtil.HOURS_PER_DAY);
}
/**
* Constructor specify retention hours.
*
* @param retentionHours
*/
public RetentionHours(int retentionHours) {
this.retentionHours = retentionHours;
}
/**
* Set retention to this number of days.
*
* @param days
*/
public void setDays(int days) {
retentionHours = days * TimeUtil.HOURS_PER_DAY;
}
/**
* Convert retention hours to days. Note values are truncated so a retention
* of 23 hours will return 0 days.
*
* @return days
*/
public int getDays() {
return retentionHours / TimeUtil.HOURS_PER_DAY;
}
/**
* Get retention in hours.
*
* @return
*/
public int getHours() {
return retentionHours;
}
/**
* Set number hours of retention.
*
* @param hours
*/
public void setHours(int hours) {
retentionHours = hours;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "RetentionHours [days:" + getDays() + ", hours:" + getHours()
+ "]";
}
}

View file

@ -0,0 +1,70 @@
/**
* 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.viz.archive;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* Activator class for Archive.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 13, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
*
* @see
* org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
/*
* (non-Javadoc)
*
* @see
* org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.localization"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.status"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.junit"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.viz.core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.archive</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,12 @@
#Mon May 06 18:17:15 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Common Archive
Bundle-SymbolicName: com.raytheon.uf.common.archive
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.raytheon.uf.common.archive
Require-Bundle: com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.viz.core;bundle-version="1.12.1174"

View file

@ -0,0 +1,45 @@
/**
* 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.common.archive;
/**
* Factory for accessing an archive CategoryManager.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 06, 2013 1966 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class ArchiveManagerFactory {
public static IArchiveManager getManager() {
return null;
}
}

View file

@ -0,0 +1,56 @@
/**
* 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.common.archive;
import java.util.List;
/**
* Interface that defines a Archive.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 7, 2013 1966 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public interface IArchive {
/**
* Obtain a list archive elements that have expired.
*
* @param archiveName
* - Name of Archive Data.
* @param categoryNameList
* - List of categories to check. All categories are checked if
* the list is null or empty.
* @return archiveElementList
*/
List<IArchiveElement> getExpiredElements(String archiveName,
List<String> categoryNameList);
}

View file

@ -0,0 +1,53 @@
/**
* 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.common.archive;
import com.raytheon.uf.common.archive.exception.ArchiveException;
/**
* Defines an Archive Element.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 7, 2013 1966 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public interface IArchiveElement {
/**
* Purge this element from the archive.
*
* @return true if successful; false otherwise.
* @throws ArchiveException
*/
public boolean purge() throws ArchiveException;
public String getName();
}

View file

@ -0,0 +1,45 @@
/**
* 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.common.archive;
/**
* Interface definition for Archive access.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 06, 2013 1966 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
import java.util.List;
public interface IArchiveManager {
public List<IArchive> getArchives();
}

View file

@ -0,0 +1,201 @@
/**
* 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.common.archive.config;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.junit.Assert;
/**
* Archive data information for retention, purging and archiving. An example:
*
* <pre>
* &lt;archive>
* &lt;name>Raw&lt;/name>
* &lt;rootDir>/data_store/&lt;/rootDir>
* &lt;!-- default retention hours for a category. -->
* &lt;retentionHours>168&lt;/retentionHours>
* &lt;category>
* &lt;name>Model grib&lt;/name>
* ...
* &lt;/category>
* &lt;category>
* &lt;name>Model grib2&lt;/name>
* ...
* &lt;/category>
* ...
* &lt;archive>
* </pre>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "archive")
public class ArchiveConfig implements Comparable<ArchiveConfig> {
/**
* Archive name.
*/
@XmlElement(name = "name")
private String name;
/**
* Fully qualified directory controlled by this archive.
*/
@XmlElement(name = "rootDir")
private String rootDir;
/**
* Minimum number of hours the purger should retain data. May be overridden
* for a given category.
*/
@XmlElement(name = "retentionHours")
private int retentionHours;
/**
* A category list that contain information on files/directories maintain
* for the archiver.
*/
@XmlElement(name = "category")
List<CategoryConfig> categoryList;
/**
* Constructor.
*/
public ArchiveConfig() {
super();
}
/**
* Get archive name. This should never be null.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Set the name for the archiver.
*
* @param name
*/
public void setName(String name) {
Assert.assertNotNull(name);
this.name = name;
}
/**
* Get the fully qualified name of the directory all components are relative
* to.
*
* @return rootDir
*/
public String getRootDir() {
return rootDir;
}
/**
* Set the fully qualified name of the directory all components are relative
*
* @param rootDir
*/
public void setRootDir(String rootDir) {
Assert.assertNotNull(rootDir);
this.rootDir = rootDir;
}
/**
* Retrive the archive's retention hours.
*
* @return retentionHours
*/
public int getRetentionHours() {
return retentionHours;
}
/**
* Set the retention hours; must be a value greater then zero.
*
* @param retentionHours
*/
public void setRetentionHours(int retentionHours) {
Assert.assertTrue(retentionHours > 0);
this.retentionHours = retentionHours;
}
/**
* Obtain a copy the list of categories.
*
* @return
*/
public List<CategoryConfig> getCategoryList() {
return new ArrayList<CategoryConfig>(categoryList);
}
/**
* Set the category list.
*
* @param categoryList
*/
public void setCategoryList(List<CategoryConfig> categoryList) {
this.categoryList = categoryList;
}
@Override
public int compareTo(ArchiveConfig o) {
return getName().compareTo(o.getName());
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ArchiveData [label: ").append(getName());
sb.append(", rootDir: ").append(getRootDir());
sb.append(", retentionHours: ").append(getRetentionHours());
for (CategoryConfig subc : getCategoryList()) {
sb.append("\n\t").append(subc.toString());
}
sb.append("]");
return sb.toString();
}
}

View file

@ -0,0 +1,339 @@
/**
* 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.common.archive.config;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.junit.Assert;
/**
* Information on a category for a given archive.
*
* An example of a processed data category:
*
* <pre>
* &lt;category>
* &lt;name>redbook&lt;/name>
* &lt;!-- When 0 default to the parent archive's retentionHours -->
* &lt;retentionHours>0&lt;/retentionHours>
* &lt;dirPattern>hdf5/redbook/([^/]*)/&lt;/dirPattern>
* &lt;display>redbook - \1&lt;/display>
* &lt;saveDir>hdf5/redbook/([^/]*)/&lt;/saveDir>
* &lt;saveFiles>redbook-${YYYY}-${MM}-${DD}-${HH}\..*&lt;/saveFiles>
* &lt;/category>
* </pre>
*
* An example of a raw data category:
*
* <pre>
* &lt;category>
* &lt;name>Model grib&lt;/name>
* &lt;retentionHours>0&lt;/retentionHours>
* &lt;dirPattern>grib/[^/]*&#47[^/]*&#47(.*\)&lt;/dirPattern>
* &lt;display>\1&lt;/display>
* &lt;saveDir>grib/${YYYY}${MM}${DD}/${HH}/(.*)&lt;/saveDir>
* &lt;saveFiles>.*&lt;/saveFiles>
* &lt;selectList>grib/${YYYY}${MM}${DD}/${HH}/NCEP_QPF/&lt;/selectList>
* &lt;/category>
* </pre>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "category")
public class CategoryConfig implements Comparable<CategoryConfig> {
/**
* The category's name.
*/
@XmlElement(name = "name")
private String name;
/**
* Minimum number of hours the purger should retain data. When 0 use the
* parent archive's value.
*/
@XmlElement(name = "retentionHours")
private int retentionHours;
/**
* A regex pattern to find directories controlled by the category. These
* directories should be relative to the parent archive's directory. For
* example:
*
* <pre>
* &lt;dirPattern>grib2/[^/]*&#47;[^/]*&#47;(.*)/&lt;/dirPattern>
* </pre>
*/
@XmlElement(name = "dirPattern")
private String dirPattern;
/**
* Use to display the information found by the dirPattern. Any groups in the
* dirPatern may be displayed. For example:
*
* <pre>
* &lt;dirName>grib2/[^/]*&#47;[^/]*&#47;(.*)&lt;/dirName>
* &lt;display>grib2 - \1&lt;/display>
* </pre>
*
* The \1 will be replaced with directory names 2 levels down from the grib2
* directory.
*/
@XmlElement(name = "display")
private String display;
/**
* A pattern to find the directories to save. This may contain the year,
* month, day and hour information. For example:
*
* <pre>
* &lt;saveDir>grib2/${YYYY}${MM}{$DD}/${HH}/.*&lt;/saveDir>
* </pre>
*/
@XmlElement(name = "saveDir")
private String saveDir;
/**
* A saveDir directory may contain files with data for several days. This
* allows any of the year, month, day and hour to be part of a file name.
* Default is all files in the directory. For example:
*
* <pre>
* &lt;saveDir>hd5/redbook/(^/]*&#47/)&lt/saveDir>
* &lt;saveFile>redbook-${YYYY}-${MM}-${DD}-${HH}\..*&lt;saveFiles>
* </pre>
*/
@XmlElement(name = "saveFiles")
private String saveFiles;
/**
* This is list of selected directories. To be used to specify which
* processed directories to move to /awips2/edex/data/archive.
*/
@XmlElement(name = "selectList")
private final List<String> selectList = new ArrayList<String>();
/*
* Constructor.
*/
public CategoryConfig() {
super();
}
/**
* @return name
*/
public String getName() {
return name;
}
/**
* Set the name; must not be null.
*
* @param name
*/
public void setName(String name) {
Assert.assertNotNull(name);
this.name = name;
}
/**
* Get the retention hours.
*
* @return retentionHours
*/
public int getRetentionHours() {
return retentionHours;
}
/**
* Set the retention hours must be greater then zero.
*/
public void setRetentionHours(int retentionHours) {
Assert.assertTrue(retentionHours > 0);
this.retentionHours = retentionHours;
}
/**
* Obtain the directory pattern.
*
* @return dirPattern
*/
public String getDirPattern() {
return dirPattern;
}
/**
* Set the directory pattern; must not be null.
*
* @param dirPattern
*/
public void setDirPattern(String dirPattern) {
Assert.assertNotNull(dirPattern);
this.dirPattern = dirPattern;
}
/**
* Get the diaplay pattern.
*
* @return display
*/
public String getDisplay() {
return display == null ? "" : display;
}
/**
* Set the disaplay pattern.
*
* @param display
*/
public void setDisplay(String display) {
Assert.assertNotNull(display);
this.display = display;
}
/**
* Get the save directory pattern..
*
* @return savedir
*/
public String getSaveDir() {
return saveDir;
}
/**
* Set the save directory pattern; must not be null.
*
* @param saveDir
*/
public void setSaveDir(String saveDir) {
Assert.assertNotNull(saveDir);
this.saveDir = saveDir;
}
/**
* Get the save files pattern.
*
* @return saveFiles
*/
public String getSaveFiles() {
return saveFiles;
}
/**
* Set the save files pattern; may be null.
*
* @param saveFiles
*/
public void setSaveFiles(String saveFiles) {
this.saveFiles = saveFiles;
}
/**
* Get list of selected directories.
*
* @return selectList
*/
public List<String> getSelectList() {
return new ArrayList<String>(selectList);
}
/**
* Rest set the list of selected directories.
*
* @param selectDir
*/
public void setSelectList(Collection<String> selectDir) {
this.selectList.clear();
this.selectList.addAll(selectDir);
}
/**
* Add an entry to the select list.
*
* @param select
*/
public void addSelectList(String select) {
selectList.add(select);
}
/**
* Remove an entry from the select list.
*
* @param select
*/
public void removeSelectList(String select) {
selectList.remove(select);
}
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(CategoryConfig o) {
return getDisplay().compareTo(o.getDisplay());
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Category [ name: ").append(getName());
sb.append(", retentionHours: ").append(getRetentionHours());
sb.append(", dirPattern: ").append(getDirPattern());
sb.append(", display: ").append(getDisplay());
sb.append(", saveDir: ").append(getSaveDir());
sb.append(", saveFiles: ").append(getSaveFiles());
sb.append(", selectList: [");
String prefix = "\"";
for (String sel : selectList) {
sb.append(prefix).append(sel).append("\"");
prefix = ", \"";
}
sb.append("]]");
return sb.toString();
}
}

View file

@ -0,0 +1,71 @@
/**
* 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.common.archive.exception;
/**
* Exceptions interacting with the archive.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 7, 2013 1966 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class ArchiveException extends Exception {
private static final long serialVersionUID = 1L;
/**
*
*/
public ArchiveException() {
}
/**
* @param message
*/
public ArchiveException(String message) {
super(message);
}
/**
* @param cause
*/
public ArchiveException(Throwable cause) {
super(cause);
}
/**
* @param message
* @param cause
*/
public ArchiveException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,104 @@
/**
* 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.common.archive.file;
import java.io.File;
import org.junit.Assert;
import com.raytheon.uf.common.archive.IArchiveElement;
import com.raytheon.uf.common.archive.exception.ArchiveException;
/**
* Archive element for a file or directory.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 13, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class FileArchiveElement implements IArchiveElement {
private String name;
public FileArchiveElement(String name) {
Assert.assertNotNull(name);
this.name = name;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.archive.IArchiveElement#purge()
*/
@Override
public boolean purge() throws ArchiveException {
File file = new File(name);
boolean state = false;
try {
if (!file.exists()) {
state = true;
} else {
if (file.isDirectory()) {
deleteContents(file);
}
state = file.delete();
}
} catch (SecurityException ex) {
throw new ArchiveException(ex.getMessage());
}
return state;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.archive.IArchiveElement#getName()
*/
@Override
public String getName() {
return name;
}
/**
* Delete all files and sub-directories.
*
* @param directory
*/
private void deleteContents(File directory) {
File[] files = directory.listFiles();
for (File file : files) {
if (file.isDirectory()) {
deleteContents(file);
}
file.delete();
}
}
}

View file

@ -0,0 +1,324 @@
/**
* 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.common.archive.manager;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXB;
import com.raytheon.uf.common.archive.config.ArchiveConfig;
import com.raytheon.uf.common.archive.config.CategoryConfig;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
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.localization.exception.LocalizationException;
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.viz.core.localization.LocalizationManager;
/**
* Manager for access to archive data information.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class ArchiveDataManager {
private final static ArchiveDataManager instance = new ArchiveDataManager();
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ArchiveDataManager.class);
private final String ARCHIVE_DIR = "archive";
private String site;
private IPathManager pathMgr;
private LocalizationContext siteCtx;
private LocalizationFile archiveDir;
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
public final static ArchiveDataManager getInstance() {
return instance;
}
private ArchiveDataManager() {
site = LocalizationManager.getInstance().getCurrentSite();
pathMgr = PathManagerFactory.getPathManager();
siteCtx = pathMgr.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
archiveDir = pathMgr.getLocalizationFile(siteCtx, ARCHIVE_DIR);
}
/**
* Get list of site's archive data configuration files.
*
* @return archiveDataList
*/
private LocalizationFile[] getArchiveDataFiles() {
String path = archiveDir.getName().trim();
LocalizationFile[] files = pathMgr.listFiles(siteCtx, path,
new String[] { "*.xml" }, false, true);
return files;
}
public String[] getArchiveDataNamesList() throws IOException,
LocalizationException {
if (archiveMap.size() == 0) {
LocalizationFile[] files = getArchiveDataFiles();
for (LocalizationFile lFile : files) {
ArchiveConfig archiveData = unmarshalArhiveDataFromXmlFile(lFile);
archiveMap.put(archiveData.getName(), archiveData);
}
}
String[] names = archiveMap.keySet().toArray(new String[0]);
Arrays.sort(names, 0, names.length, String.CASE_INSENSITIVE_ORDER);
return names;
}
public String[] getCategoryNames(ArchiveConfig archiveData) {
List<CategoryConfig> categories = archiveData.getCategoryList();
List<String> nameList = new ArrayList<String>(categories.size());
for (CategoryConfig category : archiveData.getCategoryList()) {
String name = category.getName();
nameList.add(name);
}
String[] names = nameList.toArray(new String[0]);
Arrays.sort(names, 0, names.length, String.CASE_INSENSITIVE_ORDER);
return names;
}
public ArchiveConfig loadArchiveData(LocalizationFile lFile)
throws IOException, LocalizationException {
return unmarshalArhiveDataFromXmlFile(lFile);
}
public void saveArchiveData(LocalizationFile lFile, ArchiveConfig archiveData)
throws IOException, LocalizationException {
marshalArchiveDataToXmlFile(archiveData, lFile);
}
private void marshalArchiveDataToXmlFile(ArchiveConfig archiveData,
LocalizationFile lFile) throws IOException, LocalizationException {
OutputStream stream = null;
try {
stream = lFile.openOutputStream();
JAXB.marshal(archiveData, stream);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {
// ignore
}
}
}
}
private ArchiveConfig unmarshalArhiveDataFromXmlFile(LocalizationFile lFile)
throws IOException, LocalizationException {
ArchiveConfig archiveData = null;
InputStream stream = null;
try {
stream = lFile.openInputStream();
archiveData = JAXB.unmarshal(stream, ArchiveConfig.class);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {
// ignore
}
}
}
return archiveData;
}
// TODO for testing to be removed
private void marshalArchiveDataToXmlFile(ArchiveConfig category, File file)
throws IOException, LocalizationException {
// TODO use lFile
OutputStream stream = null;
try {
stream = new BufferedOutputStream(new FileOutputStream(file));
JAXB.marshal(category, stream);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {
// ignore
}
}
}
}
// TODO for testing to be removed
private ArchiveConfig unmarshalArhiveDataFromXmlFile(File file)
throws IOException, LocalizationException {
ArchiveConfig archiveData = null;
InputStream stream = null;
try {
// stream = new BufferedInputStream(new FileInputStream(new File(
// "/home/rferrel/Desktop/RAW_DATA.xml")));
stream = new BufferedInputStream(new FileInputStream(file));
archiveData = JAXB.unmarshal(stream, ArchiveConfig.class);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {
// ignore
}
}
}
return archiveData;
}
// TODO remove main
public static void main(String[] args) {
ArchiveConfig rawArchiveData = new ArchiveConfig();
rawArchiveData.setName("Raw");
rawArchiveData.setRootDir("/data_store/");
rawArchiveData.setRetentionHours(7 * 24);
List<CategoryConfig> scList = new ArrayList<CategoryConfig>();
CategoryConfig category = new CategoryConfig();
category.setName("Model grib");
category.setDirPattern("grib/[^/]*/[^/]*/(.*\\)");
category.setDisplay("\\1");
category.setSaveDir("grib/${YYYY}${MM}${DD}/${HH}/(.*)");
category.setSaveFiles(".*");
category.addSelectList("grib/${YYYY}${MM}${DD}/${HH}/NCEP_QPF/");
scList.add(category);
category = new CategoryConfig();
category.setName("Model grib2");
category.setDirPattern("grib2/[^/]*/[^/]*/(.*\\)");
category.setDisplay("\\1");
category.setSaveDir("grib2/${YYYY}${MM}${DD}/${HH}/.*");
category.setSaveFiles(".*");
scList.add(category);
category = new CategoryConfig();
category.setName("Model other");
category.setDirPattern("(acars|airmet|binlighting|bufrmos|bufrua|bufsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/[^/]*/[^/]*/(.*)");
category.setDisplay("\\1 - \\2");
category.setSaveDir("(acars|airmet|binlighting|bufrmos|bufrua|bufsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/YYYYMMDD/HH/.*");
category.setSaveFiles(".*");
scList.add(category);
category = new CategoryConfig();
category.setName("Observations");
category.setDirPattern("(aircraft|metar|sfcobs)/[^/]*/[^/]*/(.*)");
category.setDisplay("\\1 - \\2");
category.setSaveDir("(aircraft|metar|sfcobs)/${YYYY}${MM}${DD}/${HH}/");
category.setSaveFiles(".*");
category.addSelectList("metar/)${YYYY}${MM}${DD}/${HH}/");
category = new CategoryConfig();
category.setName("Satellilte");
category.setRetentionHours(4 * 24 + 5);
category.setDirPattern("sat/[^/]*/[^/]*/(.*)");
category.setDisplay("\\1");
category.setSaveDir("sat/${YYYY}${MM}${DD}/${HH}/.*");
category.setSaveFiles(".*");
scList.add(category);
rawArchiveData.setCategoryList(scList);
ArchiveConfig procArchiveData = new ArchiveConfig();
procArchiveData.setName("Processed");
procArchiveData.setRootDir("/awips2/edex/data/archive/");
procArchiveData.setRetentionHours(7 * 24);
scList = new ArrayList<CategoryConfig>();
category = new CategoryConfig();
category.setName("redbook");
category.setDirPattern("hdf5/redbook/([^/]*)/");
category.setDisplay("redbook - \\1");
category.setSaveDir("hdf5/redbook/([^/]*)/");
category.setSaveFiles("redbook-${YYYY}-${MM}-${DD}-${HH}\\..*");
scList.add(category);
category = new CategoryConfig();
category.setName("obs");
category.setDirPattern("hdf5/(obs)/");
category.setSaveDir("hdf5/(obs)/");
category.setDisplay("\\1");
category.setSaveFiles("metar-${YYYY}-${MM}-${DD}-${HH}\\.*");
scList.add(category);
procArchiveData.setCategoryList(scList);
try {
System.out.println("marshal raw archiveData: "
+ rawArchiveData.toString());
File rawFile = new File("/home/rferrel/Desktop/RAW_DATA.xml");
instance.marshalArchiveDataToXmlFile(rawArchiveData, rawFile);
ArchiveConfig umCategory = instance
.unmarshalArhiveDataFromXmlFile(rawFile);
System.out.println("unmarshal raw archiveData: "
+ umCategory.toString());
System.out.println("marshal processed archiveData: "
+ rawArchiveData.toString());
File procFile = new File("/home/rferrel/Desktop/PROCESSED_DATA.xml");
instance.marshalArchiveDataToXmlFile(procArchiveData, procFile);
umCategory = instance.unmarshalArhiveDataFromXmlFile(procFile);
System.out.println("unmarshal processed archiveData: "
+ umCategory.toString());
} catch (IOException e) {
instance.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
} catch (LocalizationException e) {
instance.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.archive"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.status"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.archive</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,12 @@
#Mon May 06 18:16:00 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Edex Archive
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
Import-Package: com.raytheon.uf.common.archive

View file

@ -0,0 +1,33 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="archivePurge" class="com.raytheon.uf.edex.archive.purge.ArchivePurger"/>
<camelContext id="archivePurge-context"
xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<endpoint id="archivePurgeCron" uri="clusteredquartz://archive/archivePurgeScheduled/?cron=${archivePurge.cron}"/>
<!-- Run archivePurge on Scheduled timer -->
<route id="archivePurgeScheduled">
<from uri="archivePurgeCron" />
<to uri="jms-generic:queue:archivePurgeScheduledWork" />
</route>
<route id="archivePurgeScheduledWork">
<from uri="jms-generic:queue:archivePurgeScheduledWork" />
<doTry>
<bean ref="archivePurge" method="purge" />
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:archivePurge?level=ERROR&amp;showBody=false&amp;showCaughtException=true&amp;showStackTrace=true"/>
</doCatch>
</doTry>
</route>
</camelContext>
</beans>

View file

@ -0,0 +1,2 @@
# purge every half hour
archivePurge.cron=0+0/30,*,*,*,*,*+*+*+*+?

View file

@ -0,0 +1,85 @@
/**
* 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.purge;
import java.util.List;
import com.raytheon.uf.common.archive.ArchiveManagerFactory;
import com.raytheon.uf.common.archive.IArchive;
import com.raytheon.uf.common.archive.IArchiveElement;
import com.raytheon.uf.common.archive.IArchiveManager;
import com.raytheon.uf.common.archive.exception.ArchiveException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Purge task to purge archived data based on configured expiration.
*
* TODO This is a purge that will run on a timer scheduled in spring properties
* that is not related to the expiration date of data. Another possible solution
* would be to programatically schedule a timer when an archive is created based
* on the expiration date of the archive.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 6, 2013 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class ArchivePurger {
private static final IUFStatusHandler logger = UFStatus
.getHandler(ArchivePurger.class);
/**
* Purge expired elements from the archives.
*/
public void purge() {
IArchiveManager manager = ArchiveManagerFactory.getManager();
List<IArchive> archives = manager.getArchives();
for (IArchive archive : archives) {
// TODO fix...
for (IArchiveElement element : archive.getExpiredElements(null,
null)) {
try {
if (!element.purge()) {
String elementName = element == null ? "null" : element
.getName();
logger.error("ArchivePurger unable to purge element "
+ elementName);
}
} catch (ArchiveException e) {
String elementName = element == null ? "null" : element
.getName();
logger.error("ArchivePurger unable to purge element "
+ elementName, e);
}
}
}
}
}

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<archive>
<name>Processed</name>
<rootDir>/awips2/edex/data/archive/</rootDir>
<retentionHours>168</retentionHours>
<category>
<name>redbook</name>
<retentionHours>0</retentionHours>
<dirPattern>hdf5/redbook/([^/]*)/</dirPattern>
<display>redbook - \1</display>
<saveDir>hdf5/redbook/([^/]*)/</saveDir>
<saveFiles>redbook-${YYYY}-${MM}-${DD}-${HH}\..*</saveFiles>
</category>
<category>
<name>obs</name>
<retentionHours>0</retentionHours>
<dirPattern>hdf5/(obs)/</dirPattern>
<display>\1</display>
<saveDir>hdf5/(obs)/</saveDir>
<saveFiles>metar-${YYYY}-${MM}-${DD}-${HH}\.*</saveFiles>
</category>
</archive>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<archive>
<name>Raw</name>
<rootDir>/data_store/</rootDir>
<retentionHours>168</retentionHours>
<category>
<name>Model grib</name>
<retentionHours>0</retentionHours>
<dirPattern>grib/[^/]*/[^/]*/(.*\)</dirPattern>
<display>\1</display>
<saveDir>grib/${YYYY}${MM}${DD}/${HH}/(.*)</saveDir>
<saveFiles>.*</saveFiles>
<selectList>grib/${YYYY}${MM}${DD}/${HH}/NCEP_QPF/</selectList>
</category>
<category>
<name>Model grib2</name>
<retentionHours>0</retentionHours>
<dirPattern>grib2/[^/]*/[^/]*/(.*\)</dirPattern>
<display>\1</display>
<saveDir>grib2/${YYYY}${MM}${DD}/${HH}/.*</saveDir>
<saveFiles>.*</saveFiles>
</category>
<category>
<name>Model other</name>
<retentionHours>0</retentionHours>
<dirPattern>(acars|airmet|binlighting|bufrmos|bufrua|bufsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/[^/]*/[^/]*/(.*)</dirPattern>
<display>\1 - \2</display>
<saveDir>(acars|airmet|binlighting|bufrmos|bufrua|bufsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/YYYYMMDD/HH/.*</saveDir>
<saveFiles>.*</saveFiles>
</category>
<category>
<name>Satellilte</name>
<retentionHours>101</retentionHours>
<dirPattern>sat/[^/]*/[^/]*/(.*)</dirPattern>
<display>\1</display>
<saveDir>sat/${YYYY}${MM}${DD}/${HH}/.*</saveDir>
<saveFiles>.*</saveFiles>
</category>
</archive>

View file

@ -75,6 +75,7 @@
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.edex.plugin.redbook"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.edex.plugin.level"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.common.dataplugin.level"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.common.archive"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.dataplugin.ffmp"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataaccess"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.monitor"/>

View file

@ -0,0 +1,88 @@
/**
* 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.common.archive;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/**
* Test ArchiveManagerFactory.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 7, 2013 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class ArchiveManagerFactoryTest {
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link com.raytheon.uf.common.archive.ArchiveManagerFactory#getManager()}.
*/
@Ignore
@Test
public void testGetManagerNotNull() {
IArchiveManager manager = ArchiveManagerFactory.getManager();
Assert.assertNotNull("ArchiveManagerFactory returned a null manager",
manager);
}
}