Commit 2cf6ddb2 authored by mayankkakad's avatar mayankkakad

errors rectified

parent 9cee4e2d
...@@ -160,6 +160,7 @@ void RunClient() { ...@@ -160,6 +160,7 @@ void RunClient() {
Info info; Info info;
ClientContext context; ClientContext context;
Status status=stub->GETADDRESS(&context,null,&info); Status status=stub->GETADDRESS(&context,null,&info);
std::cout<<"Server: "<<info.address()<<std::endl;
std::string target_address(info.address()); std::string target_address(info.address());
// Instantiates the client // Instantiates the client
KeyValueServicesClient client( KeyValueServicesClient client(
......
...@@ -337,7 +337,7 @@ public: ...@@ -337,7 +337,7 @@ public:
//return half of the keyvalue pairs to the requesting node //return half of the keyvalue pairs to the requesting node
string address=info.address(); string address=info.address();
int id=stoi(address.substr(address.find(':')+1)); int id=stoi(address.substr(address.find(':')+1));
string keyvalues=memManager->getKeyValuePairs(id); string keyvalues=memManager->getKeyValuePairs(id,stoi(params["LISTENING_PORT"]));
string keys=keyvalues.substr(0,keyvalues.find(";;")+1); string keys=keyvalues.substr(0,keyvalues.find(";;")+1);
string values=keyvalues.substr(keyvalues.find(";;")+2); string values=keyvalues.substr(keyvalues.find(";;")+2);
cout<<"Okay, my new predecessor is: "<<info.address()<<endl; cout<<"Okay, my new predecessor is: "<<info.address()<<endl;
...@@ -1041,15 +1041,19 @@ public: ...@@ -1041,15 +1041,19 @@ public:
int my_id=stoi(params.find("LISTENING_PORT")->second); int my_id=stoi(params.find("LISTENING_PORT")->second);
ifstream fin; ifstream fin;
fin.open(NEIGHBOURS); fin.open(NEIGHBOURS);
string pred; string pred,scc;
getline(fin,pred); getline(fin,scc);
getline(fin,pred); getline(fin,pred);
fin.close(); fin.close();
int pred_id; int pred_id,succ_id;
if(pred=="-1") if(pred=="-1")
pred_id=-1; pred_id=-1;
else else
pred_id=stoi(pred.substr(pred.find(':')+1)); pred_id=stoi(pred.substr(pred.find(':')+1));
if(scc=="-1")
succ_id=-1;
else
succ_id=stoi(scc.substr(scc.find(':')+1));
if(my_id<key_id&&!(pred_id<key_id&&pred_id>my_id)) { if(my_id<key_id&&!(pred_id<key_id&&pred_id>my_id)) {
//transfer request //transfer request
int fingers[16]; int fingers[16];
...@@ -1226,7 +1230,7 @@ public: ...@@ -1226,7 +1230,7 @@ public:
stat.set_status(200); stat.set_status(200);
} }
else { else {
if(pred_id==-1||pred_id<key_id) { if(pred_id==-1||(pred_id<key_id&&my_id>=key_id)||(pred_id>my_id&&my_id>=key_id)) {
cout << "SERVER SERVES A PUT REQUEST WITH PARAMETER KEY : " << keyvalue.key() << " & VALUE : " << keyvalue.value() << endl; cout << "SERVER SERVES A PUT REQUEST WITH PARAMETER KEY : " << keyvalue.key() << " & VALUE : " << keyvalue.value() << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment