[rules-users] Re: Timestamp for processing Historical Data

PriyaSha nash.8103 at gmail.com
Mon Jun 8 11:15:45 EDT 2009


 Hi,

Thanks for your immediate response.

I've attached the source code with this.

OMMain.java is where I used the approach you gave in the Drools fusion
Example. that is, scheduling the jobs by having current time as base
timestamp.

It works as expected in the above case.

OMMainBatch is the one which triggers batch processing of events. This is
where I set the basetimestamp as  1220859119428l which is Mon Sep 08
13:01:59 IST 2008.

*

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;

}
If I need to use PSEUDO_CLOCK, how can I make it available for the Engine.



2009/6/8 Edson Tirelli <tirelli at post.com>

>
>    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 at gmail.com>
>
>
>> Hi,
>>
>> I had a chance to go through the fusion sample. I tried the same example
>> with another logfile as input
>>
>> Input:
>>
>> 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
>> *10*
>>
>> no-loop
>> **true
>>
>> when
>> *
>>
>> 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Regards,
PriyaKathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090608/39c7c77f/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OMSample.zip
Type: application/zip
Size: 31353 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090608/39c7c77f/attachment.zip 


More information about the rules-users mailing list