int main(int argc, const char *argv[]) { const char* host = "127.0.0.1:2181"; char *data = "alive"; //const char* host = "127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183,127.0.0.1:2184,127.0.0.1:2185"; int timeout = 30000; zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); zhandle_t* zkhandle = zookeeper_init(host, watcher_g, timeout, 0, "hello zookeeper.", 0); if (zkhandle == NULL) { fprintf(stderr, "Error when connecting to zookeeper servers...\n"); exit(EXIT_FAILURE); } int ret = zoo_acreate(zkhandle, "/server", data, strlen(data), &ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL, completion, "zoo_acreate"); if (ret) { fprintf(stderr, "Error %d for %s\n", ret, "acreate"); exit(EXIT_FAILURE); } do { //sleep 5, then down accept_query(); sleep(5); } while(false); zookeeper_close(zkhandle); }
void ZooKeeperSessionManager::Initialize() { if( m_isInitialized ) { char result[1024]; sprintf( result, "Session <%s> already initialized", m_host.c_str() ); throw std::runtime_error( result ); } // convert expiration timeout from seconds to milliseconds int sessionExpirationTimeout = m_expirationTimeout * 1000; m_handle = zookeeper_init( m_host.c_str(), ZooKeeperEvent::EventHandler, sessionExpirationTimeout, 0, this, 0 ); if( m_handle == NULL ) { char result[1024]; sprintf( result, "Session <%s> failed to initialize with errno <%d>", m_host.c_str(), errno ); throw std::runtime_error( result ); } // wait for connection (or expiration timeout) Lock lock( m_sessionMutex ); if( m_condition.wait_for( lock, std::chrono::seconds( m_connectionTimeout ) ) == std::cv_status::timeout ) { char result[1024]; sprintf( result, "Session <%s> connection timeout", m_host.c_str() ); throw std::runtime_error( result ); } m_isInitialized = true; }
int DevCtlServiceReg::RegService() { int timeout = 30000; zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); if (NULL == mZKHdl) { mZKHdl = zookeeper_init(mZKAddrList.c_str(), NULL, timeout, 0, (char *)"Config dev_controller", 0); } if (mZKHdl ==NULL) { LOG(ERROR)<<"Error when connecting to zookeeper servers..."; return -1; } int ret = mkdirp(mZKHdl, mNodePath.c_str(), mNodePath.c_str()); if (ret != 0) { LOG(ERROR)<<"mkdirp fail"; return -1; } ret = zoo_set(mZKHdl, mNodeRealPath.c_str(), mNodeValue.c_str(), mNodeValue.size(), -1); if(ret != ZOK){ LOG(ERROR)<<"failed to set the data of path:"<<mNodeRealPath.c_str(); return -1; } return 0; }
/** * periodically called by the main memcache loop. This will connect zookeeper if * necessary. Also, if the generation has changed (because of a zookeeper even), * it will then trigger data processing. */ void mc_zookeeper_tick() { ticker++; if (!zh) { LOG_DEBUG(("Connecting zookeeper...")); zh = zookeeper_init(settings.zookeeper_connect, process, 30000, &myid, 0, 0); if (!zh) { LOG_INFO(("Could not connect to zookeeper, error: %d", errno)); } else { LOG_DEBUG(("Zookeeper connection ok, status is %d", zoo_state(zh))); } trigger_event(); } if (connected) { long current_generation = generation; if (last_generation < current_generation) { LOG_DEBUG(("Tick (%d)", ticker)); int rc = zoo_aget_children(zh, settings.zookeeper_path, 1, node_completion, &ticker); if (rc != 0) { LOG_WARN(("Error %s while retrieving children!", zerror(rc))); } else { last_generation = current_generation; } } } }
int main(int argc, const char *argv[]) { const char* host = "127.0.0.1:2181"; int timeout = 30000; char buffer[512]; int *bufferlen; zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); //设置日志级别,避免出现一些其他信息 zhandle_t* zkhandle = zookeeper_init(host,zktest_watcher_g, timeout, 0, (void *)"hello zookeeper.", 0); if (zkhandle ==NULL) { fprintf(stderr, "Error when connecting to zookeeper servers...\n"); exit(EXIT_FAILURE); } char str[]="/xyz30000000014"; // wexists(zkhandle,str); // printf("---------------\n"); // create(zkhandle,str); get(zkhandle); getChildren(zkhandle,str); getACL(zkhandle,str); while (1) { set(zkhandle, str); sleep(1); } //ddelete(zkhandle,str); }
// Helper function to init the zk_handle void ZKClient::InitZKHandle() { zk_clientid_.client_id = 0; zk_handle_ = zookeeper_init(hostportlist_.c_str(), CallGlobalWatcher, 30000, NULL, this, 0); if (!zk_handle_) { LOG(FATAL) << "zookeeper_init failed with error " << errno << "\n"; } }
static bool connect_zookeeper(service_location_t *service, bool create_nodes) { const char *host; int recv_timeout; host = iniparser_getstring(service->config, "zookeeper:host", "no_host"); if (!strcmp(host, "no_host")) { LOG_FATAL(service->log_fd, "No zookeeper:host defined in configuration file"); return false; } service->connected_state = false; recv_timeout = iniparser_getint(service->config, "zookeeper:recv_timeout", MYSERVICES_RECV_TIMEOUT); service->zk = zookeeper_init(host, cb_switch_state, recv_timeout, 0, service, 0); if (!service->zk) { return false; } if (create_nodes == true) { create_service_nodes(service); } return true; }
static void php_zookeeper_connect_impl(INTERNAL_FUNCTION_PARAMETERS, char *host, zend_fcall_info *fci, zend_fcall_info_cache *fcc, long recv_timeout) { zval *object = getThis(); php_zk_t *i_obj; zhandle_t *zk = NULL; php_cb_data_t *cb_data = NULL; if (recv_timeout <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "recv_timeout parameter has to be greater than 0"); ZVAL_NULL(object); return; } i_obj = (php_zk_t *) zend_object_store_get_object(object TSRMLS_CC); if (fci->size != 0) { cb_data = php_cb_data_new(fci, fcc, 0 TSRMLS_CC); } zk = zookeeper_init(host, (fci->size != 0) ? php_zk_watcher_marshal : NULL, recv_timeout, 0, cb_data, 0); if (zk == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "could not init zookeeper instance"); /* not reached */ } i_obj->zk = zk; i_obj->cb_data = cb_data; }
bool ZkManager::initialize(std::string zkAddress) { if( zkAddress == "" ) { zkAddress_ = DEFAULT_ZKADDRESS; }else { zkAddress_ = zkAddress; } { boost::unique_lock<boost::mutex> lock( zkLock_ ); { boost::upgrade_lock<boost::shared_mutex> lock(managers_lock_); boost::upgrade_to_unique_lock<boost::shared_mutex> uniqueLock1(lock); zk_ = zookeeper_init(zkAddress_.c_str(), xce::distcache::ZkWatcher, 10000, 0, 0, 0); if( zk_ == NULL ) { MCE_WARN("ZkManager::initZk can not initZk!"); return false; } managers_[zk_] = this; } zkCdt_.wait( lock ); } startAndDetach(); return true; }
int main(int argc, char *argv[]) { int res = -1; zhandle_t *h = NULL; h = zookeeper_init("127.0.0.1:2181", test_watcher, 50000, NULL, (void *)12345, 0); sleep(100000); }
int start_zookeeper(view* cur_view, int *zfd, pthread_mutex_t *lock) { int rc; char zoo_host_port[32]; sprintf(zoo_host_port, "localhost:%d", zoo_port); zh = zookeeper_init(zoo_host_port, zookeeper_init_watcher, 15000, 0, 0, 0); while(is_connected != 1); int interest, fd; struct timeval tv; zookeeper_interest(zh, &fd, &interest, &tv); *zfd = fd; char path_buffer[512]; rc = zoo_create(zh, "/election/guid-n_", NULL, -1, &ZOO_OPEN_ACL_UNSAFE, ZOO_SEQUENCE|ZOO_EPHEMERAL, path_buffer, 512); if (rc) { fprintf(stderr, "Error %d for zoo_create\n", rc); } char znode_path[512]; get_znode_path(path_buffer, znode_path); check_leader(cur_view, path_buffer); struct watcherContext *watcherPara = (struct watcherContext *)malloc(sizeof(struct watcherContext)); strcpy(watcherPara->znode_path, znode_path); watcherPara->lock = lock; watcherPara->cur_view = cur_view; rc = zoo_wget_children(zh, "/election", zoo_wget_children_watcher, (void*)watcherPara, NULL); if (rc) { fprintf(stderr, "Error %d for zoo_wget_children\n", rc); } return 0; }
static VALUE method_zkrb_init(int argc, VALUE* argv, VALUE self) { VALUE hostPort; VALUE options; rb_scan_args(argc, argv, "11", &hostPort, &options); if (NIL_P(options)) { options = rb_hash_new(); } else { Check_Type(options, T_HASH); } Check_Type(hostPort, T_STRING); // Look up :zkc_log_level VALUE log_level = rb_hash_aref(options, ID2SYM(rb_intern("zkc_log_level"))); if (NIL_P(log_level)) { zoo_set_debug_level(0); // no log messages } else { Check_Type(log_level, T_FIXNUM); zoo_set_debug_level((int)log_level); } VALUE data; struct zkrb_instance_data *zk_local_ctx; data = Data_Make_Struct(Zookeeper, struct zkrb_instance_data, 0, free_zkrb_instance_data, zk_local_ctx); zk_local_ctx->queue = zkrb_queue_alloc(); if (zk_local_ctx->queue == NULL) rb_raise(rb_eRuntimeError, "could not allocate zkrb queue!"); zoo_deterministic_conn_order(0); zkrb_calling_context *ctx = zkrb_calling_context_alloc(ZKRB_GLOBAL_REQ, zk_local_ctx->queue); zk_local_ctx->object_id = FIX2LONG(rb_obj_id(self)); zk_local_ctx->zh = zookeeper_init( RSTRING_PTR(hostPort), zkrb_state_callback, session_timeout_msec(self), &zk_local_ctx->myid, ctx, 0); #warning [wickman] TODO handle this properly on the Ruby side rather than C side if (!zk_local_ctx->zh) { rb_raise(rb_eRuntimeError, "error connecting to zookeeper: %d", errno); } rb_iv_set(self, "@_data", data); rb_funcall(self, rb_intern("zkc_set_running_and_notify!"), 0); error: return Qnil; }
void Cluster::Routine() { while (1) { switch (m_state) { case ZK_STATE_DISCONNECT: { m_state = ZK_STATE_CONNECTING; m_zk = zookeeper_init(g_db->GetConf().zookeeper_servers.c_str(), ZKInitWatcherCallback, 30000, &m_zk_clientid, this, 0); continue; } case ZK_STATE_CONNECTING: { return; } case ZK_STATE_CONNECTED: { m_state = ZK_STATE_CREATE_PATH; break; } case ZK_STATE_CREATE_PATH: { if (0 != CreateZookeeperPath()) { return; } else { continue; } } case ZK_STATE_FETCH_TOPO: { if (0 != FetchClusterTopo()) { return; } else { m_state = ZK_STATE_READY; continue; } } case ZK_STATE_READY: { return; } default: { ERROR_LOG("Invalid zk agent state:%u", m_state); return; } } } }
int main(int argc, const char *argv[]) { int timeout = 30000; zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); //设置日志级别,避免出现一些其他信息 get_option(argc,argv); zhandle_t* zkhandle = zookeeper_init(g_host,NULL, timeout, 0, (char *)"Load Balancing Test", 0); if (zkhandle ==NULL){ fprintf(stderr, "Error when connecting to zookeeper servers...\n"); exit(EXIT_FAILURE); } char consumer_path[512] = "/Consumer"; char topic_path[512] = {0}; char group_path[512] = {0}; char client_path[512] = {0}; sprintf(topic_path,"%s/%s",consumer_path,g_topic); sprintf(group_path,"%s/group-%d",topic_path,g_groupid); sprintf(client_path,"%s/client-",group_path); create(zkhandle,consumer_path,0,""); create(zkhandle,topic_path,0,""); create(zkhandle,group_path,0,"00000000"); int bufferlen = sizeof(g_my_path); int ret = zoo_create(zkhandle,client_path,NULL,0, &ZOO_OPEN_ACL_UNSAFE,ZOO_SEQUENCE|ZOO_EPHEMERAL, g_my_path,bufferlen); if (ret != ZOK){ printf("节点创建失败:%s \n",client_path); exit(EXIT_FAILURE); }else { printf("创建的节点名称为:%s\n",g_my_path); } char self_name[512] = {0}; strcpy(self_name,rindex(g_my_path,'/')+1); choose_mater(zkhandle,group_path,self_name); do_work(zkhandle); getchar(); zookeeper_close(zkhandle); return 0; }
Error_Info HBAgent::readZookeeper(){ Error_Info err; string zk_snap; const string ZK_SNAP="/wde/gbase/data/snapshot"; zhandle_t * zh; bool pingpong=false; zh=zookeeper_init(zookeeperAddress.c_str(),watcher, 10000, 0, &pingpong, 0); char buffer[8192]; int buflen=sizeof(buffer); struct Stat stat; if(zh){ int rc; int sleeptimes=0; while(!pingpong){ sleep(1); sleeptimes++; if(sleeptimes==10){ err.code=-2; err.description="Can't Connected to Zookeeper: "+zookeeperAddress; return err; } } if(zoo_state(zh)!=ZOO_CONNECTED_STATE){ err.code=HB_READZOOKEEPER_FAIL; err.description="Can't Connected to Zookeeper: "+zookeeperAddress; return err; } rc=zoo_get(zh,ZK_SNAP.c_str(),0,buffer,&buflen,&stat); if(rc==ZOK){ zk_snap=string(buffer,buflen); }else{ err.code=HB_BADZOOKEEPER_CONFIG; err.description="get snapshot from zookeeper fail"; return err; } }else{ err.code=HB_READZOOKEEPER_FAIL; err.description="zookeeper init fail"; return err; } zookeeper_close(zh); boost::replace_all(zk_snap,"\'","\""); Json::Value root; Json::Reader reader; bool parseSuccess=reader.parse(zk_snap,root); if(!parseSuccess){ err.code=HB_READZOOKEEPER_FAIL; err.description="Bad Zookpeer Value for snapshot in Zookeeper"; } collection=root["name"].asString(); columnfamily="contents"; err.code=HB_OK; err.description="zookeeper init success"; return err; }
int ZKWrapper::Init(const char *host) { zoo_set_debug_level(ZOO_LOG_LEVEL_ERROR); m_zkHandler = zookeeper_init((char*)host, zkWatcherCallback, m_nTimeout, 0, this, 0); if (m_zkHandler == NULL) { std::cerr << "ERROR: connect to zookeeper server failed!!" << std::endl; return -1; } return 0; }
int init_zkhandle(const char* host, int timeout, watcher_fn fn, void *cbCtx) { int ret = 0; g_zhdl = zookeeper_init(host, fn, timeout, 0, cbCtx, 0); if(g_zhdl == NULL) { printf("init_zkhandle init error\n"); ret = -1; } return ret; }
int zkServer::zkInit() { int ret = 0; DEBUG_PRINT("host %s timeout %u", host.c_str(), timeout); zkhandle = zookeeper_init(host.c_str(), service_watcher_g, timeout, 0, NULL, 0); if ( zkhandle==NULL ) { ERROR_PRINT("error connect to zookeeper service.", ""); return EXIT_FAILURE; } return ret; }
int main(int argc, const char *argv[]) { int timeout = 30000; char path_buffer[512]; int bufferlen=sizeof(path_buffer); zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); //设置日志级别,避免出现一些其他信息 get_option(argc,argv); zhandle_t* zkhandle = zookeeper_init(g_host,NULL, timeout, 0, (char *)"Load Balancing Test", 0); if (zkhandle ==NULL){ fprintf(stderr, "Error when connecting to zookeeper servers...\n"); exit(EXIT_FAILURE); } char breaker_path[512] = "/Breaker"; char topic_path[512] = {0}; char partition_path[512] = {0}; sprintf(topic_path,"%s/%s",breaker_path,g_topic); //init environment create(zkhandle,breaker_path,0,""); create(zkhandle,topic_path,0,""); int i = 0; for(i = 0; i < g_partition_num ; ++i){ sprintf(partition_path,"%s/Partition-%d",topic_path,i); create(zkhandle,partition_path,0,""); } //send message by rand time srand(time(NULL)); char msg_path[512] = {0}; for(i = 0; i < g_repeated_num; ++i){ sprintf(msg_path,"%s/Partition-%d/msg-",topic_path,i % g_partition_num); // create seq msg node create(zkhandle,msg_path,ZOO_SEQUENCE,g_msg); int time = rand()%10; printf("sleep time:%d\n",time); sleep(time); } zookeeper_close(zkhandle); return 0; }
int main(int argc, char **argv) { int nodeCount; int cleaning=0; if (argc < 4) { usage(argv); } if(strcmp("clean",argv[3])==0){ cleaning=1; } zoo_set_debug_level(ZOO_LOG_LEVEL_INFO); zoo_deterministic_conn_order(1); // enable deterministic order zh = zookeeper_init(argv[1], listener, 10000, 0, 0, 0); if (!zh) return errno; LOG_INFO(LOGSTREAM, "Checking server connection..."); ensureConnected(); if(cleaning==1){ int rc = 0; deletedCounter=0; rc=recursiveDelete(argv[2]); if(rc==ZOK){ LOG_INFO(LOGSTREAM, "Successfully deleted a subtree starting at %s (%d nodes)", argv[2],deletedCounter); exit(0); } exit(1); } nodeCount=atoi(argv[3]); createRoot(argv[2]); while(1) { ensureConnected(); LOG_INFO(LOGSTREAM, "Creating children for path %s",argv[2]); doCreateNodes(argv[2],nodeCount); waitCounter(); LOG_INFO(LOGSTREAM, "Starting the write cycle for path %s",argv[2]); doWrites(argv[2],nodeCount); waitCounter(); LOG_INFO(LOGSTREAM, "Starting the read cycle for path %s",argv[2]); doReads(argv[2],nodeCount); waitCounter(); LOG_INFO(LOGSTREAM, "Starting the delete cycle for path %s",argv[2]); doDeletes(argv[2],nodeCount); waitCounter(); } zookeeper_close(zh); return 0; }
static zhandle_t* initialize_zookeeper(const char * zookeeper, void* param) { zoo_set_debug_level(ZOO_LOG_LEVEL_ERROR); ((kafka_t*) param)->no_brokers = 1; ((kafka_t*) param)->broker_list = NULL; zhandle_t *zh; zh = zookeeper_init(zookeeper, watcher, 10000, 0, param, 0); if (zh == NULL) { fprintf(stderr, "Zookeeper connection not established."); //exit(1); } return zh; }
int ZooKeeperWatcher::initialize() { zk = zookeeper_init("127.0.0.1:2181", watcher_callback, 10000, 0, this, 0); if (zk == NULL) return -1; if (ensureNodeExistence("/hbase") != 0 || ensureNodeExistence("/hbase/unassigned") != 0 || ensureNodeExistence("/hbase/rs") != 0 || ensureNodeExistence("/hbase/table") != 0) return -1; return 0; }
void ZkClient::connect(const folly::fbstring& serverList) { zhandle_t* zhandle = zookeeper_init( serverList.c_str(), ZkClient::watcherCallback, ZK_TIMEOUT, nullptr, this, 0 ); CHECK(nullptr != zhandle) << "zookeeper_init() failed"; LOG(INFO) << "zhandle created: " << zhandle; zHandle_.reset(zhandle); }
int main(int argc, char **argv) { char buffer[512]; char p[2048]; char *cert=0; char appId[64]; strcpy(appId, "example.foo_test"); cert = foo_get_cert_once(appId); if(cert!=0) { fprintf(stderr, "Certificate for appid [%s] is [%s]\n",appId,cert); strncpy(p,cert, sizeof(p)-1); free(cert); } else { fprintf(stderr, "Certificate for appid [%s] not found\n",appId); strcpy(p, "dummy"); } zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); zh = zookeeper_init("localhost:2181", watcher, 10000, 0, 0, 0); if (!zh) { fprintf(stderr, "Error1: %s\n", strerror(errno)); return errno; } if (zoo_add_auth(zh, "foo", p, strlen(p), 0, 0) != ZOK) { fprintf(stderr, "Error2: %s\n", strerror(errno)); return 2; } struct ACL CREATE_ONLY_ACL[] = {{ZOO_PERM_CREATE, ZOO_AUTH_IDS}}; struct ACL_vector CREATE_ONLY = {1, CREATE_ONLY_ACL}; int rc = zoo_create(zh, "/xyz", "value", 5, &CREATE_ONLY, ZOO_EPHEMERAL, (char*)&buffer, sizeof(buffer) - 1); if (!rc) { fprintf(stderr, "Error3: %s\n", strerror(errno)); return errno; } /** this operation will fail with a ZNOAUTH error */ int buflen= sizeof(buffer); struct Stat stat; rc = zoo_get(zh, "/xyz", 0, buffer, &buflen, &stat); if (rc) { fprintf(stderr, "Error4: %d for %s\n", rc, __LINE__); } else { fprintf(stdout, "Got %s\n", (char*)&buffer); } zookeeper_close(zh); return 0; }
int ZkHelper::registe_service(const std::string& sevice_name, const std::string& endpoint) { zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); zk_ = zookeeper_init("127.0.0.1:2181", &g_zk_watcher, 1000, 0, 0, 0); if( NULL == zk_ ) { printf("zookeeper_init error\n"); return errno; } int flag = ZOO_EPHEMERAL; int rc = zoo_acreate(zk_, sevice_name.c_str(), endpoint.c_str(), endpoint.size(), &ZOO_OPEN_ACL_UNSAFE, flag, acreate_completion, endpoint.c_str()); return rc; }
static zhandle_t* initialize_zookeeper(const char * zookeeper, const int debug) { zhandle_t *zh; if (debug) { zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); } zh = zookeeper_init(zookeeper, watcher, 10000, 0, 0, 0); if (zh == NULL) { fprintf(stderr, "Zookeeper connection not established."); exit(1); } return zh; }
int init (char * hostPort) { srand(time(NULL)); server_id = rand(); zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); zh = zookeeper_init(hostPort, main_watcher, 15000, 0, 0, 0); return errno; }
int Register::connect() { zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); zh=zookeeper_init(zookeeper_addr.c_str(),watcher,10000,&myid,0,0); if(!zh) { } LOG(INFO)<<"InitSucc\n"; return 0; }
int ZookeeperClient::Connect(const std::string& servers, const ZKOptions& options) { if (NULL != m_zk) { zookeeper_close(m_zk); m_zk = NULL; } m_zk = zookeeper_init(servers.c_str(), ZookeeperClient::WatchCallback, options.recv_timeout, &options.clientid, this, 0); if (NULL == m_zk) { ERROR_LOG("Failed to init zokkeeper."); return -1; } m_callback = options.cb; CheckConn(); return 0; }
void zenv_init(struct zenv_s *zenv) { g_assert(zenv != NULL); memset(zenv, 0, sizeof(*zenv)); // Init the "cell" from the environment if present or set a default value const gchar *cell_env = g_getenv(CELL_KEY_ENV); const gchar *uuid_env = g_getenv(UUID_KEY_ENV); gchar *zkurl = _zenv_get_zk_url(); if (!zkurl) g_error("ZooKeeper not configured, found none of %s, %s, %s", ZKFILE_LOCAL_PATH, ZKFILE_HOME_PATH, ZKFILE_GLOBAL_PATH); if (_has_forbidden_chars(cell_env)) g_error("CELL has invalid characters"); if (_has_forbidden_chars(uuid_env)) g_error("UUID has invalid characters"); if (NULL != cell_env) zenv->cell = g_strdup(cell_env); else zenv->cell = g_strdup(CELL_VALUE_DEFAULT); if (NULL != uuid_env) zenv->uuid = g_strdup(uuid_env); else { zenv->uuid = g_malloc0(33); uuid_randomize(zenv->uuid, 33); } zenv->zh = zookeeper_init(zkurl, NULL, 5000, NULL, NULL, 0); g_assert(zenv->zh != NULL); zenv->zctx = zmq_ctx_new(); g_assert(zenv->zctx != NULL); zenv->zr = zreactor_create(); g_assert(zenv->zr != NULL); zreactor_add_zk(zenv->zr, zenv->zh); }