Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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_ */