Commit 45626f12 authored by mayankkakad's avatar mayankkakad

new server adding code done (untested)

parent 178250d5
...@@ -22,7 +22,8 @@ std::unique_ptr<Server> server; ...@@ -22,7 +22,8 @@ std::unique_ptr<Server> server;
enum RequestType { enum RequestType {
GETADDRESS, GETADDRESS,
ADDADDRESS ADDADDRESS,
UPDATEFINGERTABLES
}; };
class DNSData { class DNSData {
...@@ -36,7 +37,7 @@ public: ...@@ -36,7 +37,7 @@ public:
status = PROCESS; status = PROCESS;
if(reqType==GETADDRESS) if(reqType==GETADDRESS)
service->RequestGETADDRESS(&context, &null, &getAddressResponder, cq, cq, this); service->RequestGETADDRESS(&context, &null, &getAddressResponder, cq, cq, this);
else else if(reqType==ADDADDRESS)
service->RequestADDADDRESS(&context, &info, &addAddressResponder, cq, cq, this); service->RequestADDADDRESS(&context, &info, &addAddressResponder, cq, cq, this);
} }
else if (status == PROCESS) { else if (status == PROCESS) {
...@@ -62,7 +63,7 @@ public: ...@@ -62,7 +63,7 @@ public:
} }
getAddressResponder.Finish(info,Status::OK,this); getAddressResponder.Finish(info,Status::OK,this);
} }
else { else if(reqType==ADDADDRESS){
ofstream fout; ofstream fout;
fout.open(SERVERS,ios::app); fout.open(SERVERS,ios::app);
fout<<info.address()<<endl; fout<<info.address()<<endl;
...@@ -70,6 +71,8 @@ public: ...@@ -70,6 +71,8 @@ public:
null.set_nothing(0); null.set_nothing(0);
addAddressResponder.Finish(null,Status::OK,this); addAddressResponder.Finish(null,Status::OK,this);
} }
else {
}
status = FINISH; status = FINISH;
} }
else { else {
...@@ -124,6 +127,7 @@ int main(int argc,char **argv) { ...@@ -124,6 +127,7 @@ int main(int argc,char **argv) {
cout<<"DNS SERVER COMES UP SUCCESSFULLY"<<endl; cout<<"DNS SERVER COMES UP SUCCESSFULLY"<<endl;
new DNSData(&service,comp_queue.get(),GETADDRESS); new DNSData(&service,comp_queue.get(),GETADDRESS);
new DNSData(&service,comp_queue.get(),ADDADDRESS); new DNSData(&service,comp_queue.get(),ADDADDRESS);
new DNSData(&service,comp_queue.get(),UPDATEFINGERTABLES);
void *tag; void *tag;
bool ok; bool ok;
while(true) { while(true) {
......
...@@ -9,9 +9,13 @@ service KeyValueServices { ...@@ -9,9 +9,13 @@ service KeyValueServices {
rpc PUT(KeyValue) returns (ReqStatus) {} rpc PUT(KeyValue) returns (ReqStatus) {}
rpc DEL(Key) returns (ReqStatus) {} rpc DEL(Key) returns (ReqStatus) {}
rpc NEW(Info) returns (SuccessorInfo) {} rpc NEW(Info) returns (SuccessorInfo) {}
rpc INFORM(Info) returns (KeyValues) {} rpc INFORMSUCCESSOR(Info) returns (KeyValues) {}
rpc INFORMPREDECESSOR(Info) returns (Null) {}
rpc GETADDRESS(Null) returns (Info) {} rpc GETADDRESS(Null) returns (Info) {}
rpc ADDADDRESS(Info) returns (Null) {} rpc ADDADDRESS(Info) returns (Null) {}
rpc UPDATEFINGERTABLES(Null) returns (Null) {}
rpc GETSUCCESSOR(Id) returns (Id) {}
rpc GETPREDECESSOR(Id) returns (Id) {}
} }
message Key { message Key {
...@@ -39,7 +43,8 @@ message Info { ...@@ -39,7 +43,8 @@ message Info {
} }
message SuccessorInfo { message SuccessorInfo {
string address = 1; string succaddress = 1;
string predaddress = 2;
} }
message KeyValues { message KeyValues {
...@@ -49,4 +54,8 @@ message KeyValues { ...@@ -49,4 +54,8 @@ message KeyValues {
message Null { message Null {
int32 nothing = 1; int32 nothing = 1;
}
message Id {
int64 id = 1;
} }
\ No newline at end of file
This diff is collapsed.
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