Skip to content
Snippets Groups Projects
Commit 140c4b92 authored by Irene Y Zhang's avatar Irene Y Zhang
Browse files

adding IR replica stubs

parent 2fc28029
No related branches found
No related tags found
No related merge requests found
// -*- 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
}
// -*- 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_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment