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