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

adding transactional store interface

parent 7876252a
No related branches found
No related tags found
No related merge requests found
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
// vim: set ts=4 sw=4:
/***********************************************************************
*
* common/txnstore.cc:
* Interface for a single node transactional store serving as a
* server-side backend
*
**********************************************************************/
#include "common/txnstore.h"
using namespace std;
TxnStore::TxnStore() {}
TxnStore::~TxnStore() {}
int
TxnStore::Get(uint64_t id, const string &key, pair<Timestamp, string> &value)
{
Panic("Unimplemented GET");
return 0;
}
int
TxnStore::Get(uint64_t id, const string &key, const Timestamp &timestamp,
pair<Timestamp, string> &value)
{
Panic("Unimplemented GET");
return 0;
}
int
TxnStore::Put(uint64_t id, const string &key, const string &value)
{
Panic("Unimplemented PUT");
return 0;
}
int
TxnStore::Prepare(uint64_t id, const Transaction &txn)
{
Panic("Unimplemented PREPARE");
return 0;
}
int
TxnStore::Prepare(uint64_t id, const Transaction &txn,
const Timestamp &timestamp, Timestamp &proposed)
{
Panic("Unimplemented PREPARE");
return 0;
}
void
TxnStore::Commit(uint64_t id, uint64_t timestamp)
{
Panic("Unimplemented COMMIT");
}
void
TxnStore::Abort(uint64_t id, const Transaction &txn)
{
Panic("Unimplemented ABORT");
}
void
TxnStore::Load(const string &key, const string &value, const Timestamp &timestamp)
{
Panic("Unimplemented LOAD");
}
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
// vim: set ts=4 sw=4:
/***********************************************************************
*
* common/txnstore.h:
* Interface for a single node transactional store serving as a
* server-side backend
*
**********************************************************************/
#ifndef _TXN_STORE_H_
#define _TXN_STORE_H_
#include "paxos-lib/lib/assert.h"
#include "paxos-lib/lib/message.h"
#include "common/transaction.h"
#include "common/timestamp.h"
// Reply types
#define REPLY_OK 0
#define REPLY_FAIL 1
#define REPLY_RETRY 2
#define REPLY_ABSTAIN 3
#define REPLY_TIMEOUT 4
#define REPLY_NETWORK_FAILURE 5
#define REPLY_MAX 6
class TxnStore
{
public:
TxnStore();
virtual ~TxnStore();
// add key to read set
virtual int Get(uint64_t id, const std::string &key,
std::pair<Timestamp, std::string> &value);
virtual int Get(uint64_t id, const std::string &key,
const Timestamp &timestamp, std::pair<Timestamp, std::string> &value);
// add key to write set
virtual int Put(uint64_t id, const std::string &key,
const std::string &value);
// check whether we can commit this transaction (and lock the read/write set)
virtual int Prepare(uint64_t id, const Transaction &txn);
virtual int Prepare(uint64_t id, const Transaction &txn,
const Timestamp &timestamp, Timestamp &proposed);
// commit the transaction
virtual void Commit(uint64_t id, uint64_t timestamp = 0);
// abort a running transaction
virtual void Abort(uint64_t id, const Transaction &txn = Transaction());
// load keys
virtual void Load(const std::string &key, const std::string &value,
const Timestamp &timestamp);
};
#endif /* _TXN_STORE_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