com.github.bigtoast.zookeeper

AsyncZooKeeperClient

class AsyncZooKeeperClient extends AnyRef

Scala wrapper around the async ZK api. This is based on the twitter scala wrapper now maintained by 4square. https://github.com/foursquare/scala-zookeeper-client

It uses Akka 2.0 Futures. Once our company gets on scala 2.10 I will refactor to use SIP 14 Futures.

I didn't implement any ACL stuff because I never use that shiz.

You can pass in a base path (defaults to "/") which will be prepended to any path that does not start with a "/". This allows you to specify a context to all requests. Absolute paths, those starting with "/", will not have the base path prepended.

On connection the base path will be created if it does not already exist.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. AsyncZooKeeperClient
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AsyncZooKeeperClient(servers: String, watcher: (AsyncZooKeeperClient) ⇒ Unit, eCtx: ExecutionContext)

  2. new AsyncZooKeeperClient(servers: String, eCtx: ExecutionContext)

  3. new AsyncZooKeeperClient(servers: String, sessionTimeout: Int, connectTimeout: Int, basePath: String, watcher: (AsyncZooKeeperClient) ⇒ Unit, eCtx: ExecutionContext)

  4. new AsyncZooKeeperClient(servers: String, sessionTimeout: Int, connectTimeout: Int, basePath: String, eCtx: ExecutionContext)

  5. new AsyncZooKeeperClient(servers: String, sessionTimeout: Int, connectTimeout: Int, basePath: String, watcher: Option[(AsyncZooKeeperClient) ⇒ Unit], eCtx: ExecutionContext)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. val basePath: String

  8. implicit val c: ExecutionContext

  9. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. def close: Unit

    close the underlying zk connection

  11. val connectTimeout: Int

  12. def create(path: String, data: Option[Array[Byte]], createMode: CreateMode, ctx: Option[Any] = None): Future[StringResponse]

    Create a path with OPEN_ACL_UNSAFE hardcoded

  13. def createAndGet(path: String, data: Option[Array[Byte]], createMode: CreateMode, ctx: Option[Any] = None, watch: Option[Watcher] = None): Future[DataResponse]

    Create a node and then return it.

    Create a node and then return it. Under the hood this is a create followed by a get. If the stat or data is not needed use a plain create which is cheaper.

  14. def createPath(path: String): Future[VoidResponse]

    Recursively create a path with persistent nodes and no watches set.

  15. def delete(path: String, version: Int = 1, ctx: Option[Any] = None, force: Boolean = false): Future[VoidResponse]

    Wrapper around zk delete method.

    Wrapper around zk delete method.

    force

    Delete all children of this node

    See also

    http://zookeeper.apache.org/doc/r3.4.1/api/org/apache/zookeeper/ZooKeeper.html#delete(java.lang.String, int, org.apache.zookeeper.AsyncCallback.VoidCallback, java.lang.Object)

    The version only applies to the node indicated by the path. If force is true all children will be deleted even if the version doesn't match.

  16. def deleteChildren(path: String, ctx: Option[Any] = None): Future[VoidResponse]

    Delete all the children of a node but not the node.

  17. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  19. def exists(path: String, ctx: Option[Any] = None, watch: Option[Watcher] = None): Future[StatResponse]

    Wrapper around the ZK exists method.

  20. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  21. def get(path: String, ctx: Option[Any] = None, watch: Option[Watcher] = None): Future[DataResponse]

    Wrapper around zk getData method.

  22. def getChildren(path: String, ctx: Option[Any] = None, watch: Option[Watcher] = None): Future[ChildrenResponse]

    Wrapper around the ZK getChildren method.

  23. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  24. def getOrCreate(path: String, data: Option[Array[Byte]], createMode: CreateMode, ctx: Option[Any] = None): Future[DataResponse]

    Return the node if it exists, otherwise create a new node with the data passed in.

    Return the node if it exists, otherwise create a new node with the data passed in. If the node is created a get will be called and the value returned. In case of a race condition where a two or more requests are executed at the same time and one of the creates will fail with a NodeExistsException, it will be handled and a get will be called.

  25. def handleResponse[T](rc: Int, path: String, p: Promise[T], stat: Stat, cxt: Option[Any])(f: ⇒ T): Future[T]

    helper method to convert a zk response in to a client reponse and handle the errors

  26. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  27. def isAlive: Future[Boolean]

    Checks the connection by checking existence of "/"

  28. def isAliveSync: Boolean

    Check the connection synchronously

  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  31. final def notify(): Unit

    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  33. val servers: String

  34. val sessionTimeout: Int

  35. def set(path: String, data: Option[Array[Byte]], version: Int = 1, ctx: Option[Any] = None): Future[StatResponse]

    Wrapper around the zk setData method.

  36. def subPaths(path: String, sep: Char): List[String]

    Given a string representing a path, return each subpath Ex.

    Given a string representing a path, return each subpath Ex. subPaths("/a/b/c", "/") == ["/a", "/a/b", "/a/b/c"]

  37. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  38. def toString(): String

    Definition Classes
    AnyRef → Any
  39. def underlying: Option[ZooKeeper]

    get the underlying ZK connection

  40. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  41. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  42. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  43. def watchChildren(path: String, persistent: ⇒ Boolean)(onKids: (ChildrenResponse) ⇒ Unit): Future[ChildrenResponse]

    set a persistent watch on if the children of this node change.

    set a persistent watch on if the children of this node change. If they do the updated ChildResponse will be returned.

    path
    persistent
    onKids

    @return

  44. def watchChildren(path: String)(onKids: (ChildrenResponse) ⇒ Unit): Future[ChildrenResponse]

    Sets a persistent child watch.

    Sets a persistent child watch.

    See also

    watchChildren

  45. def watchConnection(onState: (KeeperState) ⇒ Unit): Unit

    sets the client watcher.

    sets the client watcher. reconnecting on session expired is handled by the client and doesn't need to be handled here.

  46. def watchData(path: String, persistent: ⇒ Boolean)(onData: (String, Option[DataResponse]) ⇒ Unit): Future[DataResponse]

    set a persistent watch on a node listening for data changes.

    set a persistent watch on a node listening for data changes. If a NodeDataChanged event is received or a NodeCreated event is received the DataResponse will be returned with the new data and the watch will be reset. If a None or NodeChildrenChanged the watch will be reset returning nothing. If the node is deleted receiving a NodeDeleted event None will be returned.

    In the event of an error nothing will be returned but errors will be logged.

    path

    relative or absolute

    persistent

    if this is false the watch will not be reset after receiving an event. ( normal zk behavior )

    onData

    callback executed on data events. None on node deleted event. path will always be absolute regardless of what is passed into the function

    returns

    initial data. If this returns successfully the watch was set otherwise it wasn't

  47. def watchData(path: String)(onData: (String, Option[DataResponse]) ⇒ Unit): Future[DataResponse]

    Set a persistent watch on data.

    Set a persistent watch on data.

    See also

    watchData

Inherited from AnyRef

Inherited from Any