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 index 61445e0571..4e3aa07e16 100644 --- 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 @@ -9,10 +9,29 @@ import javax.persistence.Column; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +/** + * Provides logging and deletion services for camel + * + *
+ * + * SOFTWARE HISTORY + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Nov 5, 2012 #1305 bgonzale Added LogLevel enum and transient attribute. + * + *+ * + * @author jsanchez + * @version 1.0 + */ public abstract class Event implements Serializable, ISerializableObject { private static final long serialVersionUID = 1L; + public enum LogLevel { + DEBUG, INFO, WARN, ERROR, FATAL, ALL, OFF, TRACE + } + @Column @DynamicSerializeElement protected Calendar date; @@ -21,8 +40,16 @@ public abstract class Event implements Serializable, ISerializableObject { @DynamicSerializeElement protected String id; + @DynamicSerializeElement + protected LogLevel logLevel; + public Event() { + this(LogLevel.DEBUG); + } + + public Event(LogLevel logLevel) { date = Calendar.getInstance(); + this.logLevel = logLevel; } public Calendar getDate() { @@ -46,4 +73,19 @@ public abstract class Event implements Serializable, ISerializableObject { return formatter.format(date.getTime()) + " Id: " + id; } + /** + * @return the logLevel + */ + public LogLevel getLogLevel() { + return logLevel; + } + + /** + * @param logLevel + * the logLevel to set + */ + public void setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel; + } + } \ 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 index ba9ad63ec7..c31457c044 100644 --- 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 @@ -25,7 +25,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; /** - * TODO Add Description + * Event for file ingest statistics (processing time and processing latency.) * *
* @@ -46,11 +46,21 @@ public class ProcessEvent extends Event { private static final long serialVersionUID = 1L; @DynamicSerializeElement - private final String message; + private String message; - public ProcessEvent(String message) { - super(); - this.message = message; + @DynamicSerializeElement + private String pluginName; + + @DynamicSerializeElement + private String fileName; + + @DynamicSerializeElement + private double processingTimeMilliseconds; + + @DynamicSerializeElement + private double processingLatencyMilliseconds; + + public ProcessEvent() { } @Override @@ -65,4 +75,73 @@ public class ProcessEvent extends Event { return message; } + /** + * @param message + * the message to set + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * @return the pluginName + */ + public String getPluginName() { + return pluginName; + } + + /** + * @param pluginName + * the pluginName to set + */ + public void setPluginName(String pluginName) { + this.pluginName = pluginName; + } + + /** + * @return the fileName + */ + public String getFileName() { + return fileName; + } + + /** + * @param fileName + * the fileName to set + */ + public void setFileName(String fileName) { + this.fileName = fileName; + } + + /** + * @return the processingTimeMilliseconds + */ + public double getProcessingTimeMilliseconds() { + return processingTimeMilliseconds; + } + + /** + * @param processingTimeMilliseconds + * the processingTimeMilliseconds to set + */ + public void setProcessingTimeMilliseconds(double processingTimeMilliseconds) { + this.processingTimeMilliseconds = processingTimeMilliseconds; + } + + /** + * @return the processingLatencyMilliseconds + */ + public double getProcessingLatencyMilliseconds() { + return processingLatencyMilliseconds; + } + + /** + * @param processingLatencyMilliseconds + * the processingLatencyMilliseconds to set + */ + public void setProcessingLatencyMilliseconds( + double processingLatencyMilliseconds) { + this.processingLatencyMilliseconds = processingLatencyMilliseconds; + } + } 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 9d79c550c4..99cf8763f7 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 @@ -90,35 +90,42 @@ public class ProcessUtil { StringBuilder sb = new StringBuilder(128); + ProcessEvent processEvent = new ProcessEvent(); String pluginName = getHeaderProperty(headers, "pluginName"); if (pluginName != null) { sb.append(pluginName); + processEvent.setPluginName(pluginName); } String fileName = getHeaderProperty(headers, "ingestFileName"); if (fileName != null) { sb.append(":: "); sb.append(fileName); + processEvent.setFileName(fileName); } Long dequeueTime = getHeaderProperty(headers, "dequeueTime"); DecimalFormat df = FORMAT.get(); if (dequeueTime != null) { - double elapsed = (curTime - dequeueTime) / 1000.0; + double elapsedMilliseconds = curTime - dequeueTime; + double elapsed = (elapsedMilliseconds) / 1000.0; sb.append(" processed in: "); sb.append(df.format(elapsed)); sb.append(" (sec)"); + processEvent.setProcessingTimeMilliseconds(elapsedMilliseconds); } Long enqueueTime = getHeaderProperty(headers, "enqueueTime"); if (enqueueTime != null) { - double latency = (curTime - enqueueTime) / 1000.0; + double latencyMilliseconds = curTime - enqueueTime; + double latency = (latencyMilliseconds) / 1000.0; sb.append(" Latency: "); sb.append(df.format(latency)); sb.append(" (sec)"); + processEvent.setProcessingLatencyMilliseconds(latencyMilliseconds); } - EventBus.getInstance().publish(new ProcessEvent(sb.toString())); + EventBus.getInstance().publish(processEvent); // Make sure we have something to log. if (sb.length() > 0) { 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 index 111cc3b21b..788397d42d 100644 --- 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 @@ -19,6 +19,7 @@ import com.raytheon.uf.edex.event.EventBus; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 1, 2012 jsanchez Initial creation + * Nov 5, 2012 #1305 bgonzale Added log level Event logging. * ** @@ -47,6 +48,29 @@ public class LogHandler { @Subscribe @AllowConcurrentEvents public void eventListener(Event event) { - logger.info(event.toString()); + switch (event.getLogLevel()) { + case DEBUG: + logger.debug(event.toString()); + break; + case INFO: + logger.info(event.toString()); + break; + case WARN: + logger.warn(event.toString()); + break; + case ERROR: + logger.error(event.toString()); + break; + case FATAL: + logger.fatal(event.toString()); + break; + case TRACE: + logger.trace(event.toString()); + break; + default: + // ALL + // logger.(event.toString()); + break; + } } } diff --git a/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties b/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties deleted file mode 100644 index 32798b08c0..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.stats/resources/processStats.properties +++ /dev/null @@ -1,4 +0,0 @@ -# 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/utility/edex_static/base/stats/edexProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml index f40b1d303e..ee9786cd3b 100644 --- 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 @@ -2,9 +2,8 @@