Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS744 DECS-PA4-KEYVALUE-SERVER
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
1
Merge Requests
1
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
Kamal Khodabhai
CS744 DECS-PA4-KEYVALUE-SERVER
Commits
b69e736e
Commit
b69e736e
authored
Nov 18, 2021
by
mayankkakad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
splitting keyvalues template made
parent
ce5b49e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
Backend.h
Backend.h
+11
-0
keyvaluestore.proto
keyvaluestore.proto
+2
-2
server.cpp
server.cpp
+19
-2
No files found.
Backend.h
View file @
b69e736e
...
@@ -20,6 +20,9 @@ public:
...
@@ -20,6 +20,9 @@ public:
virtual
void
pushAll
()
{
virtual
void
pushAll
()
{
return
;
return
;
}
}
virtual
string
getKeyValuePairs
(
int
id
)
{
return
"This will never run"
;
}
};
};
class
storageLRU
:
public
memoryManagement
{
class
storageLRU
:
public
memoryManagement
{
...
@@ -57,6 +60,10 @@ public:
...
@@ -57,6 +60,10 @@ public:
void
pushAll
()
{
void
pushAll
()
{
mycache
.
pushAll
();
mycache
.
pushAll
();
}
}
string
getKeyValuePairs
(
int
id
)
{
return
"keyvaluepairs"
;
}
};
};
class
storageLFU
:
public
memoryManagement
{
class
storageLFU
:
public
memoryManagement
{
...
@@ -93,4 +100,8 @@ public:
...
@@ -93,4 +100,8 @@ public:
void
pushAll
()
{
void
pushAll
()
{
mycache
.
pushAll
();
mycache
.
pushAll
();
}
}
string
getKeyValuePairs
(
int
id
)
{
return
"keyvaluepairs"
;
}
};
};
\ No newline at end of file
keyvaluestore.proto
View file @
b69e736e
...
@@ -50,8 +50,8 @@ message SuccessorInfo {
...
@@ -50,8 +50,8 @@ message SuccessorInfo {
}
}
message
KeyValues
{
message
KeyValues
{
repeated
string
keys
=
1
;
string
keys
=
1
;
repeated
string
values
=
2
;
string
values
=
2
;
}
}
message
Null
{
message
Null
{
...
...
server.cpp
View file @
b69e736e
...
@@ -214,9 +214,12 @@ public:
...
@@ -214,9 +214,12 @@ public:
}
}
else
if
(
reqType
==
INFORMSUCCESSOR
){
else
if
(
reqType
==
INFORMSUCCESSOR
){
//return half of the keyvalue pairs to the requesting node
//return half of the keyvalue pairs to the requesting node
//cout<<"Okay, my new predecessor is: "<<info.address()<<endl;
string
address
=
info
.
address
();
string
address
=
info
.
address
();
int
id
=
stoi
(
address
.
substr
(
address
.
find
(
':'
)
+
1
));
int
id
=
stoi
(
address
.
substr
(
address
.
find
(
':'
)
+
1
));
string
keyvalues
=
memManager
->
getKeyValuePairs
(
id
);
string
keys
=
keyvalues
.
substr
(
0
,
keyvalues
.
find
(
";;"
)
+
1
);
string
values
=
keyvalues
.
substr
(
keyvalues
.
find
(
";;"
)
+
2
);
//cout<<"Okay, my new predecessor is: "<<info.address()<<endl;
ifstream
fin
;
ifstream
fin
;
fin
.
open
(
NEIGHBOURS
);
fin
.
open
(
NEIGHBOURS
);
string
successor
,
predecessor
;
string
successor
,
predecessor
;
...
@@ -229,7 +232,8 @@ public:
...
@@ -229,7 +232,8 @@ public:
fout
<<
successor
<<
endl
;
fout
<<
successor
<<
endl
;
fout
<<
predecessor
<<
endl
;
fout
<<
predecessor
<<
endl
;
fout
.
close
();
fout
.
close
();
null
.
set_nothing
(
0
);
keyValues
.
set_keys
(
keys
);
keyValues
.
set_values
(
values
);
//cout<<"Done making changes accordingly"<<endl;
//cout<<"Done making changes accordingly"<<endl;
informSuccessorResponder
.
Finish
(
keyValues
,
Status
::
OK
,
this
);
informSuccessorResponder
.
Finish
(
keyValues
,
Status
::
OK
,
this
);
}
}
...
@@ -1340,6 +1344,19 @@ void register_server_DNS(string my_address) {
...
@@ -1340,6 +1344,19 @@ void register_server_DNS(string my_address) {
ClientContext
context2
;
ClientContext
context2
;
//cout<<"Informing successor about my presence"<<endl;
//cout<<"Informing successor about my presence"<<endl;
status
=
stub
->
INFORMSUCCESSOR
(
&
context2
,
info
,
&
keyValues
);
status
=
stub
->
INFORMSUCCESSOR
(
&
context2
,
info
,
&
keyValues
);
string
keys
=
keyValues
.
keys
();
string
values
=
keyValues
.
values
();
while
(
true
)
{
string
key
=
keys
.
substr
(
0
,
keys
.
find
(
';'
));
string
value
=
values
.
substr
(
0
,
values
.
find
(
';'
));
if
(
key
.
size
()
==
0
)
break
;
if
(
keys
.
find
(
';'
)
+
1
==
keys
.
size
())
break
;
keys
=
keys
.
substr
(
keys
.
find
(
';'
)
+
1
);
values
=
values
.
substr
(
values
.
find
(
';'
)
+
1
);
memManager
->
put
(
key
,
value
);
}
//cout<<"Informed succesor"<<endl;
//cout<<"Informed succesor"<<endl;
channel
=
grpc
::
CreateChannel
(
predecessor
,
grpc
::
InsecureChannelCredentials
());
channel
=
grpc
::
CreateChannel
(
predecessor
,
grpc
::
InsecureChannelCredentials
());
stub
=
KeyValueServices
::
NewStub
(
channel
);
stub
=
KeyValueServices
::
NewStub
(
channel
);
...
...
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