Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tapir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
Ashlie Martinez
tapir
Commits
140c4b92
Commit
140c4b92
authored
9 years ago
by
Irene Y Zhang
Browse files
Options
Downloads
Patches
Plain Diff
adding IR replica stubs
parent
2fc28029
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
replication/ir/replica.cc
+108
-0
108 additions, 0 deletions
replication/ir/replica.cc
replication/ir/replica.h
+73
-0
73 additions, 0 deletions
replication/ir/replica.h
with
181 additions
and
0 deletions
replication/ir/replica.cc
0 → 100644
+
108
−
0
View file @
140c4b92
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
/***********************************************************************
*
* replication/ir/replica.cc:
* IR Replica server
*
**********************************************************************/
#include
"replication/ir/replica.cc"
#include
"common/tracer.h"
namespace
ir
{
using
namespace
std
;
using
namespace
proto
;
IRReplica
::
IRReplica
(
const
transport
::
Configuration
&
configuration
,
int
myIdx
,
Transport
*
transport
)
:
store
(
store
),
configuration
(
configuration
),
myIdx
(
myIdx
),
transport
(
transport
)
{
transport
->
Register
(
this
,
configuration
,
myIdx
);
}
IRReplica
::~
IRReplica
()
{
}
void
IRReplica
::
ReceiveMessage
(
const
TransportAddress
&
remote
,
const
string
&
type
,
const
string
&
data
)
{
HandleMessage
(
remote
,
type
,
data
);
}
void
IRReplica
::
HandleMessage
(
const
TransportAddress
&
remote
,
const
string
&
type
,
const
string
&
data
)
{
static
ProposeInconsistentMessage
proposeInconsistent
;
static
FinalizeInconsistentMessage
finalizeInconsistent
;
static
ProposeConsensusMessage
proposeConsensus
;
static
FinalizeConsensusMessage
finalizeConsensus
;
static
UnloggedRequestMessage
unloggedRequest
;
if
(
type
==
proposeInconsistent
.
GetTypeName
())
{
proposeInconsistent
.
ParseFromString
(
data
);
HandleProposeInconsistent
(
remote
,
proposeInconsistent
);
}
else
if
(
type
==
finalizeInconsistent
.
GetTypeName
())
{
finalizeInconsistent
.
ParseFromString
(
data
);
HandleFinalizeInconsistent
(
remote
,
finalizeInconsistent
);
}
else
if
(
type
==
proposeConsensus
.
GetTypeName
())
{
proposeConsensus
.
ParseFromString
(
data
);
HandleProposeConsensus
(
remote
,
proposeConsensus
);
}
else
if
(
type
==
finalizeConsensus
.
GetTypeName
())
{
finalizeConsensus
.
ParseFromString
(
data
);
HandleFinalizeConsensus
(
remote
,
finalizeConsensus
);
}
else
if
(
type
==
unloggedRequest
.
GetTypeName
())
{
unloggedRequest
.
ParseFromString
(
data
);
HandleUnlogged
(
remote
,
unloggedRequest
);
}
else
{
Panic
(
"Received unexpected message type in IR proto: %s"
,
type
.
c_str
());
}
}
void
IRReplica
::
HandleProposeInconsistent
(
const
TransportAddress
&
remote
,
const
ProposeInconsistentMessage
&
msg
)
{
// 1. Execute
// 2. Add to record as tentative
// 3. Return Reply
}
void
IRReplica
::
HandleFinalizeInconsistent
(
const
TransportAddress
&
remote
,
const
FinalizeInconsistentMessage
&
msg
)
{
// 1. Mark as finalized
// 2. Return Confirm
}
void
IRReplica
::
HandleProposeConsensus
(
const
TransportAddress
&
remote
,
const
ProposeConsensusMessage
&
msg
)
{
// 1. Execute
// 2. Add to record as tentative with result
// 3. Return Reply
}
void
IRReplica
::
HandleFinalizeConsensus
(
const
TransportAddress
&
remote
,
const
FinalizeConsensusMessage
&
msg
)
{
// 1. Mark as finalized with result
// 2. Return Confirm
}
void
HandleUnlogged
(
const
TransportAddress
&
remote
,
const
UnloggedRequestMessage
&
msg
)
{
// 1. Execute
}
This diff is collapsed.
Click to expand it.
replication/ir/replica.h
0 → 100644
+
73
−
0
View file @
140c4b92
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
// vim: set ts=4 sw=4:
/***********************************************************************
*
* replication/ir/replica.h:
* IR Replica server
*
**********************************************************************/
#ifndef _IR_REPLICA_H_
#define _IR_REPLICA_H_
#include
"lib/assert.h"
#include
"lib/message.h"
#include
"lib/udptransport.h"
#include
"lib/configuration.h"
namespace
ir
{
class
AppReplica
{
public:
AppReplica
()
{
};
virtual
~
AppReplica
()
{
};
// Invoke inconsistent operation, no return value
virtual
void
ExecInconsistentUpcall
(
const
string
&
str1
);
// Invoke consensus operation
virtual
void
ReplicaUpcall
(
const
string
&
str1
,
string
&
str2
)
{
};
// Invoke call back for unreplicated operations run on only one replica
virtual
void
UnloggedUpcall
(
const
string
&
str1
,
string
&
str2
)
{
};
};
class
IRReplica
:
TransportReceiver
{
private:
view_t
view
;
// Index of 'this' replica, and handle to transport layer.
int
myIdx
;
Transport
*
transport
;
public:
IRReplica
(
const
specpaxos
::
Configuration
&
configuration
,
int
myIdx
,
Transport
*
transport
);
~
IRReplica
();
void
ReceiveMessage
(
const
TransportAddress
&
remote
,
const
std
::
string
&
type
,
const
std
::
string
&
data
);
void
HandleMessage
(
const
TransportAddress
&
remote
,
const
std
::
string
&
type
,
const
std
::
string
&
data
);
void
HandleProposeInconsistent
(
const
TransportAddress
&
remote
,
const
proto
::
ProposeInconsistentMessage
&
msg
);
void
HandleFinalizeInconsistent
(
const
TransportAddress
&
remote
,
const
proto
::
FinalizeInconsistentMessage
&
msg
);
void
HandleProposeConsensus
(
const
TransportAddress
&
remote
,
const
proto
::
ProposeConsensusMessage
&
msg
);
void
HandleFinalizeConsensus
(
const
TransportAddress
&
remote
,
const
proto
::
FinalizeConsensusMessage
&
msg
);
void
HandleUnlogged
(
const
TransportAddress
&
remote
,
const
proto
::
UnloggedRequestMessage
&
msg
);
void
Load
(
const
std
::
string
&
key
,
const
std
::
string
&
value
,
const
Timestamp
&
timestamp
);
};
}
// namespace ir
#endif
/* _IR_REPLICA_H_ */
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