From def04648984789c911bcdfe80c01331a21f5b47a Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 7 Feb 2013 15:39:02 -0600 Subject: [PATCH] Issue #1580 - Implementation of Stats/Event framework. Change-Id: I45a5a855f81c975a8a13d73f18ab9de3ddecf7cd Former-commit-id: ca2f288876b80fe5e491f335fb6b22b20a468fca --- .../META-INF/MANIFEST.MF | 6 +- ....raytheon.uf.common.event.IEventBusHandler | 2 +- .../com/raytheon/uf/viz/event/Activator.java | 83 ++++++++ .../uf/viz/event/CaveEventBusHandler.java | 54 +++-- .../META-INF/MANIFEST.MF | 5 +- .../META-INF/MANIFEST.MF | 3 +- .../uf/viz/stats/utils/StatsConstants.java | 110 ++++++++++ .../META-INF/MANIFEST.MF | 1 + .../raytheon/uf/common/stats/LoadEvent.java | 194 ++++++++++++++++++ .../base/stats/retrievalProcessStats.xml | 29 +++ .../res/spring/event-common.xml | 4 + .../event/handler/EventPublishHandler.java | 3 +- .../base/stats/registryProcessStats.xml | 14 ++ .../res/spring/stats-graph-request.xml | 4 +- .../uf/edex/stats/util/ConfigLoader.java | 5 +- .../base/stats/edexProcessStats.xml | 13 ++ 16 files changed, 506 insertions(+), 24 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/Activator.java create mode 100644 cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/utils/StatsConstants.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/LoadEvent.java create mode 100644 edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/common_static/base/stats/retrievalProcessStats.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/common_static/base/stats/registryProcessStats.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/stats/edexProcessStats.xml diff --git a/cave/com.raytheon.uf.viz.event/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.event/META-INF/MANIFEST.MF index d0caefde64..e395cc27a0 100644 --- a/cave/com.raytheon.uf.viz.event/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.event/META-INF/MANIFEST.MF @@ -8,6 +8,10 @@ Bundle-Vendor: RAYTHEON Require-Bundle: org.eclipse.core.runtime, com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", - com.raytheon.uf.common.status;bundle-version="1.12.1174" + com.raytheon.uf.common.status;bundle-version="1.12.1174", + org.eclipse.ui;bundle-version="3.6.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy +Export-Package: com.raytheon.uf.viz.event +Eclipse-BuddyPolicy: ext, registered, global +Eclipse-RegisterBuddy: com.raytheon.uf.common.event diff --git a/cave/com.raytheon.uf.viz.event/META-INF/services/com.raytheon.uf.common.event.IEventBusHandler b/cave/com.raytheon.uf.viz.event/META-INF/services/com.raytheon.uf.common.event.IEventBusHandler index ffd41feab3..a26f180e27 100644 --- a/cave/com.raytheon.uf.viz.event/META-INF/services/com.raytheon.uf.common.event.IEventBusHandler +++ b/cave/com.raytheon.uf.viz.event/META-INF/services/com.raytheon.uf.common.event.IEventBusHandler @@ -1 +1 @@ -com.raytheon.uf.viz.event.CaveEventBusHandler \ No newline at end of file +com.raytheon.uf.viz.event.CaveEventBusHandler diff --git a/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/Activator.java b/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/Activator.java new file mode 100644 index 0000000000..3595f51c2a --- /dev/null +++ b/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/Activator.java @@ -0,0 +1,83 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.event; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.raytheon.uf.viz.event"; + + // The shared instance + private static Activator plugin; + + private BundleContext ctx; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + this.ctx = context; + plugin = this; + } + + public BundleContext getContext() { + return ctx; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/CaveEventBusHandler.java b/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/CaveEventBusHandler.java index 47e87e372f..6d3f4a3866 100644 --- a/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/CaveEventBusHandler.java +++ b/cave/com.raytheon.uf.viz.event/src/com/raytheon/uf/viz/event/CaveEventBusHandler.java @@ -19,13 +19,14 @@ **/ package com.raytheon.uf.viz.event; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + import com.raytheon.uf.common.event.Event; import com.raytheon.uf.common.event.EventPublishRequest; import com.raytheon.uf.common.event.IEventBusHandler; import com.raytheon.uf.common.serialization.comm.RequestRouter; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; /** * Cave implementation of the {@link IEventBusHandler} @@ -45,24 +46,47 @@ import com.raytheon.uf.common.status.UFStatus.Priority; */ public class CaveEventBusHandler implements IEventBusHandler { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(CaveEventBusHandler.class); + /** Core pool size */ + private final int corePoolSize = 1; + + /** Max pool size */ + private final int maxPoolSize = 3; + + /** Time for threads to live */ + private final int keepAliveTime = 1; + + /** Max queue size */ + private final int maxQueueSize = 10; + + /** Thread pool executor */ + private final ThreadPoolExecutor executor = new ThreadPoolExecutor( + corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MINUTES, + new ArrayBlockingQueue(maxQueueSize)); + { + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + } /** * {@inheritDoc} */ @Override - public void publish(Event event) { - EventPublishRequest request = new EventPublishRequest(event); - try { - RequestRouter.route(request); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, "Error sending Event", e); - } + public void publish(final Event event) { + executor.execute(new Runnable() { + @Override + public void run() { + EventPublishRequest request = new EventPublishRequest(event); + try { + RequestRouter.route(request); + } catch (Exception e) { + // ignore failed + } + } + }); } /** - * {@inheritDoc} + * This method is not supported in CAVE and will throw and + * UnsupportedOperationException. */ @Override public void register(Object subscriber) { @@ -70,11 +94,11 @@ public class CaveEventBusHandler implements IEventBusHandler { } /** - * {@inheritDoc} + * This method is not supported in CAVE and will throw and + * UnsupportedOperationException. */ @Override public void unregister(Object subscriber) { throw new UnsupportedOperationException(); } - } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF index e9786c74cd..c45fe7ef3e 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF @@ -20,7 +20,10 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.localization, javax.measure;bundle-version="1.0.0", com.raytheon.uf.common.ohd;bundle-version="1.12.1174", - com.raytheon.uf.common.cache;bundle-version="1.12.1174" + com.raytheon.uf.common.cache;bundle-version="1.12.1174", + com.raytheon.uf.common.stats;bundle-version="1.0.0", + com.raytheon.uf.viz.stats;bundle-version="1.0.0", + com.raytheon.uf.common.event;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: com.raytheon.uf.common.colormap, diff --git a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF index 87e75da1c0..3952891111 100644 --- a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF @@ -17,4 +17,5 @@ Require-Bundle: org.eclipse.ui, Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.stats, - com.raytheon.uf.viz.stats.ui + com.raytheon.uf.viz.stats.ui, + com.raytheon.uf.viz.stats.utils diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/utils/StatsConstants.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/utils/StatsConstants.java new file mode 100644 index 0000000000..3bee5ddb39 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/utils/StatsConstants.java @@ -0,0 +1,110 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 6, 2013    1584     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class StatsConstants { + /** + * Hostname of the workstation running CAVE. + */ + private static final String hostname = defineHostName(); + + /** + * CAVE version. + */ + private static final String release = defineRelease(); + + /** + * @return Hostname of the workstation running CAVE + */ + public static String getHostname() { + return hostname; + } + + private static String defineHostName() { + String hn = null; + InetAddress addr; + try { + addr = InetAddress.getLocalHost(); + hn = addr.getHostName(); + } catch (UnknownHostException e) { + // Nothing we can do + } + + return hn; + } + + private static String defineRelease() { + String release = null; + BufferedReader in = null; + try { + Process p = Runtime.getRuntime().exec( + "rpm -q --queryformat '%{VERSION}\n' awips2"); + in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = null; + while ((line = in.readLine()) != null) { + if (!line.contains("not installed")) { + release = line; + } + } + } catch (IOException e) { + // do nothing + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ioe) { + // do nothing + } + } + } + + return release; + } + + /** + * @return CAVE version + */ + public static String getRelease() { + return release; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF index 7ae13d9e94..41e59be548 100644 --- a/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.event/META-INF/MANIFEST.MF @@ -12,3 +12,4 @@ Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", com.google.guava;bundle-version="1.0.0", com.raytheon.uf.common.status;bundle-version="1.12.1174" Export-Package: com.raytheon.uf.common.event +Eclipse-BuddyPolicy: ext, registered, global diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/LoadEvent.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/LoadEvent.java new file mode 100644 index 0000000000..3400f0fb8d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/LoadEvent.java @@ -0,0 +1,194 @@ +/** + * 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.Collections; +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Load event to track dialog/table/data load times. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 5, 2013    1584     mpduff      Initial creation.
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@DynamicSerialize +public class LoadEvent extends StatisticsEvent { + private static final long serialVersionUID = 1L; + + private static final Map FIELD_UNIT_MAP; + static { + Map m = new HashMap(); + m.put("loadTime", "ms"); + FIELD_UNIT_MAP = Collections.unmodifiableMap(m); + } + + /** + * The plugin name + */ + @DynamicSerializeElement + private String pluginName; + + /** + * The workstation id + */ + @DynamicSerializeElement + private String workstation; + + /** + * The type of object that is having its load time tracked + */ + @DynamicSerializeElement + private String type; + + /** + * The version of CAVE + */ + @DynamicSerializeElement + private String caveVersion; + + /** + * The load time in ms + */ + @DynamicSerializeElement + private long loadTime; + + /** + * Message + */ + @DynamicSerializeElement + private String message; + + @Override + protected Map getFieldUnitMap() { + return FIELD_UNIT_MAP; + } + + /** + * @return the pluginName + */ + public String getPluginName() { + return pluginName; + } + + /** + * @param pluginName + * the pluginName to set + */ + public void setPluginName(String pluginName) { + this.pluginName = pluginName; + } + + /** + * @return the workstation + */ + public String getWorkstation() { + return workstation; + } + + /** + * @param workstation + * the workstation to set + */ + public void setWorkstation(String workstation) { + this.workstation = workstation; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type + * the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the loadTime + */ + public long getLoadTime() { + return loadTime; + } + + /** + * @param loadTime + * the loadTime to set + */ + public void setLoadTime(long loadTime) { + this.loadTime = loadTime; + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * @param message + * the message to set + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * @return the caveVersion + */ + public String getCaveVersion() { + return caveVersion; + } + + /** + * @param caveVersion + * the caveVersion to set + */ + public void setCaveVersion(String caveVersion) { + this.caveVersion = caveVersion; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return super.toString() + " : " + getMessage(); + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/common_static/base/stats/retrievalProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/common_static/base/stats/retrievalProcessStats.xml new file mode 100644 index 0000000000..2759dde1d3 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/common_static/base/stats/retrievalProcessStats.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-common.xml b/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-common.xml index 635630f131..d1b016bc44 100644 --- a/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-common.xml +++ b/edexOsgi/com.raytheon.uf.edex.event/res/spring/event-common.xml @@ -8,4 +8,8 @@ + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/EventPublishHandler.java b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/EventPublishHandler.java index acdd7cb4dc..b16798cfa2 100644 --- a/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/EventPublishHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.event/src/com/raytheon/uf/edex/event/handler/EventPublishHandler.java @@ -24,7 +24,7 @@ import com.raytheon.uf.common.event.EventPublishRequest; import com.raytheon.uf.common.serialization.comm.IRequestHandler; /** - * Stats handler bean. + * Event handler bean. * *
  * 
@@ -49,5 +49,4 @@ public class EventPublishHandler implements
 
         return null;
     }
-
 }
diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/common_static/base/stats/registryProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/common_static/base/stats/registryProcessStats.xml
new file mode 100644
index 0000000000..7c3ed01ee8
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/common_static/base/stats/registryProcessStats.xml
@@ -0,0 +1,14 @@
+
+    
+    
+        
+        
+        
+        
+        
+    
+
diff --git a/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-graph-request.xml b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-graph-request.xml
index 56356ed96c..9748fb9b8f 100644
--- a/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-graph-request.xml
+++ b/edexOsgi/com.raytheon.uf.edex.stats/res/spring/stats-graph-request.xml
@@ -5,9 +5,9 @@
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-    
+    
     
     	
-     	
+     	
     
 
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
index 239ebfc79d..9f7629b1f0 100644
--- 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
@@ -115,10 +115,13 @@ public class ConfigLoader {
 
     /**
      * Loads the StatisticsConfig files in the STATS_DIR directory.
+     * 
+     * @throws Exception
+     *             Exception
      */
     public void load() throws Exception {
         LocalizationContext[] searchContext = pm
-                .getLocalSearchHierarchy(LocalizationType.EDEX_STATIC);
+                .getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
         Map statConfs = new HashMap();
 
         // grab all stats from contexts, allowing overwrite by name
diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/stats/edexProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/stats/edexProcessStats.xml
new file mode 100644
index 0000000000..90c2d74058
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/common_static/base/stats/edexProcessStats.xml
@@ -0,0 +1,13 @@
+
+    
+    
+        
+        
+        
+        
+    
+