Curator RPC Proxy / Events

Events

Event Loop

In order to receive out-of-bounds messages (connection state changes, watcher triggers, etc.) you must have an event loop to recieve messages from the EventService. Here is pseudo code:

inThread => {
    while isOpen {
        event = eventService.getNextEvent(curatorProjection)
        ... process event ...
    }
}

IMPORTANT: your event handling should operate as quickly as possible. You should return to calling getNextEvent() as soon as possible.

Schema

CuratorEvent

Field Type Description
type CuratorEventType The event type
resultCode int some event types have a result code (i.e. async API calls)
path string if there is a path associated with the event
context string async context for async API calls
stat Stat some event types have a ZooKeeper Stat object
data bytes ZNode data if the event type has it
name string ZNode name if the event type has it
children list of string list of node names if the event type has it
aclList list of Acl list of ACL data if the event type has it
watchedEvent WatchedEvent if the event type is WATCHED
leaderEvent LeaderEvent if the event type is LEADER
childrenCacheEvent PathChildrenCacheEvent if the event type is PATH_CHILDREN_CACHE

CuratorEventType

Value Description
PING Returned if no events have been generated within the configured pingTime
CREATE Async createNode() API completion
DELETE Async deleteNode() API completion
EXISTS Async exists() API completion
GET_DATA Async getData() API completion
SET_DATA Async setData() API completion
CHILDREN Async getChildren() API completion
SYNC Async sync() API completion
WATCHED A watcher has triggered
CONNECTION_CONNECTED A Curator ConnectionStateListener is installed. This event is for the initial successful connection.
CONNECTION_SUSPENDED A Curator ConnectionStateListener is installed. This event means the connection has been suspended.
CONNECTION_RECONNECTED A Curator ConnectionStateListener is installed. This event means the connection has been reconnected.
CONNECTION_LOST A Curator ConnectionStateListener is installed. This event means the connection has been lost.
CONNECTION_READ_ONLY A Curator ConnectionStateListener is installed. This event means the connection has changed to read only.
LEADER A Leader recipe event
PATH_CHILDREN_CACHE A path children cache event
NODE_CACHE The node for a node cache has changed

LeaderEvent

Field Type Description
path string The leader's path
participantId string The participant ID for the event being reported
isLeader bool if true, this participant is being made leader. If false, it is losing leadership.

PathChildrenCacheEvent

Field Type Description
cachedPath name The path being cached
type PathChildrenCacheEventType cache event type
data ChildData data for the child ZNode

PathChildrenCacheEventType

Values: CHILD_ADDED, CHILD_UPDATED, CHILD_REMOVED, CONNECTION_SUSPENDED, CONNECTION_RECONNECTED, CONNECTION_LOST, INITIALIZED

ChildData

Field Type Description
path string The ZNode path
stat Stat ZooKeeper Stat object
data bytes ZNode data (if the cache is configured to cache data)