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; }
int c_zht_teardown_std(ZHTClient_c zhtClient) { #ifdef IND_MUTEX pthread_mutex_destroy (&c_zht_lookup_mutex); pthread_mutex_destroy (&c_zht_remove_mutex); pthread_mutex_destroy (&c_zht_insert_mutex); pthread_mutex_destroy (&c_zht_append_mutex); pthread_mutex_destroy (&c_zht_compare_swap_mutex); pthread_mutex_destroy (&c_zht_state_change_callback_mutex); #elif SHARED_MUTEX pthread_mutex_destroy(&c_zht_client_mutex); #else #endif ZHTClient * zhtcppClient = (ZHTClient *) zhtClient; int rc = zhtcppClient->teardown(); delete zhtcppClient; zhtcppClient = NULL; return rc; }
int main(int argc, char **argv) { extern char *optarg; int printHelp = 0, numThrds = 0; string zhtConf = ""; string neighborConf = ""; int c; while ((c = getopt(argc, argv, "z:n:t:h")) != -1) { switch (c) { case 'z': zhtConf = string(optarg); break; case 'n': neighborConf = string(optarg); break; case 't': numThrds = atoi(optarg); break; case 'h': printHelp = 1; break; default: fprintf(stderr, "Illegal argument \"%c\"\n", c); printUsage(argv[0]); exit(1); } } int helpPrinted = 0; if (printHelp) { printUsage(argv[0]); helpPrinted = 1; } try { if (!zhtConf.empty() && !neighborConf.empty() && numThrds != 0) { zc.init(zhtConf, neighborConf); cout << "Initializing Worker" << endl; string result; zc.push("temp", "test", "q1", result); zc.pop("xxxx", "q1", result); id = 1000; job_count = 1000; //test_insert(); //test_pop(); startWorker(numThrds); zc.teardown(); } else { if (!helpPrinted) printUsage(argv[0]); } } catch (exception& e) { fprintf(stderr, "%s, exception caught:\n\t%s", "ZHTServer::main", e.what()); } }