OHLCPlugInView: update comments

This commit is contained in:
2018-06-28 13:57:08 -07:00
parent 158460d428
commit 9f7b97c4c2

View File

@ -66,7 +66,7 @@ public class OHLCPlugInView extends ViewSupport {
scheduleSlot = context.getStatementContext().getScheduleBucket().allocateSlot(); scheduleSlot = context.getStatementContext().getScheduleBucket().allocateSlot();
interval = parseInterval(intervalExpression); interval = parseInterval(intervalExpression);
log.info("Interval is {}", interval); // log.info("Interval is {}", interval);
this.timestampExpression = timestampExpression; this.timestampExpression = timestampExpression;
this.valueExpression = valueExpression; this.valueExpression = valueExpression;
@ -149,15 +149,14 @@ public class OHLCPlugInView extends ViewSupport {
Duration interval) Duration interval)
{ {
DateTime today = timestamp.withTimeAtStartOfDay(); DateTime today = timestamp.withTimeAtStartOfDay();
// log.info("Timestamp is {}", timestamp); // log.info("Timestamp is {}", timestamp);
// log.info("Day start is {}", today); // log.info("Day start is {}", today);
Duration intoToday = new Duration(today, timestamp); 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(); long intoPeriod = intoToday.getMillis() % interval.getMillis();
// then subtract modulo from current time to get window start
return timestamp.minus(intoPeriod); return timestamp.minus(intoPeriod);
} }
@ -206,6 +205,7 @@ public class OHLCPlugInView extends ViewSupport {
SchedulingService sched = agentContext.getStatementContext().getSchedulingService(); SchedulingService sched = agentContext.getStatementContext().getSchedulingService();
if (handle != null) { if (handle != null) {
// remove old schedule // remove old schedule
// log.info("Removing old callback");
sched.remove(handle, scheduleSlot); sched.remove(handle, scheduleSlot);
handle = null; handle = null;
} }
@ -217,19 +217,32 @@ public class OHLCPlugInView extends ViewSupport {
ScheduleHandleCallback callback = new ScheduleHandleCallback() { ScheduleHandleCallback callback = new ScheduleHandleCallback() {
public void scheduledTrigger(EngineLevelExtensionServicesContext esc) { public void scheduledTrigger(EngineLevelExtensionServicesContext esc) {
handle = null; // clear out schedule handle handle = null; // clear out schedule handle
// log.info("Callback running");
OHLCPlugInView.this.postData(); OHLCPlugInView.this.postData();
} }
}; };
handle = new EPStatementHandleCallback(agentContext.getEpStatementAgentInstanceHandle(), callback); handle = new EPStatementHandleCallback(agentContext.getEpStatementAgentInstanceHandle(), callback);
sched.add(callbackTime, handle, scheduleSlot); sched.add(callbackTime, handle, scheduleSlot);
// log.info("Scheduled callback for {}", callbackTime);
} }
DateTime lastStartTime;
/** /**
* Update listeners with our new value. * Update listeners with our new value.
*/ */
private void postData() { 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); OHLCEvent value = new OHLCEvent(windowStartTime, open, high, low, close);
@ -244,6 +257,8 @@ public class OHLCPlugInView extends ViewSupport {
close = null; close = null;
high = null; high = null;
low = null; low = null;
lastStartTime = windowStartTime;
} }
// //