当前位置: 首页>>代码示例>>C++>>正文


C++ zerror函数代码示例

本文整理汇总了C++中zerror函数的典型用法代码示例。如果您正苦于以下问题:C++ zerror函数的具体用法?C++ zerror怎么用?C++ zerror使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lk

bool zk::set(const string& path, const string& payload) {
  scoped_lock lk(m_);
  int rc = zoo_set(zh_, path.c_str(), payload.c_str(), payload.length(), -1);
  if (rc != ZOK) {
    LOG(ERROR) << path << " failed in setting " << rc << " " << zerror(rc);
    return false;
  }
  DLOG(INFO) << __func__ << " " << path << " - " << payload;
  return true;
}
开发者ID:Tukamotosan,项目名称:jubatus,代码行数:10,代码来源:zk.cpp

示例2: node_completion

/**
 * Callback with the list of children. If the local announcement is not present, create an ephemeral node on zk.
 */
static void node_completion(int rc, const struct String_vector *strings, const void *data) {
    if (rc) {
        LOG_WARN(("Error %s while retrieving children!", zerror(rc)));
        return;
    }

    unsigned long tick = *((unsigned long *)data);
    LOG_DEBUG(("Callback Tick (%d/%lx)", tick));

    if (!strings) {
        return;
    }

    for (int i = 0; i < strings->count; i++) {
        if (!strcmp(strings->data[i], announce_name)) {
            LOG_DEBUG(("Found local announcement %s", announce_name));
            return;
        }
    }

    // Need to add local announcement.
    LOG_DEBUG(("Local announcement not found, creating %s", announce_path));
    int rc2 = zoo_acreate(zh, announce_path, announce_data, strlen(announce_data), &ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL, void_completion, NULL);
    if (rc2) {
        LOG_WARN(("Error %s while creating announcement!", zerror(rc)));
    }
}
开发者ID:NessComputing,项目名称:memcached,代码行数:30,代码来源:zookeeper.c

示例3: platform_read_entire_file

char *
platform_read_entire_file(const char *path, Memory_Arena *ma)
{
	int fd = open(path, O_RDONLY);
	if (fd < 0) {
		zerror("could not load file %s", path);
		return NULL;
	}
	off_t len = lseek(fd, 0, SEEK_END);
	if (len < 0) {
		zerror("could not get %s file length. %s.\n", path, perrno());
		return NULL;
	}
	lseek(fd, 0, SEEK_SET);
	char *buf = mem_alloc_array(char, (len+1), ma);
	// read may return less bytes than requested, so we have to loop.
	off_t tot_read = 0, cur_read = 0;
	char *pos = buf;
	do {
		cur_read = read(fd, pos, (len - tot_read));
		tot_read += cur_read;
		pos += cur_read;
	} while (tot_read < len && cur_read != 0);
	if (tot_read != len) {
		zerror("could not read file %s.", path, perrno());
		return NULL;
	}
	buf[len] = '\0';
	close(fd);
	return buf;
}
开发者ID:ahamidullah,项目名称:cge,代码行数:31,代码来源:linux_cge.cpp

示例4: create_log_thread

void
create_log_thread(zlog_t *logp, zoneid_t id)
{
	int res;
	zlog_mode_t mode;

	shutting_down = 0;
	zlogp = logp;

	mode = get_logger_mode();
	if (mode == ZLOG_NONE)
		return;

	if (init_zfd_devs(zlogp, mode) == -1) {
		zerror(zlogp, B_FALSE,
		    "zfd setup: device initialization failed");
		return;
	}

	res = thr_create(NULL, 0, (void * (*)(void *))srvr, (void *)mode, 0,
	    &logger_tid);
	if (res != 0) {
		zerror(zlogp, B_FALSE, "error %d creating logger thread", res);
		logger_tid = 0;
	}
}
开发者ID:arekinath,项目名称:illumos-joyent,代码行数:26,代码来源:zfd.c

示例5: destroy_console_devs

static int
destroy_console_devs(zlog_t *zlogp)
{
	char conspath[MAXPATHLEN];
	di_node_t root;
	struct cb_data cb;
	int masterfd;
	int slavefd;

	/*
	 * Signal the master side to release its handle on the slave side by
	 * issuing a ZC_RELEASESLAVE ioctl.
	 */
	(void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s",
	    zone_name, ZCONS_MASTER_NAME);
	if ((masterfd = open(conspath, O_RDWR | O_NOCTTY)) != -1) {
		(void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s",
		    zone_name, ZCONS_SLAVE_NAME);
		if ((slavefd = open(conspath, O_RDWR | O_NOCTTY)) != -1) {
			if (ioctl(masterfd, ZC_RELEASESLAVE,
			    (caddr_t)(intptr_t)slavefd) != 0)
				zerror(zlogp, B_TRUE, "WARNING: error while "
				    "releasing slave handle of zone console for"
				    " %s", zone_name);
			(void) close(slavefd);
		} else {
			zerror(zlogp, B_TRUE, "WARNING: could not open slave "
			    "side of zone console for %s to release slave "
			    "handle", zone_name);
		}
		(void) close(masterfd);
	} else {
		zerror(zlogp, B_TRUE, "WARNING: could not open master side of "
		    "zone console for %s to release slave handle", zone_name);
	}

	bzero(&cb, sizeof (cb));
	cb.zlogp = zlogp;

	if ((root = di_init(ZCONSNEX_DEVTREEPATH, DINFOCPYALL)) ==
	    DI_NODE_NIL) {
		zerror(zlogp, B_TRUE, "%s failed", "di_init");
		return (-1);
	}

	(void) di_walk_node(root, DI_WALK_CLDFIRST, (void *)&cb, destroy_cb);
	if (cb.found > 1) {
		zerror(zlogp, B_FALSE, "WARNING: multiple zone console "
		    "instances detected for zone '%s'; %d of %d "
		    "successfully removed.",
		    zone_name, cb.killed, cb.found);
	}

	di_fini(root);
	return (0);
}
开发者ID:maosi66,项目名称:illumos-joyent,代码行数:56,代码来源:zcons.c

示例6: LOG

/**
 * create node in zookeeper server
 * \param node indicate key
 * param flag =ZOO_EPHEMERAL
*/ 
bool ZKOP::zkCreateNodePath(const std::string& node, int flag) 
{/*{{{*/
	int rc = 0;
/*
	if ((rc = zoo_exists(zkhandle, node.data(), 0, NULL)) == ZOK) {
		return true;
	}

	if (rc != ZNONODE) {
		//LOG(ERROR) << "create new node failed, node = [" << node << "], error = [" << zerror(rc) << "]";
		return false;
	}

	if (zoo_exists(zkhandle, node.data(), 0, NULL) == ZNONODE) {
		if ((rc = zoo_create(zkhandle, node.data(),
						NULL, -1, &ZOO_OPEN_ACL_UNSAFE,
						flag, NULL, 0)) != ZOK) {
			LOG(ERROR) << "create new node failed, node = [" << node << "], error = [" << zerror(rc) << "]";
			return false;
		}
	}

	LOG(INFO) << "create new node successful, node = [" << node << "], flag = [" << flag << "]";

	return true;
*/
	rc = zkNodeExists(node, flag);
	if( ZOK == rc ) {
		return true;
	}
	if(ZNONODE != rc){
		return false;
	}


	if(ZNONODE == rc){
		if ((rc = zoo_create(zkhandle, node.data(),
						NULL, -1, &ZOO_OPEN_ACL_UNSAFE,
						flag, NULL, 0)) != ZOK) {
			LOG(ERROR) << "create new node failed, node = [" << node << "], error = [" << zerror(rc) << "]";
			return false;
		}
	}else{
		std::stringstream ss;
		std::string str;
		ss << rc;
		ss >> str;
		LOG(ERROR) << "create new node failed, node = [" << node << "], error = [" << zerror(rc) << "]" << "\trc=" << str;
		return false;
	}

	return true;
}/*}}}*/
开发者ID:BGCX261,项目名称:zookeeper-host-info-svn-to-git,代码行数:58,代码来源:zk_framework.cpp

示例7: init_console

int
init_console(zlog_t *zlogp)
{
	if (init_console_dev(zlogp) == -1) {
		zerror(zlogp, B_FALSE,
		    "console setup: device initialization failed");
	}

	if ((serverfd = init_console_sock(zlogp)) == -1) {
		zerror(zlogp, B_FALSE,
		    "console setup: socket initialization failed");
		return (-1);
	}
	return (0);
}
开发者ID:maosi66,项目名称:illumos-joyent,代码行数:15,代码来源:zcons.c

示例8: LOG

vector<BackendItem> MasterHandler::getExistingAssignments() {
	vector<BackendItem> result;
	if (ZooHandler::getInstance().sessionState != ZOO_CONNECTED_STATE) {
		LOG(ERROR)<<"Invalid sessionstate";
		return result;
	}

	//1)get list of (assignmentznode)/BFSElection children and set a watch for changes in these folder
	String_vector children;
	int callResult = zoo_get_children(ZooHandler::getInstance().zh, ZooHandler::getInstance().assignmentZNode.c_str(),0, &children);
	if (callResult != ZOK) {
		LOG(ERROR)<<"zoo_get_children failed:"<<zerror(callResult);
		return result;
	}
	//2)get content of each node
	for (int i = 0; i < children.count; i++) {
		string node(children.data[i]);
		//Allocate 1MB data
		const int length = 1024 * 1024;
		char *buffer = new char[length];
		int len = length;
		int callResult =
					zoo_get(ZooHandler::getInstance().zh,
						(ZooHandler::getInstance().assignmentZNode + "/" + node).c_str(),
						0, buffer, &len, nullptr);
		if (callResult != ZOK) {
			LOG(ERROR)<<"zoo_get failed:"<<zerror(callResult);
			delete[] buffer;
			buffer = nullptr;
			continue;
		}
		if(len >= 0 && len <= length-1)
			buffer[len] = '\0';

		//3)parse node content to a znode
		char *tok = strtok(buffer, "\n");
		while (tok != NULL) {
			string file(tok);
			result.push_back(BackendItem(file,-1l,"",""));
			tok = strtok(NULL, "\n");
		}
		//Release memory
		delete[] buffer;
		buffer = nullptr;
	}

	return result;
}
开发者ID:40a,项目名称:BFS,代码行数:48,代码来源:MasterHandler.cpp

示例9: lk

void zk::remove(const std::string& path) {
    scoped_lock lk(m_);
    int rc = zoo_delete(zh_, path.c_str(), -1);
    if(rc != ZOK and rc != ZNONODE) {
        LOG(ERROR) << path << ": removal failed - " << zerror(rc);
    }
};
开发者ID:nakj,项目名称:jubatus,代码行数:7,代码来源:zk.cpp

示例10: malloc

static MinixInode *search_dir(MinixInode *di,String name){
    if(isNullp(di)) return NULL;
    static char block[BLOCK_SIZE];
    MinixDirentry *drp = (MinixDirentry *)block;
    MinixInode *inode = malloc(sizeof(MinixInode));
    if(inode == NULL) goto error_ret;

    zone_t dnoze = FULL_BLOCK(di->i_size);
    for(int i = 0;i < dnoze;i++){
        if(ERROR == zone_rw(di,READ,i,block)){
            zerror("search_dir : zone_rw fail");
            goto error_ret;
        }
        for(int j = 0;j < DIR_IN_BLOCK;j++){
            if(_isEqName(name,drp[j].name)){
                if(ERROR == get_inode(drp[j].inode,inode))
                    goto error_ret;
                return inode;
            }
        }
    }
error_ret:
    if(inode) free(inode);
    return NULL;
}
开发者ID:SkyPrayerStudio,项目名称:none,代码行数:25,代码来源:path.c

示例11: mc_zookeeper_tick

/**
 * 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;
            }
        }
    }
}
开发者ID:NessComputing,项目名称:memcached,代码行数:34,代码来源:zookeeper.c

示例12: void_completion

/**
 * Callback for the node creation.
 */
static void void_completion(int rc, const char *name, const void *data) {
    if (rc) {
        LOG_WARN(("Error %s while creating announcement!", zerror(rc)));
    }
    else {
        LOG_DEBUG(("Node creation complete, service now announced!"));
    }
}
开发者ID:NessComputing,项目名称:memcached,代码行数:11,代码来源:zookeeper.c

示例13: zrealloc

/* 
 * Given a pointer returned by zmalloc or zcalloc, free it and
 * return a pointer to a new size, basically acting like realloc().
 * Requires: ptr was returned by zmalloc, zcalloc, or zrealloc with the
 * same type.
 * Effects: Returns a pointer to the new memory, or aborts.
 */
void *
zrealloc (int type, void *ptr, size_t size)
{
  void *memory;

  memory = realloc (ptr, size);
  if (memory == NULL)
    zerror ("realloc", type, size);
  return memory;
}
开发者ID:Jafaral,项目名称:quagga-mtr,代码行数:17,代码来源:memory.c

示例14: zstrdup

/*
 * Duplicate a string, counting memory usage by type.
 * Effects: The string is duplicated, and the return value must
 * eventually be passed to zfree with the same type.  The function will
 * succeed or abort.
 */
char *
zstrdup (int type, const char *str)
{
  void *dup;

  dup = strdup (str);
  if (dup == NULL)
    zerror ("strdup", type, strlen (str));
  alloc_inc (type);
  return dup;
}
开发者ID:Jafaral,项目名称:quagga-mtr,代码行数:17,代码来源:memory.c

示例15: zoo_get_children

void zk::list_(const std::string& path, std::vector<std::string>& out) {
    struct String_vector s;
    int rc = zoo_get_children(zh_, path.c_str(), 0, &s);
    if(rc == ZOK) {
        for(int i=0; i<s.count; ++i) {
            out.push_back(s.data[i]); // full path => #{path}/#{s.data[i]}
        }
        std::sort(out.begin(), out.end());
    } else {
        LOG(ERROR) << zerror(rc) << " (" << path << ")";
    }
};
开发者ID:nakj,项目名称:jubatus,代码行数:12,代码来源:zk.cpp


注:本文中的zerror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。