You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've hacked in SetWatches request into a local version of Kazoo for testing.
I'm not sure if this would be a feature that's relatively useful for people to expose as an API, but I think it could be useful in the case where a connection is dropped and removed from the server before a session expires, as can be the case in client restart.
Example: Client exits abnormally. The original connection is loss, the ZooKeeper server removes the connection, which removes all watches associated with that connection (as the ServerCnxn object itself is the watcher on the server side).
User had persisted KazooClient.client_id, as well as information about paths that were being watched, and KazooClient.last_zxid.
Upon reconnect, user supplies that information back to KazooClient.
User reconstructs watcher(s).
KazooClient starts, reconnecting with the previous session ID, restoring the previous session, and immediately sets watches.
If anything has changed since the relativeZxid, those events are immediately triggered (which is why client-side watch handlers should be to be set before this request).
Here is an example of the SetWatches for serialization.py:
class SetWatches(namedtuple('SetWatches', 'relativeZxid dataWatches existsWatches childWatches')):
type = 101
def serialize(self):
b = bytearray()
b.extend(long_struct.pack(self.relativeZxid))
self.svector(b, self.dataWatches)
self.svector(b, self.existsWatches)
self.svector(b, self.childWatches)
return b
def svector(self, b, arr):
b.extend(int_struct.pack(len(arr)))
for elem in arr:
b.extend(write_string(elem))
# Not sure what we need for deserialization here
The text was updated successfully, but these errors were encountered:
I've hacked in SetWatches request into a local version of Kazoo for testing.
I'm not sure if this would be a feature that's relatively useful for people to expose as an API, but I think it could be useful in the case where a connection is dropped and removed from the server before a session expires, as can be the case in client restart.
Example: Client exits abnormally. The original connection is loss, the ZooKeeper server removes the connection, which removes all watches associated with that connection (as the ServerCnxn object itself is the watcher on the server side).
User had persisted KazooClient.client_id, as well as information about paths that were being watched, and KazooClient.last_zxid.
Upon reconnect, user supplies that information back to KazooClient.
User reconstructs watcher(s).
KazooClient starts, reconnecting with the previous session ID, restoring the previous session, and immediately sets watches.
If anything has changed since the relativeZxid, those events are immediately triggered (which is why client-side watch handlers should be to be set before this request).
Here is an example of the SetWatches for serialization.py:
The text was updated successfully, but these errors were encountered: