edits
authorbdemsky <bdemsky@uci.edu>
Fri, 19 Jan 2018 07:08:41 +0000 (23:08 -0800)
committerbdemsky <bdemsky@uci.edu>
Fri, 19 Jan 2018 07:08:41 +0000 (23:08 -0800)
13 files changed:
version2/src/C/Abort.cc
version2/src/C/Abort.h
version2/src/C/ByteBuffer.h
version2/src/C/CommitPart.cc
version2/src/C/CommitPart.h
version2/src/C/Entry.cc
version2/src/C/Entry.h
version2/src/C/LocalComm.cc
version2/src/C/NewKey.h
version2/src/C/RejectedMessage.h
version2/src/C/Table.cc
version2/src/C/TransactionPart.h
version2/src/C/common.h

index bd0c6a2..77e1653 100644 (file)
@@ -22,7 +22,7 @@ Abort::Abort(Slot *slot, int64_t _transactionClientLocalSequenceNumber, int64_t
        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();
index ad54c4f..4a420d1 100644 (file)
@@ -35,5 +35,5 @@ public:
        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
index ec98caf..92d4f16 100644 (file)
@@ -7,6 +7,7 @@ public:
        void put(char c);
        void putLong(int64_t l);
        int64_t getLong();
+       char get();
 private:
 };
 #endif
index fd560d9..08cd46b 100644 (file)
@@ -7,7 +7,7 @@ CommitPart::CommitPart(Slot *s, int64_t _machineId, int64_t _sequenceNumber, int
        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)) {
@@ -45,7 +45,7 @@ Pair<int64_t, int64_t> *CommitPart::getCommitId() {
 }
 
 bool CommitPart::isLastPart() {
-       return isLastPart;
+       return fldisLastPart;
 }
 
 int64_t CommitPart::getMachineId() {
@@ -83,7 +83,7 @@ void CommitPart::encode(ByteBuffer bb) {
        bb->putInt(partNumber);
        bb->putInt(data.length);
 
-       if (isLastPart) {
+       if (fldisLastPart) {
                bb->put((char)1);
        } else {
                bb->put((char)0);
@@ -97,5 +97,5 @@ char CommitPart::getType() {
 }
 
 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);
 }
index 6d17998..19e8b7a 100644 (file)
@@ -13,10 +13,10 @@ private:
        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:
@@ -26,7 +26,7 @@ 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();
index 7d0a039..538a686 100644 (file)
@@ -1,5 +1,13 @@
 #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.
@@ -28,7 +36,6 @@ Entry *Entry_decode(Slot *slot, ByteBuffer *bb) {
 
        case TypeRejectedMessage:
                return RejectedMessage_decode(slot, bb);
-
        case TypeTableStatus:
                return TableStatus_decode(slot, bb);
 
index 1ec48b1..363b771 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "Liveness.h"
+#include "common.h"
 
 #define TypeCommitPart 1
 #define TypeAbort 2
index 18ba37f..9640277 100644 (file)
@@ -1,5 +1,5 @@
 #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()) {
index 019d66c..74b9dbc 100644 (file)
@@ -35,3 +35,4 @@ public:
 
 Entry *NewKey_decode(Slot *slot, ByteBuffer *bb);
 
+#endif
index 5259f68..86a005e 100644 (file)
@@ -39,7 +39,7 @@ private:
        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); }
@@ -50,4 +50,4 @@ private:
 };
 
 Entry *RejectedMessage_decode(Slot *slot, ByteBuffer *bb);
-#ifndef
+#endif
index de0a1da..1148e93 100644 (file)
@@ -144,7 +144,7 @@ synchronized void Table::printSlots() {
  * 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
@@ -169,7 +169,7 @@ synchronized void Table::initTable() throws ServerException {
 /**
  * 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);
@@ -305,7 +305,7 @@ synchronized bool Table::update()  {
        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
@@ -436,7 +436,7 @@ int64_t Table::getLocalSequenceNumber() {
 
 bool lastInsertedNewKey = false;
 
-bool Table::sendToServer(NewKey newKey) throws ServerException {
+bool Table::sendToServer(NewKey newKey) {
 
        bool fromRetry = false;
 
@@ -1061,8 +1061,7 @@ synchronized Array<char> *Table::acceptDataFromLocal(Array<char> *data) {
        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;
 
index d00a01a..84aa1b4 100644 (file)
@@ -8,17 +8,17 @@
 
 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),
@@ -27,9 +27,9 @@ public:
                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) {
        }
 
@@ -37,7 +37,7 @@ public:
        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();
index f23a526..afa511f 100644 (file)
@@ -37,4 +37,13 @@ class Transaction;
 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