Issue #1350: Fix ingestGrib and ingestDat posting of stats

Change-Id: I74154680ff6b4e8f5b5e4b2b3440e2b99a16b6df

Former-commit-id: 6c81be8499 [formerly 98297abdd0 [formerly e9afcf3d12599fc3bace2b140deb0d85ee303c6c]]
Former-commit-id: 98297abdd0
Former-commit-id: cffbf1da06
This commit is contained in:
Richard Peter 2012-11-27 10:59:46 -06:00
parent 7973f0f807
commit fe234bb17e
7 changed files with 36 additions and 32 deletions

View file

@ -55,6 +55,8 @@ public class ProcessUtil {
protected static final IUFStatusHandler handler = UFStatus
.getNamedHandler("Ingest");
protected static final EventBus eventBus = EventBus.getInstance();
protected transient final static ThreadLocal<DecimalFormat> FORMAT = new ThreadLocal<DecimalFormat>() {
@Override
@ -164,7 +166,7 @@ public class ProcessUtil {
// error occurred and statement logged incorrectly
if ((processEvent.getProcessingLatency() > 0)
&& (processEvent.getProcessingTime() > 0)) {
EventBus.getInstance().publish(processEvent);
eventBus.publish(processEvent);
}
// Make sure we have something to log.

View file

@ -5,11 +5,5 @@
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="eventBusThreadCount" class="java.lang.String">
<constructor-arg type="java.lang.String" value="15" />
</bean>
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler"/>
</beans>

View file

@ -0,0 +1,2 @@
# Number of threads for async event bus
eventBusThreadCount=15

View file

@ -6,7 +6,6 @@ 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;
/**
*
@ -36,11 +35,11 @@ public class EventBus {
static {
int threadCount = 15;
try {
threadCount = Integer.parseInt((String) EDEXUtil
.getESBComponent("eventBusThreadCount"));
threadCount = Integer.parseInt(System.getProperty(
"eventBusThreadCount", "15"));
} catch (Exception e) {
statusHandler.error(
"Unable to set thread pool size from spring; defaulting size to "
statusHandler
.error("Unable to set thread pool size from property eventBusThreadCount; defaulting size to "
+ threadCount + ".", e);
}
asyncEventBus = new AsyncEventBus("EventBus",

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.registry.feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>

View file

@ -16,6 +16,5 @@
</bean>
<bean id="statsHandler"
class="com.raytheon.uf.edex.stats.handler.StatsHandler"
depends-on="eventBusThreadCount"/>
class="com.raytheon.uf.edex.stats.handler.StatsHandler"/>
</beans>

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.edex.stats.handler;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -36,6 +37,7 @@ import com.raytheon.uf.common.status.UFStatus;
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.util.ConfigLoader;
/**
* Subscribes to the event bus and stores them in the appropriate stats table
@ -81,10 +83,33 @@ public class StatsHandler {
/**
* Registers StatsHandler with the event bus
*/
public StatsHandler() {
public StatsHandler() throws Exception {
loadEventValidTypes();
EventBus.getInstance().register(this);
}
/**
* Loads the stats configuration to determine the events to track.
*
* TODO: Update ConfigLoader to be instance and have file time checking to
* know if config needs to be reloaded.
*
* @throws Exception
*/
protected void loadEventValidTypes() throws Exception {
ConfigLoader configLoader = new ConfigLoader();
configLoader.load();
HashSet<String> myValidEventTypes = new HashSet<String>();
for (StatisticsConfig config : configLoader.getConfigurations()) {
for (StatisticsEvent event : config.getEvents()) {
myValidEventTypes.add(event.getType());
}
}
validEventTypes = Collections.unmodifiableSet(myValidEventTypes);
}
@Subscribe
@AllowConcurrentEvents
public void eventListener(Event event) {