Hi Ashan,

Currently, you would not be able to get the timestamp out of the event
unless you use a databridge agent callback. In that case, you can use
Java code to simply get by calling event.getTimestamp().

However, if you want to use the timestamp as an attribute while doing
processing within CEP, you would have to pass the timestamp as an
attribute of the stream. i.e. add it as an attribute of either meta,
correlation or payload data. Then you can use that timestamp and
format the output event as necessary.

Thanks,
Lasantha

On Tue, Jul 7, 2015 at 1:04 PM, Ashan Dhananjaya <dhananjay...@gmail.com> wrote:
> Hi All,
>
> I applied the above patch and get the timestamp in the Input Adapter. The
> formatter i used was "member_average_memory_consumption_stats:1.0.0". I
> tried several time to get the timeStamp attribute but failed. Is there any
> way to get a data which is outside in the payload? The Input stream is as
> below,
>
> 10:40:27,757 [-] [DataBridge-Core-pool-2-thread-1]  INFO TenantId=-1234 :
> Input Event Adaptor : DefaultWSO2EventInputAdaptor, received
>
> Event{
>   streamId='cartridge_agent_health_stats:1.0.0',
>   timeStamp=1436245827731,
>   metaData=null,
>   correlationData=null,
>   payloadData=[single-cartridge-app.my-php.php.domain,
> single-cartridge-app-1, network-partition-1,
> single-cartridge-app.my-php.php.domaina5598e2b-995f-4620-b652-e66341e24c99,
> partition-1, memory_consumption, 20.0],
>   arbitraryDataMap={},
> }
>
> Any help will be really appreciated.
>
> Thank You!
> Best Regards,
> Ashan
>
> On Tue, Jul 7, 2015 at 9:32 AM, Chamila De Alwis <chami...@wso2.com> wrote:
>>
>> Hi Ashan,
>>
>> As I've seen from the PCA testing recently, the timestamp is added to
>> every ThriftEvent before publishing. Are you working on PCA or the Mock
>> IaaS? I took a look at the Mock IaaS and the WSO2CEPStatisticsPublisher as
>> well, and found out that the latter indeed doesn't add the timestamp to the
>> ThriftEvents. This means that the JCA also publishes Thrift Events with
>> empty timestamp fields.
>>
>> Following is the simple fix for that. I've attached the patch herewith.
>> Could you quickly verify with the patch applied build also?
>>
>> chamilad@chamilad-ThinkPad-T530:~/dev/stratos[master *]$ git diff
>> diff --git
>> a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPStatisticsPublisher.java
>> b/c
>> index 653288d..f1fe426 100644
>> ---
>> a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPStatisticsPublisher.java
>> +++
>> b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPStatisticsPublisher.java
>> @@ -29,6 +29,7 @@ import
>> org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
>>  import org.wso2.carbon.databridge.commons.Event;
>>  import org.wso2.carbon.databridge.commons.StreamDefinition;
>>
>> +import java.util.Date;
>>  import java.util.HashMap;
>>
>>  /**
>> @@ -98,6 +99,7 @@ public class WSO2CEPStatisticsPublisher implements
>> StatisticsPublisher {
>>
>>          Event event = new Event();
>>          event.setPayloadData(payload);
>> +        event.setTimeStamp(new Date().getTime());
>>          event.setArbitraryDataMap(new HashMap<String, String>());
>>
>>          try {
>>
>>
>>
>>
>>
>> Regards,
>> Chamila de Alwis
>> Committer and PMC Member - Apache Stratos
>> Software Engineer | WSO2 | +94772207163
>> Blog: code.chamiladealwis.com
>>
>>
>

Reply via email to