int main() { Node *chord = NULL; ChordNode *node = NULL; //We are hardcoding in values to connect from. This makes our other //stuff easier.... //our chord server will always be run from mimosa.cs.uchicago.edu //port: 8000 //"overlay identifier" - ruemud node = P_SINGLETON->initChordNode(std::string("mimosa.cs.uchicago.edu"), 8000, std::string("ruemud"),std::string(".")); chord = NULL; // since this is the server, we don't join to an existing chord char entry[256]; string key; string value; while (1) { // sleep... cout << "\n0) Print status\n" << "1) Exit\n\n"; cout << "---> "; //All the server does is start the connection. :) It is //assumed to always be running! cin >> entry; int chx = atoi(entry); switch (chx) { case 0: cout << "\n" << node->printStatus(); break; case 1: node->shutDown(); default: break; } } return 0; }
// This application receives args, "ip", "port", "overlay identifier (unique string)", "root directory)" int main(int argc, char * const argv[]) { string backBone[] = { // user backbone "127.0.0.1", }; Node *chord = NULL; ChordNode *node = NULL; if (argc >= 4) { // Create a test node node = P_SINGLETON->initChordNode(std::string(argv[1]), atoi(argv[2]), std::string("chordTestBed"), std::string(argv[3])); chord = NULL; // join to an existing chord if (argc == 5) { cout << "joining...\n"; int i = 0; chord = new Node(backBone[0], 8000); node->join(chord); } char entry[256]; string key; string value; while (1) { // sleep... cout << "\n0) Print status\n" << "1) Put\n" << "2) Get\n" << "3) Remove\n" << "4) Exit\n\n"; cout << "---> "; cin >> entry; int chx = atoi(entry); switch (chx) { case 0: cout << "\n" << node->printStatus(); break; case 1: cout << "Key = "; cin >> key; cout << "Value = "; cin >> value; node->put(key, value); break; case 2: cout << "Key = "; cin >> key; cout << "\n" << node->get(key) << "------> found!" << endl; break; case 3: cout << "Key = "; cin >> key; node->removekey(key); break; case 4: node->shutDown(); default: break; } } } else {