本文整理汇总了C++中ZHTClient类的典型用法代码示例。如果您正苦于以下问题:C++ ZHTClient类的具体用法?C++ ZHTClient怎么用?C++ ZHTClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZHTClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: c_zht_compare_swap_std
int c_zht_compare_swap_std(ZHTClient_c zhtClient, const char *key,
const char *seen_value, const char *new_value, char *value_queried) {
#ifdef IND_MUTEX
LockGuard lock(&c_zht_compare_swap_mutex);
#elif SHARED_MUTEX
LockGuard lock(&c_zht_client_mutex);
#else
#endif
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string skey(key);
string sseenValue(seen_value);
string snewValue(new_value);
string resultStr;
int rc = zhtcppClient->compare_swap(skey, sseenValue, snewValue, resultStr);
memset(value_queried, 0, strlen(value_queried));
strncpy(value_queried, resultStr.c_str(), resultStr.size());
return rc;
}
开发者ID:xiaobingo,项目名称:iit.datasys.zht-mpi,代码行数:25,代码来源:c_zhtclientStd.cpp
示例2: c_zht_init_std
int c_zht_init_std(ZHTClient_c *zhtClient, const char *zhtConfig,
const char *neighborConf) {
#ifdef IND_MUTEX
pthread_mutex_init(&c_zht_lookup_mutex, NULL);
pthread_mutex_init(&c_zht_remove_mutex, NULL);
pthread_mutex_init(&c_zht_insert_mutex, NULL);
pthread_mutex_init(&c_zht_append_mutex, NULL);
pthread_mutex_init(&c_zht_compare_swap_mutex, NULL);
pthread_mutex_init(&c_zht_state_change_callback_mutex, NULL);
#elif SHARED_MUTEX
pthread_mutex_init(&c_zht_client_mutex, NULL);
#else
#endif
ZHTClient *zhtcppClient = new ZHTClient();
string zhtConfigStr(zhtConfig);
string neighborConfStr(neighborConf);
if (zhtcppClient->init(zhtConfigStr, neighborConfStr) != 0) {
printf("ZHTClient initialization failed, program exits.");
return -1;
}
*zhtClient = (ZHTClient_c) zhtcppClient;
return 0;
}
开发者ID:xiaobingo,项目名称:iit.datasys.zht-mpi,代码行数:30,代码来源:c_zhtclientStd.cpp
示例3: benchmark
int benchmark(string &zhtConf, string &neighborConf) {
srand(getpid() + TimeUtil::getTime_usec());
if (zc.init(zhtConf, neighborConf) != 0) {
cout << "ZHTClient initialization failed, program exits." << endl;
return -1;
}
init_packages();
benchmarkInsert();
benchmarkLookup();
benchmarkAppend();
benchmarkRemove();
zc.teardown();
return 0;
}
开发者ID:kwangiit,项目名称:SLURMPP_V2,代码行数:25,代码来源:benchmark_client.cpp
示例4: c_zht_compare_and_swap_std
int c_zht_compare_and_swap_std(ZHTClient_c zhtClient, const char *key,
const char *seen_value, const char *new_value, char **value_queried) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string sKey(key);
string sSeenValue(seen_value);
string sNewValue(new_value);
Package package;
package.set_virtualpath(sKey);
package.set_isdir(true);
package.set_replicano(5);
package.set_operation(5); // 5 for comapre and swap
if (!sSeenValue.empty()) {
package.set_realfullpath(sSeenValue);
}
if (!sNewValue.empty()) {
package.set_newfullpath(sNewValue);
}
string return_str;
int rc = zhtcppClient->compare_and_swap(package.SerializeAsString(),
return_str);
Package ret_pack;
ret_pack.ParseFromString(return_str);
strcpy(*value_queried, ret_pack.realfullpath().c_str());
return rc;
}
开发者ID:kwangiit,项目名称:dist_job_launch,代码行数:31,代码来源:c_zhtclientStd.cpp
示例5: c_zht_remove_std
int c_zht_remove_std(ZHTClient_c zhtClient, const char *pair) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string str(pair);
return zhtcppClient->remove(str);
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:8,代码来源:c_zhtclientStd.cpp
示例6: c_zht_insert_std
int c_zht_insert_std(ZHTClient_c zhtClient, const char *pair) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string str(pair);
return zhtcppClient->insert(str);
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:8,代码来源:c_zhtclientStd.cpp
示例7: c_zht_append_std
int c_zht_append_std(ZHTClient_c zhtClient, const char *pair) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string str(pair);
return zhtcppClient->append(str);
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:8,代码来源:c_zhtclientStd.cpp
示例8: zht_insert_meta
int zht_insert_meta(ZHTClient_c zhtClient, struct metadata * meta){
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
Package package;
string keyStr(meta->key);
//1. General infos on the file/storage
package.set_virtualpath(keyStr); //as key
package.set_isdir(false);
package.set_replicano(1);
package.set_operation(3); //1 for look up, 2 for remove, 3 for insert
package.set_realfullpath(keyStr);
//2. General infos on the encoding
package.set_k(meta->k);
package.set_m(meta->m);
package.set_encodinglib(meta->encodingLib);
package.set_filesize(meta->fileSize);
package.set_bufsize(meta->bufsize);
//3. Chunks/Replicas locations
struct comTransfer * current = meta->loc->transfers;
Package_Location* location;
while(current != NULL){
location = package.add_location();
location->set_hostname(string(current->hostName));
location->set_port(current->port);
location->set_distantchunkname(string(current->distantChunkName));
current=current->next;
}
//4. Insertion
std::string serialized = package.SerializeAsString();
dbgprintf("Package Length:%i\n",serialized.size());
//TEST
Package package4;
package4.ParseFromString(serialized);
dbgprintf("Serialized: %s \n",serialized.c_str());
dbgprintf("key: %s \n",(package4.virtualpath()).c_str());
dbgprintf("k:%i,m:%i,encodinglib:%i,filesize:%i \n",package4.k(),package4.m(),package4.encodinglib(),package4.filesize());
for (int j = 0; j < package4.location_size(); j++) {
const Package_Location& location = package4.location(j);
dbgprintf("chunk:%s, port:%i\n",location.distantchunkname().c_str(), location.port());
}
//END TEST
int res = zhtcppClient->insert(serialized);
return res;
}
开发者ID:kev40293,项目名称:ida,代码行数:58,代码来源:zht_bridger.cpp
示例9: benchmarkInsert
int benchmarkInsert(string cfgFile, string memberList, vector<string> &pkgList,
ZHTClient &clientRet, int numTest, int lenString) {
// if (clientRet.initialize(cfgFile, memberList) != 0) { //zhouxb
if (clientRet.initialize(cfgFile, memberList, TCP) != 0) {
cout << "Crap! ZHTClient initialization failed, program exits." << endl;
return -1;
}
for (int i = 0; i < numTest; i++) {
Package package, package_ret;
package.set_virtualpath(randomString(lenString)); //as key
package.set_isdir(true);
package.set_replicano(5); //orginal--Note: never let it be nagative!!!
package.set_operation(3); // 3 for insert, 1 for look up, 2 for remove
package.set_realfullpath(
"Some-Real-longer-longer-and-longer-Paths--------");
package.add_listitem("item-----2");
package.add_listitem("item-----3");
package.add_listitem("item-----4");
package.add_listitem("item-----5");
package.add_listitem("item-----6");
string str = package.SerializeAsString();
// cout << "package size = " << str.size() << endl;
// cout<<"Client.cpp:benchmarkInsert: "<<endl;
// cout<<"string: "<<str<<endl;
// cout<<"Insert str: "<<str.c_str()<<endl;
// cout<<"data(): "<< str.data()<<endl;
pkgList.push_back(str);
}
double start = 0;
double end = 0;
start = getTime_msec();
int errCount = 0;
vector<string>::iterator it;
int c = 0;
// cout << "-----2" << endl;
for (it = pkgList.begin(); it != pkgList.end(); it++) {
// cerr <<"insert count "<< c << endl;
c++;
string str_ins = *it;
//cout << "-----1" << endl;
int ret = clientRet.insert(str_ins);
//cout << "-----2" << endl;
if (ret < 0) {
errCount++;
}
}
//close(sock);
end = getTime_msec();
cout << "Inserted " << numTest - errCount << " packages out of " << numTest
<< ", cost " << end - start << " ms" << endl;
return 0;
}
开发者ID:kwangiit,项目名称:ZHT,代码行数:54,代码来源:benchmark_client.cpp
示例10: c_zht_remove2_std
int c_zht_remove2_std(ZHTClient_c zhtClient, const char *key) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string sKey(key);
Package package;
package.set_virtualpath(sKey);
package.set_operation(2); //1 for look up, 2 for remove, 3 for insert, 4 append
return zhtcppClient->remove(package.SerializeAsString());
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:12,代码来源:c_zhtclientStd.cpp
示例11: c_zht_remove_std
int c_zht_remove_std(ZHTClient_c zhtClient, const char *key) {
#ifdef IND_MUTEX
LockGuard lock(&c_zht_remove_mutex);
#elif SHARED_MUTEX
LockGuard lock(&c_zht_client_mutex);
#else
#endif
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string skey(key);
return zhtcppClient->remove(skey);
}
开发者ID:xiaobingo,项目名称:iit.datasys.zht-mpi,代码行数:15,代码来源:c_zhtclientStd.cpp
示例12: benchmarkLookup
float benchmarkLookup(vector<string> strList, ZHTClient &client) {
vector<string>::iterator it;
double start = 0;
double end = 0;
start = getTime_msec();
int errCount = 0;
//cout << "Client: benchmarkLookup: start lookup \n";
int c = 0;
for (it = strList.begin(); it != strList.end(); it++) {
string result;
// cout << c << endl;
c++;
// cout<<"lookup: "<<c<<endl;
//sleep(1);
//
// cout << "Client: What I want to find: \n";
// cout <<"Lookup: "<< (*it).c_str() << endl;
if (client.lookup((*it), result) < 0) {
errCount++;
} else if (result.empty()) { //empty string
errCount++;
}
// cout << "Client: What I get: ";
// cout << result.c_str() << endl;
}
end = getTime_msec();
cout << "Lookup " << strList.size() - errCount << " packages out of "
<< strList.size() << ", cost " << end - start << " ms" << endl;
return 0;
}
开发者ID:kwangiit,项目名称:ZHT,代码行数:34,代码来源:benchmark_client.cpp
示例13: initconfig
int initconfig(ZHTClient &clientRet, string cfgFile, string memberList) {
if (clientRet.initialize(cfgFile, memberList, TCP) != 0) {
cout << "Crap! ZHTClient initialization failed, program exits." << endl;
return -1;
}
return 0;
}
开发者ID:anupammr89,项目名称:matrix,代码行数:8,代码来源:benchmark_client.cpp
示例14: main
int main(int argc, char* argv[]) {
//cout << "Usage: ./client <num_operations> <memberList> <configFile>"<< endl;
/* For BG/P:
const string cmd = "cat /proc/personality.sh | grep BG_PSETORG";
string torusID = executeShell(cmd);
torusID.resize(torusID.size() - 1);
int pid = getpid();
unsigned int v = myhash(torusID.c_str(), 1000000) + pid;
//cout<<"client: pid = "<<pid<<endl;
//cout<<"Client random n = "<<v<<endl;
srand(v);
*/
char* isTCP = argv[4];
//cout<<"Protocol = "<<isTCP<<endl;
if (!strcmp("TCP", isTCP)) {
TCP = true;
} else {
TCP = false;
}
int numOper = atoi(argv[1]);
//cout<<"numOper = "<<numOper<<endl;
string cfgFile(argv[3]);
//cout<<"cfgFile = "<<cfgFile<<endl;
string memberList(argv[2]);
//cout<<"memberList: "<<memberList<<endl;
vector<string> pkgList;
ZHTClient testClient;
// int pid = getpid();
char* tmpStr;
stringstream ss; //create a stringstream
// ss << pid;
// string recordFile = "record." + ss.str();
// benchmarkTimeAnalize(cfgFile, memberList, pkgList, testClient, numOper, 15, recordFile);
//cout<<"start to insert..."<<endl;
insertMetadata(cfgFile, memberList, pkgList, testClient, numOper, 15); //25fro 128bytes.
//cout << "Client:main, start lookup \n";
benchmarkLookup(pkgList, testClient);
benchmarkRemove(pkgList, testClient);
testClient.tearDownTCP(TCP);
return 0;
}
开发者ID:corentone,项目名称:FusionFS-IDA,代码行数:46,代码来源:client_main.cpp
示例15: c_zht_insert_std
int c_zht_insert_std(ZHTClient_c zhtClient, const char *key,
const char *value) {
#ifdef IND_MUTEX
LockGuard lock(&c_zht_insert_mutex);
#elif SHARED_MUTEX
LockGuard lock(&c_zht_client_mutex);
#else
#endif
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string skey(key);
string sval(value);
return zhtcppClient->insert(skey, sval);
}
开发者ID:xiaobingo,项目名称:iit.datasys.zht-mpi,代码行数:17,代码来源:c_zhtclientStd.cpp
示例16: c_zht_insert2_std
int c_zht_insert2_std(ZHTClient_c zhtClient, const char *key,
const char *value) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string sKey(key);
string sValue(value);
Package package;
package.set_virtualpath(sKey); //as key
package.set_isdir(true);
package.set_replicano(5);
package.set_operation(3); //1 for look up, 2 for remove, 3 for insert, 4 append
if (!sValue.empty())
package.set_realfullpath(sValue);
return zhtcppClient->insert(package.SerializeAsString());
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:18,代码来源:c_zhtclientStd.cpp
示例17: c_zht_init_std
int c_zht_init_std(ZHTClient_c * zhtClient, const char *memberConfig,
const char *zhtConfig, bool tcp) {
ZHTClient * zhtcppClient = new ZHTClient();
string zhtStr(zhtConfig);
string memberStr(memberConfig);
if (zhtcppClient->initialize(zhtStr, memberStr, tcp) != 0) {
printf("Crap! ZHTClient initialization failed, program exits.");
return -1;
}
*zhtClient = (ZHTClient_c) zhtcppClient;
return 0;
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:18,代码来源:c_zhtclientStd.cpp
示例18: submittaskszht
void submittaskszht(ZHTClient &clientRet, string client_id)
{
int ret = 0;
Package package;
package.set_virtualpath(client_id);
package.set_operation(21);
cout << "Ok, what is the hell!\n" << endl;
for (map<uint32_t, NodeList>::iterator map_it = update_map_zht.begin(); map_it != update_map_zht.end(); ++map_it)
{
uint32_t index = map_it->first;
NodeList &update_list = map_it->second;
while (!update_list.empty())
{
int num_vector_count, per_vector_count;
string alltasks;
vector< vector<string> > tokenize_string = tokenize_1(update_list.front(), '$', '#', num_vector_count, per_vector_count);
//cout << " num_vector_count = " << num_vector_count << " per_vector_count = " << per_vector_count << endl;
for(int i = 0; i < per_vector_count; i++)
{
Package tmpPackage;
tmpPackage.ParseFromString(tokenize_string.at(0).at(i));
string key = tmpPackage.virtualpath();
alltasks.append(key); alltasks.append("\'\"");
} //cout << "Serve
package.set_realfullpath(alltasks);
string str = package.SerializeAsString();
ret += clientRet.svrtosvr(str, str.length(), index);
update_list.pop_front();
}
}
// Package package; string alltasks;
// package.set_virtualpath(client_id); // Here key is just the client ID
// package.set_operation(21);
// //package.set_operation(22);
// num_packages++;
//
// int num_tasks_this_package = max_tasks_per_package;
// int num_tasks_left = num_tasks - total_submitted1;
// if (num_tasks_left < max_tasks_per_package) {
// num_tasks_this_package = num_tasks_left;
// }
// for(int j = 0; j < num_tasks_this_package; j++) {
// int task_id = it->first; ++it;
//
// stringstream task_id_ss;
// task_id_ss << task_id << client_id; // Task ID + Client ID
// alltasks.append(task_id_ss.str()); alltasks.append("\'\""); // Task ID
// }
// total_submitted1 = total_submitted1 + num_tasks_this_package;
// package.set_realfullpath(alltasks);
// string str = package.SerializeAsString();
// //cout << "String size = " << str.size() << " str length = " << strlen(str.c_str());
// int32_t ret = clientRet.svrtosvr(str, str.length(), toserver);
}
开发者ID:kwangiit,项目名称:matrix,代码行数:56,代码来源:matrix_client.cpp
示例19: c_zht_lookup2_std
int c_zht_lookup2_std(ZHTClient_c zhtClient, const char *key, char *result,
size_t *n) {
ZHTClient *zhtcppClient = (ZHTClient *) zhtClient;
string sKey(key);
Package package;
package.set_virtualpath(sKey); //as key
package.set_isdir(true);
package.set_replicano(5);
package.set_operation(1); //1 for look up, 2 for remove, 3 for insert, 4 append
string resultStr;
int ret = zhtcppClient->lookup(package.SerializeAsString(), resultStr);
/*
* hello,zht:hello,zht ==> hello,zht:zht
* */
string store;
char * pch, *sp;
pch = strtok_r((char*) resultStr.c_str(), ":", &sp);
Package package2;
while (pch != NULL) {
package2.ParseFromString(pch);
string strRealfullpath = package2.realfullpath();
store.append(strRealfullpath);
store.append(":");
pch = strtok_r(NULL, ":", &sp);
}
size_t found = store.find_last_of(":");
store = store.substr(0, found);
strncpy(result, store.c_str(), strlen(store.c_str()));
*n = store.size();
return ret;
}
开发者ID:dongfangzhao,项目名称:FusionFS-Surveyor,代码行数:43,代码来源:c_zhtclientStd.cpp
示例20: c_zht_state_change_callback_std
int c_zht_state_change_callback_std(ZHTClient_c zhtClient, const char *key,
const char *expected_val, int lease) {
#ifdef IND_MUTEX
LockGuard lock(&c_zht_state_change_callback_mutex);
#elif SHARED_MUTEX
LockGuard lock(&c_zht_client_mutex);
#else
#endif
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string skey(key);
string expectedval(expected_val);
int rc = zhtcppClient->state_change_callback(skey, expectedval, lease);
return rc;
}
开发者ID:xiaobingo,项目名称:iit.datasys.zht-mpi,代码行数:19,代码来源:c_zhtclientStd.cpp
注:本文中的ZHTClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论