Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
5.3.0.Final
Description
When using a custom @timestamp together with PSEUDO clock, all events are accumulated rather than just those within the window:time period. I have tried using long (millisecond) and java.util.Date without success.
==================================
declare SimpleObject
@role(event)
@timestamp(customTime)
@expires(10m)
end;
rule "honour custom timestamp"
when
$avgVal : Number (longValue > 0) from accumulate ( SimpleObject($valueLng : valueLong ) over window:time (10s) from entry-point "SimpleEP", average ( $valueLng ) )
then
System.out.println("avg: " + $avgVal);
end
---------------------------------------
import java.util.Date;
public class SimpleObject {
private long customTime;
public long valueLong;
public SimpleObject(Date customTime, long valueLong)
{ this.customTime = customTime.getTime(); this.valueLong = valueLong; }public long getCustomTime()
{ return customTime; }public void setCustomTime(long customTime)
{ this.customTime = customTime; }public long getValueLong()
{ return valueLong; }public void setValueLong(long valueLong)
{ this.valueLong = valueLong; }}
------------ Trivial Spock/Groovy unit test ----------------
@IgnoreRest
def "should honour custom timestamp"() {
when:
use (TimeCategory)
then:
1 == 1 // no assertions - we're examining the stdout.
}
==================================
OUTPUT (INCORRECT - all values are included for each evalutation):
avg: 100.0
avg: 95.0
avg: 90.0
avg: 85.0
avg: 80.0
avg: 75.0
Note that when commenting out the @timestamp tag the output changes to the following (correct) output:
avg: 100.0
avg: 95.0
avg: 90.0
avg: 85.0
avg: 80.0
avg: 75.0
avg: 70.0
avg: 65.0
avg: 60.0
avg: 55.0
avg: 50.0
Also note that when using the REALTIME clock with Thread.sleep the output is correct.