Handling relation-get gives null data issue
Kapil Thangavelu
kapil.thangavelu at canonical.com
Fri Oct 31 10:14:50 UTC 2014
You've setup a race condition. First you should be receiving data in
relation-changed not relation-joined. If you try to receive set values in
relation-joined and the sending side comes up second, you'll never see the
data. Also you should make things resistant to races by exiting if the data
you want is not present, relation-changed will be called again when the
data on the remote side changes.
ie. in pseudo code.
charm x / foo-relation-joined
relation-set x=1
charm y / bar-relation-changed
x=relation-get x
if not x: # other side not ready, exit, and we'll be called again when it
is.
exit 0
# do some stuff with the data
On Fri, Oct 31, 2014 at 6:06 AM, Malshan Peiris <malshan at hsenidmobile.com>
wrote:
> Hi all,
>
> I have two charms which is joined by a relation, and supposed to send data
> both ways.
> In the relation-joined hook of the charms i have put appropriate
> relation-set in one charm and relation-get in the other. Same is done vice
> versa. However, randomly atleast one charm fails to get the values (hence
> have null values).
>
> I tried to have loops with sleep command which would do relation-get till
> not-null values are returned, but they don't return data after number of
> tries. There's no useful info in machine and unit logs.
>
> Is there a standard/known way to handle this.
>
> environment: LXC on ubuntu 14.04 x86_64
> juju: 1.20.0-trusty-amd64
>
> Have a nice day.
>
>
> --
> <http://www.hsenidmobile.com/>Malshan Peiris,Implementation EngineerTel:
> 94-77-5525110 Head Office (Singapore)*P*: +65 65 332 140*M*: +65 00 000
> 000*F*: +65 65 332 140 R&D (Sri Lanka)*P*: +94 11 268 3751*M*: +94 00 000
> 000*F*: +94 11 268 3951 *www.hSenidMobile.com*
> <http://www.hSenidMobile.com>
> <https://www.facebook.com/hSenidMobileSolutions>
> <https://twitter.com/hSenidMobile>
> <http://www.linkedin.com/company/hsenid-mobile-solutions-pvt-ltd>
> <http://www.youtube.com/user/hSenidmobile>
> <http://www.hsenidmobile.com/events/telecom-application-developer-summit-2014/>
> Disclaimer: This email and any files transmitted with it are
> confidential and intended solely for the use of the individual or entity to
> which they are addressed. The content and opinions contained in this email
> are not necessarily those of hSenid Mobile Solutions. If you have received
> this email in error please contact the sender.
>
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20141031/96caa6d5/attachment.html>
More information about the Juju
mailing list