SynchronousZookeeper

com.loopfor.zookeeper.SynchronousZookeeper
See theSynchronousZookeeper companion object

A ZooKeeper client with ''synchronous'' operations.

Attributes

Companion:
object
Graph
Supertypes
trait Zookeeper
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

def children(path: String): Seq[String]

Returns the children of the node specified by the given path.

Returns the children of the node specified by the given path.

Attributes

path

the path of the node

Returns:

an unordered sequence containing the names of each child node

Throws:
NoNodeException

if the node does not exist

def create(path: String, data: Array[Byte], acl: Seq[ACL], disp: Disposition): String

Creates a new node at the given path.

Creates a new node at the given path.

If a ''sequential'' disposition is provided in disp, then path is appended with a monotonically increasing sequence, thus guaranteeing that all sequential nodes are unique with path as their prefix.

Attributes

acl

an access control list to apply to the node, which must not be empty

data

the data to associate with the node, which may be empty, but not null

disp

the disposition of the node

path

the path of the node to create

Returns:

the final path of the created node, which will differ from path if disp is either PersistentSequential, PersistentSequentialTimeToLive or EphemeralSequential

def delete(path: String, version: Option[Int]): Unit

Deletes the node specified by the given path.

Deletes the node specified by the given path.

Attributes

path

the path of the node

version

a Some containing the expected version of the node or None if a version match is not required

Throws:
BadVersionException

if version is specified and does not match the node version

NoNodeException

if the node does not exist

NotEmptyException

if the node contains children

def exists(path: String): Option[Status]

Returns the status of the node specified by the given path if it exists.

Returns the status of the node specified by the given path if it exists.

Attributes

path

the path of the node

Returns:

a Some containing the node status or None if the node does not exist

def get(path: String): (Array[Byte], Status)

Returns the data and status of the node specified by the given path.

Returns the data and status of the node specified by the given path.

Attributes

path

the path of the node

Returns:

a tuple containing the data and status of the node

Throws:
NoNodeException

if the node does not exist

def getACL(path: String): (Seq[ACL], Status)

Returns the ACL and status of the node specified by the given path.

Returns the ACL and status of the node specified by the given path.

Attributes

path

the path of the node

Returns:

a tuple containing the ACL and status of the node

Throws:
NoNodeException

if the node does not exist

def set(path: String, data: Array[Byte], version: Option[Int]): Status

Sets the data for the node specified by the given path.

Sets the data for the node specified by the given path.

Attributes

data

the data to associate with the node, which may be empty, but not null

path

the path of the node

version

a Some containing the expected version of the node or None if a version match is not required

Returns:

the status of the node

Throws:
BadVersionException

if version is specified and does not match the node version

NoNodeException

if the node does not exist

def setACL(path: String, acl: Seq[ACL], version: Option[Int]): Status

Sets the ACL for the node specified by the given path.

Sets the ACL for the node specified by the given path.

Attributes

acl

an access control list to apply to the node, which must not be empty

path

the path of the node

version

a Some containing the expected version of the node or None if a version match is not required

Returns:

the status of the node

Throws:
BadVersionException

if version is specified and does not match the node version

NoNodeException

if the node does not exist

Atomically performs a set of operations, either committing all or none.

Atomically performs a set of operations, either committing all or none.

The set of operations are applied by ZooKeeper in sequential order. If successful, this method returns a Right containing a sequence of results that positionally correlate to the sequence of operations. Otherwise, it returns a Left similarly containing a sequence of problems.

Example:

val ops = CheckOperation("/foo", None) ::
         CreateOperation("/bar", Array(), ACL.EveryoneAll, Persistent) :: Nil
zk transact ops match {
 case Right(results) => ...
 case Left(problems) => ...
}

Attributes

Returns a synchronous client in which operations implicitly attach the specified watch function.

Returns a synchronous client in which operations implicitly attach the specified watch function.

The partial function fn is invoked when a watch is triggered or the session state changes. This method is typically used in a transient manner to introduce a watch function prior to performing a watchable ZooKeeper operation.

Example:

val zk = SynchronousZookeeper(config)
val (data, node) = zk watch {
 case e: NodeEvent => ...
 case e: StateEvent => ...
} get "/foo"

Attributes

Inherited methods

Returns a view of this client in which operations are performed ''asynchronously''.

Returns a view of this client in which operations are performed ''asynchronously''.

Attributes

Returns:

an asynchronous view of this client

Inherited from:
Zookeeper
def close(): Unit

Closes the client connection to the ZooKeeper cluster.

Closes the client connection to the ZooKeeper cluster.

A consequence of closing the connection is that ZooKeeper will expire the corresponding session, which further implies that all ephemeral nodes created by this client will be deleted.

Attributes

Inherited from:
Zookeeper
def ensure(path: String): Future[Unit]

Ensures that the value of a node, specified by the given path, is synchronized across the ZooKeeper cluster.

Ensures that the value of a node, specified by the given path, is synchronized across the ZooKeeper cluster.

'''An important note on consistency''': ZooKeeper does not guarantee, for any given point in time, that all clients will have a consistent view of the cluster. Since reads can be served by any node in the cluster, whereas writes are serialized through the leader, there exists the possibility in which two separate clients may have inconsistent views. This scenario occurs when the leader commits a change once consensus is reached, but the change has not yet propagated across the cluster. Therefore, reads occurring before the commit has propagated will be globally inconsistent. This behavior is normally acceptable, but for some use cases, writes may need to be globally visible before subsequent reads occur.

This method is particularly useful when a ''write'' occurring in one process is followed by a ''read'' in another process. For example, consider the following sequence of operations:

  • process A writes a value
  • process A sends a message to process B
  • process B reads the value

The assumption is that process B expects to see the value written by process A, but as mentioned, ZooKeeper does not make this guarantee. A call to this method before process B attempts to read the value ensures that all prior writes are consistently applied across the cluster, thus observing the write in process A.

Attributes

Returns:

a future that completes when the node is synchronized across the cluster

Inherited from:
Zookeeper

Returns the session associated with ZooKeeper.

Returns the session associated with ZooKeeper.

Note that the connection with ZooKeeper is established asynchronously, which means there is no implied guarantee that the session has connected nor will eventually connect at the time that an instance of this trait is created.

Attributes

Returns:

the session associated with ZooKeeper

Inherited from:
Zookeeper

Returns a view of this client in which operations are performed ''synchronously''.

Returns a view of this client in which operations are performed ''synchronously''.

Attributes

Returns:

a synchronous view of this client

Inherited from:
Zookeeper