abortId(new Pair<int64_t, int64_t>(transactionMachineId, transactionClientLocalSequenceNumber)) {
}
-Entry *Abortdecode(Slot *slot, ByteBuffer *bb) {
+Entry *Abort_decode(Slot *slot, ByteBuffer *bb) {
int64_t transactionClientLocalSequenceNumber = bb->getLong();
int64_t transactionSequenceNumber = bb->getLong();
int64_t sequenceNumber = bb->getLong();
Entry *getCopy(Slot *s) { return new Abort(s, transactionClientLocalSequenceNumber, transactionSequenceNumber, sequenceNumber, transactionMachineId, transactionArbitrator, arbitratorLocalSequenceNumber); }
};
-Entry *Abortdecode(Slot *slot, ByteBuffer *bb);
+Entry *Abort_decode(Slot *slot, ByteBuffer *bb);
#endif
void put(char c);
void putLong(int64_t l);
int64_t getLong();
+ char get();
private:
};
#endif
sequenceNumber(_sequenceNumber),
transactionSequenceNumber(_transactionSequenceNumber),
partNumber(_partNumber),
- isLastPart(_isLastPart),
+ fldisLastPart(_isLastPart),
data(_data),
partId(new Pair<int64_t int32_t>(sequenceNumber, partNumber)),
commitId(new Pair<int64_t, int64_t>(machineId, sequenceNumber)) {
}
bool CommitPart::isLastPart() {
- return isLastPart;
+ return fldisLastPart;
}
int64_t CommitPart::getMachineId() {
bb->putInt(partNumber);
bb->putInt(data.length);
- if (isLastPart) {
+ if (fldisLastPart) {
bb->put((char)1);
} else {
bb->put((char)0);
}
Entry *CommitPart::getCopy(Slot *s) {
- return new CommitPart(s, machineId, sequenceNumber, transactionSequenceNumber, partNumber, data, isLastPart);
+ return new CommitPart(s, machineId, sequenceNumber, transactionSequenceNumber, partNumber, data, fldisLastPart);
}
int64_t sequenceNumber; // commit sequence number for this arbitrator
int64_t transactionSequenceNumber;
int32_t partNumber; // Parts position in the
- bool isLastPart;
+ bool fldisLastPart;
Array<char> *data;
- Pair<int64_t int32_t> *partId;
+ Pair<int64_t, int32_t> *partId;
Pair<int64_t, int64_t> *commitId;
public:
int getPartNumber();
int getDataSize();
Array<char> *getData();
- Pair<int64_t int32_t> *getPartId();
+ Pair<int64_t, int32_t> *getPartId();
Pair<int64_t, int64_t> *getCommitId();
bool isLastPart();
int64_t getMachineId();
#include "Entry.h"
-
+#include "Slot.h"
+#include "ByteBuffer.h"
+#include "Abort.h"
+#include "CommitPart.h"
+#include "NewKey.h"
+#include "LastMessage.h"
+#include "RejectedMessage.h"
+#include "TableStatus.h"
+#include "TransactionPart.h"
/**
* Generic class that wraps all the different types of information
* that can be stored in a Slot.
case TypeRejectedMessage:
return RejectedMessage_decode(slot, bb);
-
case TypeTableStatus:
return TableStatus_decode(slot, bb);
*/
#include "Liveness.h"
+#include "common.h"
#define TypeCommitPart 1
#define TypeAbort 2
#include "LocalComm.h"
-Array<char> *LocalComm::sendDataToLocalDevice(int64_t deviceId, Array<char> *data) throws InterruptedException {
+Array<char> *LocalComm::sendDataToLocalDevice(int64_t deviceId, Array<char> *data) {
printf("Passing Locally\n");
if (deviceId == t1->getMachineId()) {
Entry *NewKey_decode(Slot *slot, ByteBuffer *bb);
+#endif
bool getEqual() { return equalto; }
int64_t getMachineID() { return machineid; }
int64_t getSequenceNumber() { return sequencenum; }
- void setWatchSet(HashSet<int64_t> *_watchset) { watchset = _watchset; }
+ void setWatchSet(Hashset<int64_t> *_watchset) { watchset = _watchset; }
void removeWatcher(int64_t machineid);
void encode(ByteBuffer *bb);
int getSize() { return 4 * sizeof(int64_t) + 2 * sizeof(char); }
};
Entry *RejectedMessage_decode(Slot *slot, ByteBuffer *bb);
-#ifndef
+#endif
* Initialize the table by inserting a table status as the first entry into the table status
* also initialize the crypto stuff.
*/
-synchronized void Table::initTable() throws ServerException {
+synchronized void Table::initTable() {
cloud.initSecurity();
// Create the first insertion into the block chain which is the table status
/**
* Rebuild the table from scratch by pulling the latest block chain from the server.
*/
-synchronized void Table::rebuild() throws ServerException {
+synchronized void Table::rebuild() {
// Just pull the latest slots from the server
Slot[] newslots = cloud.getSlots(sequenceNumber + 1);
validateAndUpdate(newslots, true);
return false;
}
-synchronized bool Table::createNewKey(IoTString keyName, int64_t machineId) throws ServerException {
+synchronized bool Table::createNewKey(IoTString keyName, int64_t machineId) {
while (true) {
if (arbitratorTable.get(keyName) != NULL) {
// There is already an arbitrator
bool lastInsertedNewKey = false;
-bool Table::sendToServer(NewKey newKey) throws ServerException {
+bool Table::sendToServer(NewKey newKey) {
bool fromRetry = false;
return returnData;
}
-ThreeTuple<bool, bool, Slot[]> Table::sendSlotsToServer(Slot slot, int newSize, bool isNewKey) throws ServerException {
-
+ThreeTuple<bool, bool, Slot[]> Table::sendSlotsToServer(Slot slot, int newSize, bool isNewKey) {
bool attemptedToSendToServerTmp = attemptedToSendToServer;
attemptedToSendToServer = true;
class TransactionPart : public Entry {
private:
- int64_t sequenceNumber = -1;
- int64_t machineId = -1;
- int64_t arbitratorId = -1;
- int64_t clientLocalSequenceNumber = -1; // Sequence number of the transaction that this is a part of
- int partNumber = -1; // Parts position in the
- bool isLastPart = false;
+ int64_t sequenceNumber;
+ int64_t machineId;
+ int64_t arbitratorId;
+ int64_t clientLocalSequenceNumber; // Sequence number of the transaction that this is a part of
+ int partNumber; // Parts position in the
+ bool fldisLastPart;
- Pair<int64_t, int64_t> *transactionId = NULL;
- Pair<int64_t int32_t> *partId = NULL;
+ Pair<int64_t, int64_t> *transactionId;
+ Pair<int64_t, int32_t> *partId;
- Array<char> *data = NULL;
+ Array<char> *data;
public:
TransactionPart(Slot *s, int64_t _machineId, int64_t _arbitratorId, int64_t _clientLocalSequenceNumber, int _partNumber, Array<char> *_data, bool _isLastPart) : Entry(s),
arbitratorId(_arbitratorId),
clientLocalSequenceNumber(_clientLocalSequenceNumber),
partNumber(_partNumber),
- isLastPart(_isLastPart)
+ fldisLastPart(_isLastPart),
transactionId(new Pair<int64_t, int64_t>(machineId, clientLocalSequenceNumber)),
- partId(new Pair<int64_t int32_t>(clientLocalSequenceNumber, partNumber)),
+ partId(new Pair<int64_t, int32_t>(clientLocalSequenceNumber, partNumber)),
data(_data) {
}
void setSlot(Slot s);
Pair<int64_t, int64_t> *getTransactionId();
int64_t getArbitratorId();
- Pair<int64_t int32_t> *getPartId();
+ Pair<int64_t, int32_t> *getPartId();
int getPartNumber();
int getDataSize();
Array<char> *getData();
class TransactionPart;
class TransactionStatus;
+#define ASSERT(expr) \
+ do { \
+ if (!(expr)) { \
+ fprintf(stderr, "Error: assertion failed in %s at line %d\n", __FILE__, __LINE__); \
+ /* print_trace(); // Trace printing may cause dynamic memory allocation */ \
+ exit(EXIT_FAILURE); \
+ } \
+ } while (0)
+
#endif