Curator RPC Proxy / Reference

API Reference

CuratorService

API Arguments Return Value Description
newCuratorProjection connectionName CuratorProjection Allocates a projection to a configured CuratorFramework instance in the RPC server. "connectionName" is the name of a configured connection.
closeCuratorProjection CuratorProjection void Close a CuratorProjection. Also closes any recipes, etc. created for the projection.
pingCuratorProjection CuratorProjection void Keeps the CuratorProjection from timing out. NOTE: your EventService event loop will do this for you.
createNode CreateSpec Created path name Create a ZNode
deleteNode DeleteSpec void Delete a ZNode
getData GetDataSpec bytes Return a ZNode's data
setData SetDataSpec Stat Set a ZNode's data
exists ExistsSpec Stat Check if a ZNode exists
getChildren GetChildrenSpec List of nodes Get the child nodes for a ZNode
sync path and async context void Do a ZooKeeper sync
closeGenericProjection id void Closes any projection. All projections have an "id" field. This is the value to pass.
acquireLock path, maxWaitMs optional lock projection Acquire a lock for the given path. Will wait at most maxWaitMs to acquire the lock. If the acquisition fails, result will be null.
startLeaderSelector path, participantId, waitForLeadershipMs LeaderResult Start a leader selector on the given path. The instance will be assigned the specified participantId. If waitForLeadershipMs is non-zero, the method will block for that amount of time waiting for leadership.
getLeaderParticipants leaderProjection List of Participant Return the participants in a leader selector
isLeader leaderProjection bool Return true if the specified projection is the current leader
startPathChildrenCache path, cacheData, dataIsCompressed, startMode cache projection Start a PathChildrenCache for the given path. Can optionally cache data, use compressed data.
getPathChildrenCacheData cacheProjection List of ChildData Get all the data for a path cache
getPathChildrenCacheDataForPath cacheProjection, path ChildData Get the data for a single ZNode in a path cache
startNodeCache path, dataIsCompressed, buildInitial node cache projection Start a node cache for the given path. Can optionally use compressed data and build the initial cache.
getNodeCacheData node cache projection ChildData Return the data for the cached node. If the node doesn't exist, the fields of the ChildData object will be null.
startPersistentEphemeralNode path, data, mode projection Start a PersistentEphemeralNode for the given path using the given data and mode.
acquireSemaphore path, acquireQty, maxWaitMs, maxLeases List of lease projections Acquire one or more leases for a semaphore on the given path. acquireQty is the number of leases to acquire. maxWaitMs is the max time to wait to get the leases. maxLeases is the maximum leases to allow for the semaphore. If the number of leases cannot be acquired within the max time, an empty list is returned.

EventService

API Arguments Return Value Description
getNextEvent CuratorProjection CuratorEvent Returns the next queued event for the given CuratorProjection. If no events are queued within the configured ping time, a PING event is returned.

See the Events Page for the CuratorEvent schema reference.

DiscoveryService

API Arguments Return Value Description
makeDiscoveryInstance name, payload, port DiscoveryInstance Return a completed DiscoveryInstance using the RPC server's address and the given name, payload and port.
startDiscovery basePath, yourInstance discovery projection Start a Service Discovery instance on the given path. If yourInstance is not null it will be registered as the local service.
startProvider discoveryProjection, serviceName, providerStrategy, downTimeoutMs, downErrorThreshold provider projection start a Service Discovery Provider to return instances for the given service name using the given provider strategy. Specify "down" instance characteristics with downTimeoutMs and downErrorThreshold.
getInstance provider projection DiscoveryInstance Return a single instance for the given service
getAllInstances provider projection list of DiscoveryInstance Return all instances for the given service
noteError provider projection, service id void Note an error for the given service instance

Struct Reference

CreateSpec

Field Type Required Description
path string Y the ZNode path
data bytes - data for the node
mode CreateMode - PERSISTENT, PERSISTENT_SEQUENTIAL, EPHEMERAL, or EPHEMERAL_SEQUENTIAL
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message
compressed bool - if true, compress the data
creatingParentsIfNeeded bool - if true, create any needed parent nodes
withProtection bool - if true, use Curator protection
creatingParentContainersIfNeeded bool - if true, create any needed parent nodes as CONTAINERs

DeleteSpec

Field Type Required Description
path string Y the ZNode path
guaranteed bool - if true, use guaranteed deletion
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message
compressed bool - if true, compress the data
version Version - if not null, uses Version.version when deleting the node. Otherwise, -1 is used.

GetDataSpec

Field Type Required Description
path string Y the ZNode path
watched bool - if true, trigger watch events for this node
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message
decompressed bool - if true, decompress the data

SetDataSpec

Field Type Required Description
path string Y the ZNode path
data bytes Y data for the node
watched bool - if true, trigger watch events for this node
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message
compressed bool - if true, compress the data
version Version - if not null, uses Version.version when setting the node data. Otherwise, -1 is used.

ExistsSpec

Field Type Required Description
path string Y the ZNode path
watched bool - if true, trigger watch events for this node
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message

GetChildrenSpec

Field Type Required Description
path string Y the ZNode path
watched bool - if true, trigger watch events for this node
asyncContext string - if not null, createNode() is performed asynchronously and this is the context used in the async message

LeaderResult

Field Type Description
projection LeaderProjection the projection of the leader
isLeader bool true if this projection is the leader

Participant

Field Type Description
id string participant id
isLeader bool true if this participant is the leader

ChildData

Field Type Description
path string the ZNode path
stat Stat ZooKeeper stat for the node
data bytes node data or null