You need to sign in or sign up before continuing.
Commit afb42e10 authored by Mayank Manoj's avatar Mayank Manoj

Merge branch 'mayank' into 'master'

error rectified

See merge request !6
parents 93938e76 78b86f17
...@@ -351,6 +351,8 @@ public: ...@@ -351,6 +351,8 @@ public:
string keyvalues=memManager->getKeyValuePairs(id,stoi(params["LISTENING_PORT"])); 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<<"Keys: "<<keys<<endl;
cout<<"Values: "<<values<<endl;
ifstream fin; ifstream fin;
fin.open(NEIGHBOURS); fin.open(NEIGHBOURS);
string successor,predecessor; string successor,predecessor;
...@@ -686,16 +688,20 @@ public: ...@@ -686,16 +688,20 @@ 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(my_id<key_id&&!(pred_id<key_id&&pred_id>my_id)) { 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)&&pred_id!=-1) {
cout<<"I don't have the key"<<endl; cout<<"I don't have the key"<<endl;
//transfer request //transfer request
int fingers[16]; int fingers[16];
...@@ -876,7 +882,7 @@ public: ...@@ -876,7 +882,7 @@ public:
memManager->traverse(); memManager->traverse();
} }
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 GET REQUEST WITH PARAMETER KEY : " << key.key(); cout << "SERVER SERVES A GET REQUEST WITH PARAMETER KEY : " << key.key();
int status = 200; int status = 200;
pthread_mutex_lock(&_masterLock); pthread_mutex_lock(&_masterLock);
...@@ -1077,7 +1083,7 @@ public: ...@@ -1077,7 +1083,7 @@ public:
succ_id=-1; succ_id=-1;
else else
succ_id=stoi(scc.substr(scc.find(':')+1)); 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)&&pred_id!=-1) {
cout<<"I don't have the key"<<endl; cout<<"I don't have the key"<<endl;
//transfer request //transfer request
int fingers[16]; int fingers[16];
...@@ -1443,7 +1449,7 @@ public: ...@@ -1443,7 +1449,7 @@ public:
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(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)&&pred_id!=-1) {
cout<<"I don't have the key"<<endl; cout<<"I don't have the key"<<endl;
//transfer request //transfer request
int fingers[16]; int fingers[16];
...@@ -1624,7 +1630,7 @@ public: ...@@ -1624,7 +1630,7 @@ public:
memManager->traverse(); memManager->traverse();
} }
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 DEL REQUEST WITH PARAMETER KEY : " << key.key() << endl; cout << "SERVER SERVES A DEL REQUEST WITH PARAMETER KEY : " << key.key() << endl;
int status = 200; int status = 200;
...@@ -2018,15 +2024,17 @@ void register_server_DNS(string my_address) { ...@@ -2018,15 +2024,17 @@ void register_server_DNS(string my_address) {
string keys=keyValues.keys(); string keys=keyValues.keys();
string values=keyValues.values(); string values=keyValues.values();
while(true) { while(true) {
cout<<"Keys: "<<keys<<endl;
cout<<"Values: "<<values<<endl;
string key=keys.substr(0,keys.find(';')); string key=keys.substr(0,keys.find(';'));
string value=values.substr(0,values.find(';')); string value=values.substr(0,values.find(';'));
if(key.size()==0) if(key.size()==0)
break; break;
memManager->put(key,value);
if(keys.find(';')+1==keys.size()) if(keys.find(';')+1==keys.size())
break; break;
keys=keys.substr(keys.find(';')+1); keys=keys.substr(keys.find(';')+1);
values=values.substr(values.find(';')+1); values=values.substr(values.find(';')+1);
memManager->put(key,value);
} }
channel=grpc::CreateChannel(predecessor,grpc::InsecureChannelCredentials()); channel=grpc::CreateChannel(predecessor,grpc::InsecureChannelCredentials());
stub=KeyValueServices::NewStub(channel); stub=KeyValueServices::NewStub(channel);
......
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