2005-01-19 00:51:54 +00:00
|
|
|
#include <../../src/apps/cht/cht.h>
|
|
|
|
#include <assert.h>
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
char * conf = "client.conf";
|
|
|
|
|
|
|
|
if(argc == 2) {
|
|
|
|
conf = argv[1];
|
|
|
|
} else if(argc > 2) {
|
|
|
|
printf("Usage: %s [client.conf]\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tinit();
|
|
|
|
|
|
|
|
DfaSet * cht_client = cHtClientInit(conf);
|
|
|
|
pthread_t main_worker_loop = spawn_main_thread(cht_client);
|
|
|
|
|
|
|
|
// cht_evals go here...
|
|
|
|
|
|
|
|
int xid = 1;//NULL_MACHINE; // What's the deal with this? ;)
|
|
|
|
clusterHashTable_t * new_ht;
|
|
|
|
cHtCreate(xid, cht_client, new_ht);
|
|
|
|
int i;
|
2005-02-03 02:01:23 +00:00
|
|
|
for(i = 0; i < 1000; i++) {
|
2005-01-19 00:51:54 +00:00
|
|
|
int one = i; int two = i+1;
|
|
|
|
cHtInsert(xid, cht_client, new_ht, &one, sizeof(int), &two, sizeof(int));
|
2005-02-03 02:01:23 +00:00
|
|
|
// xid++;
|
2005-01-19 00:51:54 +00:00
|
|
|
/* int i =0;
|
|
|
|
for(i =0; i < 100; i++) {
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
fflush(NULL); */
|
|
|
|
|
|
|
|
int newOne, newTwo;
|
|
|
|
newOne = i;
|
|
|
|
newTwo = 0;
|
|
|
|
unsigned int newLen = sizeof(int);
|
|
|
|
int ret = cHtLookup(xid, cht_client, new_ht, &newOne, sizeof(int), &newTwo, &newLen);
|
2005-02-03 02:01:23 +00:00
|
|
|
// xid++;
|
2005-01-20 23:58:29 +00:00
|
|
|
//printf("lookup returned %d (%d->%d)\n", ret, newOne, newTwo);
|
|
|
|
assert(ret);
|
2005-01-19 00:51:54 +00:00
|
|
|
assert(newOne == one);
|
|
|
|
assert(newTwo == two);
|
|
|
|
assert(newLen == sizeof(int));
|
|
|
|
}
|
2005-02-03 02:01:23 +00:00
|
|
|
cHtCommit(xid, cht_client);
|
2005-01-20 23:58:29 +00:00
|
|
|
/** @todo devise a way to cleanly shut a CHT down. */
|
2005-01-19 00:51:54 +00:00
|
|
|
|
|
|
|
// dfa_free(cht_client);
|
|
|
|
}
|