Logo Search packages:      
Sourcecode: zookeeper version File versions  Download package

zookeeper.h File Reference


Detailed Description

ZooKeeper functions and definitions.

The state of ZK at the time of sending this event. It can be either ZOO_CONNECTING_STATE, ZOO_ASSOCIATING_STATE, ZOO_CONNECTED_STATE, ZOO_EXPIRED_SESSION_STATE or AUTH_FAILED_STATE. See {} for more details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

ZooKeeper is a network service that may be backed by a cluster of synchronized servers. The data in the service is represented as a tree of data nodes. Each node has data, children, an ACL, and status information. The data for a node is read and write in its entirety.

ZooKeeper clients can leave watches when they queries the data or children of a node. If a watch is left, that client will be notified of the change. The notification is a one time trigger. Subsequent chances to the node will not trigger a notification unless the client issues a querity with the watch flag set. If the client is ever disconnected from the service, even if the disconnection is temporary, the watches of the client will be removed from the service, so a client must treat a disconnect notification as an implicit trigger of all outstanding watches.

When a node is created, it may be flagged as an ephemeral node. Ephemeral nodes are automatically removed when a client session is closed or when a session times out due to inactivity (the ZooKeeper runtime fills in periods of inactivity with pings). Ephemeral nodes cannot have children.

ZooKeeper clients are identified by a server assigned session id. For security reasons The server also generates a corresponding password for a session. A client may save its id and corresponding password to persistent storage in order to use the session across program invocation boundaries.

Definition in file zookeeper.h.

#include <sys/time.h>
#include <stdio.h>
#include "zookeeper_version.h"
#include "recordio.h"
#include "zookeeper.jute.h"

Go to the source code of this file.

Classes

struct  clientid_t
 client id structure. More...

Typedefs

typedef void(* acl_completion_t )(int rc, struct ACL_vector *acl, struct Stat *stat, const void *data)
 signature of a completion function that returns an ACL.
typedef void(* data_completion_t )(int rc, const char *value, int value_len, const struct Stat *stat, const void *data)
 signature of a completion function that returns data.
typedef void(* stat_completion_t )(int rc, const struct Stat *stat, const void *data)
 signature of a completion function that returns a Stat structure.
typedef void(* string_completion_t )(int rc, const char *value, const void *data)
 signature of a completion function that returns a list of strings.
typedef void(* strings_completion_t )(int rc, const struct String_vector *strings, const void *data)
 signature of a completion function that returns a list of strings.
typedef void(* void_completion_t )(int rc, const void *data)
 signature of a completion function for a call that returns void.
typedef void(* watcher_fn )(zhandle_t *zh, int type, int state, const char *path, void *watcherCtx)
 signature of a watch function.
typedef struct _zhandle zhandle_t
 ZooKeeper handle.

Enumerations

enum  ZOO_ERRORS {
  ZOK = 0, ZSYSTEMERROR = -1, ZRUNTIMEINCONSISTENCY = -2, ZDATAINCONSISTENCY = -3,
  ZCONNECTIONLOSS = -4, ZMARSHALLINGERROR = -5, ZUNIMPLEMENTED = -6, ZOPERATIONTIMEOUT = -7,
  ZBADARGUMENTS = -8, ZINVALIDSTATE = -9, ZAPIERROR = -100, ZNONODE = -101,
  ZNOAUTH = -102, ZBADVERSION = -103, ZNOCHILDRENFOREPHEMERALS = -108, ZNODEEXISTS = -110,
  ZNOTEMPTY = -111, ZSESSIONEXPIRED = -112, ZINVALIDCALLBACK = -113, ZINVALIDACL = -114,
  ZAUTHFAILED = -115, ZCLOSING = -116, ZNOTHING = -117, ZSESSIONMOVED = -118
}
Debug levels
enum  ZooLogLevel { ZOO_LOG_LEVEL_ERROR = 1, ZOO_LOG_LEVEL_WARN = 2, ZOO_LOG_LEVEL_INFO = 3, ZOO_LOG_LEVEL_DEBUG = 4 }

Functions

ZOOAPI int is_unrecoverable (zhandle_t *zh)
 checks if the current zookeeper connection state can't be recovered.
ZOOAPI const char * zerror (int c)
 return an error string.
ZOOAPI int zoo_acreate (zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, string_completion_t completion, const void *data)
 create a node.
ZOOAPI int zoo_add_auth (zhandle_t *zh, const char *scheme, const char *cert, int certLen, void_completion_t completion, const void *data)
 specify application credentials.
ZOOAPI int zoo_adelete (zhandle_t *zh, const char *path, int version, void_completion_t completion, const void *data)
 delete a node in zookeeper.
ZOOAPI int zoo_aexists (zhandle_t *zh, const char *path, int watch, stat_completion_t completion, const void *data)
 checks the existence of a node in zookeeper.
ZOOAPI int zoo_aget (zhandle_t *zh, const char *path, int watch, data_completion_t completion, const void *data)
 gets the data associated with a node.
ZOOAPI int zoo_aget_acl (zhandle_t *zh, const char *path, acl_completion_t completion, const void *data)
 gets the acl associated with a node.
ZOOAPI int zoo_aget_children (zhandle_t *zh, const char *path, int watch, strings_completion_t completion, const void *data)
 lists the children of a node.
ZOOAPI int zoo_aset (zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, stat_completion_t completion, const void *data)
 sets the data associated with a node.
ZOOAPI int zoo_aset_acl (zhandle_t *zh, const char *path, int version, struct ACL_vector *acl, void_completion_t, const void *data)
 sets the acl associated with a node.
ZOOAPI int zoo_async (zhandle_t *zh, const char *path, string_completion_t completion, const void *data)
 Flush leader channel.
ZOOAPI int zoo_awexists (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, stat_completion_t completion, const void *data)
 checks the existence of a node in zookeeper.
ZOOAPI int zoo_awget (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, data_completion_t completion, const void *data)
 gets the data associated with a node.
ZOOAPI int zoo_awget_children (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, strings_completion_t completion, const void *data)
 lists the children of a node.
ZOOAPI const clientid_tzoo_client_id (zhandle_t *zh)
 return the client session id, only valid if the connections is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE)
ZOOAPI int zoo_create (zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, char *path_buffer, int path_buffer_len)
 create a node synchronously.
ZOOAPI int zoo_delete (zhandle_t *zh, const char *path, int version)
 delete a node in zookeeper synchronously.
ZOOAPI void zoo_deterministic_conn_order (int yesOrNo)
 enable/disable quorum endpoint order randomization
ZOOAPI int zoo_exists (zhandle_t *zh, const char *path, int watch, struct Stat *stat)
 checks the existence of a node in zookeeper synchronously.
ZOOAPI int zoo_get (zhandle_t *zh, const char *path, int watch, char *buffer, int *buffer_len, struct Stat *stat)
 gets the data associated with a node synchronously.
ZOOAPI int zoo_get_acl (zhandle_t *zh, const char *path, struct ACL_vector *acl, struct Stat *stat)
 gets the acl associated with a node synchronously.
ZOOAPI int zoo_get_children (zhandle_t *zh, const char *path, int watch, struct String_vector *strings)
 lists the children of a node synchronously.
ZOOAPI const void * zoo_get_context (zhandle_t *zh)
ZOOAPI int zoo_recv_timeout (zhandle_t *zh)
ZOOAPI int zoo_set (zhandle_t *zh, const char *path, const char *buffer, int buflen, int version)
 sets the data associated with a node. See zoo_set2 function if you require access to the stat information associated with the znode.
ZOOAPI int zoo_set2 (zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat)
 sets the data associated with a node. This function is the same as zoo_set except that it also provides access to stat information associated with the znode.
ZOOAPI int zoo_set_acl (zhandle_t *zh, const char *path, int version, const struct ACL_vector *acl)
 sets the acl associated with a node synchronously.
ZOOAPI void zoo_set_context (zhandle_t *zh, void *context)
ZOOAPI void zoo_set_debug_level (ZooLogLevel logLevel)
 sets the debugging level for the library
ZOOAPI void zoo_set_log_stream (FILE *logStream)
 sets the stream to be used by the library for logging
ZOOAPI watcher_fn zoo_set_watcher (zhandle_t *zh, watcher_fn newFn)
 set a watcher function
ZOOAPI int zoo_state (zhandle_t *zh)
 get the state of the zookeeper connection.
ZOOAPI int zoo_wexists (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, struct Stat *stat)
 checks the existence of a node in zookeeper synchronously.
ZOOAPI int zoo_wget (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, char *buffer, int *buffer_len, struct Stat *stat)
 gets the data associated with a node synchronously.
ZOOAPI int zoo_wget_children (zhandle_t *zh, const char *path, watcher_fn watcher, void *watcherCtx, struct String_vector *strings)
 lists the children of a node synchronously.
ZOOAPI int zookeeper_close (zhandle_t *zh)
 close the zookeeper handle and free up any resources.
ZOOAPI zhandle_tzookeeper_init (const char *host, watcher_fn fn, int recv_timeout, const clientid_t *clientid, void *context, int flags)
 create a handle to used communicate with zookeeper.
ZOOAPI int zookeeper_interest (zhandle_t *zh, int *fd, int *interest, struct timeval *tv)
 Returns the events that zookeeper is interested in.
ZOOAPI int zookeeper_process (zhandle_t *zh, int events)
 Notifies zookeeper that an event of interest has happened.

Variables

ACL Consts
ZOOAPI struct Id ZOO_ANYONE_ID_UNSAFE
ZOOAPI struct Id ZOO_AUTH_IDS
ZOOAPI struct ACL_vector ZOO_CREATOR_ALL_ACL
ZOOAPI struct ACL_vector ZOO_OPEN_ACL_UNSAFE
ZOOAPI const int ZOO_PERM_ADMIN
ZOOAPI const int ZOO_PERM_ALL
ZOOAPI const int ZOO_PERM_CREATE
ZOOAPI const int ZOO_PERM_DELETE
ZOOAPI const int ZOO_PERM_READ
ZOOAPI const int ZOO_PERM_WRITE
ZOOAPI struct ACL_vector ZOO_READ_ACL_UNSAFE
State Consts
These constants represent the states of a zookeeper connection. They are possible parameters of the watcher callback.

ZOOAPI const int ZOO_ASSOCIATING_STATE
ZOOAPI const int ZOO_AUTH_FAILED_STATE
ZOOAPI const int ZOO_CONNECTED_STATE
ZOOAPI const int ZOO_CONNECTING_STATE
ZOOAPI const int ZOO_EXPIRED_SESSION_STATE
Watch Types
These constants indicate the event that caused the watch event. They are possible values of the first parameter of the watcher callback.

ZOOAPI const int ZOO_CHANGED_EVENT
 a node has changed.
ZOOAPI const int ZOO_CHILD_EVENT
 a change as occurred in the list of children.
ZOOAPI const int ZOO_CREATED_EVENT
 a node has been created.
ZOOAPI const int ZOO_DELETED_EVENT
 a node has been deleted.
ZOOAPI const int ZOO_NOTWATCHING_EVENT
 a watch has been removed.
ZOOAPI const int ZOO_SESSION_EVENT
 a session has been lost.
Create Flags
These flags are used by zoo_create to affect node create. They may be ORed together to combine effects.

ZOOAPI const int ZOO_EPHEMERAL
ZOOAPI const int ZOO_SEQUENCE
Interest Consts
These constants are used to express interest in an event and to indicate to zookeeper which events have occurred. They can be ORed together to express multiple interests. These flags are used in the interest and event parameters of zookeeper_interest and zookeeper_process.

ZOOAPI const int ZOOKEEPER_READ
ZOOAPI const int ZOOKEEPER_WRITE


Generated by  Doxygen 1.6.0   Back to index