From 0bce26cce6c8768d0f5147bddf66b950d7791e76 Mon Sep 17 00:00:00 2001 From: Irene Y Zhang <iyzhang@cs.washington.edu> Date: Thu, 25 Jun 2015 17:07:44 -0700 Subject: [PATCH] adding transactional store interface --- store/txnstore/lib/txnstore.cc | 71 ++++++++++++++++++++++++++++++++++ store/txnstore/lib/txnstore.h | 63 ++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 store/txnstore/lib/txnstore.cc create mode 100644 store/txnstore/lib/txnstore.h diff --git a/store/txnstore/lib/txnstore.cc b/store/txnstore/lib/txnstore.cc new file mode 100644 index 0000000..54b0a66 --- /dev/null +++ b/store/txnstore/lib/txnstore.cc @@ -0,0 +1,71 @@ +// -*- 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 ×tamp, + 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 ×tamp, 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 ×tamp) +{ + Panic("Unimplemented LOAD"); +} diff --git a/store/txnstore/lib/txnstore.h b/store/txnstore/lib/txnstore.h new file mode 100644 index 0000000..d46a9e0 --- /dev/null +++ b/store/txnstore/lib/txnstore.h @@ -0,0 +1,63 @@ +// -*- 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 ×tamp, 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 ×tamp, 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 ×tamp); +}; + +#endif /* _TXN_STORE_H_ */ -- GitLab