Liveliness #72
Replies: 3 comments 9 replies
-
@OlivierHecart, I think it would be nice to also have the ability to support testaments. In other terms a value that is produced automatically by the infrastructure when the lifelines is lost. Have you thought about this? |
Beta Was this translation helpful? Give feedback.
-
Few comments:
|
Beta Was this translation helpful? Give feedback.
-
That's a good feature. |
Beta Was this translation helpful? Give feedback.
-
Liveliness
Context
The ability to check the liveliness of a Zenoh entity (application, publisher, subscriber, etc...) and the ability to be notified of liveliness changes of Zenoh entities (apparition/disappearance of an entity) is a functionnality that is needed in some use cases.
The ability to monitor the liveliness of any entity in the system at any time puts a lot of pressure on the infrastructure. Zenoh needs to anticipate the possibility that any application could monitor the liveliness of any other entity at any time even if this never happens. This will cause huge scalability issues in a large system with a lot of entities.
To offer such functionality without impacting scalability, users should be able to explicitely declare which entities may have their liveliness monitored by other applications or not.
Such a functionality is already offered by the group management feature in
zenoh-ext
, but the group management feature is quite resource consuming and may also suffer scalability issues. In particular each group member needs to periodically assert it's liveliness by broadcasting a HeartBeat message to all other members of the group.It should be possible to build a far less resource consuming generic liveliness mechanism in the routing layer that would rely on the existing Transport Session liveliness.
The basics
Any Zenoh application can declare one or multiple liveliness tokens. Each liveliness token is declared on a key expression. A declared liveliness token will be seen as alive by any other Zenoh application in the system that monitors it while the liveliness token is not undeclared or dropped, while the Zenoh application that declared it is alive (didn't stop or crashed) and while the Zenoh application that declared the token has Zenoh connectivity with the Zenoh application that monitors it.
In the case of a network partition, the Zenoh applications that still have connectivity with the Zenoh application that declared the token still see it as alive while the Zenoh applications that loosed connectivity with the Zenoh application that declared the token see it as dropped.
Multiple liveliness tokens on the same key
If one or multiple Zenoh applications declare multiple liveliness tokens on the same key, the token will be seen as alive as asson as the first declaration occurs and will be seen as dropped when the last token is dropped.
Declaring liveliness tokens
A liveliness token can be declared on any key expression with the help of the
Session
declare_liveliness
function:Example:
A liveliness token can be explicitely undeclared or dropped.
Example:
Querying liveliness tokens
Each alive token can be accessed through queries at any pont in the system with the key prefix
@/liveliness
. So a token with keygroup1/member1
is accessible in key@/liveliness/group1/member1
and all alive tokens in the system can be accessed with the following key expression:@/liveliness/**
.Example
Using the
z_get
example:Notifications of liveliness changes
Each time a liveliness token is declared on a given key (assume
group1/member1
), aput
is sent to matching subscribers:@/liveliness/group1/member1
Put
Each time a liveliness token is dropped (because the application that declared it stopped, crashed or loosed connectivity), a
delete
is sent to matching subscribers:@/liveliness/group1/member1
Delete
Example
Using the
z_sub
example:Using the
QueryingSubscriber
When monitoring liveliness changes by declaring a
Subscriber
, theSubscriber
only receives changes that occured after it's declaration. In particular, theSubscriber
will not see liveliness tokens declared before theSubscriber
declaration. In order to access liveliness tokens declared before theSubscriber
declaration as well as future connectivity changes, azenoh-ext
QueryingSubscriber
can be used.Example
Using the
z_query_sub
example:Client liveliness Subscribers loosing connectivity
When a client Zenoh application that subscribed to liveliness changes looses connectivity with the system (looses connectivity with it's router and fails to reesatblish connectivity), as it loosed connectivity with all remote applications a user could expect to receive a
delete
for all existing liveliness tokens. But this implies keeping a state of all tokens in the client itself which is undesirable.So, in such situation, to indicate to the user that all tokens are dropped, the following
delete
is sent to matching subscribers:@/liveliness/**
Delete
Future improvements
Liveliness tokens associated value
It may be usefull to allow Zenoh applications to attach a
value
to liveliness tokens they declare. This attachedvalue
would be seen by applications that query or subscribe to liveliness tokens/changes.The
LivelinessTokenBuilder
would offer awith_value
funtion:Example:
Multiple associated values on the same key
This rises the question of which value is seen associated to a token when the token has been declared multiple times on the same key with different values. Two behaviors could be offered in such case:
Beta Was this translation helpful? Give feedback.
All reactions