Hi Malith,

Sorry for the delayed response. You can refer to [1] to see how the Python
Thrift publisher is used.

Create a ThriftPublisher object using the Thrift receiver url, the
credentials and the Stream Definition. The ThriftPublisher class will
connect to the Thrift receiver and define the Stream when the object is
created.

publisher = ThriftPublisher(
    cep_ip,
    cep_port,
    self.cep_admin_username,
    self.cep_admin_password,
    self.stream_definition)

When publishing an event, create a ThriftEvent object and add metaData,
correlationData or payloadData accordingly [2]. Then execute the
`publish()` method on the publisher object created above [3].

event = ThriftEvent()
event.payloadData.append(Config.cluster_id)
event.payloadData.append(Config.cluster_instance_id)
event.payloadData.append(Config.network_partition_id)
.....
event.payloadData.append(float(memory_usage))

....

try:
    publisher.publish(event)
except Exception as ex:
    raise ThriftReceiverOfflineException(ex)


Please note that multiple publishers have to be managed manually [4].

[1] -
https://github.com/apache/stratos/blob/stratos-4.1.x/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/healthstats.py#L186
[2] -
https://github.com/apache/stratos/blob/stratos-4.1.x/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/healthstats.py#L144
[3] -
https://github.com/apache/stratos/blob/stratos-4.1.x/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/healthstats.py#L226
[4] -
https://github.com/apache/stratos/blob/stratos-4.1.x/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/healthstats.py#L104


Regards,
Chamila de Alwis
Committer and PMC Member - Apache Stratos
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com



On Tue, Nov 10, 2015 at 10:51 AM, Malith Dhanushka <[email protected]> wrote:

> Thanks guys
>
> On Mon, Nov 9, 2015 at 7:50 PM, Imesh Gunaratne <[email protected]> wrote:
>
>> Yes, source code can be found here:
>>
>>
>> https://github.com/apache/stratos/tree/master/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge
>>
>> On Mon, Nov 9, 2015 at 6:27 AM, Reka Thirunavukkarasu <[email protected]>
>> wrote:
>>
>>> Hi Malith,
>>>
>>> Chamila has implemented python data publisher in PPaaS. Hope he can help
>>> you with it.
>>>
>>> Thanks,
>>> Reka
>>>
>>> On Mon, Nov 9, 2015 at 4:38 PM, Malith Dhanushka <[email protected]>
>>> wrote:
>>>
>>>> Hi Folks,
>>>>
>>>> We have a requirement for a python data publisher for DAS and got to
>>>> know that this has already implemented in PPAAS. Could you please provide
>>>> some details on what extent that was done in terms of functionality.  (i.e
>>>> - authentication, even bundling, message queuing..)
>>>>
>>>> Thanks
>>>> Malith
>>>> --
>>>> Malith Dhanushka
>>>> Senior Software Engineer - Data Technologies
>>>> *WSO2, Inc. : wso2.com <http://wso2.com/>*
>>>> *Mobile*          : +94 716 506 693
>>>>
>>>
>>>
>>>
>>> --
>>> Reka Thirunavukkarasu
>>> Senior Software Engineer,
>>> WSO2, Inc.:http://wso2.com,
>>> Mobile: +94776442007
>>>
>>>
>>>
>>
>>
>> --
>> *Imesh Gunaratne*
>> Senior Technical Lead
>> WSO2 Inc: http://wso2.com
>> T: +94 11 214 5345 M: +94 77 374 2057
>> W: http://imesh.gunaratne.org
>> Lean . Enterprise . Middleware
>>
>>
>
>
> --
> Malith Dhanushka
> Senior Software Engineer - Data Technologies
> *WSO2, Inc. : wso2.com <http://wso2.com/>*
> *Mobile*          : +94 716 506 693
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to