Small bug fix

parent 1838e1d5
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <sstream> #include <sstream>
#include <map> #include <map>
#include <cstdio> #include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
...@@ -89,17 +91,17 @@ public: ...@@ -89,17 +91,17 @@ public:
//Impliment here //Impliment here
//Start //Start
result = get12(request_.key()); result = get12(request_.key());
if(result=="4") if (result == "4")
{ {
response_.set_status(400); response_.set_status(400);
response_.set_val("key or value is empty"); response_.set_val("key or value is empty");
} }
else if (result=="2") else if (result == "2")
{ {
response_.set_status(400); response_.set_status(400);
response_.set_val("key not found"); response_.set_val("key not found");
} }
else if(result=="3") else if (result == "3")
{ {
response_.set_status(400); response_.set_status(400);
response_.set_val("key or value string byte is more than 256 byte"); response_.set_val("key or value string byte is more than 256 byte");
...@@ -109,7 +111,7 @@ public: ...@@ -109,7 +111,7 @@ public:
response_.set_status(200); response_.set_status(200);
response_.set_val(result); response_.set_val(result);
} }
//End //End
responder_.Finish(response_, grpc::Status::OK, &proceed); responder_.Finish(response_, grpc::Status::OK, &proceed);
status_ = FINISH; status_ = FINISH;
...@@ -186,17 +188,17 @@ public: ...@@ -186,17 +188,17 @@ public:
//Impliment here //Impliment here
//Start //Start
result = delete1(request_.key()); result = delete1(request_.key());
if(result==1) if (result == 1)
{ {
response_.set_status(200); response_.set_status(200);
response_.set_err("Entry Deleted"); response_.set_err("Entry Deleted");
} }
else if (result==2) else if (result == 2)
{ {
response_.set_status(400); response_.set_status(400);
response_.set_err("key not found"); response_.set_err("key not found");
} }
else if(result==3) else if (result == 3)
{ {
response_.set_status(400); response_.set_status(400);
response_.set_err("key or value string byte is more than 256 byte"); response_.set_err("key or value string byte is more than 256 byte");
...@@ -282,7 +284,7 @@ public: ...@@ -282,7 +284,7 @@ public:
new PutCall(data_); new PutCall(data_);
//Impliment here //Impliment here
//Start //Start
result = put(request_.key(),request_.val()); result = put(request_.key(), request_.val());
response_.set_status(200); response_.set_status(200);
//End //End
responder_.Finish(response_, grpc::Status::OK, &proceed); responder_.Finish(response_, grpc::Status::OK, &proceed);
...@@ -456,16 +458,24 @@ void config() ...@@ -456,16 +458,24 @@ void config()
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
freopen("log.txt", "w", stderr); freopen("log.txt", "w", stderr);
int check = mkdir("data", 0777);
if (!check)
std::cerr << "Directory created\n";
else
{
std::cerr <<"Unable to create directory\n";
exit(1);
}
config(); config();
run(); run();
cache_block = cache_size / 512; cache_block = cache_size / 512;
if(cache_type=="LFU") if (cache_type == "LFU")
{ {
config_cache(1,cache_block); config_cache(1, cache_block);
} }
else else
{ {
config_cache(2,cache_block); config_cache(2, cache_block);
} }
ServerImpl server; ServerImpl server;
server.Run(); server.Run();
......
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