public
class OMMainForBatch { public static void main(String[] args) throws Exception {OMProcessor omProcessor =
new OMProcessor();OMSource source =
new OMSource();source.openForRead(
new InputStreamReader( OMMainForBatch.class.getResourceAsStream( "/OMoutput.txt" ) ),1220859119428l );
while ( source.hasNext() ) {Event< ? > event = source.getNext();
omProcessor.receive(event);
}
omProcessor.dispose();
}
}
//In OMSource.java, I add basetimestamp with the first column
public OMTicket load() throws ParseException, IOException {
String input = in.readLine();
if (input == null) return null;
Object[] results = format.parse( input );
OMTicket tick = new OMTicket( ((String)results[2]).trim(),
((String) results[1]).trim(),
new Date(((Number)results[0]).longValue() + baseTimestamp ));
return tick;
}
I can't say for sure that the results are right or wrong, because when time is involved, a lot of things must be taken in consideration. So, assuming you are using the fusion example as is, with the only difference that you are using your input/rules, meaning specifically that you are using the event feeder, knowledge base configured to stream mode and real time session clock, it is necessary to check what is discrepant between the results.
Please note that since the engine is running in near-realtime as well as event feeders are running in near-realtime, you might have interferences from threads and processes running in the same machine. In other words, for your 3 inputs bellow and a time-window of 5 seconds, I would not be surprised if sometimes events 1 and 3 are reported in the same window and sometimes they don't since each one of them sit at one of the edges of the window.
I would be concerned if events 2 and 3 are not in the same window and unless your machine is swapping or heavily loaded, events 1 and 2 should also be reported in the same window.
If you want to test the actual algorithm with extreme precision, the only way I know is using the PSEUDO_CLOCK, so that the application can completely control the time flow with discrete advances.
If the above is not what you are seeing, please give more details.
Thank you,
Edson
2009/6/8 PriyaSha <nash.8103@gmail.com>
Hi,I had a chance to go through the fusion sample. I tried the same example with another logfile as inputInput:
1000 critical Symantec
5000 critical Symantec
6000 critical Symantec
Here I set the timestamp as ( some date in the past + first column of the input).Following is the simple DRL which has the rule to count number of OMTicket using sliding window.
package
org.drools.examples.broker;import
org.drools.examples.broker.model.OMTicket;dialect
"mvel"declare
OMTicket@role( event )
@timestamp (timestamp)
@expires (1h)
end
rule
"Count over last 5 seconds"salience
10no-loop
truewhen
Number( $count : intValue )
from accumulate (OMTicket($severity:severity) over window:time(5s)
from entry-point "OM stream", count() )then
System.out.println(
"Number of Critical Tickets over last 5 seconds : " + $count);end
Here, I just read and insert facts as events with no scheduling.
But the ouput varies for each invocation and it is also not as expected.
Am I missing any configuration here?
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users