Reputation: 4458
Zookeeper API contains an operation called zoo_async(). The documentation says that the given operation is used to
Flush the leader Channel
Can someone please explain the functionality of this operation and suggest some use cases that we might need to use this operation?
Upvotes: 2
Views: 160
Reputation: 9844
The code for this function is in zookeeper.c. We can see that it is sending a SyncRequest
to the ZooKeeper server:
struct SyncRequest req;
This means that zoo_async
in the C client API is equivalent to sync
in the Java client API.
This method can be called to guarantee that the client's view of ZooKeeper state is fully caught up with the server-side view. This method is used only rarely in practice. Most ZooKeeper usage patterns don't require it. The Apache ZooKeeper documentation on Consistency Guarantees contains further discussion about the problem of simultaneously consistent cross-client views and how the sync
method can be applied to the problem.
You might be wondering about the naming inconsistency between async
in the C API and sync
in the Java API. The confusion arises from the fact that the operation is synchronizing state between client and server, but it executes asynchronously, with the client receiving a callback upon completion. Thus, it is a "asynchronous synchronization". It appears the naming in the C API chose to emphasize the asynchronous nature of the function, while the naming in the Java API chose to emphasize the action performed.
Upvotes: 1