edits
[iotcloud.git] / version2 / src / C / PendingTransaction.h
1 #ifndef PENDINGTRANSACTION_H
2 #define PENDINGTRANSACTION_H
3
4 #include "common.h"
5
6 class PendingTransaction {
7 private:
8         Hashset<KeyValue *> *keyValueUpdateSet;
9         Hashset<KeyValue *> *keyValueGuardSet;
10         int64_t arbitrator;
11         int64_t clientLocalSequenceNumber;
12         int64_t machineId;
13         int32_t currentDataSize;
14
15 public:
16         PendingTransaction(int64_t _machineId);
17         /**
18          * Add a new key value to the updates
19          *
20          */
21         void addKV(KeyValue * newKV);
22         /**
23          * Add a new key value to the guard set
24          *
25          */
26         void addKVGuard(KeyValue * newKV);
27         /**
28          * Checks if the arbitrator is the same
29          */
30         bool checkArbitrator(int64_t arb);
31         /**
32          * Get the transaction arbitrator
33          */
34         int64_t getArbitrator();
35         /**
36          * Get the key value update set
37          */
38         Hashset<KeyValue *> *getKVUpdates() { return keyValueUpdateSet; }
39
40         /**
41          * Get the key value update set
42          */
43         Hashset<KeyValue *> *getKVGuard() { return keyValueGuardSet; }
44
45         void setClientLocalSequenceNumber(int64_t _clientLocalSequenceNumber) { clientLocalSequenceNumber = _clientLocalSequenceNumber; }
46
47         int64_t getClientLocalSequenceNumber() { return clientLocalSequenceNumber; }
48
49         int64_t getMachineId() { return machineId; }
50
51         bool evaluateGuard(Hashtable<IoTString *, KeyValue *> * keyValTableCommitted, Hashtable<IoTString *, KeyValue *> * keyValTableSpeculative, Hashtable<IoTString *, KeyValue *> * keyValTablePendingTransSpeculative);
52
53         Transaction *createTransaction();
54
55         Array<char> *convertDataToBytes();
56 };
57 #endif