<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:17.804800033569336px">
i have a class called Event which has the following members { name, source, timestamp } with getters ,setters and constructor. i have a rule file which creates Event objects whenever a file is added / deleted in a particular folder. the rule file is as follows</p>
<pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit">rule &quot;new file&quot;
when
$p: RuleContext( $old : getOldContext().getContainedFiles(), $new :getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $s : Object( this not memberOf $old ) from $new, $plus : collectList( $s ) )  
events : Object() from $plus;
then
Event event = new Event(&quot;new file added&quot;,$p.getOldContext().getParent(),new Date());
end


rule &quot; file deleted&quot;
when
$p: RuleContext( $old : getOldContext().getContainedFiles(), $new:getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $t : Object( this not memberOf $new ) from $old, $mins : collectList( $t ) )
events : Object() from $mins; 
then
Event event = new Event(&quot;file deleted&quot;,$p.getOldContext().getParent(),new Date());
end 
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:17.804800033569336px">
(do not confuse with RuleContext and other unknown identifiers.. they r just related with other classes in the project.. these two rules just works fine )..i need to use a sliding time window and create another event if the number of file additions are &gt; 5 over the past 1 minute. my rule file is :</p>
<pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit">declare Event 
@role( event ) 
end 


rule &quot;More than 5 additions&quot;
when     
Number(intValue &gt; 5) 
from    accumulate( $tick : Event ( name == &quot;new file added&quot; ) <span style="white-space:inherit">over window:time( 1m ),<br></span><span style="white-space:inherit">        count( $tick ) )</span> )
then 
    System.out.println(&quot;too many additions&quot;); 
end 
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:17.804800033569336px">
i have enabled stream mode processing too.. but it doesnt seem to work. what could be the problem?</p></div>