Issue #1580 - Implementation of Stats/Event framework.

Change-Id: I45a5a855f81c975a8a13d73f18ab9de3ddecf7cd

Former-commit-id: ca2f288876b80fe5e491f335fb6b22b20a468fca
This commit is contained in:
Mike Duff 2013-02-07 15:39:02 -06:00
parent f204191837
commit def0464898
16 changed files with 506 additions and 24 deletions

View file

@ -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

View file

@ -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;
}
}

View file

@ -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<Runnable>(maxQueueSize));
{
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
}
/**
* {@inheritDoc}
*/
@Override
public void publish(Event event) {
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) {
statusHandler.handle(Priority.PROBLEM, "Error sending Event", 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();
}
}

View file

@ -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,

View file

@ -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

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 6, 2013 1584 mpduff Initial creation
*
* </pre>
*
* @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;
}
}

View file

@ -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

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1584 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class LoadEvent extends StatisticsEvent {
private static final long serialVersionUID = 1L;
private static final Map<String, String> FIELD_UNIT_MAP;
static {
Map<String, String> m = new HashMap<String, String>();
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<String, String> 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();
}
}

View file

@ -0,0 +1,29 @@
<statisticsConfig>
<!-- Event Type should be fully qualified name of stat event -->
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRetrievalEvent"
displayName="Subscription Retrieval" category="Data Delivery">
<statisticsGroup name="plugin" displayName="Data Type" />
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<statisticsGroup name="subscriptionType" displayName="Subscription Type" />
<statisticsAggregate field="numFailed"
displayName="Number of Failed Subscriptions" displayUnit="Count" />
<statisticsAggregate field="numComplete"
displayName="Number of Completed Subscriptions" displayUnit="Count" />
</statisticsEvent>
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent"
displayName="Data Retrieval" category="Data Delivery">
<statisticsGroup name="plugin" displayName="Data Type" />
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<!--
Display unit options are bytes, KB, MB, GB
-->
<statisticsAggregate field="bytes"
displayName="Amount of Data Downloaded" displayUnit="MB" />
<statisticsAggregate field="numRecords"
displayName="Number of Records Downloaded" displayUnit="Count" />
</statisticsEvent>
</statisticsConfig>

View file

@ -8,4 +8,8 @@
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler"/>
<bean id="eventPublishHandler" class="com.raytheon.uf.edex.event.handler.EventPublishHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.event.EventPublishRequest"/>
<constructor-arg ref="eventPublishHandler"/>
</bean>
</beans>

View file

@ -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.
*
* <pre>
*
@ -49,5 +49,4 @@ public class EventPublishHandler implements
return null;
}
}

View file

@ -0,0 +1,14 @@
<statisticsConfig>
<!-- Event Type should be fully qualified name of stat event -->
<statisticsEvent type="com.raytheon.uf.common.registry.event.RegistryStatisticsEvent"
displayName="Registry Statistics" category="Registry">
<statisticsGroup name="owner" displayName="Transaction Owner" />
<statisticsGroup name="status" displayName="Transaction Status" />
<statisticsGroup name="type" displayName="Transaction Type" />
<!--
Display unit options are ms, Seconds, Minutes, Hours
-->
<statisticsAggregate field="duration"
displayName="Total Registry Duration" displayUnit="Minutes" />
</statisticsEvent>
</statisticsConfig>

View file

@ -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">
<bean id="statsHandler" class="com.raytheon.uf.edex.stats.handler.GraphDataHandler"/>
<bean id="statsGraphDataHandler" class="com.raytheon.uf.edex.stats.handler.GraphDataHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.stats.GraphDataRequest"/>
<constructor-arg ref="statsHandler"/>
<constructor-arg ref="statsGraphDataHandler"/>
</bean>
</beans>

View file

@ -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<String, LocalizationFile> statConfs = new HashMap<String, LocalizationFile>();
// grab all stats from contexts, allowing overwrite by name

View file

@ -0,0 +1,13 @@
<statisticsConfig>
<!-- Event Type should be fully qualified name of stat event -->
<statisticsEvent type="com.raytheon.uf.common.stats.ProcessEvent"
displayName="Processing Events" category="Data Ingest Events">
<statisticsGroup name="pluginName" displayName="Data Type" />
<!-- Processing time available display units:
ms, Seconds, Minutes, Hours -->
<statisticsAggregate field="processingTime"
displayName="Processing Time" displayUnit="ms" />
<statisticsAggregate field="processingLatency"
displayName="Processing Latency" displayUnit="ms" />
</statisticsEvent>
</statisticsConfig>