Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
Key-Val Store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rupasai
Key-Val Store
Commits
a73a3cc5
Commit
a73a3cc5
authored
Oct 30, 2021
by
Jaiminkumar Nareshbhai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small bug fix
parent
1838e1d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
key_val_store/cmake/build/.DS_Store
key_val_store/cmake/build/.DS_Store
+0
-0
key_val_store/server.cc
key_val_store/server.cc
+21
-11
No files found.
key_val_store/cmake/build/.DS_Store
View file @
a73a3cc5
No preview for this file type
key_val_store/server.cc
View file @
a73a3cc5
...
...
@@ -11,6 +11,8 @@
#include <sstream>
#include <map>
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <grpc/support/log.h>
#include <grpcpp/grpcpp.h>
...
...
@@ -89,17 +91,17 @@ public:
//Impliment here
//Start
result
=
get12
(
request_
.
key
());
if
(
result
==
"4"
)
if
(
result
==
"4"
)
{
response_
.
set_status
(
400
);
response_
.
set_val
(
"key or value is empty"
);
}
else
if
(
result
==
"2"
)
else
if
(
result
==
"2"
)
{
response_
.
set_status
(
400
);
response_
.
set_val
(
"key not found"
);
}
else
if
(
result
==
"3"
)
else
if
(
result
==
"3"
)
{
response_
.
set_status
(
400
);
response_
.
set_val
(
"key or value string byte is more than 256 byte"
);
...
...
@@ -109,7 +111,7 @@ public:
response_
.
set_status
(
200
);
response_
.
set_val
(
result
);
}
//End
responder_
.
Finish
(
response_
,
grpc
::
Status
::
OK
,
&
proceed
);
status_
=
FINISH
;
...
...
@@ -186,17 +188,17 @@ public:
//Impliment here
//Start
result
=
delete1
(
request_
.
key
());
if
(
result
==
1
)
if
(
result
==
1
)
{
response_
.
set_status
(
200
);
response_
.
set_err
(
"Entry Deleted"
);
}
else
if
(
result
==
2
)
else
if
(
result
==
2
)
{
response_
.
set_status
(
400
);
response_
.
set_err
(
"key not found"
);
}
else
if
(
result
==
3
)
else
if
(
result
==
3
)
{
response_
.
set_status
(
400
);
response_
.
set_err
(
"key or value string byte is more than 256 byte"
);
...
...
@@ -282,7 +284,7 @@ public:
new
PutCall
(
data_
);
//Impliment here
//Start
result
=
put
(
request_
.
key
(),
request_
.
val
());
result
=
put
(
request_
.
key
(),
request_
.
val
());
response_
.
set_status
(
200
);
//End
responder_
.
Finish
(
response_
,
grpc
::
Status
::
OK
,
&
proceed
);
...
...
@@ -456,16 +458,24 @@ void config()
int
main
(
int
argc
,
char
**
argv
)
{
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
();
run
();
cache_block
=
cache_size
/
512
;
if
(
cache_type
==
"LFU"
)
if
(
cache_type
==
"LFU"
)
{
config_cache
(
1
,
cache_block
);
config_cache
(
1
,
cache_block
);
}
else
{
config_cache
(
2
,
cache_block
);
config_cache
(
2
,
cache_block
);
}
ServerImpl
server
;
server
.
Run
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment