From e1a106fdbb827388458673ba4f63c3e39c4abf95 Mon Sep 17 00:00:00 2001 From: Brad Gonzales Date: Fri, 26 Oct 2012 14:00:55 -0500 Subject: [PATCH] Issue # 1292 Migrate the common and edex projects required for stats from the 5-Data_Delivery branch to the development branch in the AWIPS2_baseline repository: edexOsgi/com.raytheon.uf.common.event edexOsgi/com.raytheon.uf.common.stats edexOsgi/com.raytheon.uf.edex.event.feature edexOsgi/com.raytheon.uf.edex.event edexOsgi/com.raytheon.uf.edex.stats update the edex feature and edex build.xml to include the edex stat projects. Change-Id: I8d3232a765124eefa5d6f8387d6ca386163382c4 Former-commit-id: b2656df2f87ff7476172b11eeaf3da37f2bb6648 [formerly b2656df2f87ff7476172b11eeaf3da37f2bb6648 [formerly 6db4ef518672ee4fdfde9109ea4b606ccf6c5e55]] Former-commit-id: 24fc32ee14b41ed051e60137103c147b755039ad Former-commit-id: 5949c8b09c7a1951913c89065ebed8456665dfb1 --- .../feature.xml | 7 + edexOsgi/build.edex/build.xml | 4 + .../feature.xml | 4 + .../com.raytheon.uf.common.event/.classpath | 7 + .../com.raytheon.uf.common.event/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 12 + .../build.properties | 4 + .../component-deploy.xml | 8 + .../com/raytheon/uf/common/event/Event.java | 49 ++ .../uf/common/event/ProcessEvent.java | 68 +++ .../com.raytheon.uf.common.stats/.classpath | 7 + .../com.raytheon.uf.common.stats/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 13 + ...f.common.serialization.ISerializableObject | 2 + .../build.properties | 4 + .../uf/common/stats/AggregateRecord.java | 189 +++++++ .../common/stats/AggregatedStatsRequest.java | 88 ++++ .../common/stats/AggregatedStatsResponse.java | 107 ++++ .../raytheon/uf/common/stats/StatsRecord.java | 108 ++++ .../feature.xml | 7 + .../uf/edex/database/dao/CoreDao.java | 9 + .../META-INF/MANIFEST.MF | 4 +- .../uf/edex/esb/camel/ProcessUtil.java | 5 + .../.project | 17 + .../build.properties | 1 + .../feature.xml | 48 ++ .../com.raytheon.uf.edex.event/.classpath | 7 + edexOsgi/com.raytheon.uf.edex.event/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 22 + .../build.properties | 5 + .../component-deploy.xml | 7 + .../res/spring/event-ingest.xml | 29 ++ .../com/raytheon/uf/edex/event/EventBus.java | 86 ++++ .../uf/edex/event/handler/LogHandler.java | 52 ++ .../com.raytheon.uf.edex.stats/.classpath | 7 + edexOsgi/com.raytheon.uf.edex.stats/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 22 + .../build.properties | 5 + .../res/spring/edex-process-stats.xml | 42 ++ .../res/spring/stats-common.xml | 18 + .../res/spring/stats-request.xml | 19 + .../resources/edexProcessStats.properties | 4 + .../resources/processStats.properties | 4 + .../uf/edex/stats/AggregateManager.java | 485 ++++++++++++++++++ .../raytheon/uf/edex/stats/StatsPurge.java | 180 +++++++ .../raytheon/uf/edex/stats/dao/StatsDao.java | 57 ++ .../stats/handler/AggregatedStatsHandler.java | 98 ++++ .../uf/edex/stats/handler/StatsHandler.java | 95 ++++ .../raytheon/uf/edex/stats/util/Archiver.java | 260 ++++++++++ .../uf/edex/stats/util/ConfigLoader.java | 158 ++++++ .../raytheon/uf/edex/stats/xml/Aggregate.java | 74 +++ .../raytheon/uf/edex/stats/xml/GroupBy.java | 59 +++ .../com/raytheon/uf/edex/stats/xml/Item.java | 71 +++ .../uf/edex/stats/xml/Statistics.java | 119 +++++ .../uf/edex/stats/xml/StatsConfig.java | 85 +++ .../base/purge/aggregatePurgeRules.xml | 10 + .../base/purge/statsPurgeRules.xml | 10 + .../base/stats/edexProcessStats.xml | 10 + 62 files changed, 3015 insertions(+), 1 deletion(-) create mode 100644 edexOsgi/com.raytheon.uf.common.event/.classpath create mode 100644 edexOsgi/com.raytheon.uf.common.event/.project create mode 100644 edexOsgi/com.raytheon.uf.common.event/.settings/org.eclipse.jdt.core.prefs create mode 100644 edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF create mode 100644 edexOsgi/com.raytheon.uf.common.event/build.properties create mode 100644 edexOsgi/com.raytheon.uf.common.event/component-deploy.xml create mode 100644 edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java create mode 100644 edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/ProcessEvent.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/.classpath create mode 100644 edexOsgi/com.raytheon.uf.common.stats/.project create mode 100644 edexOsgi/com.raytheon.uf.common.stats/.settings/org.eclipse.jdt.core.prefs create mode 100644 edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF create mode 100644 edexOsgi/com.raytheon.uf.common.stats/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject create mode 100644 edexOsgi/com.raytheon.uf.common.stats/build.properties create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregateRecord.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsRequest.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsResponse.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/StatsRecord.java create mode 100644 edexOsgi/com.raytheon.uf.edex.event.feature/.project create mode 100644 edexOsgi/com.raytheon.uf.edex.event.feature/build.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.event.feature/feature.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.event/.classpath create mode 100644 edexOsgi/com.raytheon.uf.edex.event/.project create mode 100644 edexOsgi/com.raytheon.uf.edex.event/.settings/org.eclipse.jdt.core.prefs create mode 100644 edexOsgi/com.raytheon.uf.edex.event/META-INF/MANIFEST.MF create mode 100644 edexOsgi/com.raytheon.uf.edex.event/build.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.event/component-deploy.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.event/res/spring/event-ingest.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/EventBus.java create mode 100644 edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/LogHandler.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/.classpath create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/.project create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/.settings/org.eclipse.jdt.core.prefs create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/META-INF/MANIFEST.MF create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/build.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/res/spring/edex-process-stats.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-common.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-request.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/resources/edexProcessStats.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/AggregateManager.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/StatsPurge.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/dao/StatsDao.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/AggregatedStatsHandler.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/StatsHandler.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/ConfigLoader.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Aggregate.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/GroupBy.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Item.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Statistics.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/StatsConfig.java create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/aggregatePurgeRules.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/statsPurgeRules.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml diff --git a/cave/com.raytheon.uf.viz.cots.feature/feature.xml b/cave/com.raytheon.uf.viz.cots.feature/feature.xml index 25456a2cc0..d0caabd398 100644 --- a/cave/com.raytheon.uf.viz.cots.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.cots.feature/feature.xml @@ -23,6 +23,13 @@ install-size="0" version="0.0.0"/> + + + + + diff --git a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml index 1a4376696c..4fb553e514 100644 --- a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml +++ b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml @@ -96,6 +96,10 @@ id="com.raytheon.uf.edex.ost.feature" version="0.0.0"/> + + diff --git a/edexOsgi/com.raytheon.uf.common.event/.classpath b/edexOsgi/com.raytheon.uf.common.event/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.event/.project b/edexOsgi/com.raytheon.uf.common.event/.project new file mode 100644 index 0000000000..a5e31e2ffb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.event + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.event/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.event/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..6231358f5d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Jun 14 10:58:39 CDT 2012 +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 diff --git a/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..364617af80 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Event +Bundle-SymbolicName: com.raytheon.uf.common.event +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + javax.persistence;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174" +Export-Package: com.raytheon.uf.common.event diff --git a/edexOsgi/com.raytheon.uf.common.event/build.properties b/edexOsgi/com.raytheon.uf.common.event/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.event/component-deploy.xml b/edexOsgi/com.raytheon.uf.common.event/component-deploy.xml new file mode 100644 index 0000000000..a4b7d8c4f6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/component-deploy.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java new file mode 100644 index 0000000000..61445e0571 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/Event.java @@ -0,0 +1,49 @@ +package com.raytheon.uf.common.event; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import javax.persistence.Column; + +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +public abstract class Event implements Serializable, ISerializableObject { + + private static final long serialVersionUID = 1L; + + @Column + @DynamicSerializeElement + protected Calendar date; + + @Column + @DynamicSerializeElement + protected String id; + + public Event() { + date = Calendar.getInstance(); + } + + public Calendar getDate() { + return date; + } + + public void setDate(Calendar date) { + this.date = date; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String toString() { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-d hh:mm:ss"); + return formatter.format(date.getTime()) + " Id: " + id; + } + +} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/ProcessEvent.java b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/ProcessEvent.java new file mode 100644 index 0000000000..ba9ad63ec7 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.event/src/com/raytheon/uf/common/event/ProcessEvent.java @@ -0,0 +1,68 @@ +/** + * 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.event; + + + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 25, 2012  #1292     bgonzale     Initial creation
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ +@DynamicSerialize +public class ProcessEvent extends Event { + + private static final long serialVersionUID = 1L; + + @DynamicSerializeElement + private final String message; + + public ProcessEvent(String message) { + super(); + this.message = message; + } + + @Override + public String toString() { + return super.toString() + " : " + getMessage(); + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.stats/.classpath b/edexOsgi/com.raytheon.uf.common.stats/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.stats/.project b/edexOsgi/com.raytheon.uf.common.stats/.project new file mode 100644 index 0000000000..b961719532 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.stats + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.stats/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.stats/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..277fa3721e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Aug 06 10:54:57 CDT 2012 +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 diff --git a/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..3efba560f6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Stats +Bundle-SymbolicName: com.raytheon.uf.common.stats +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: com.raytheon.uf.common.stats +Require-Bundle: com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + javax.persistence;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174" diff --git a/edexOsgi/com.raytheon.uf.common.stats/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.stats/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject new file mode 100644 index 0000000000..62f07fe400 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -0,0 +1,2 @@ +com.raytheon.uf.common.stats.StatsRecord +com.raytheon.uf.common.stats.AggregateRecord \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.stats/build.properties b/edexOsgi/com.raytheon.uf.common.stats/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregateRecord.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregateRecord.java new file mode 100644 index 0000000000..f9c563f425 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregateRecord.java @@ -0,0 +1,189 @@ +/** + * 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.stats; + +import java.util.Calendar; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Record class for an aggregate result. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Initial creation
+ * 
+ * 
+ * + * @author jsanchez + * @version 1.0 + */ +@Entity +@Table(name = "aggregate", schema = "events") +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class AggregateRecord extends PersistableDataObject { + + @GeneratedValue(strategy = GenerationType.AUTO) + @Id + @DynamicSerializeElement + private Integer id; + + @Column(nullable = false) + @DynamicSerializeElement + private Calendar startDate; + + @Column(nullable = false) + @DynamicSerializeElement + private Calendar endDate; + + @Column(nullable = false) + @DynamicSerializeElement + private String eventType; + + @DynamicSerializeElement + private String grouping; + + @Column(nullable = false) + @DynamicSerializeElement + private String field; + + @DynamicSerializeElement + private double max; + + @DynamicSerializeElement + private double min; + + @DynamicSerializeElement + private double sum; + + @DynamicSerializeElement + private double count; + + public AggregateRecord() { + + } + + public AggregateRecord(String eventType, Calendar startDate, + Calendar endDate, String groupings, String field) { + this.eventType = eventType; + this.startDate = startDate; + this.endDate = endDate; + this.grouping = groupings; + this.field = field; + } + + public Calendar getStartDate() { + return startDate; + } + + public void setStartDate(Calendar startDate) { + this.startDate = startDate; + } + + public Calendar getEndDate() { + return endDate; + } + + public void setEndDate(Calendar endDate) { + this.endDate = endDate; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getGrouping() { + return grouping; + } + + public void setGrouping(String grouping) { + this.grouping = grouping; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public double getMax() { + return max; + } + + public void setMax(double max) { + this.max = max; + } + + public double getMin() { + return min; + } + + public void setMin(double min) { + this.min = min; + } + + public double getSum() { + return sum; + } + + public void setSum(double sum) { + this.sum = sum; + } + + public double getCount() { + return count; + } + + public void setCount(double count) { + this.count = count; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsRequest.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsRequest.java new file mode 100644 index 0000000000..0f1cd8d474 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsRequest.java @@ -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.stats; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.serialization.comm.IServerRequest; +import com.raytheon.uf.common.time.TimeRange; + +/** + * Request results from the metadata.aggregate table. + * + * SOFTWARE HISTORY + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Aug 21, 2012 jsanchez Initial creation + * + * @author jsanchez + * + */ +@DynamicSerialize +public class AggregatedStatsRequest implements IServerRequest { + @DynamicSerializeElement + private TimeRange timeRange; + + @DynamicSerializeElement + private String eventType; + + @DynamicSerializeElement + private String[] grouping; + + @DynamicSerializeElement + private String field; + + public AggregatedStatsRequest() { + + } + + public TimeRange getTimeRange() { + return timeRange; + } + + public void setTimeRange(TimeRange timeRange) { + this.timeRange = timeRange; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String[] getGrouping() { + return grouping; + } + + public void setGrouping(String[] grouping) { + this.grouping = grouping; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsResponse.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsResponse.java new file mode 100644 index 0000000000..d5abe7ac05 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/AggregatedStatsResponse.java @@ -0,0 +1,107 @@ +/** + * 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.stats; + +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.time.TimeRange; + +/** + * Response from the handler of the results in the metadata.aggregate table. + * + * SOFTWARE HISTORY + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Aug 21, 2012 jsanchez Initial creation + * + * @author jsanchez + * + */ +@DynamicSerialize +public class AggregatedStatsResponse implements ISerializableObject { + @DynamicSerializeElement + private TimeRange timeRange; + + @DynamicSerializeElement + private String eventType; + + @DynamicSerializeElement + private String[] grouping; + + @DynamicSerializeElement + private String field; + + @DynamicSerializeElement + private AggregateRecord[] records; + + public AggregatedStatsResponse() { + + } + + public AggregatedStatsResponse(TimeRange timeRange, String eventType, + String[] grouping, String field) { + this.timeRange = timeRange; + this.eventType = eventType; + this.grouping = grouping; + this.field = field; + } + + public TimeRange getTimeRange() { + return timeRange; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String[] getGrouping() { + return grouping; + } + + public void setGrouping(String[] grouping) { + this.grouping = grouping; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public void setTimeRange(TimeRange timeRange) { + this.timeRange = timeRange; + } + + public AggregateRecord[] getRecords() { + return records; + } + + public void setRecords(AggregateRecord[] records) { + this.records = records; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/StatsRecord.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/StatsRecord.java new file mode 100644 index 0000000000..e709d6c206 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/StatsRecord.java @@ -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.common.stats; + +import java.util.Calendar; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Record class for stats waiting to be stored in the appropriate bucket. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Initial creation
+ * 
+ * 
+ * + * @author jsanchez + * + */ +@Entity +@Table(name = "stats", schema = "events") +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +@DynamicSerialize +public class StatsRecord extends PersistableDataObject { + @GeneratedValue(strategy = GenerationType.AUTO) + @Id + @DynamicSerializeElement + private Integer id; + + @Column(nullable = false) + @DynamicSerializeElement + private Calendar date; + + @Column(nullable = false) + @DynamicSerializeElement + private String eventType; + + @Column(nullable = false) + @DynamicSerializeElement + private byte[] event; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Calendar getDate() { + return date; + } + + public void setDate(Calendar date) { + this.date = date; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public byte[] getEvent() { + return event; + } + + public void setEvent(byte[] event) { + this.event = event; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml index b8ae845cd0..ed07815a5d 100644 --- a/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.cots.feature/feature.xml @@ -293,6 +293,13 @@ install-size="0" version="0.0.0"/> + + objs) { + txTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { + getHibernateTemplate().deleteAll(objs); + } + }); + } } diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF index 1e03fcae7e..8a76ef99c0 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/META-INF/MANIFEST.MF @@ -17,6 +17,8 @@ Require-Bundle: org.apache.camel;bundle-version="1.0.0", javax.servlet Export-Package: com.raytheon.uf.edex.esb.camel, com.raytheon.uf.edex.esb.camel.directvm -Import-Package: com.raytheon.uf.common.message, +Import-Package: com.raytheon.uf.common.event, + com.raytheon.uf.common.message, com.raytheon.uf.edex.database.cluster, + com.raytheon.uf.edex.event, javax.persistence diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java index c4f89d4b74..e15f96d467 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/ProcessUtil.java @@ -29,9 +29,11 @@ import org.apache.camel.Header; import org.apache.camel.Headers; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.event.ProcessEvent; 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.event.EventBus; /** * Provides logging and deletion services for camel @@ -111,6 +113,9 @@ public class ProcessUtil { } sb.append(" (sec)"); } + + EventBus.getInstance().publish(new ProcessEvent(sb.toString())); + // Make sure we have something to log. if (sb.length() > 0) { handler.handle(Priority.INFO, sb.toString()); diff --git a/edexOsgi/com.raytheon.uf.edex.event.feature/.project b/edexOsgi/com.raytheon.uf.edex.event.feature/.project new file mode 100644 index 0000000000..daa16ed48a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event.feature/.project @@ -0,0 +1,17 @@ + + + com.raytheon.uf.edex.event.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/edexOsgi/com.raytheon.uf.edex.event.feature/build.properties b/edexOsgi/com.raytheon.uf.edex.event.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/edexOsgi/com.raytheon.uf.edex.event.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.event.feature/feature.xml new file mode 100644 index 0000000000..4b662036e8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event.feature/feature.xml @@ -0,0 +1,48 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.event/.classpath b/edexOsgi/com.raytheon.uf.edex.event/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.event/.project b/edexOsgi/com.raytheon.uf.edex.event/.project new file mode 100644 index 0000000000..254c0a6afa --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.edex.event + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.edex.event/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.event/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..9cb7470e61 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Jun 14 11:22:23 CDT 2012 +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 diff --git a/edexOsgi/com.raytheon.uf.edex.event/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.event/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f515c34baa --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Event +Bundle-SymbolicName: com.raytheon.uf.edex.event +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.google.guava;bundle-version="1.0.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.edex.core;bundle-version="1.12.1174", + com.raytheon.uf.common.event;bundle-version="1.0.0", + org.apache.commons.logging;bundle-version="1.1.1", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.edex.database;bundle-version="1.0.0", + com.raytheon.uf.common.dataquery;bundle-version="1.0.0", + org.springframework;bundle-version="2.5.6", + 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.dataplugin;bundle-version="1.12.1174", + org.junit +Export-Package: com.raytheon.uf.edex.event diff --git a/edexOsgi/com.raytheon.uf.edex.event/build.properties b/edexOsgi/com.raytheon.uf.edex.event/build.properties new file mode 100644 index 0000000000..5791d48d5f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + res/ diff --git a/edexOsgi/com.raytheon.uf.edex.event/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.event/component-deploy.xml new file mode 100644 index 0000000000..98acd607b6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/component-deploy.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-ingest.xml b/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-ingest.xml new file mode 100644 index 0000000000..c46a2f88eb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-ingest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/EventBus.java b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/EventBus.java new file mode 100644 index 0000000000..d0142e2dcb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/EventBus.java @@ -0,0 +1,86 @@ +package com.raytheon.uf.edex.event; + +import java.util.concurrent.Executors; + +import com.google.common.eventbus.AsyncEventBus; +import com.raytheon.uf.common.event.Event; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.core.EDEXUtil; + +/** + * + * The EventBus. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 11, 2012 1261       djohnson     Add SW history, create constants for fields, 
+ *                                      add unregister.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ +public class EventBus { + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(EventBus.class); + + private static final EventBus instance = new EventBus(); + + private static final AsyncEventBus asyncEventBus; + static { + int threadCount = 15; + try { + threadCount = Integer.parseInt((String) EDEXUtil + .getESBComponent("eventBusThreadCount")); + } catch (Exception e) { + statusHandler.error( + "Unable to set thread pool size from spring; defaulting size to " + + threadCount + ".", + e); + } + asyncEventBus = new AsyncEventBus( + Executors.newFixedThreadPool(threadCount)); + } + + /** + * Returns the same instance of the data delivery event bus + * + * @return + */ + public static EventBus getInstance() { + return instance; + } + + /** + * Register an object with the event bus. + * + * @param subscriber + */ + public void register(Object subscriber) { + asyncEventBus.register(subscriber); + } + + /** + * Publishes events for all subscribers to receive + * + * @param event + */ + public void publish(Event event) { + asyncEventBus.post(event); + } + + /** + * Unregister an object with the event bus. + * + * @param instance2 + */ + public void unregister(Object subscriber) { + asyncEventBus.unregister(subscriber); + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/LogHandler.java b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/LogHandler.java new file mode 100644 index 0000000000..111cc3b21b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/LogHandler.java @@ -0,0 +1,52 @@ +package com.raytheon.uf.edex.event.handler; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.google.common.eventbus.AllowConcurrentEvents; +import com.google.common.eventbus.Subscribe; +import com.raytheon.uf.common.event.Event; +import com.raytheon.uf.edex.event.EventBus; + +/** + * + * Logs ALL events published on the event bus + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 1, 2012            jsanchez     Initial creation
+ * 
+ * 
+ * + * @author jsanchez + * @version 1.0 + */ +public class LogHandler { + + private final Log logger; + + private static EventBus eventBus = EventBus.getInstance(); + + /** + * Creates a new object + */ + public LogHandler() { + eventBus.register(this); + logger = LogFactory.getLog("Event"); + } + + /** + * Listens for any DataDeliveryEvent object published on the event bus + * + * @param event + */ + @Subscribe + @AllowConcurrentEvents + public void eventListener(Event event) { + logger.info(event.toString()); + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/.classpath b/edexOsgi/com.raytheon.uf.edex.stats/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.stats/.project b/edexOsgi/com.raytheon.uf.edex.stats/.project new file mode 100644 index 0000000000..3da103ed13 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.edex.stats + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.edex.stats/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.stats/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..d9eae69d6f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Jun 18 16:45:16 CDT 2012 +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 diff --git a/edexOsgi/com.raytheon.uf.edex.stats/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.stats/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6c7aa8ff35 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Stats +Bundle-SymbolicName: com.raytheon.uf.edex.stats +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.edex.event;bundle-version="1.0.0", + com.raytheon.uf.common.event;bundle-version="1.0.0", + com.google.guava;bundle-version="1.0.0", + com.raytheon.uf.edex.database;bundle-version="1.0.0", + com.raytheon.uf.common.localization;bundle-version="1.12.1174", + com.raytheon.uf.common.dataquery;bundle-version="1.0.0", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + com.raytheon.uf.common.stats;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", + org.springframework;bundle-version="2.5.6", + com.raytheon.uf.edex.core;bundle-version="1.12.1174", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + org.apache.commons.collections;bundle-version="3.2.0" diff --git a/edexOsgi/com.raytheon.uf.edex.stats/build.properties b/edexOsgi/com.raytheon.uf.edex.stats/build.properties new file mode 100644 index 0000000000..5791d48d5f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + res/ diff --git a/edexOsgi/com.raytheon.uf.edex.stats/res/spring/edex-process-stats.xml b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/edex-process-stats.xml new file mode 100644 index 0000000000..f646461d53 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/edex-process-stats.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-common.xml b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-common.xml new file mode 100644 index 0000000000..02282638f5 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-common.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-request.xml b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-request.xml new file mode 100644 index 0000000000..41e6dd11eb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-request.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.stats/resources/edexProcessStats.properties b/edexOsgi/com.raytheon.uf.edex.stats/resources/edexProcessStats.properties new file mode 100644 index 0000000000..32798b08c0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/resources/edexProcessStats.properties @@ -0,0 +1,4 @@ +# scan interval of stats table in minutes +stats.scanInterval=15 +# bucket interval or period of when to aggregate in minutes +stats.period=2 \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties b/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties new file mode 100644 index 0000000000..32798b08c0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties @@ -0,0 +1,4 @@ +# scan interval of stats table in minutes +stats.scanInterval=15 +# bucket interval or period of when to aggregate in minutes +stats.period=2 \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/AggregateManager.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/AggregateManager.java new file mode 100644 index 0000000000..35b76a0a2c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/AggregateManager.java @@ -0,0 +1,485 @@ +/** + * 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.stats; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TimeZone; + +import com.raytheon.uf.common.event.Event; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.stats.AggregateRecord; +import com.raytheon.uf.common.stats.StatsRecord; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.stats.dao.StatsDao; +import com.raytheon.uf.edex.stats.handler.StatsHandler; +import com.raytheon.uf.edex.stats.util.ConfigLoader; +import com.raytheon.uf.edex.stats.xml.Aggregate; +import com.raytheon.uf.edex.stats.xml.Item; +import com.raytheon.uf.edex.stats.xml.StatsConfig; + +/** + * Aggregates stat records based on the statsConfig files and stores them after + * a configured period. + * + * * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Stored the aggregate buckets in the db.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class AggregateManager { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(AggregateManager.class); + + private class TimeRangeKey extends TimeRange { + public TimeRangeKey(Calendar cal1, Calendar cal2) { + super(cal1, cal2); + } + + @Override + public boolean equals(Object o) { + if (o != null && o instanceof TimeRange) { + TimeRange other = (TimeRange) o; + + return (this.getStart().equals(other.getStart()) && this + .getEnd().equals(other.getEnd())); + } + + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String toString() { + return super.toString(); + } + } + + /** In minutes */ + private int bucketInterval; + + /** In minutes */ + private int scanInterval; + + /** default value */ + private static final int defaultBucketInterval = 5; + + /** default value */ + private static final int defaultScanInterval = 15; + + /** loads localized copies of the statsConfig */ + private ConfigLoader configLoader; + + private CoreDao aggregateRecordDao = new CoreDao(DaoConfig.forClass( + "metadata", AggregateRecord.class)); + + public AggregateManager(String bucketInterval, String scanInterval) + throws Exception { + this.configLoader = new ConfigLoader(); + validateIntervals(bucketInterval, scanInterval); + configLoader.load(); + StatsHandler.setValidEventTypes(configLoader.getConfigurations()); + } + + /** + * Tests if the bucket interval and the scan interval are valid values. If + * values are invalid then values will be set to default values. + * + * @param bucketInt + * @param scanInt + * @return + */ + private void validateIntervals(String bucketInt, String scanInt) { + try { + bucketInterval = Integer.parseInt(bucketInt); + } catch (NumberFormatException e) { + bucketInterval = defaultBucketInterval; + statusHandler.info("'" + bucketInt + + "' is not a valid bucket interval value. Setting to '" + + defaultBucketInterval + "'"); + } + + try { + scanInterval = Integer.parseInt(scanInt); + } catch (NumberFormatException e) { + scanInterval = defaultScanInterval; + statusHandler.info("'" + scanInt + + "' is not a valid scan interval value. Setting to '" + + defaultScanInterval + "'"); + } + + if (scanInterval < bucketInterval) { + scanInterval = defaultBucketInterval; + bucketInterval = defaultBucketInterval; + statusHandler + .info("The bucket interval can not be greater than the scan interval. Setting scan interval to '" + + defaultBucketInterval + + "' and bucket interval to '" + + bucketInterval + + "'"); + } + + int incrementsWithinHour = bucketInterval; + // checks if period is larger than 60 minutes + if (bucketInterval > 60) { + incrementsWithinHour = bucketInterval % 60; + } + if (60 % incrementsWithinHour != 0) { + bucketInterval = defaultBucketInterval; + statusHandler + .info("The bucket interval must go into an hour evenly. Setting bucket interval to '" + + bucketInterval + "'"); + } + } + + /** + * Scans the stats table to be stored in buckets and aggregate if necessary. + */ + public void scan() throws Exception { + StatsDao statsRecordDao = new StatsDao(); + Map>> aggregateBuckets = new HashMap>>(); + + // retrieves records and sorts in buckets + retrieveStatRecords(statsRecordDao, aggregateBuckets); + + // loops through map to aggregate buckets + for (StatsConfig statsConfig : configLoader.getConfigurations()) { + String eventType = statsConfig.getEventType(); + + Map> map = aggregateBuckets + .get(eventType); + // map should never be null, since it will be set in the 'sort' + // method. + for (Iterator>> iter = map.entrySet().iterator(); iter.hasNext(); ) { + Entry> element = iter.next(); + TimeRangeKey tr = element.getKey(); + List records = element.getValue(); + if (!records.isEmpty()) { + List data = extractEvents(records); + aggregate(statsConfig, tr, data); + try { + statsRecordDao.deleteAll(records); + } catch (Exception e) { + statusHandler.error("Error deleting stat records", e); + } + } + iter.remove(); + } + } + } + + /** + * Retrieve StatRecords from the metadata.event.stats table. This method + * does not retrieve records of the current bucket. + */ + private void retrieveStatRecords(StatsDao statsRecordDao, + Map>> aggregateBuckets) + throws Exception { + Calendar current = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + for (StatsConfig statsConfig : configLoader.getConfigurations()) { + String eventType = statsConfig.getEventType(); + // Does not retrieve stat records of current bucket. + // this method should always return a valid array. + StatsRecord[] records = statsRecordDao.retrieveRecords( + getBucketStartTime(current), eventType); + sort(eventType, records, aggregateBuckets); + } + } + + /** + * Stores the results into proper aggregate buckets. This method assumes + * that the records are in date order. + * + * @param events + */ + private void sort(String eventType, StatsRecord[] records, + Map>> aggregateBuckets) + throws Exception { + Map> map = aggregateBuckets + .get(eventType); + if (map == null) { + map = new HashMap>(); + aggregateBuckets.put(eventType, map); + } + + TimeRangeKey timeRange = null; + for (StatsRecord record : records) { + if (timeRange == null + || !timeRange.contains(record.getDate().getTime())) { + // Create bucket based on stats record date + timeRange = createTimeRangeKey(record.getDate()); + } + + List bucketList = map.get(timeRange); + if (bucketList == null) { + bucketList = new ArrayList(); + map.put(timeRange, bucketList); + } + bucketList.add(record); + } + } + + /** + * Creates a time range from a date and the bucket interval. The time range + * start time that will be the date rounded to the next bucket interval. The + * time range end time will be the start time plus the bucket interval. + * + * @param date + * @return + */ + private TimeRangeKey createTimeRangeKey(Calendar date) { + Calendar start = getBucketStartTime(date); + Calendar end = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + end.setTimeInMillis(start.getTimeInMillis()); + end.add(Calendar.MINUTE, bucketInterval); + + TimeRangeKey timeRangeKey = new TimeRangeKey(start, end); + + return timeRangeKey; + } + + /** + * Calculates the start time that will be the date rounded to the next + * bucket interval + * + * @param date + * @return + */ + private Calendar getBucketStartTime(Calendar date) { + int currentMinutes = date.get(Calendar.MINUTE); + + int incrementsWithinHour = bucketInterval; + // checks if period is larger than 60 minutes + if (bucketInterval > 60) { + incrementsWithinHour = bucketInterval % 60; + } + + int mod = currentMinutes % incrementsWithinHour; + + Calendar start = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + start.setTimeInMillis(date.getTimeInMillis()); + start.add(Calendar.MINUTE, -mod); + start.set(Calendar.SECOND, 0); + start.set(Calendar.MILLISECOND, 0); + + return start; + } + + /** + * Extracts the events from the stats records. + * + * @param records + * @return + */ + private List extractEvents(List records) { + List eventsList = new ArrayList(records.size()); + + for (StatsRecord record : records) { + try { + Event event = (Event) SerializationUtil + .transformFromThrift(record.getEvent()); + eventsList.add(event); + } catch (SerializationException e) { + statusHandler + .error("Error trying to transform event. Aggregation may be inaccurate. ", + e); + } + } + + return eventsList; + } + + /** + * Performs the aggregation based on the statsConfig file. + * + * @param key + * @param data + */ + private void aggregate(StatsConfig statsConfig, TimeRange timeRange, + List data) { + Calendar start = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + start.setTime(timeRange.getStart()); + + Calendar end = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + end.setTime(timeRange.getEnd()); + + // collect grouping names from stats config + List groupByColumns = new ArrayList(); + for (Item item : statsConfig.getGroupBy().getAttributes()) { + String column = item.getName(); + groupByColumns.add(column); + } + + // breaks data into groups + Map> map = divideIntoGroups(data, groupByColumns); + + // perform aggregate functions on the grouped data + for (String groupKey : map.keySet()) { + + List groupData = map.get(groupKey); + for (Aggregate aggregate : statsConfig.getAggregates()) { + String field = aggregate.getField(); + try { + double[] values = new double[groupData.size()]; + String methodName = getterMethodName(field); + for (int i = 0; i < groupData.size(); i++) { + Object obj = groupData.get(i); + Class clazz = obj.getClass(); + Method m = clazz.getMethod(methodName, new Class[0]); + Number number = (Number) m.invoke(obj, new Object[0]); + values[i] = number.doubleValue(); + } + + double count = values.length; + double max = 0; + double min = Double.MAX_VALUE; + double sum = 0; + + for (int i = 0; i < values.length; i++) { + sum += values[i]; + if (values[i] > max) { + max = values[i]; + } + + if (values[i] < min) { + min = values[i]; + } + } + + AggregateRecord record = new AggregateRecord( + statsConfig.getEventType(), start, end, groupKey, + field); + record.setSum(sum); + record.setMin(min); + record.setMax(max); + record.setCount(count); + aggregateRecordDao.persist(record); + } catch (Exception e) { + statusHandler.error("Unable to aggregate '" + field + "'", + e); + } + } + } + } + + /** + * Breaks the list of data into groups based on groupByColumns. The key is a + * concatenation of the column values (i.e. datatype.username). This method + * can group data to n-number of levels. + * + * @param data + * @param groupByColumns + * @return + */ + private Map> divideIntoGroups(List data, + List groupByColumns) { + Map> map = new HashMap>(); + map.put("", data); + for (String column : groupByColumns) { + + List>> listOfMaps = new ArrayList>>(); + for (String parent : map.keySet()) { + List list = map.get(parent); + listOfMaps.add(group(list, column, parent)); + } + + map.clear(); + + // replace map with grouped data + for (Map> m : listOfMaps) { + for (String k : m.keySet()) { + map.put(k, m.get(k)); + } + } + } + + return map; + } + + /** + * Helper method to group data to one level. + * + * @param data + * @param column + * @param parent + * @return + */ + private Map> group(List data, String column, + String parent) { + Map> map = new HashMap>(); + String methodName = getterMethodName(column); + for (Event rec : data) { + try { + Class clazz = rec.getClass(); + Method m = clazz.getMethod(methodName, new Class[0]); + String value = column + ":" + + String.valueOf(m.invoke(rec, new Object[0])); + if (parent.length() > 0) { + value = parent + "-" + value; + } + List list = map.get(value); + if (list == null) { + list = new ArrayList(); + } + list.add(rec); + map.put(value, list); + } catch (Exception e) { + statusHandler.error("Error creating groups", e); + } + } + + return map; + } + + /** + * Returns the name of the getter method for the parameter + * + * @param parameter + * @return + */ + private String getterMethodName(String parameter) { + return "get" + parameter.substring(0, 1).toUpperCase() + + parameter.substring(1); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/StatsPurge.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/StatsPurge.java new file mode 100644 index 0000000000..dc0a37b11e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/StatsPurge.java @@ -0,0 +1,180 @@ +/** + * 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.stats; + +import java.io.File; +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import javax.xml.bind.JAXBException; + +import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.stats.AggregateRecord; +import com.raytheon.uf.common.stats.StatsRecord; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.database.DataAccessLayerException; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.database.purge.PurgeRule; +import com.raytheon.uf.edex.database.purge.PurgeRuleSet; +import com.raytheon.uf.edex.database.query.DatabaseQuery; +import com.raytheon.uf.edex.stats.util.Archiver; + +/** + * Purges the stats table of expired/unused stat records. Purges the aggregate + * table and write it to disk. + * + * * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Initial creation.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class StatsPurge { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(StatsPurge.class); + + private Archiver archiver; + + private CoreDao aggregateRecordDao = new CoreDao(DaoConfig.forClass( + "metadata", AggregateRecord.class)); + + private CoreDao statsRecordDao = new CoreDao(DaoConfig.forClass("metadata", + StatsRecord.class)); + + private PurgeRuleSet aggregatePurgeRules; + + private PurgeRuleSet statsPurgeRules; + + public StatsPurge() { + aggregatePurgeRules = readPurgeRules("aggregatePurgeRules.xml"); + statsPurgeRules = readPurgeRules("statsPurgeRules.xml"); + try { + archiver = new Archiver(); + purgeStats(); + } catch (JAXBException e) { + statusHandler + .error("Error starting up archiver. Aggregates will not be archived. ", + e); + } catch (DataAccessLayerException e) { + statusHandler + .error("Error purging stats on start up. Stats will not be purged. ", + e); + } + } + + /** + * Reads the purge files. + */ + private PurgeRuleSet readPurgeRules(String xml) { + PurgeRuleSet purgeRules = null; + try { + File file = PathManagerFactory.getPathManager().getStaticFile( + "purge/" + xml); + if (file != null) { + try { + purgeRules = (PurgeRuleSet) SerializationUtil + .jaxbUnmarshalFromXmlFile(file); + } catch (SerializationException e) { + statusHandler.error("Error deserializing purge rule " + xml + + "!"); + } + + } else { + statusHandler.error(xml + + " rule not defined!! Data will not be purged."); + } + } catch (Exception e) { + statusHandler.error("Error reading purge file " + xml, e); + } + return purgeRules; + } + + /** + * Purges records from the stats table if they are older than the expiration + * time. + */ + private void purgeStats() throws DataAccessLayerException { + if (statsPurgeRules != null) { + Calendar expiration = Calendar.getInstance(TimeZone + .getTimeZone("GMT")); + DatabaseQuery deleteStmt = new DatabaseQuery(StatsRecord.class); + + for (PurgeRule rule : statsPurgeRules.getRules()) { + if (rule.isPeriodSpecified()) { + long ms = rule.getPeriodInMillis(); + int minutes = new Long(ms / (1000 * 60)).intValue(); + expiration.add(Calendar.MINUTE, -minutes); + deleteStmt.addQueryParam("date", expiration, + QueryOperand.LESSTHAN); + statsRecordDao.deleteByCriteria(deleteStmt); + } + } + } + } + + /** + * Purges records from the aggregate table and writes them to disk. + */ + public void purgeAggregates() throws JAXBException, + DataAccessLayerException { + if (aggregatePurgeRules != null) { + Calendar expiration = Calendar.getInstance(TimeZone + .getTimeZone("GMT")); + DatabaseQuery query = new DatabaseQuery(AggregateRecord.class); + + for (PurgeRule rule : aggregatePurgeRules.getRules()) { + if (rule.isPeriodSpecified()) { + long ms = rule.getPeriodInMillis(); + int minutes = new Long(ms / (1000 * 60)).intValue(); + expiration.add(Calendar.MINUTE, -minutes); + query.addQueryParam("endDate", expiration, + QueryOperand.LESSTHAN); + List objects = aggregateRecordDao.queryByCriteria(query); + if (!objects.isEmpty()) { + AggregateRecord[] aggregateRecords = new AggregateRecord[objects + .size()]; + + for (int i = 0; i < aggregateRecords.length; i++) { + aggregateRecords[i] = (AggregateRecord) objects + .get(i); + } + archiver.writeToDisk(aggregateRecords); + aggregateRecordDao.deleteAll(objects); + } + } + } + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/dao/StatsDao.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/dao/StatsDao.java new file mode 100644 index 0000000000..bfcec2efa0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/dao/StatsDao.java @@ -0,0 +1,57 @@ +package com.raytheon.uf.edex.stats.dao; + +import java.util.Calendar; +import java.util.List; + +import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand; +import com.raytheon.uf.common.stats.StatsRecord; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.database.DataAccessLayerException; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.database.query.DatabaseQuery; + +public class StatsDao extends CoreDao { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(StatsDao.class); + + /** + * Creates a new data access object + */ + public StatsDao() { + super(DaoConfig.forClass("metadata", StatsRecord.class)); + } + + /** + * Retrieves stat records that has a date before the limit. + * + * @param limit + * @param eventType + * @return an array of stat records. If an error occurs, then an array of + * size 0 will be returned. + * @throws DataAccessLayerException + */ + public StatsRecord[] retrieveRecords(Calendar limit, String eventType) { + DatabaseQuery query = new DatabaseQuery(StatsRecord.class); + query.addQueryParam("eventType", eventType, QueryOperand.EQUALS); + query.addQueryParam("date", limit, QueryOperand.LESSTHAN); + query.setMaxResults(1000); + + // TODO Need to make StatsDao to keep track to determine next 1000 + // results. + StatsRecord[] records = null; + try { + List objects = queryByCriteria(query); + records = new StatsRecord[objects.size()]; + for (int i = 0; i < records.length; i++) { + records[i] = (StatsRecord) objects.get(i); + } + } catch (DataAccessLayerException e) { + records = new StatsRecord[0]; + statusHandler.error("Error querying the stats table", e); + } + + return records; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/AggregatedStatsHandler.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/AggregatedStatsHandler.java new file mode 100644 index 0000000000..90a3194951 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/AggregatedStatsHandler.java @@ -0,0 +1,98 @@ +/** + * 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.stats.handler; + +import java.util.List; + +import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand; +import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.common.stats.AggregateRecord; +import com.raytheon.uf.common.stats.AggregatedStatsRequest; +import com.raytheon.uf.common.stats.AggregatedStatsResponse; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.database.query.DatabaseQuery; + +/** + * Handles an AggregateStatsRequest and queries the metadata.aggregate table and + * return the results in an AggregateStatsResponse + * + * *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Initial creation.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class AggregatedStatsHandler implements + IRequestHandler { + + private CoreDao dao = new CoreDao(DaoConfig.forClass("metadata", + AggregateRecord.class)); + + @Override + public AggregatedStatsResponse handleRequest(AggregatedStatsRequest request) + throws Exception { + DatabaseQuery query = new DatabaseQuery(AggregateRecord.class.getName()); + + // TODO Add a time range implementation + + if (request.getEventType() != null) { + query.addQueryParam("eventType", request.getEventType(), + QueryOperand.EQUALS); + } + + if (request.getGrouping() != null) { + StringBuffer grouping = new StringBuffer(); + for (String group : request.getGrouping()) { + if (grouping.length() > 0) { + grouping.append("-"); + } + grouping.append(group); + } + query.addQueryParam("grouping", grouping, QueryOperand.EQUALS); + } + + if (request.getField() != null) { + query.addQueryParam("field", request.getField(), + QueryOperand.EQUALS); + } + + List results = dao.queryByCriteria(query); + AggregateRecord[] records = new AggregateRecord[results.size()]; + for (int i = 0; i < results.size(); i++) { + if (results.get(i) instanceof AggregateRecord) { + records[i] = (AggregateRecord) results.get(i); + } + } + + AggregatedStatsResponse response = new AggregatedStatsResponse( + request.getTimeRange(), request.getEventType(), + request.getGrouping(), request.getField()); + response.setRecords(records); + + return response; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/StatsHandler.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/StatsHandler.java new file mode 100644 index 0000000000..3a2a3cd3b2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/handler/StatsHandler.java @@ -0,0 +1,95 @@ +/** + * 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.stats.handler; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.google.common.eventbus.AllowConcurrentEvents; +import com.google.common.eventbus.Subscribe; +import com.raytheon.uf.common.event.Event; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.stats.StatsRecord; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.event.EventBus; +import com.raytheon.uf.edex.stats.xml.StatsConfig; + +/** + * Subscribes to the event bus and stores them in the appropriate stats table + * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Removed instance variable of event bus.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class StatsHandler { + + private CoreDao dao = new CoreDao(DaoConfig.forClass("metadata", + StatsRecord.class)); + + // TODO Make unmodifiable + private static Set validEventTypes = new HashSet(); + + /** + * Registers StatsHandler with the event bus + */ + public StatsHandler() { + EventBus.getInstance().register(this); + } + + @Subscribe + @AllowConcurrentEvents + public void eventListener(Event event) { + String clazz = String.valueOf(event.getClass().getName()); + + if (validEventTypes.contains(clazz)) { + try { + byte[] bytes = SerializationUtil.transformToThrift(event); + + StatsRecord record = new StatsRecord(); + record.setDate(event.getDate()); + record.setEventType(clazz); + record.setEvent(bytes); + dao.persist(record); + } catch (SerializationException e) { + e.printStackTrace(); + } + } + } + + public static void setValidEventTypes(List configurations) { + validEventTypes = new HashSet(); + for (StatsConfig config : configurations) { + validEventTypes.add(config.getEventType()); + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java new file mode 100644 index 0000000000..fc632375f7 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java @@ -0,0 +1,260 @@ +/** + * 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.stats.util; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +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.stats.AggregateRecord; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.edex.stats.xml.Aggregate; +import com.raytheon.uf.edex.stats.xml.GroupBy; +import com.raytheon.uf.edex.stats.xml.Item; +import com.raytheon.uf.edex.stats.xml.Statistics; + +/** + * Archives the data in the aggregate_bucket table to an xml file. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Initial creation.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class Archiver { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(Archiver.class); + + private class StatisticsKey { + public String eventType; + + public String grouping; + + public TimeRange timeRange; + + @Override + public boolean equals(Object o) { + if (o != null && o instanceof StatisticsKey) { + StatisticsKey other = (StatisticsKey) o; + + return (this.eventType.equals(other.eventType) + && this.timeRange.getStart().equals( + other.timeRange.getStart()) && this.timeRange + .getEnd().equals(other.timeRange.getEnd())); + } + + return false; + } + + @Override + public int hashCode() { + return 1; + } + } + + /** Marshaller object */ + private Marshaller marshaller; + + /** JAXB context */ + private JAXBContext jax; + + private IPathManager pm = PathManagerFactory.getPathManager(); + + private LocalizationContext context = pm.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); + + private SimpleDateFormat dateFormatter = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss"); + + private SimpleDateFormat fileDateFormatter = new SimpleDateFormat( + "yyyyMMdd_HHmm"); + + public Archiver() throws JAXBException { + jax = JAXBContext.newInstance(new Class[] { Statistics.class }); + this.marshaller = jax.createMarshaller(); + } + + /** + * Writes the statistics xml to disk. + * + * @param statistics + * @throws JAXBException + */ + public void writeToDisk(String filename, Statistics statistics) + throws JAXBException { + LocalizationFile siteLocalization = pm.getLocalizationFile(context, + filename); + marshaller.marshal(statistics, siteLocalization.getFile()); + } + + /** + * Writes the aggregate records to disk. + * + * @param aggregateRecords + * @throws JAXBException + */ + public void writeToDisk(AggregateRecord[] aggregateRecords) { + + Map> statisticsMap = new HashMap>(); + + for (AggregateRecord record : aggregateRecords) { + StatisticsKey key = new StatisticsKey(); + key.eventType = record.getEventType(); + key.grouping = record.getGrouping(); + key.timeRange = new TimeRange(record.getStartDate(), + record.getEndDate()); + + List aggregateRecordList = statisticsMap.get(key); + if (aggregateRecordList == null) { + aggregateRecordList = new ArrayList(); + statisticsMap.put(key, aggregateRecordList); + } + + aggregateRecordList.add(record); + } + + for (StatisticsKey key : statisticsMap.keySet()) { + Statistics statistics = new Statistics(); + statistics.setEventType(key.eventType); + statistics.setStart(dateFormatter.format(key.timeRange.getStart())); + statistics.setEnd(dateFormatter.format(key.timeRange.getEnd())); + statistics.setGroupBy(createGroupBy(key.grouping)); + statistics.setAggregates(createAggregates(statisticsMap.get(key))); + + String filename = createFilename(key.timeRange, statistics); + try { + writeToDisk(filename, statistics); + } catch (JAXBException e) { + statusHandler.error("Unable to write statistics file " + + filename, e); + } + } + + } + + /** + * Creates a filename in the format + * /stats/aggregates/groupBy{0}/groupby{1}... + * /group{n}/eventType.start-end.dat + * + * @param items + * @return + */ + private String createFilename(TimeRange tr, Statistics statistics) { + StringBuffer sb = new StringBuffer("stats/aggregates"); + for (Item item : statistics.getGroupBy().getAttributes()) { + sb.append("/" + item.getResult()); + } + sb.append("/" + statistics.getEventType() + "." + + fileDateFormatter.format(tr.getStart()) + "-" + + fileDateFormatter.format(tr.getEnd()) + ".dat"); + + return sb.toString(); + } + + /** + * Transforms the grouping string from the record into a GroupBy object. + * + * @param recordGroupBy + * @return + */ + private GroupBy createGroupBy(String recordGroupBy) { + GroupBy groupBy = new GroupBy(); + String[] groups = recordGroupBy.split("-"); + Item[] attributes = new Item[groups.length]; + + for (int i = 0; i < groups.length; i++) { + String[] g = groups[i].split(":"); + + String name = g[0]; + String result = g[1]; + + Item item = new Item(); + item.setName(name); + item.setResult(result); + attributes[i] = item; + } + + groupBy.setAttributes(attributes); + + return groupBy; + } + + /** + * Transforms the records into Aggregate objects + * + * @param aggregateRecordList + * @return + */ + private Aggregate[] createAggregates( + List aggregateRecordList) { + Aggregate[] aggregates = new Aggregate[aggregateRecordList.size()]; + + for (int i = 0; i < aggregates.length; i++) { + AggregateRecord record = aggregateRecordList.get(i); + Aggregate aggregate = new Aggregate(); + aggregate.setField(record.getField()); + + Item sumItem = new Item(); + sumItem.setName("sum"); + sumItem.setResult(String.valueOf(record.getSum())); + + Item minItem = new Item(); + minItem.setName("min"); + minItem.setResult(String.valueOf(record.getMin())); + + Item maxItem = new Item(); + sumItem.setName("max"); + sumItem.setResult(String.valueOf(record.getMax())); + + Item countItem = new Item(); + minItem.setName("count"); + minItem.setResult(String.valueOf(record.getCount())); + + aggregate.setFunctions(new Item[] { sumItem, minItem, maxItem, + countItem }); + aggregates[i] = aggregate; + } + + return aggregates; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/ConfigLoader.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/ConfigLoader.java new file mode 100644 index 0000000000..653f082946 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/ConfigLoader.java @@ -0,0 +1,158 @@ +/** + * 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.stats.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +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.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.stats.xml.Aggregate; +import com.raytheon.uf.edex.stats.xml.Statistics; +import com.raytheon.uf.edex.stats.xml.StatsConfig; + +/** + * Loads statsConfig files from localization. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Updated error handling and validated config files.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +public class ConfigLoader { + + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ConfigLoader.class); + + private JAXBContext jax; + + /** Unmarshaller object */ + private Unmarshaller unmarshaller; + + /** Marshaller object */ + private Marshaller marshaller; + + private IPathManager pm = PathManagerFactory.getPathManager(); + + private List configurations; + + private final String STATS_DIR = "stats"; + + /** + * Constructor. Performs an initial statsCon + */ + public ConfigLoader() throws JAXBException { + jax = JAXBContext.newInstance(new Class[] { StatsConfig.class, + Statistics.class }); + unmarshaller = jax.createUnmarshaller(); + this.marshaller = jax.createMarshaller(); + this.marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + this.configurations = new ArrayList(); + } + + /** + * Loads the statsConfig files in the STATS_DIR directory. + */ + public void load() throws Exception { + LocalizationContext[] searchContext = pm + .getLocalSearchHierarchy(LocalizationType.EDEX_STATIC); + LocalizationFile[] localizationFiles = null; + for (LocalizationContext ctx : searchContext) { + localizationFiles = pm.listFiles(ctx, STATS_DIR, null, false, true); + if (localizationFiles != null && localizationFiles.length > 0) { + break; + } + + } + + if (localizationFiles != null && localizationFiles.length > 0) { + configurations.clear(); + for (LocalizationFile localizationFile : localizationFiles) { + if (localizationFile.getFile() != null + && localizationFile.getFile().exists()) { + StatsConfig config = (StatsConfig) unmarshaller + .unmarshal(localizationFile.getFile()); + config = validateAggregates(config); + configurations.add(config); + } + } + } + } + + /** + * Removes the aggregate if its not a numerical parameter. + * + * @param config + */ + private StatsConfig validateAggregates(StatsConfig config) + throws ClassNotFoundException { + Class clazz = Class.forName(config.getEventType()); + List aggregates = new ArrayList(); + + for (Aggregate aggregate : config.getAggregates()) { + String aggregateField = aggregate.getField(); + try { + Field field = clazz.getDeclaredField(aggregateField); + if (!field.getType().isPrimitive()) { + statusHandler + .info("'" + + aggregateField + + "' not a primitive type. Aggregate being removed. "); + } + aggregates.add(aggregate); + } catch (NoSuchFieldException e) { + statusHandler.info("'" + aggregateField + + "' not a valid field. Aggregate being removed. "); + } + } + + config.setAggregates(aggregates.toArray(new Aggregate[aggregates.size()])); + + return config; + } + + /** + * Returns a list of all statsConfig files. + * + * @return + */ + public List getConfigurations() { + return configurations; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Aggregate.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Aggregate.java new file mode 100644 index 0000000000..af944d90cc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Aggregate.java @@ -0,0 +1,74 @@ +/** + * 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.stats.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Made serializable.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +@DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) +public class Aggregate { + /** the field to perform the function on. */ + @XmlAttribute + @DynamicSerializeElement + private String field; + + /** the name of the statistic function */ + @XmlElement(name = "function") + @DynamicSerializeElement + private Item[] functions; + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public Item[] getFunctions() { + return functions; + } + + public void setFunctions(Item[] functions) { + this.functions = functions; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/GroupBy.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/GroupBy.java new file mode 100644 index 0000000000..bb50ded100 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/GroupBy.java @@ -0,0 +1,59 @@ +/** + * 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.stats.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Made serializable.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +@DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) +public class GroupBy { + @XmlElement(name = "attribute") + @DynamicSerializeElement + private Item[] attributes; + + public Item[] getAttributes() { + return attributes; + } + + public void setAttributes(Item[] attributes) { + this.attributes = attributes; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Item.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Item.java new file mode 100644 index 0000000000..eb617f3eaa --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Item.java @@ -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.edex.stats.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Made serializable.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +@DynamicSerialize +@XmlAccessorType(XmlAccessType.NONE) +public class Item { + @XmlAttribute + @DynamicSerializeElement + private String name; + + @XmlAttribute + @DynamicSerializeElement + private String result; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Statistics.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Statistics.java new file mode 100644 index 0000000000..e9e652d2eb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/Statistics.java @@ -0,0 +1,119 @@ +/** + * 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.stats.xml; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.raytheon.uf.common.serialization.ISerializableObject; + +/** + * + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 21, 2012            jsanchez     Made serializable.
+ * 
+ * 
+ * + * @author jsanchez + * + */ +@XmlRootElement(name = "statistics") +@XmlAccessorType(XmlAccessType.NONE) +public class Statistics implements ISerializableObject { + + /** the start time of the period YYYY-MM-DD HH:MM:SS */ + @XmlAttribute + private String start; + + /** the end time of the period YYYY-MM-DD HH:MM:SS */ + @XmlAttribute + private String end; + + /** the event type that will be monitored */ + @XmlElement(name = "eventType") + private String eventType; + + @XmlElement(name = "groupBy") + private GroupBy groupBy; + + @XmlElement(name = "aggregate") + private Aggregate[] aggregates; + + /** + * default constructor + */ + public Statistics() { + + } + + public Statistics(StatsConfig config) { + this.eventType = config.getEventType(); + this.groupBy = config.getGroupBy(); + this.aggregates = config.getAggregates(); + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public GroupBy getGroupBy() { + return groupBy; + } + + public void setGroupBy(GroupBy groupBy) { + this.groupBy = groupBy; + } + + public Aggregate[] getAggregates() { + return aggregates; + } + + public void setAggregates(Aggregate[] aggregates) { + this.aggregates = aggregates; + } + + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/StatsConfig.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/StatsConfig.java new file mode 100644 index 0000000000..1467522773 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/xml/StatsConfig.java @@ -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.stats.xml; + +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 com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * The config file that will be used to set the specific parameters that + * statistic files can be aggregated against. + * + * SOFTWARE HISTORY + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Aug 21, 2012 jsanchez Made serializable. + * + * @author jsanchez + * + */ +@DynamicSerialize +@XmlRootElement(name = "statsConfig") +@XmlAccessorType(XmlAccessType.NONE) +public class StatsConfig implements ISerializableObject { + + /** the event type that will be monitored */ + @XmlElement(name = "eventType") + @DynamicSerializeElement + private String eventType; + + @XmlElement(name = "groupBy") + @DynamicSerializeElement + private GroupBy groupBy; + + @XmlElement(name = "aggregate") + @DynamicSerializeElement + private Aggregate[] aggregates; + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public GroupBy getGroupBy() { + return groupBy; + } + + public void setGroupBy(GroupBy groupBy) { + this.groupBy = groupBy; + } + + public Aggregate[] getAggregates() { + return aggregates; + } + + public void setAggregates(Aggregate[] aggregates) { + this.aggregates = aggregates; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/aggregatePurgeRules.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/aggregatePurgeRules.xml new file mode 100644 index 0000000000..6b685c9e50 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/aggregatePurgeRules.xml @@ -0,0 +1,10 @@ + + + + + aggregate + default + + 30-00:00:00 + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/statsPurgeRules.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/statsPurgeRules.xml new file mode 100644 index 0000000000..79da93bde2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/purge/statsPurgeRules.xml @@ -0,0 +1,10 @@ + + + + + stats + default + + 00-24:00:00 + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml new file mode 100644 index 0000000000..f40b1d303e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml @@ -0,0 +1,10 @@ + + + com.raytheon.uf.common.event.ProcessEvent + + + + + + +