From 9f7b97c4c2c4cb70aa5ea2902b76027ee8a24c45 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Thu, 28 Jun 2018 13:57:08 -0700 Subject: [PATCH] OHLCPlugInView: update comments --- src/main/java/ats/plugin/OHLCPlugInView.java | 27 +++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/ats/plugin/OHLCPlugInView.java b/src/main/java/ats/plugin/OHLCPlugInView.java index adae554..936d125 100644 --- a/src/main/java/ats/plugin/OHLCPlugInView.java +++ b/src/main/java/ats/plugin/OHLCPlugInView.java @@ -66,7 +66,7 @@ public class OHLCPlugInView extends ViewSupport { scheduleSlot = context.getStatementContext().getScheduleBucket().allocateSlot(); interval = parseInterval(intervalExpression); - log.info("Interval is {}", interval); + // log.info("Interval is {}", interval); this.timestampExpression = timestampExpression; this.valueExpression = valueExpression; @@ -149,15 +149,14 @@ public class OHLCPlugInView extends ViewSupport { Duration interval) { DateTime today = timestamp.withTimeAtStartOfDay(); - // log.info("Timestamp is {}", timestamp); - // log.info("Day start is {}", today); + // log.info("Timestamp is {}", timestamp); + // log.info("Day start is {}", today); Duration intoToday = new Duration(today, timestamp); - // then modulo timestamp to find how far into the current window we'd be in + // calc how far into the current window we are long intoPeriod = intoToday.getMillis() % interval.getMillis(); - // then subtract modulo from current time to get window start return timestamp.minus(intoPeriod); } @@ -206,6 +205,7 @@ public class OHLCPlugInView extends ViewSupport { SchedulingService sched = agentContext.getStatementContext().getSchedulingService(); if (handle != null) { // remove old schedule + // log.info("Removing old callback"); sched.remove(handle, scheduleSlot); handle = null; } @@ -217,19 +217,32 @@ public class OHLCPlugInView extends ViewSupport { ScheduleHandleCallback callback = new ScheduleHandleCallback() { public void scheduledTrigger(EngineLevelExtensionServicesContext esc) { handle = null; // clear out schedule handle + // log.info("Callback running"); OHLCPlugInView.this.postData(); } }; handle = new EPStatementHandleCallback(agentContext.getEpStatementAgentInstanceHandle(), callback); sched.add(callbackTime, handle, scheduleSlot); + // log.info("Scheduled callback for {}", callbackTime); } + DateTime lastStartTime; + /** * Update listeners with our new value. */ private void postData() { - if (open == null) return; + if (open == null) { + // log.info("No data to post"); + return; + } + + if (lastStartTime != null && lastStartTime.compareTo(windowStartTime) == 0) { + log.warn("DUP START TIME"); + } + + // log.info("posting {} with {} events in {}", windowStartTime, eventCount, Thread.currentThread()); OHLCEvent value = new OHLCEvent(windowStartTime, open, high, low, close); @@ -244,6 +257,8 @@ public class OHLCPlugInView extends ViewSupport { close = null; high = null; low = null; + + lastStartTime = windowStartTime; } //