pub struct ZooKeeper { /* private fields */ }
Expand description

A connection to ZooKeeper.

All interactions with ZooKeeper are performed by calling the methods of a ZooKeeper instance. All clones of the same ZooKeeper instance use the same underlying connection. Once a connection to a server is established, a session ID is assigned to the client. The client will send heart beats to the server periodically to keep the session valid.

The application can call ZooKeeper APIs through a client as long as the session ID of the client remains valid. If for some reason, the client fails to send heart beats to the server for a prolonged period of time (exceeding the session timeout value, for instance), the server will expire the session, and the session ID will become invalid. The ZooKeeper instance will then no longer be usable, and all futures will resolve with a protocol-level error. To make further ZooKeeper API calls, the application must create a new ZooKeeper instance.

If the ZooKeeper server the client currently connects to fails or otherwise does not respond, the client will automatically try to connect to another server before its session ID expires. If successful, the application can continue to use the client.

Some successful ZooKeeper API calls can leave watches on the “data nodes” in the ZooKeeper server. Other successful ZooKeeper API calls can trigger those watches. Once a watch is triggered, an event will be delivered to the client which left the watch at the first place. Each watch can be triggered only once. Thus, up to one event will be delivered to a client for every watch it leaves.

Implementations§

Connect to a ZooKeeper server instance at the given address with default parameters.

See ZooKeeperBuilder::connect.

Create a node with the given path with data as its contents.

The mode argument specifies additional options for the newly created node.

If mode is set to CreateMode::Ephemeral (or CreateMode::EphemeralSequential), the node will be removed by the ZooKeeper automatically when the session associated with the creation of the node expires.

If mode is set to CreateMode::PersistentSequential or CreateMode::EphemeralSequential, the actual path name of a sequential node will be the given path plus a suffix i where i is the current sequential number of the node. The sequence number is always fixed length of 10 digits, 0 padded. Once such a node is created, the sequential number will be incremented by one. The newly created node’s full name is returned when the future is resolved.

If a node with the same actual path already exists in the ZooKeeper, the returned future resolves with an error of error::Create::NodeExists. Note that since a different actual path is used for each invocation of creating sequential nodes with the same path argument, calls with sequential modes will never return NodeExists.

Ephemeral nodes cannot have children in ZooKeeper. Therefore, if the parent node of the given path is ephemeral, the return future resolves to error::Create::NoChildrenForEphemerals.

If a node is created successfully, the ZooKeeper server will trigger the watches on the path left by exists calls, and the watches on the parent of the node by get_children calls.

The maximum allowable size of the data array is 1 MB (1,048,576 bytes).

Set the data for the node at the given path.

The call will succeed if such a node exists, and the given version matches the version of the node (if the given version is None, it matches any version). On success, the updated Stat of the node is returned.

This operation, if successful, will trigger all the watches on the node of the given path left by get_data calls.

The maximum allowable size of the data array is 1 MB (1,048,576 bytes).

Delete the node at the given path.

The call will succeed if such a node exists, and the given version matches the node’s version (if the given version is None, it matches any versions).

This operation, if successful, will trigger all the watches on the node of the given path left by exists API calls, and the watches on the parent node left by get_children API calls.

Return the ACL and Stat of the node at the given path.

If no node exists for the given path, the returned future resolves with an error of error::GetAcl::NoNode.

Set the ACL for the node of the given path.

The call will succeed if such a node exists and the given version matches the ACL version of the node. On success, the updated Stat of the node is returned.

If no node exists for the given path, the returned future resolves with an error of error::SetAcl::NoNode. If the given version does not match the ACL version, the returned future resolves with an error of error::SetAcl::BadVersion.

Add a global watch for the next chained operation.

Add a watch for the next chained operation, and return a future for any received event along with the operation’s (successful) result.

Return the Stat of the node of the given path, or None if the node does not exist.

Return the names of the children of the node at the given path, or None if the node does not exist.

The returned list of children is not sorted and no guarantee is provided as to its natural or lexical order.

Return the data and the Stat of the node at the given path, or None if it does not exist.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.