Re: Control different relation sequence

2013-09-04 Thread Gustavo Niemeyer
Exactly, that's what I would probably do as well. Once you are within
a relation you want to wait for further actions, dump the
$JUJU_RELATION_ID into a file and wait until you want to wake it up
again.  Hooks are guaranteed to be run in series, so you don't have to
worry about concurrency issues around the file.

On Wed, Sep 4, 2013 at 12:01 AM, Mike Sam mikesam...@gmail.com wrote:
 Thanks. Does this mean that the charm should cache the relation id's in a
 text file or something?


 On Tue, Sep 3, 2013 at 7:33 PM, Gustavo Niemeyer
 gustavo.nieme...@canonical.com wrote:

 The relation-set command accepts a -r parameter which takes the relation
 id
 to act upon. You can pick the relation id of an executing hook from
 the JUJU_RELATION_ID environment variable. This way you can act across
 relations.

 Hopefully this will be better documented at some point.

 On Tue, Sep 3, 2013 at 11:23 PM, Mike Sam mikesam...@gmail.com wrote:
  Thanks Gustavo but I did not quite get your point. The problem is that
  for
  the new unit for service A, the dependent hooks are on two different
  independent relationships. I mean I can control when the new unit of
  Service
  A has properly established a relation with all the units of service B on
  say
  relation x_relation_changed, but how do I make all the units of service
  C to
  now trigger the y_relation_changed hook of the Service A unit because
  the
  unit is ready to process them? How do I make y_relation_changed hook to
  get
  triggered AGAIN (in case it has already been triggered but ignored
  because
  relation with service B was not done setting up) when x_relation_changed
  see
  fit? Would you please explain your point is the Service A, B, C context
  of
  my example?
 
 
 
 
  On Tue, Sep 3, 2013 at 6:38 PM, Gustavo Niemeyer
  gustavo.nieme...@canonical.com wrote:
 
  Hi Mike,
 
  You cannot control the sequence in which the hooks are executed, but
  you have full control of what you do when the hooks do execute. You
  can choose to send nothing to the other side of the relation until its
  time to report that a connection may now be established, and when you
  do change the relation, the remote hook will run again to report the
  change.
 
  On Tue, Sep 3, 2013 at 10:17 PM, Mike Sam mikesam...@gmail.com wrote:
   Imagine a unit needs to be added to an existing service like service
   A.
   Service A is already in relations with other services like Service B
   and
   Service C on different requires.
  
   For the new unit on Service A to work, it needs to first process the
   relation_joined and relation_changed with the units of service B
   before
   it
   could process  relation_joined and relation_changed with the units of
   service C.
  
   Is there a way to enforce such desired sequence relationship
   establishment
   at the charm level? In other words, I do not think we can control the
   hook
   execution sequence of different relationships officially but then I
   am
   wondering how can we do a situation like above nicely?
  
   Thanks,
   Mike
  
  
  
  
  
   --
   Juju-dev mailing list
   juju-...@lists.ubuntu.com
   Modify settings or unsubscribe at:
   https://lists.ubuntu.com/mailman/listinfo/juju-dev
  
 
  --
  gustavo @ http://niemeyer.net
 
 



 --
 gustavo @ http://niemeyer.net





-- 
gustavo @ http://niemeyer.net

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Control different relation sequence

2013-09-04 Thread Gustavo Niemeyer
Exactly, that's what I would probably do as well. Once you are within
a relation you want to wait for further actions, dump the
$JUJU_RELATION_ID into a file and wait until you want to wake it up
again.  Hooks are guaranteed to be run in series, so you don't have to
worry about concurrency issues around the file.

On Wed, Sep 4, 2013 at 12:01 AM, Mike Sam mikesam...@gmail.com wrote:
 Thanks. Does this mean that the charm should cache the relation id's in a
 text file or something?


 On Tue, Sep 3, 2013 at 7:33 PM, Gustavo Niemeyer
 gustavo.nieme...@canonical.com wrote:

 The relation-set command accepts a -r parameter which takes the relation
 id
 to act upon. You can pick the relation id of an executing hook from
 the JUJU_RELATION_ID environment variable. This way you can act across
 relations.

 Hopefully this will be better documented at some point.

 On Tue, Sep 3, 2013 at 11:23 PM, Mike Sam mikesam...@gmail.com wrote:
  Thanks Gustavo but I did not quite get your point. The problem is that
  for
  the new unit for service A, the dependent hooks are on two different
  independent relationships. I mean I can control when the new unit of
  Service
  A has properly established a relation with all the units of service B on
  say
  relation x_relation_changed, but how do I make all the units of service
  C to
  now trigger the y_relation_changed hook of the Service A unit because
  the
  unit is ready to process them? How do I make y_relation_changed hook to
  get
  triggered AGAIN (in case it has already been triggered but ignored
  because
  relation with service B was not done setting up) when x_relation_changed
  see
  fit? Would you please explain your point is the Service A, B, C context
  of
  my example?
 
 
 
 
  On Tue, Sep 3, 2013 at 6:38 PM, Gustavo Niemeyer
  gustavo.nieme...@canonical.com wrote:
 
  Hi Mike,
 
  You cannot control the sequence in which the hooks are executed, but
  you have full control of what you do when the hooks do execute. You
  can choose to send nothing to the other side of the relation until its
  time to report that a connection may now be established, and when you
  do change the relation, the remote hook will run again to report the
  change.
 
  On Tue, Sep 3, 2013 at 10:17 PM, Mike Sam mikesam...@gmail.com wrote:
   Imagine a unit needs to be added to an existing service like service
   A.
   Service A is already in relations with other services like Service B
   and
   Service C on different requires.
  
   For the new unit on Service A to work, it needs to first process the
   relation_joined and relation_changed with the units of service B
   before
   it
   could process  relation_joined and relation_changed with the units of
   service C.
  
   Is there a way to enforce such desired sequence relationship
   establishment
   at the charm level? In other words, I do not think we can control the
   hook
   execution sequence of different relationships officially but then I
   am
   wondering how can we do a situation like above nicely?
  
   Thanks,
   Mike
  
  
  
  
  
   --
   Juju-dev mailing list
   Juju-dev@lists.ubuntu.com
   Modify settings or unsubscribe at:
   https://lists.ubuntu.com/mailman/listinfo/juju-dev
  
 
  --
  gustavo @ http://niemeyer.net
 
 



 --
 gustavo @ http://niemeyer.net





-- 
gustavo @ http://niemeyer.net

-- 
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev


Re: Control different relation sequence

2013-09-04 Thread Kapil Thangavelu
The missing command here is relation-ids to list the relation ids of a
given relation name. JUJU_RELATION_ID gives the current relation be
executed for, to trigger/inspect state on other relations, the relation-ids
command can be used to find their id, which can be passed to
relation-get/set with -r. Any mutations of the other relation state via
relation-set will trigger change hooks on remote related units.

cheers,
Kapil


On Tue, Sep 3, 2013 at 10:33 PM, Gustavo Niemeyer 
gustavo.nieme...@canonical.com wrote:

 The relation-set command accepts a -r parameter which takes the relation
 id
 to act upon. You can pick the relation id of an executing hook from
 the JUJU_RELATION_ID environment variable. This way you can act across
 relations.

 Hopefully this will be better documented at some point.

 On Tue, Sep 3, 2013 at 11:23 PM, Mike Sam mikesam...@gmail.com wrote:
  Thanks Gustavo but I did not quite get your point. The problem is that
 for
  the new unit for service A, the dependent hooks are on two different
  independent relationships. I mean I can control when the new unit of
 Service
  A has properly established a relation with all the units of service B on
 say
  relation x_relation_changed, but how do I make all the units of service
 C to
  now trigger the y_relation_changed hook of the Service A unit because the
  unit is ready to process them? How do I make y_relation_changed hook to
 get
  triggered AGAIN (in case it has already been triggered but ignored
 because
  relation with service B was not done setting up) when x_relation_changed
 see
  fit? Would you please explain your point is the Service A, B, C context
 of
  my example?
 
 
 
 
  On Tue, Sep 3, 2013 at 6:38 PM, Gustavo Niemeyer
  gustavo.nieme...@canonical.com wrote:
 
  Hi Mike,
 
  You cannot control the sequence in which the hooks are executed, but
  you have full control of what you do when the hooks do execute. You
  can choose to send nothing to the other side of the relation until its
  time to report that a connection may now be established, and when you
  do change the relation, the remote hook will run again to report the
  change.
 
  On Tue, Sep 3, 2013 at 10:17 PM, Mike Sam mikesam...@gmail.com wrote:
   Imagine a unit needs to be added to an existing service like service
 A.
   Service A is already in relations with other services like Service B
 and
   Service C on different requires.
  
   For the new unit on Service A to work, it needs to first process the
   relation_joined and relation_changed with the units of service B
 before
   it
   could process  relation_joined and relation_changed with the units of
   service C.
  
   Is there a way to enforce such desired sequence relationship
   establishment
   at the charm level? In other words, I do not think we can control the
   hook
   execution sequence of different relationships officially but then I am
   wondering how can we do a situation like above nicely?
  
   Thanks,
   Mike
  
  
  
  
  
   --
   Juju-dev mailing list
   Juju-dev@lists.ubuntu.com
   Modify settings or unsubscribe at:
   https://lists.ubuntu.com/mailman/listinfo/juju-dev
  
 
  --
  gustavo @ http://niemeyer.net
 
 



 --
 gustavo @ http://niemeyer.net

 --
 Juju-dev mailing list
 Juju-dev@lists.ubuntu.com
 Modify settings or unsubscribe at:
 https://lists.ubuntu.com/mailman/listinfo/juju-dev

-- 
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev


Re: Control different relation sequence

2013-09-03 Thread Gustavo Niemeyer
Hi Mike,

You cannot control the sequence in which the hooks are executed, but
you have full control of what you do when the hooks do execute. You
can choose to send nothing to the other side of the relation until its
time to report that a connection may now be established, and when you
do change the relation, the remote hook will run again to report the
change.

On Tue, Sep 3, 2013 at 10:17 PM, Mike Sam mikesam...@gmail.com wrote:
 Imagine a unit needs to be added to an existing service like service A.
 Service A is already in relations with other services like Service B and
 Service C on different requires.

 For the new unit on Service A to work, it needs to first process the
 relation_joined and relation_changed with the units of service B before it
 could process  relation_joined and relation_changed with the units of
 service C.

 Is there a way to enforce such desired sequence relationship establishment
 at the charm level? In other words, I do not think we can control the hook
 execution sequence of different relationships officially but then I am
 wondering how can we do a situation like above nicely?

 Thanks,
 Mike





 --
 Juju-dev mailing list
 Juju-dev@lists.ubuntu.com
 Modify settings or unsubscribe at:
 https://lists.ubuntu.com/mailman/listinfo/juju-dev


-- 
gustavo @ http://niemeyer.net

-- 
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev