Hi Aneela,

As I pointed out in [1], you can use externalTimeBatch [2] with above
scenario. Furthermore, in CEP 4.2.0 (Siddhi 3.1.0 <), it'll introduce 2 new
optional parameters to externalTimeBatch, namely startTime and timeout.
However, you might not be needing those params with above scenario.

Moreover, CEP 4.2.0 is yet to be released, and at the time being you can
download CEP 4.2.0 RC1 [3] as @damith pointed out in reply to [4].


>    - *startTime* (Optional): User defined start time. This could either
>    be a constant (of type int, long or time) or an attribute of the
>    corresponding stream (of type long). If an attribute is provided, initial
>    value of attribute would be considered as startTime. When startTime is not
>    given, initial value of timestamp is used as the default.
>
>
>    - *timeout *(Optional): Time to wait for arrival of new event, before
>    flushing and giving output for events belonging to a specific batch. If
>    timeout is not provided, system waits till an event from next batch arrives
>    to flush current batch.
>
>
[1] http://stackoverflow.com/a/38811132/1805178
[2]
https://docs.wso2.com/display/CEP410/Inbuilt+Windows#InbuiltWindows-externalTimeBatch
[3] https://github.com/wso2/product-cep/releases/download/
v4.2.0-rc1/wso2cep-4.2.0-RC1.zip
[4] [Dev] Donwloading latest wso2cep 4.2.0 release

Regards,
Grainier.

On Sat, Aug 6, 2016 at 2:31 PM, Aneela Safdar <ansaf_...@yahoo.com> wrote:

> Hi,
>
> I have a siddhi query to get the count of total events in one minute by
> using a timebatch window. Using an output stream I am updating a bar chart
> with constant coming values, tmestammps(date and time,till minute ) on
> x-axis and events count on y-axis.
>
> But there are sometimes when either the number of events in one minute
> take too long to be transmitted and hence query doesnot give correct
> resutls.
>
> For instance if I get total 60 events and this query first gives me the
> count of 40 which dislpayed in bar chart but then after a minute it changes
> its value to 20 which is correct according to the logic but I am concerned
> if there is a way I could update the stream as well as bar chart for any
> previous timestamps (in that case 40+20) and insert into it new values for
> the next upcoming timestamps.
>
> I have seen update function is used with tables not stream, is it so?
> And also I want two outputStreams populating two different bar charts from
> a same input stream. So is below query correct for that purpose?
>
> Query is:
>
> /* Enter a unique ExecutionPlan */
> @Plan:name('FTPExecutionPlan')
>
> /* Enter a unique description for ExecutionPlan */
> -- @Plan:description('ExecutionPlan')
>
> /* define streams/tables and write queries here ... */
>
> @Import('FTPInStream:1.0.0')
> define stream FTPInStream (ts string, uid string, id_orig_h string,
> id_orig_p int, id_resp_h string, id_resp_p int, user string, password
> string,command string, arg string, mime_type string, file_size string,
> reply_code int, reply_msg string);
>
> @Export('FTPIPOutStream:1.0.0')
> define stream FTPIPOutStream (ip_address string, ftp_requests int);
>
> @Export('FTPOutStream:1.0.0')
> define stream FTPOutStream (ts string, ftp_requests int);
>
>
> from FTPInStream
> select time:dateFormat(str:replaceAll(ts,'T',' '),'yyyy-MM-dd HH:mm',
> 'yyyy-MM-dd HH:mm:ss') as ts, uid, id_orig_h, id_orig_p, id_resp_h,
> id_resp_p
> insert into intermediateStream;
>
> from intermediateStream#window.timeBatch(1 min)
> select ts, cast(count(ts), 'int') as ftp_requests
> group by ts
> insert into FTPOutStream;
>
> from intermediateStream#window.timeBatch(1 min)
> select id_orig_h as ip_address, cast(count(id_orig_h), 'int') as
> ftp_requests
> group by id_orig_h
> insert into FTPIPOutStream;
>
> Regards,
> Aneela Safdar
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Grainier Perera
Software Engineer
Mobile : +94716122384
WSO2 Inc. | http://wso2.com
lean.enterprise.middleware
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to