edits
authorbdemsky <bdemsky@uci.edu>
Tue, 6 Mar 2018 19:13:56 +0000 (11:13 -0800)
committerbdemsky <bdemsky@uci.edu>
Tue, 6 Mar 2018 19:13:56 +0000 (11:13 -0800)
13 files changed:
version2/src/C/ArbitrationRound.cc
version2/src/C/CloudComm.cc
version2/src/C/CloudComm.h
version2/src/C/Commit.cc
version2/src/C/Commit.h
version2/src/C/Error.h
version2/src/C/KeyValue.h
version2/src/C/Makefile
version2/src/C/NewKey.cc
version2/src/C/PendingTransaction.h
version2/src/C/Table.cc
version2/src/C/Table.h
version2/src/C/vector.h

index 3ddf5cb49852141d216a3f6783cf70dfdabd3e4a..f038fa24b7cc17d0861e70feb492c1e372025655 100644 (file)
@@ -22,10 +22,34 @@ ArbitrationRound::~ArbitrationRound() {
        delete parts;
 }
 
        delete parts;
 }
 
+void ArbitrationRound::generateParts() {
+       if (didGenerateParts) {
+               return;
+       }
+       parts = new Vector<Entry *>();
+       SetIterator<Abort *, Abort *> * abit = abortsBefore->iterator();
+       while(abit->hasNext())
+               parts->add((Entry *)abit->next());
+       delete abit;
+       if (commit != NULL) {
+               Vector<CommitPart *> * cParts = commit->getParts();
+               uint cPartsSize = cParts->size();
+               for(uint i=0; i < cPartsSize; i++) {
+                       parts->add((Entry *)cParts->get(i));
+               }
+       }
+}
+
 Vector<Entry *> *ArbitrationRound::getParts() {
        return parts;
 }
 
 Vector<Entry *> *ArbitrationRound::getParts() {
        return parts;
 }
 
+void ArbitrationRound::removeParts(Vector<Entry *> *removeParts) {
+       parts->removeAll(removeParts);
+       didSendPart = true;
+}
+
+
 bool ArbitrationRound::isDoneSending() {
        if ((commit == NULL) && abortsBefore->isEmpty()) {
                return true;
 bool ArbitrationRound::isDoneSending() {
        if ((commit == NULL) && abortsBefore->isEmpty()) {
                return true;
index 9055d8624c0e2708decad944755a829c94681438..224018ba63671f23f6632264f37998d367df769a 100644 (file)
@@ -55,12 +55,20 @@ CloudComm::CloudComm(Table *_table,  IoTString *_baseurl, IoTString *_password,
        table(_table),
        listeningPort(_listeningPort),
        doEnd(false),
        table(_table),
        listeningPort(_listeningPort),
        doEnd(false),
-       timer(TimingSingleton_getInstance()) {
+       timer(TimingSingleton_getInstance()),
+       getslot(new Array<char>("getslot", 7)),
+       putslot(new Array<char>("putslot", 7)) {
        if (listeningPort > 0) {
                pthread_create(&localServerThread, NULL, threadWrapper, this);
        }
 }
 
        if (listeningPort > 0) {
                pthread_create(&localServerThread, NULL, threadWrapper, this);
        }
 }
 
+CloudComm::~CloudComm() {
+       delete random;
+       delete getslot;
+       delete putslot;
+}
+
 /**
  * Generates Key from password.
  */
 /**
  * Generates Key from password.
  */
index 728025c50cc98985b7eb3894bc0b90c8860680fd..daa7989f14a7b5399c010a9a20fc77d92f28b8b3 100644 (file)
@@ -67,7 +67,8 @@ public:
         * Constructor for actual use. Takes in the url and password.
         */
        CloudComm(Table *_table,  IoTString *_baseurl, IoTString *_password, int _listeningPort);
         * Constructor for actual use. Takes in the url and password.
         */
        CloudComm(Table *_table,  IoTString *_baseurl, IoTString *_password, int _listeningPort);
-
+       ~CloudComm();
+       
        /**
         * Inits all the security stuff
         */
        /**
         * Inits all the security stuff
         */
index cb707e2fe67c0cf6db8f65b0a159667b494eedaf..5ed8c8902e0ba2fab1735dad0baf5e9e7d5edd88 100644 (file)
@@ -9,7 +9,7 @@ Commit::Commit() :
        missingParts(NULL),
        fldisComplete(false),
        hasLastPart(false),
        missingParts(NULL),
        fldisComplete(false),
        hasLastPart(false),
-       keyValueUpdateSet(new Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue>()),
+       keyValueUpdateSet(new Hashset<KeyValue *, uintptr_t, 0>()),
        isDead(false),
        sequenceNumber(-1),
        machineId(-1),
        isDead(false),
        sequenceNumber(-1),
        machineId(-1),
@@ -23,7 +23,7 @@ Commit::Commit(int64_t _sequenceNumber, int64_t _machineId, int64_t _transaction
        missingParts(NULL),
        fldisComplete(true),
        hasLastPart(false),
        missingParts(NULL),
        fldisComplete(true),
        hasLastPart(false),
-       keyValueUpdateSet(new Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue>()),
+       keyValueUpdateSet(new Hashset<KeyValue *, uintptr_t, 0>()),
        isDead(false),
        sequenceNumber(_sequenceNumber),
        machineId(_machineId),
        isDead(false),
        sequenceNumber(_sequenceNumber),
        machineId(_machineId),
@@ -103,7 +103,7 @@ void Commit::invalidateKey(IoTString *key) {
        }
 }
 
        }
 }
 
-Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *Commit::getKeyValueUpdateSet() {
+Hashset<KeyValue *, uintptr_t, 0> *Commit::getKeyValueUpdateSet() {
        return keyValueUpdateSet;
 }
 
        return keyValueUpdateSet;
 }
 
@@ -198,7 +198,7 @@ void Commit::decodeCommitData() {
 Array<char> *Commit::convertDataToBytes() {
        // Calculate the size of the data
        int sizeOfData = sizeof(int32_t);       // Number of Update KV's
 Array<char> *Commit::convertDataToBytes() {
        // Calculate the size of the data
        int sizeOfData = sizeof(int32_t);       // Number of Update KV's
-       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = keyValueUpdateSet->iterator();
+       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = keyValueUpdateSet->iterator();
        while (kvit->hasNext()) {
                KeyValue *kv = kvit->next();
                sizeOfData += kv->getSize();
        while (kvit->hasNext()) {
                KeyValue *kv = kvit->next();
                sizeOfData += kv->getSize();
@@ -223,11 +223,11 @@ Array<char> *Commit::convertDataToBytes() {
        return bbEncode->array();
 }
 
        return bbEncode->array();
 }
 
-void Commit::setKVsMap(Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *newKVs) {
+void Commit::setKVsMap(Hashset<KeyValue *, uintptr_t, 0> *newKVs) {
        keyValueUpdateSet->clear();
        keyValueUpdateSet->addAll(newKVs);
        liveKeys->clear();
        keyValueUpdateSet->clear();
        keyValueUpdateSet->addAll(newKVs);
        liveKeys->clear();
-       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = newKVs->iterator();
+       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = newKVs->iterator();
        while (kvit->hasNext()) {
                liveKeys->add(kvit->next()->getKey());
        }
        while (kvit->hasNext()) {
                liveKeys->add(kvit->next()->getKey());
        }
@@ -240,8 +240,8 @@ Commit *Commit_merge(Commit *newer, Commit *older, int64_t newSequenceNumber) {
        } else if (newer == NULL) {
                return older;
        }
        } else if (newer == NULL) {
                return older;
        }
-       Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvSet = new Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue>();
-       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = older->getKeyValueUpdateSet()->iterator();
+       Hashset<KeyValue *, uintptr_t, 0> *kvSet = new Hashset<KeyValue *, uintptr_t, 0>();
+       SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = older->getKeyValueUpdateSet()->iterator();
        while (kvit->hasNext()) {
                KeyValue *kv = kvit->next();
                kvSet->add(kv);
        while (kvit->hasNext()) {
                KeyValue *kv = kvit->next();
                kvSet->add(kv);
index 8084eb7867df037207cdbd9d8677e46afc166173..1c48250192e28817150bb10ee1a3caaad3e46e24 100644 (file)
@@ -10,14 +10,14 @@ private:
        Hashset<int32_t> *missingParts;
        bool fldisComplete;
        bool hasLastPart;
        Hashset<int32_t> *missingParts;
        bool fldisComplete;
        bool hasLastPart;
-       Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *keyValueUpdateSet;
+       Hashset<KeyValue *, uintptr_t, 0> *keyValueUpdateSet;
        bool isDead;
        int64_t sequenceNumber;
        int64_t machineId;
        int64_t transactionSequenceNumber;
        Hashset<IoTString *> *liveKeys;
        Array<char> *convertDataToBytes();
        bool isDead;
        int64_t sequenceNumber;
        int64_t machineId;
        int64_t transactionSequenceNumber;
        Hashset<IoTString *> *liveKeys;
        Array<char> *convertDataToBytes();
-       void setKVsMap(Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *newKVs);
+       void setKVsMap(Hashset<KeyValue *, uintptr_t, 0> *newKVs);
 
 public:
        Commit();
 
 public:
        Commit();
@@ -28,7 +28,7 @@ public:
        Vector<CommitPart *> *getParts();
        void addKV(KeyValue *kv);
        void invalidateKey(IoTString *key);
        Vector<CommitPart *> *getParts();
        void addKV(KeyValue *kv);
        void invalidateKey(IoTString *key);
-       Hashset<KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *getKeyValueUpdateSet();
+       Hashset<KeyValue *, uintptr_t, 0> *getKeyValueUpdateSet();
        int32_t getNumberOfParts();
        int64_t getMachineId() { return machineId; }
        bool isComplete() { return fldisComplete; }
        int32_t getNumberOfParts();
        int64_t getMachineId() { return machineId; }
        bool isComplete() { return fldisComplete; }
index ff8eb8de7ddefc0ce2ccf39b88727ac325357c95..44e2845bb69fc0d2badddda559491d35d56696f2 100644 (file)
@@ -20,9 +20,9 @@ public:
 #define ServerException_TypeSalt 3
 
 class ServerException {
 #define ServerException_TypeSalt 3
 
 class ServerException {
-public:
-       ServerException(const char *msg, char _type) : type(_type) {}
-       char getType();
        char type;
        char type;
+ public:
+  ServerException(const char *msg, char _type) : type(_type) {}
+       char getType() {return type;}
 };
 #endif
 };
 #endif
index 9234b2dfbcc98a4a295d39670607c05015f58ac8..06f514b577e096bc59692b9b406a20c3159419d4 100644 (file)
@@ -28,6 +28,4 @@ public:
 };
 
 KeyValue *KeyValue_decode(ByteBuffer *bb);
 };
 
 KeyValue *KeyValue_decode(ByteBuffer *bb);
-unsigned int hashKeyValue(KeyValue *kv);
-bool equalsKeyValue(KeyValue *a, KeyValue *b);
 #endif
 #endif
index 495cc70c5141fe27f4d134a28dbd94a6348c7098..11ac1cbf0852add5637d3594fea71fc10ba582d1 100644 (file)
@@ -10,7 +10,7 @@ HEADERS := $(wildcard *.h)
 
 OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
 
 
 OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
 
-CFLAGS := -Wall -O3 -g
+CFLAGS := -Wall -O0 -g
 CFLAGS += -I.
 LDFLAGS := -ldl -lrt -rdynamic -g
 SHARED := -shared
 CFLAGS += -I.
 LDFLAGS := -ldl -lrt -rdynamic -g
 SHARED := -shared
index 25798394ec7f37bc752a896e91dacaba8445a031..a302a78d40877bc6c436691520aacb4036e9ba3e 100644 (file)
@@ -12,7 +12,7 @@ NewKey::~NewKey() {
        delete key;
 }
 
        delete key;
 }
 
-Entry *decode(Slot *slot, ByteBuffer *bb) {
+Entry *NewKey_decode(Slot *slot, ByteBuffer *bb) {
        int keylength = bb->getInt();
        Array<char> *key = new Array<char>(keylength);
        bb->get(key);
        int keylength = bb->getInt();
        Array<char> *key = new Array<char>(keylength);
        bb->get(key);
index 3e72fa364579bea3a2ee7f7aa453b4bb3bfa2fa2..96f6f949bddc570defef7243c4f859f54a9d6c9d 100644 (file)
@@ -32,7 +32,7 @@ public:
        /**
         * Get the transaction arbitrator
         */
        /**
         * Get the transaction arbitrator
         */
-       int64_t getArbitrator();
+       int64_t getArbitrator() {return arbitrator;}
        /**
         * Get the key value update set
         */
        /**
         * Get the key value update set
         */
index dce3a8f1969e4e960419b080ffe8ec17595c523a..df6099acdc3c0df093a53366cc749bd360e2126b 100644 (file)
@@ -156,6 +156,40 @@ Table::Table(CloudComm *_cloud, int64_t _localMachineId) :
        init();
 }
 
        init();
 }
 
+Table::~Table() {
+       delete cloud;
+       delete random;
+       delete buffer;
+       // init data structs
+       delete committedKeyValueTable;
+       delete speculatedKeyValueTable;
+       delete pendingTransactionSpeculatedKeyValueTable;
+       delete liveNewKeyTable;
+       delete lastMessageTable;
+       delete rejectedMessageWatchVectorTable;
+       delete arbitratorTable;
+       delete liveAbortTable;
+       delete newTransactionParts;
+       delete newCommitParts;
+       delete lastArbitratedTransactionNumberByArbitratorTable;
+       delete liveTransactionBySequenceNumberTable;
+       delete liveTransactionByTransactionIdTable;
+       delete liveCommitsTable;
+       delete liveCommitsByKeyTable;
+       delete lastCommitSeenSequenceNumberByArbitratorTable;
+       delete rejectedSlotVector;
+       delete pendingTransactionQueue;
+       delete pendingSendArbitrationEntriesToDelete;
+       delete transactionPartsSent;
+       delete outstandingTransactionStatus;
+       delete liveAbortsGeneratedByLocal;
+       delete offlineTransactionsCommittedAndAtServer;
+       delete localCommunicationTable;
+       delete lastTransactionSeenFromMachineFromServer;
+       delete pendingSendArbitrationRounds;
+       delete lastArbitrationDataLocalSequenceNumberSeenFromArbitrator;
+}
+
 /**
  * Init all the stuff needed for for table usage
  */
 /**
  * Init all the stuff needed for for table usage
  */
@@ -2130,7 +2164,7 @@ bool Table::updateCommittedTable() {
                        // have live values for their keys
                        Hashset<Commit *> *commitsToEdit = new Hashset<Commit *>();
                        {
                        // have live values for their keys
                        Hashset<Commit *> *commitsToEdit = new Hashset<Commit *>();
                        {
-                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = commit->getKeyValueUpdateSet()->iterator();
+                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = commit->getKeyValueUpdateSet()->iterator();
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
                                        Commit *commit = liveCommitsByKeyTable->get(kv->getKey());
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
                                        Commit *commit = liveCommitsByKeyTable->get(kv->getKey());
@@ -2150,7 +2184,7 @@ bool Table::updateCommittedTable() {
 
                                        // Update which keys in the old commits are still live
                                        {
 
                                        // Update which keys in the old commits are still live
                                        {
-                                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = commit->getKeyValueUpdateSet()->iterator();
+                                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = commit->getKeyValueUpdateSet()->iterator();
                                                while (kvit->hasNext()) {
                                                        KeyValue *kv = kvit->next();
                                                        previousCommit->invalidateKey(kv->getKey());
                                                while (kvit->hasNext()) {
                                                        KeyValue *kv = kvit->next();
                                                        previousCommit->invalidateKey(kv->getKey());
@@ -2180,7 +2214,7 @@ bool Table::updateCommittedTable() {
 
                        // Update the committed table of keys and which commit is using which key
                        {
 
                        // Update the committed table of keys and which commit is using which key
                        {
-                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = commit->getKeyValueUpdateSet()->iterator();
+                               SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = commit->getKeyValueUpdateSet()->iterator();
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
                                        committedKeyValueTable->put(kv->getKey(), kv);
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
                                        committedKeyValueTable->put(kv->getKey(), kv);
index a8a759dfe1e94b98ffe507c63cbee34f53a0b3ea..d3d22d7e5032d07aca0906f35209214cb4425f36 100644 (file)
@@ -239,7 +239,8 @@ private:
 public:
        Table(IoTString *baseurl, IoTString *password, int64_t _localMachineId, int listeningPort);
        Table(CloudComm *_cloud, int64_t _localMachineId);
 public:
        Table(IoTString *baseurl, IoTString *password, int64_t _localMachineId, int listeningPort);
        Table(CloudComm *_cloud, int64_t _localMachineId);
-
+       ~Table();
+       
        /**
         * Initialize the table by inserting a table status as the first entry into the table status
         * also initialize the crypto stuff.
        /**
         * Initialize the table by inserting a table status as the first entry into the table status
         * also initialize the crypto stuff.
index 438b2361522308cf661884a1cbed2f3c818ff17f..4c4a7e5cb1a2cd3807b5fd757172cbc01a8152ef 100644 (file)
@@ -71,6 +71,12 @@ public:
                memcpy(&array[fldsize], v->array, v->fldsize * sizeof(type));
        }
 
                memcpy(&array[fldsize], v->array, v->fldsize * sizeof(type));
        }
 
+       void removeAll(Vector<type> *v) {
+               uint vsize = v->size();
+               for(uint i = 0; i < vsize; i++)
+                       remove(v->get(i));
+       }
+
        void add(type item) {
                if (fldsize >= capacity) {
                        uint newcap = capacity << 1;
        void add(type item) {
                if (fldsize >= capacity) {
                        uint newcap = capacity << 1;