forked from mierl/ZHT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleClient.cpp
More file actions
51 lines (40 loc) · 1.16 KB
/
SimpleClient.cpp
File metadata and controls
51 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <iomanip>
#include "ZHTClient.cpp"
using namespace std;
int main(int argc, const char* argv[]) {
if (argc != 3) {
cout<<"Usage: ./SimpleClient <memberListFilePath> <configFilePath>"<<endl;
return -1;
}
ZHTClient client;
string memberList(argv[1]);
string cfgFile(argv[2]);
if (client.initialize(cfgFile, memberList) != 0) {
cout << "Crap! ZHTClient initialization failed, program exits." << endl;
return -1;
}
string pointerToString;
string key("key");
int ret = client.insert(key, "Hello World!");
if (ret != 0) {
cout << "Error Inserting: " << strerror(ret) << endl;
return -1;
} else {
cout << "Inserted value" << endl;
}
ret = client.get(key, pointerToString);
if (ret != 0) {
cout << "Error On Lookup: " << strerror(ret) << endl;
return -1;
} else {
cout << "Found value '" << pointerToString << "'\n";
}
ret = client.remove(key);
if (ret != 0) {
cout << "Error On Remove: " << strerror(ret) << endl;
} else {
cout << "Removed value" << endl;
}
return 0;
}