Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tapir
Manage
Activity
Members
Labels
Plan
Issues
8
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
syslab
tapir
Commits
5838669c
Commit
5838669c
authored
9 years ago
by
Irene Zhang
Browse files
Options
Downloads
Patches
Plain Diff
adding parsing and dispatch code for tapir server
parent
5c8a68fd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/tapir/server.cc
+66
-0
66 additions, 0 deletions
store/tapir/server.cc
with
66 additions
and
0 deletions
store/tapir/server.cc
+
66
−
0
View file @
5838669c
...
...
@@ -49,16 +49,82 @@ Server::~Server()
void
Server
::
ExecInconsistentUpcall
(
const
string
&
str1
)
{
Debug
(
"Received Inconsistent Request: %s"
,
str1
.
c_str
());
Request
request
;
request
.
ParseFromString
(
str1
);
switch
(
request
.
op
())
{
case
tapir
::
proto
::
Request
::
COMMIT
:
store
->
Commit
(
request
.
txnid
(),
request
.
commit
().
timestamp
());
break
;
case
tapir
::
proto
::
Request
::
ABORT
:
store
->
Abort
(
request
.
txnid
(),
Transaction
(
request
.
abort
().
txn
()));
break
;
default:
Panic
(
"Unrecognized inconsisternt operation."
);
}
}
void
Server
::
ExecConsensusUpcall
(
const
string
&
str1
,
string
&
str2
)
{
Debug
(
"Received Consensus Request: %s"
,
str1
.
c_str
());
Request
request
;
Reply
reply
;
int
status
;
request
.
ParseFromString
(
str1
);
switch
(
request
.
op
())
{
case
tapir
::
proto
::
Request
::
PREPARE
:
status
=
store
->
Prepare
(
request
.
txnid
(),
Transaction
(
request
.
prepare
().
txn
()));
reply
.
set_status
(
status
);
reply
.
SerializeToString
(
&
str2
);
break
;
default:
Panic
(
"Unrecognized consensus operation."
);
}
}
void
Server
::
UnloggedUpcall
(
const
string
&
str1
,
string
&
str2
)
{
Debug
(
"Received Consensus Request: %s"
,
str1
.
c_str
());
Request
request
;
Reply
reply
;
int
status
;
request
.
ParseFromString
(
str1
);
switch
(
request
.
op
())
{
case
tapir
::
proto
::
Request
::
GET
:
if
(
request
.
get
().
has_timestamp
())
{
pair
<
Timestamp
,
string
>
val
;
status
=
store
->
Get
(
request
.
txnid
(),
request
.
get
().
key
(),
request
.
get
().
timestamp
(),
val
);
if
(
status
==
0
)
{
reply
.
set_value
(
val
.
second
);
}
}
else
{
pair
<
Timestamp
,
string
>
val
;
status
=
store
->
Get
(
request
.
txnid
(),
request
.
get
().
key
(),
val
);
if
(
status
==
0
)
{
reply
.
set_value
(
val
.
second
);
reply
.
set_timestamp
(
val
.
first
.
getTimestamp
());
}
}
reply
.
set_status
(
status
);
reply
.
SerializeToString
(
&
str2
);
break
;
default
:
Panic
(
"Unrecognized Unlogged request."
);
}
}
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment