tabbing
authorbdemsky <bdemsky@uci.edu>
Fri, 2 Mar 2018 08:46:35 +0000 (00:46 -0800)
committerbdemsky <bdemsky@uci.edu>
Fri, 2 Mar 2018 08:46:35 +0000 (00:46 -0800)
13 files changed:
version2/src/C/CloudComm.cc
version2/src/C/CloudComm.h
version2/src/C/Crypto.h
version2/src/C/Error.h
version2/src/C/Liveness.h
version2/src/C/Pair.h
version2/src/C/SecureRandom.h
version2/src/C/Table.cc
version2/src/C/Transaction.cc
version2/src/C/Transaction.h
version2/src/C/hashset.h
version2/src/C/hashtable.h
version2/src/C/vector.h

index 4e4000fae9ee310be4836cbb3b83a021ef902005..b91fa4ad45d0542c2eb3fc1bbbccb14ea27a34ee 100644 (file)
@@ -32,7 +32,7 @@ CloudComm::CloudComm() :
 {
 }
 
-void * threadWrapper(void * cloud) {
+void *threadWrapper(void *cloud) {
        CloudComm *c = (CloudComm *) cloud;
        c->localServerWorkerFunction();
        return NULL;
@@ -63,10 +63,10 @@ CloudComm::CloudComm(Table *_table,  IoTString *_baseurl, IoTString *_password,
  */
 AESKey *CloudComm::initKey() {
        try {
-               AESKey * key = new AESKey(password->internalBytes(),
-                                                                                                                       salt,
-                                                                                                                       65536,
-                                                                                                                       128);
+               AESKey *key = new AESKey(password->internalBytes(),
+                                                                                                                salt,
+                                                                                                                65536,
+                                                                                                                128);
                return key;
        } catch (Exception *e) {
                throw new Error("Failed generating key.");
@@ -146,7 +146,7 @@ void readSocketData(int fd, Array<char> *data) {}
 void writeURLData(int fd, Array<char> *data) {
 }
 
-void readURLData(int fd, Array<char> * output) {
+void readURLData(int fd, Array<char> *output) {
 }
 
 int readURLInt(int fd) {
@@ -195,7 +195,7 @@ void CloudComm::setSalt() {
 bool CloudComm::getSalt() {
        int fd = -1;
        IoTString *urlstr = NULL;
-       
+
        try {
                char *buffer = (char *) malloc(baseurl->length() + 100);
                memcpy(buffer, baseurl->internalBytes(), baseurl->length());
@@ -245,11 +245,11 @@ Array<char> *CloudComm::createIV(int64_t machineId, int64_t localSequenceNumber)
        return buffer->array();
 }
 
-Array<char> *AESEncrypt(Array<char> * ivBytes, AESKey * key, Array<char> * data) {
+Array<char> *AESEncrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
        return NULL;
 }
 
-Array<char> *AESDecrypt(Array<char> * ivBytes, AESKey * key, Array<char> * data) {
+Array<char> *AESDecrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
        return NULL;
 }
 
@@ -397,7 +397,7 @@ Array<Slot *> *CloudComm::processSlots(int fd) {
        return slots;
 }
 
-Array<char> *CloudComm::sendLocalData(Array<char> *sendData, int64_t localSequenceNumber, IoTString * host, int port) {
+Array<char> *CloudComm::sendLocalData(Array<char> *sendData, int64_t localSequenceNumber, IoTString *host, int port) {
        if (salt == NULL)
                return NULL;
        try {
index 08fba52939cbc8c7a0e3a9a8271d0367e1563788..728025c50cc98985b7eb3894bc0b90c8860680fd 100644 (file)
@@ -34,7 +34,7 @@ private:
        TimingSingleton *timer;
        Array<char> *getslot;
        Array<char> *putslot;
-       
+
        /**
         * Generates Key from password.
         */
index 40a587fdd4c57aeb5a3f439c6050ff43f5ca5e9d..261e5a63c7cfd1b6c8273510711153930d3d19d0 100644 (file)
@@ -3,10 +3,10 @@
 #include "common.h"
 
 class AESKey {
- public:
-       AESKey(Array<char> * password, Array<char> * salt, int iterationCount, int keyLength);
-       
- private:
+public:
+       AESKey(Array<char> *password, Array<char> *salt, int iterationCount, int keyLength);
+
+private:
 };
 
 #endif
index 4d12c168febdc7d978c48d293c18f9a1903ceb9e..ff8eb8de7ddefc0ce2ccf39b88727ac325357c95 100644 (file)
@@ -6,8 +6,8 @@ public:
 };
 
 class SocketTimeoutException {
- public:
- private:
+public:
+private:
 };
 
 class Exception {
@@ -21,7 +21,7 @@ public:
 
 class ServerException {
 public:
- ServerException(const char *msg, char _type) : type(_type) {}
      ServerException(const char *msg, char _type) : type(_type) {}
        char getType();
        char type;
 };
index 2a5b2047c77c233e65018310c183b886429a8baa..bee230221baac3752646ca361fa84a5ab40e9f0d 100644 (file)
@@ -2,7 +2,7 @@
 #define LIVENESS_H
 
 class Liveness {
- public:
+public:
        /**
         * Returns a char encoding the type of the entry object.
         */
index 81d5ebb3e388d117a0fd16e204362ea9df99a064..1e398231df7eb98a50f1862d5601016926245ae4 100644 (file)
@@ -13,11 +13,11 @@ public:
                b(_b) {
        }
 
Pair(Pair<A, B> * p) :
      Pair(Pair<A, B> *p) :
                a(p->a),
-                       b(p->b) {
-               }
-               
+               b(p->b) {
+       }
+
        A getFirst() {
                return a;
        }
@@ -28,7 +28,7 @@ public:
 };
 
 template<typename A, typename B>
-inline unsigned int pairHashFunction(Pair<A, B> * p) {
+inline unsigned int pairHashFunction(Pair<A, B> *p) {
        return (p->getFirst() << 1) ^ p->getSecond();
 }
 
index 111efa6af1bd17e3eadd670623066dfdde9d8c1f..a62c7e746124da80c7dc139f93afdd2c7a8042ae 100644 (file)
@@ -3,6 +3,6 @@
 class SecureRandom {
 public:
        SecureRandom();
-       void nextBytes(Array<char> * array);
+       void nextBytes(Array<char> *array);
 };
 #endif
index 835b9db7b4e4a44fcd6ee52571af0073fe3f4781..400ecc344bf4e4bed0932d556b7222c1c15cb759 100644 (file)
@@ -21,9 +21,9 @@
 #include "SlotIndexer.h"
 #include <stdlib.h>
 
-int compareInt64(const void * a, const void *b) {
-       const int64_t * pa = (const int64_t *) a;
-       const int64_t * pb = (const int64_t *) b;
+int compareInt64(const void *a, const void *b) {
+       const int64_t *pa = (const int64_t *) a;
+       const int64_t *pb = (const int64_t *) b;
        if (*pa < *pb)
                return -1;
        else if (*pa > *pb)
@@ -604,9 +604,9 @@ bool Table::sendToServer(NewKey *newKey) {
                                        // Process each entry in the slot
                                        Vector<Entry *> *entries = s->getEntries();
                                        uint eSize = entries->size();
-                                       for(uint ei=0; ei < eSize; ei++) {
-                                               Entry * entry = entries->get(ei);
-                                               
+                                       for (uint ei = 0; ei < eSize; ei++) {
+                                               Entry *entry = entries->get(ei);
+
                                                if (entry->getType() == TypeLastMessage) {
                                                        LastMessage *lastMessage = (LastMessage *)entry;
                                                        if ((lastMessage->getMachineID() == localMachineId) && (lastMessage->getSequenceNumber() == lastSlotAttemptedToSend->getSequenceNumber())) {
@@ -846,7 +846,7 @@ bool Table::updateFromLocal(int64_t machineId) {
        if (!localCommunicationTable->contains(machineId))
                return false;
 
-       Pair<IoTString *, int32_t> * localCommunicationInformation = localCommunicationTable->get(machineId);
+       Pair<IoTString *, int32_t> *localCommunicationInformation = localCommunicationTable->get(machineId);
 
        // Get the size of the send data
        int sendDataSize = sizeof(int32_t) + sizeof(int64_t);
@@ -897,16 +897,16 @@ Pair<bool, bool> Table::sendTransactionToLocal(Transaction *transaction) {
        // Get the devices local communications
        if (!localCommunicationTable->contains(transaction->getArbitrator()))
                return Pair<bool, bool>(true, false);
-       
-       Pair<IoTString *, int32_t> * localCommunicationInformation = localCommunicationTable->get(transaction->getArbitrator());
+
+       Pair<IoTString *, int32_t> *localCommunicationInformation = localCommunicationTable->get(transaction->getArbitrator());
 
        // Get the size of the send data
        int sendDataSize = sizeof(int32_t) + sizeof(int64_t);
        {
-               Vector<TransactionPart *> * tParts = transaction->getParts();
+               Vector<TransactionPart *> *tParts = transaction->getParts();
                uint tPartsSize = tParts->size();
                for (uint i = 0; i < tPartsSize; i++) {
-                       TransactionPart * part = tParts->get(i);
+                       TransactionPart *part = tParts->get(i);
                        sendDataSize += part->getSize();
                }
        }
@@ -924,10 +924,10 @@ Pair<bool, bool> Table::sendTransactionToLocal(Transaction *transaction) {
        bbEncode->putLong(lastArbitrationDataLocalSequenceNumber);
        bbEncode->putInt(transaction->getParts()->size());
        {
-               Vector<TransactionPart *> * tParts = transaction->getParts();
+               Vector<TransactionPart *> *tParts = transaction->getParts();
                uint tPartsSize = tParts->size();
                for (uint i = 0; i < tPartsSize; i++) {
-                       TransactionPart * part = tParts->get(i);
+                       TransactionPart *part = tParts->get(i);
                        part->encode(bbEncode);
                }
        }
@@ -967,14 +967,14 @@ Pair<bool, bool> Table::sendTransactionToLocal(Transaction *transaction) {
        updateLiveStateFromLocal();
 
        if (couldArbitrate) {
-               TransactionStatus * status =  transaction->getTransactionStatus();
+               TransactionStatus *status =  transaction->getTransactionStatus();
                if (didCommit) {
                        status->setStatus(TransactionStatus_StatusCommitted);
                } else {
                        status->setStatus(TransactionStatus_StatusAborted);
                }
        } else {
-               TransactionStatus * status =  transaction->getTransactionStatus();
+               TransactionStatus *status =  transaction->getTransactionStatus();
                if (foundAbort) {
                        status->setStatus(TransactionStatus_StatusAborted);
                } else {
@@ -1026,20 +1026,20 @@ Array<char> *Table::acceptDataFromLocal(Array<char> *data) {
        Vector<int64_t> *abortLocalSequenceNumbers = new Vector<int64_t>();
        {
                SetIterator<int64_t, Abort *> *abortit = getKeyIterator(liveAbortsGeneratedByLocal);
-               while(abortit->hasNext())
+               while (abortit->hasNext())
                        abortLocalSequenceNumbers->add(abortit->next());
                delete abortit;
        }
-       
+
        qsort(abortLocalSequenceNumbers->expose(), abortLocalSequenceNumbers->size(), sizeof(int64_t), compareInt64);
 
        uint asize = abortLocalSequenceNumbers->size();
-       for(uint i=0; i<asize; i++) {
+       for (uint i = 0; i < asize; i++) {
                int64_t localSequenceNumber = abortLocalSequenceNumbers->get(i);
                if (localSequenceNumber <= lastArbitratedSequenceNumberSeen) {
                        continue;
                }
-               
+
                Abort *abort = liveAbortsGeneratedByLocal->get(localSequenceNumber);
                unseenArbitrations->add(abort);
                returnDataSize += abort->getSize();
@@ -1051,14 +1051,14 @@ Array<char> *Table::acceptDataFromLocal(Array<char> *data) {
                Vector<int64_t> *commitLocalSequenceNumbers = new Vector<int64_t>();
                {
                        SetIterator<int64_t, Commit *> *commitit = getKeyIterator(commitForClientTable);
-                       while(commitit->hasNext())
+                       while (commitit->hasNext())
                                commitLocalSequenceNumbers->add(commitit->next());
                        delete commitit;
                }
                qsort(commitLocalSequenceNumbers->expose(), commitLocalSequenceNumbers->size(), sizeof(int64_t), compareInt64);
 
                uint clsSize = commitLocalSequenceNumbers->size();
-               for(uint clsi = 0; clsi < clsSize; clsi++) {
+               for (uint clsi = 0; clsi < clsSize; clsi++) {
                        int64_t localSequenceNumber = commitLocalSequenceNumbers->get(clsi);
                        Commit *commit = commitForClientTable->get(localSequenceNumber);
 
@@ -1067,10 +1067,10 @@ Array<char> *Table::acceptDataFromLocal(Array<char> *data) {
                        }
 
                        {
-                               Vector<CommitPart *> * parts = commit->getParts();
+                               Vector<CommitPart *> *parts = commit->getParts();
                                uint nParts = parts->size();
-                               for(uint i=0; i<nParts; i++) {
-                                       CommitPart * commitPart = parts->get(i);
+                               for (uint i = 0; i < nParts; i++) {
+                                       CommitPart *commitPart = parts->get(i);
                                        unseenArbitrations->add(commitPart);
                                        returnDataSize += commitPart->getSize();
                                }
@@ -1154,8 +1154,8 @@ ThreeTuple<bool, bool, Array<Slot *> *> Table::sendSlotsToServer(Slot *slot, int
                                // Process each entry in the slot
                                Vector<Entry *> *entries = s->getEntries();
                                uint eSize = entries->size();
-                               for(uint ei=0; ei < eSize; ei++) {
-                                       Entry * entry = entries->get(ei);
+                               for (uint ei = 0; ei < eSize; ei++) {
+                                       Entry *entry = entries->get(ei);
 
                                        if (entry->getType() == TypeLastMessage) {
                                                LastMessage *lastMessage = (LastMessage *)entry;
@@ -1348,7 +1348,7 @@ ThreeTuple<bool, bool, int64_t> Table::doMandatoryResuce(Slot *slot, bool resize
 
        // Mandatory Rescue
        for (; currentSequenceNumber < threshold; currentSequenceNumber++) {
-               Slot * previousSlot = buffer->getSlot(currentSequenceNumber);
+               Slot *previousSlot = buffer->getSlot(currentSequenceNumber);
                // Push slot number forward
                if (!seenLiveSlot) {
                        oldestLiveSlotSequenceNumver = currentSequenceNumber;
@@ -1366,8 +1366,8 @@ ThreeTuple<bool, bool, int64_t> Table::doMandatoryResuce(Slot *slot, bool resize
 
                // Iterate over all the live entries and try to rescue them
                uint lESize = liveEntries->size();
-               for (uint i=0; i< lESize; i++) {
-                       Entry * liveEntry = liveEntries->get(i);
+               for (uint i = 0; i < lESize; i++) {
+                       Entry *liveEntry = liveEntries->get(i);
                        if (slot->hasSpace(liveEntry)) {
                                // Enough space to rescue the entry
                                slot->addEntry(liveEntry);
@@ -1399,8 +1399,8 @@ void Table::doOptionalRescue(Slot *s, bool seenliveslot, int64_t seqn, bool resi
                seenliveslot = true;
                Vector<Entry *> *liveentries = prevslot->getLiveEntries(resize);
                uint lESize = liveentries->size();
-               for (uint i=0; i< lESize; i++) {
-                       Entry * liveentry = liveentries->get(i);
+               for (uint i = 0; i < lESize; i++) {
+                       Entry *liveentry = liveentries->get(i);
                        if (s->hasSpace(liveentry))
                                s->addEntry(liveentry);
                        else {
@@ -1410,7 +1410,7 @@ void Table::doOptionalRescue(Slot *s, bool seenliveslot, int64_t seqn, bool resi
                        }
                }
        }
- donesearch:
+donesearch:
        ;
 }
 
@@ -1441,8 +1441,8 @@ void Table::validateAndUpdate(Array<Slot *> *newSlots, bool acceptUpdatesToLocal
        // Set to keep track of messages from clients
        Hashset<int64_t> *machineSet = new Hashset<int64_t>();
        {
-               SetIterator<int64_t, Pair<int64_t, Liveness *> *> * lmit=getKeyIterator(lastMessageTable);
-               while(lmit->hasNext())
+               SetIterator<int64_t, Pair<int64_t, Liveness *> *> *lmit = getKeyIterator(lastMessageTable);
+               while (lmit->hasNext())
                        machineSet->add(lmit->next());
                delete lmit;
        }
@@ -1450,7 +1450,7 @@ void Table::validateAndUpdate(Array<Slot *> *newSlots, bool acceptUpdatesToLocal
        // Process each slots data
        {
                uint numSlots = newSlots->length();
-               for(uint i=0; i<numSlots; i++) {
+               for (uint i = 0; i < numSlots; i++) {
                        Slot *slot = newSlots->get(i);
                        processSlot(indexer, slot, acceptUpdatesToLocal, machineSet);
                        updateExpectedSize();
@@ -1479,12 +1479,12 @@ void Table::validateAndUpdate(Array<Slot *> *newSlots, bool acceptUpdatesToLocal
        // Commit new to slots to the local block chain->
        {
                uint numSlots = newSlots->length();
-               for(uint i=0; i<numSlots; i++) {
+               for (uint i = 0; i < numSlots; i++) {
                        Slot *slot = newSlots->get(i);
-                       
+
                        // Insert this slot into our local block chain copy->
                        buffer->putSlot(slot);
-                       
+
                        // Keep track of how many slots are currently live (have live data
                        // in them)->
                        liveSlotCount++;
@@ -1597,15 +1597,15 @@ void Table::processNewTransactionParts() {
 
        // Iterate through all the machine Ids that we received new parts
        // for
-       SetIterator<int64_t, Hashtable<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> * tpit= getKeyIterator(newTransactionParts);
-       while(tpit->hasNext()) {
+       SetIterator<int64_t, Hashtable<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> *tpit = getKeyIterator(newTransactionParts);
+       while (tpit->hasNext()) {
                int64_t machineId = tpit->next();
                Hashtable<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *parts = newTransactionParts->get(machineId);
 
                SetIterator<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *ptit = getKeyIterator(parts);
                // Iterate through all the parts for that machine Id
-               while(ptit->hasNext()) {
-                       Pair<int64_t, int32_t> * partId = ptit->next();
+               while (ptit->hasNext()) {
+                       Pair<int64_t, int32_t> *partId = ptit->next();
                        TransactionPart *part = parts->get(partId);
 
                        if (lastArbitratedTransactionNumberByArbitratorTable->contains(part->getArbitratorId())) {
@@ -1616,7 +1616,7 @@ void Table::processNewTransactionParts() {
                                        continue;
                                }
                        }
-                       
+
                        // Get the transaction object for that sequence number
                        Transaction *transaction = liveTransactionBySequenceNumberTable->get(part->getSequenceNumber());
 
@@ -1650,21 +1650,21 @@ void Table::arbitrateFromServer() {
        // Get the transaction sequence numbers and sort from oldest to newest
        Vector<int64_t> *transactionSequenceNumbers = new Vector<int64_t>();
        {
-               SetIterator<int64_t, Transaction *> * trit = getKeyIterator(liveTransactionBySequenceNumberTable);
-               while(trit->hasNext())
+               SetIterator<int64_t, Transaction *> *trit = getKeyIterator(liveTransactionBySequenceNumberTable);
+               while (trit->hasNext())
                        transactionSequenceNumbers->add(trit->next());
                delete trit;
        }
        qsort(transactionSequenceNumbers->expose(), transactionSequenceNumbers->size(), sizeof(int64_t), compareInt64);
 
        // Collection of key value pairs that are
-       Hashtable<IoTString *, KeyValue *> * speculativeTableTmp = new Hashtable<IoTString *, KeyValue *>();
+       Hashtable<IoTString *, KeyValue *> *speculativeTableTmp = new Hashtable<IoTString *, KeyValue *>();
 
        // The last transaction arbitrated on
        int64_t lastTransactionCommitted = -1;
        Hashset<Abort *> *generatedAborts = new Hashset<Abort *>();
        uint tsnSize = transactionSequenceNumbers->size();
-       for(uint i=0; i<tsnSize; i++) {
+       for (uint i = 0; i < tsnSize; i++) {
                int64_t transactionSequenceNumber = transactionSequenceNumbers->get(i);
                Transaction *transaction = liveTransactionBySequenceNumberTable->get(transactionSequenceNumber);
 
@@ -1711,7 +1711,7 @@ void Table::arbitrateFromServer() {
                                speculativeTableTmp->put(kv->getKey(), kv);
                        }
                        delete kvit;
-                       
+
                        // Update what the last transaction committed was for use in batch commit
                        lastTransactionCommitted = transactionSequenceNumber;
                } else {
@@ -1742,24 +1742,24 @@ void Table::arbitrateFromServer() {
                localArbitrationSequenceNumber++;
 
                // Add all the new keys to the commit
-               SetIterator<IoTString *, KeyValue *> * spit = getKeyIterator(speculativeTableTmp);
-               while(spit->hasNext()) {
-                       IoTString * string = spit->next();
-                       KeyValue * kv = speculativeTableTmp->get(string);
+               SetIterator<IoTString *, KeyValue *> *spit = getKeyIterator(speculativeTableTmp);
+               while (spit->hasNext()) {
+                       IoTString *string = spit->next();
+                       KeyValue *kv = speculativeTableTmp->get(string);
                        newCommit->addKV(kv);
                }
                delete spit;
-               
+
                // create the commit parts
                newCommit->createCommitParts();
 
                // Append all the commit parts to the end of the pending queue
                // waiting for sending to the server
                // Insert the commit so we can process it
-               Vector<CommitPart *> * parts = newCommit->getParts();
+               Vector<CommitPart *> *parts = newCommit->getParts();
                uint partsSize = parts->size();
-               for(uint i=0; i<partsSize; i++) {
-                       CommitPart * commitPart = parts->get(i);
+               for (uint i = 0; i < partsSize; i++) {
+                       CommitPart *commitPart = parts->get(i);
                        processEntry(commitPart);
                }
        }
@@ -1771,10 +1771,10 @@ void Table::arbitrateFromServer() {
                if (compactArbitrationData()) {
                        ArbitrationRound *newArbitrationRound = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - 1);
                        if (newArbitrationRound->getCommit() != NULL) {
-                               Vector<CommitPart *> * parts = newArbitrationRound->getCommit()->getParts();
+                               Vector<CommitPart *> *parts = newArbitrationRound->getCommit()->getParts();
                                uint partsSize = parts->size();
-                               for(uint i=0; i<partsSize; i++) {
-                                       CommitPart * commitPart = parts->get(i);
+                               for (uint i = 0; i < partsSize; i++) {
+                                       CommitPart *commitPart = parts->get(i);
                                        processEntry(commitPart);
                                }
                        }
@@ -1819,7 +1819,7 @@ Pair<bool, bool> Table::arbitrateOnLocalTransaction(Transaction *transaction) {
                        newCommit->addKV(kv);
                }
                delete kvit;
-               
+
                // create the commit parts
                newCommit->createCommitParts();
 
@@ -1830,18 +1830,18 @@ Pair<bool, bool> Table::arbitrateOnLocalTransaction(Transaction *transaction) {
 
                if (compactArbitrationData()) {
                        ArbitrationRound *newArbitrationRound = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - 1);
-                       Vector<CommitPart *> * parts = newArbitrationRound->getCommit()->getParts();
+                       Vector<CommitPart *> *parts = newArbitrationRound->getCommit()->getParts();
                        uint partsSize = parts->size();
-                       for(uint i=0; i<partsSize; i++) {
-                               CommitPart * commitPart = parts->get(i);
+                       for (uint i = 0; i < partsSize; i++) {
+                               CommitPart *commitPart = parts->get(i);
                                processEntry(commitPart);
                        }
                } else {
                        // Insert the commit so we can process it
-                       Vector<CommitPart *> * parts = newCommit->getParts();
+                       Vector<CommitPart *> *parts = newCommit->getParts();
                        uint partsSize = parts->size();
-                       for(uint i=0; i<partsSize; i++) {
-                               CommitPart * commitPart = parts->get(i);
+                       for (uint i = 0; i < partsSize; i++) {
+                               CommitPart *commitPart = parts->get(i);
                                processEntry(commitPart);
                        }
                }
@@ -1859,7 +1859,7 @@ Pair<bool, bool> Table::arbitrateOnLocalTransaction(Transaction *transaction) {
                if (transaction->getMachineId() == localMachineId) {
                        // For locally created messages update the status
                        // Guard evaluated was false so create abort
-                       TransactionStatus * status = transaction->getTransactionStatus();
+                       TransactionStatus *status = transaction->getTransactionStatus();
                        if (status != NULL) {
                                status->setStatus(TransactionStatus_StatusAborted);
                        }
@@ -1884,10 +1884,10 @@ Pair<bool, bool> Table::arbitrateOnLocalTransaction(Transaction *transaction) {
                        if (compactArbitrationData()) {
                                ArbitrationRound *newArbitrationRound = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - 1);
 
-                               Vector<CommitPart *> * parts = newArbitrationRound->getCommit()->getParts();
+                               Vector<CommitPart *> *parts = newArbitrationRound->getCommit()->getParts();
                                uint partsSize = parts->size();
-                               for(uint i=0; i<partsSize; i++) {
-                                       CommitPart * commitPart = parts->get(i);
+                               for (uint i = 0; i < partsSize; i++) {
+                                       CommitPart *commitPart = parts->get(i);
                                        processEntry(commitPart);
                                }
                        }
@@ -1937,7 +1937,7 @@ bool Table::compactArbitrationData() {
                        lastRound->addAborts(round->getAborts());
                } else {
                        // Create a new larger commit
-                       Commit * newCommit = Commit_merge(lastRound->getCommit(), round->getCommit(), localArbitrationSequenceNumber);
+                       Commit *newCommit = Commit_merge(lastRound->getCommit(), round->getCommit(), localArbitrationSequenceNumber);
                        localArbitrationSequenceNumber++;
 
                        // Create the commit parts so that we can count them
@@ -1997,15 +1997,15 @@ bool Table::updateCommittedTable() {
        }
 
        // Iterate through all the machine Ids that we received new parts for
-       SetIterator<int64_t, Hashtable<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> * partsit=getKeyIterator(newCommitParts);
-       while(partsit->hasNext()) {
+       SetIterator<int64_t, Hashtable<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> *partsit = getKeyIterator(newCommitParts);
+       while (partsit->hasNext()) {
                int64_t machineId = partsit->next();
                Hashtable<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *parts = newCommitParts->get(machineId);
 
                // Iterate through all the parts for that machine Id
-               SetIterator<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> * pairit=getKeyIterator(parts);
-               while(pairit->hasNext()) {
-                       Pair<int64_t, int32_t> * partId = pairit->next();
+               SetIterator<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *pairit = getKeyIterator(parts);
+               while (pairit->hasNext()) {
+                       Pair<int64_t, int32_t> *partId = pairit->next();
                        CommitPart *part = parts->get(partId);
 
                        // Get the transaction object for that sequence number
@@ -2033,7 +2033,7 @@ bool Table::updateCommittedTable() {
                delete pairit;
        }
        delete partsit;
-       
+
        // Clear all the new commits parts in preparation for the next time
        // the server sends slots
        newCommitParts->clear();
@@ -2042,7 +2042,7 @@ bool Table::updateCommittedTable() {
        bool didProcessANewCommit = false;
 
        // Process the commits one by one
-       SetIterator<int64_t, Hashtable<int64_t, Commit *> *> * liveit = getKeyIterator(liveCommitsTable);
+       SetIterator<int64_t, Hashtable<int64_t, Commit *> *> *liveit = getKeyIterator(liveCommitsTable);
        while (liveit->hasNext()) {
                int64_t arbitratorId = liveit->next();
 
@@ -2052,8 +2052,8 @@ bool Table::updateCommittedTable() {
                // Sort the commits in order
                Vector<int64_t> *commitSequenceNumbers = new Vector<int64_t>();
                {
-                       SetIterator<int64_t, Commit *> * clientit = getKeyIterator(commitForClientTable);
-                       while(clientit->hasNext())
+                       SetIterator<int64_t, Commit *> *clientit = getKeyIterator(commitForClientTable);
+                       while (clientit->hasNext())
                                commitSequenceNumbers->add(clientit->next());
                        delete clientit;
                }
@@ -2133,7 +2133,7 @@ bool Table::updateCommittedTable() {
                                SetIterator<KeyValue *, KeyValue *, uintptr_t, 0, hashKeyValue, equalsKeyValue> *kvit = commit->getKeyValueUpdateSet()->iterator();
                                while (kvit->hasNext()) {
                                        KeyValue *kv = kvit->next();
-                                       Commit * commit = liveCommitsByKeyTable->get(kv->getKey());
+                                       Commit *commit = liveCommitsByKeyTable->get(kv->getKey());
                                        if (commit != NULL)
                                                commitsToEdit->add(commit);
                                }
@@ -2141,8 +2141,8 @@ bool Table::updateCommittedTable() {
                        }
 
                        // Update each previous commit that needs to be updated
-                       SetIterator<Commit *, Commit *> * commitit = commitsToEdit->iterator();
-                       while(commitit->hasNext()) {
+                       SetIterator<Commit *, Commit *> *commitit = commitsToEdit->iterator();
+                       while (commitit->hasNext()) {
                                Commit *previousCommit = commitit->next();
 
                                // Only bother with live commits (TODO: Maybe remove this check)
@@ -2157,7 +2157,7 @@ bool Table::updateCommittedTable() {
                                                }
                                                delete kvit;
                                        }
-                                       
+
                                        // if the commit is now dead then remove it
                                        if (!previousCommit->isLive()) {
                                                commitForClientTable->remove(previousCommit->getSequenceNumber());
@@ -2188,9 +2188,9 @@ bool Table::updateCommittedTable() {
                                }
                                delete kvit;
                        }
-         }
-}
-delete liveit;
+               }
+       }
+       delete liveit;
 
        return didProcessANewCommit;
 }
@@ -2209,12 +2209,12 @@ bool Table::updateSpeculativeTable(bool didProcessNewCommits) {
        // from oldest to newest
        Vector<int64_t> *transactionSequenceNumbersSorted = new Vector<int64_t>();
        {
-               SetIterator<int64_t, Transaction *> * trit = getKeyIterator(liveTransactionBySequenceNumberTable);
-               while(trit->hasNext())
+               SetIterator<int64_t, Transaction *> *trit = getKeyIterator(liveTransactionBySequenceNumberTable);
+               while (trit->hasNext())
                        transactionSequenceNumbersSorted->add(trit->next());
                delete trit;
        }
-       
+
        qsort(transactionSequenceNumbersSorted->expose(), transactionSequenceNumbersSorted->size(), sizeof(int64_t), compareInt64);
 
        bool hasGapInTransactionSequenceNumbers = transactionSequenceNumbersSorted->get(0) != oldestTransactionSequenceNumberSpeculatedOn;
@@ -2238,11 +2238,11 @@ bool Table::updateSpeculativeTable(bool didProcessNewCommits) {
        // Find where to start arbitration from
        int startIndex = 0;
 
-       for(; startIndex < transactionSequenceNumbersSorted->size(); startIndex++)
+       for (; startIndex < transactionSequenceNumbersSorted->size(); startIndex++)
                if (transactionSequenceNumbersSorted->get(startIndex) == lastTransactionSequenceNumberSpeculatedOn)
                        break;
        startIndex++;
-                               
+
        if (startIndex >= transactionSequenceNumbersSorted->size()) {
                // Make sure we are not out of bounds
                return false;           // did not speculate
@@ -2313,10 +2313,10 @@ void Table::updatePendingTransactionSpeculativeTable(bool didProcessNewCommitsOr
        // Find where to start arbitration from
        int startIndex = 0;
 
-       for(; startIndex < pendingTransactionQueue->size(); startIndex++)
+       for (; startIndex < pendingTransactionQueue->size(); startIndex++)
                if (pendingTransactionQueue->get(startIndex) == firstPendingTransaction)
                        break;
-       
+
        if (startIndex >= pendingTransactionQueue->size()) {
                // Make sure we are not out of bounds
                return;
@@ -2346,16 +2346,16 @@ void Table::updatePendingTransactionSpeculativeTable(bool didProcessNewCommitsOr
 void Table::updateLiveTransactionsAndStatus() {
        // Go through each of the transactions
        {
-               SetIterator<int64_t, Transaction *> * iter = getKeyIterator(liveTransactionBySequenceNumberTable);
-               while(iter->hasNext()) {
+               SetIterator<int64_t, Transaction *> *iter = getKeyIterator(liveTransactionBySequenceNumberTable);
+               while (iter->hasNext()) {
                        int64_t key = iter->next();
                        Transaction *transaction = liveTransactionBySequenceNumberTable->get(key);
-                       
+
                        // Check if the transaction is dead
                        if (lastArbitratedTransactionNumberByArbitratorTable->contains(transaction->getArbitrator()) && lastArbitratedTransactionNumberByArbitratorTable->get(transaction->getArbitrator() >= transaction->getSequenceNumber())) {
                                // Set dead the transaction
                                transaction->setDead();
-                               
+
                                // Remove the transaction from the live table
                                iter->remove();
                                liveTransactionByTransactionIdTable->remove(transaction->getId());
@@ -2363,20 +2363,20 @@ void Table::updateLiveTransactionsAndStatus() {
                }
                delete iter;
        }
-       
+
        // Go through each of the transactions
        {
-               SetIterator<int64_t, TransactionStatus *> * iter = getKeyIterator(outstandingTransactionStatus);
-               while(iter->hasNext()) {
+               SetIterator<int64_t, TransactionStatus *> *iter = getKeyIterator(outstandingTransactionStatus);
+               while (iter->hasNext()) {
                        int64_t key = iter->next();
                        TransactionStatus *status = outstandingTransactionStatus->get(key);
 
                        // Check if the transaction is dead
                        if (lastArbitratedTransactionNumberByArbitratorTable->contains(status->getTransactionArbitrator()) && (lastArbitratedTransactionNumberByArbitratorTable->get(status->getTransactionArbitrator()) >= status->getTransactionSequenceNumber())) {
-                               
+
                                // Set committed
                                status->setStatus(TransactionStatus_StatusCommitted);
-                               
+
                                // Remove
                                iter->remove();
                        }
@@ -2396,8 +2396,8 @@ void Table::processSlot(SlotIndexer *indexer, Slot *slot, bool acceptUpdatesToLo
        // Process each entry in the slot
        Vector<Entry *> *entries = slot->getEntries();
        uint eSize = entries->size();
-       for(uint ei=0; ei < eSize; ei++) {
-               Entry * entry = entries->get(ei);
+       for (uint ei = 0; ei < eSize; ei++) {
+               Entry *entry = entries->get(ei);
                switch (entry->getType()) {
                case TypeCommitPart:
                        processEntry((CommitPart *)entry);
@@ -2456,7 +2456,7 @@ void Table::processEntry(NewKey *entry) {
  * seen in this current round of updating the local copy of the block
  * chain
  */
-void Table::processEntry(TableStatus * entry, int64_t seq) {
+void Table::processEntry(TableStatus *entry, int64_t seq) {
        int newNumSlots = entry->getMaxSlots();
        updateCurrMaxSize(newNumSlots);
        initExpectedSize(seq, newNumSlots);
@@ -2501,8 +2501,8 @@ void Table::processEntry(RejectedMessage *entry, SlotIndexer *indexer) {
        // Create a list of clients to watch until they see this rejected
        // message entry->
        Hashset<int64_t> *deviceWatchSet = new Hashset<int64_t>();
-       SetIterator<int64_t, Pair<int64_t, Liveness*> *> * iter = getKeyIterator(lastMessageTable);
-       while(iter->hasNext()) {
+       SetIterator<int64_t, Pair<int64_t, Liveness *> *> *iter = getKeyIterator(lastMessageTable);
+       while (iter->hasNext()) {
                // Machine ID for the last message entry
                int64_t lastMessageEntryMachineId = iter->next();
 
@@ -2512,7 +2512,7 @@ void Table::processEntry(RejectedMessage *entry, SlotIndexer *indexer) {
                        continue;
                }
 
-               Pair<int64_t, Liveness *> * lastMessageValue = lastMessageTable->get(lastMessageEntryMachineId);
+               Pair<int64_t, Liveness *> *lastMessageValue = lastMessageTable->get(lastMessageEntryMachineId);
                int64_t entrySequenceNumber = lastMessageValue->getFirst();
 
                if (entrySequenceNumber < seq) {
@@ -2525,7 +2525,7 @@ void Table::processEntry(RejectedMessage *entry, SlotIndexer *indexer) {
                }
        }
        delete iter;
-       
+
        if (deviceWatchSet->isEmpty()) {
                // This rejected message has been seen by all the clients so
                entry->setDead();
@@ -2550,7 +2550,7 @@ void Table::processEntry(Abort *entry) {
 
        // Abort has not been seen by the client it is for yet so we need to
        // keep track of it
-       
+
        Abort *previouslySeenAbort = liveAbortTable->put(new Pair<int64_t, int64_t>(entry->getAbortId()), entry);
        if (previouslySeenAbort != NULL) {
                previouslySeenAbort->setDead();         // Delete old version of the abort since we got a rescued newer version
@@ -2586,7 +2586,7 @@ void Table::processEntry(Abort *entry) {
 
        // Set dead a transaction if we can
        Pair<int64_t, int64_t> deadPair = Pair<int64_t, int64_t>(entry->getTransactionMachineId(), entry->getTransactionClientLocalSequenceNumber());
-       
+
        Transaction *transactionToSetDead = liveTransactionByTransactionIdTable->remove(&deadPair);
        if (transactionToSetDead != NULL) {
                liveTransactionBySequenceNumberTable->remove(transactionToSetDead->getSequenceNumber());
@@ -2639,7 +2639,7 @@ void Table::processEntry(TransactionPart *entry) {
 void Table::processEntry(CommitPart *entry) {
        // Update the last transaction that was updated if we can
        if (entry->getTransactionSequenceNumber() != -1) {
-               if (!lastArbitratedTransactionNumberByArbitratorTable->contains(entry->getMachineId() || lastArbitratedTransactionNumberByArbitratorTable->get(entry->getMachineId()) < entry->getTransactionSequenceNumber())) {
+               if (!lastArbitratedTransactionNumberByArbitratorTable->contains(entry->getMachineId() || lastArbitratedTransactionNumberByArbitratorTable->get(entry->getMachineId()) < entry->getTransactionSequenceNumber())) {
                        lastArbitratedTransactionNumberByArbitratorTable->put(entry->getMachineId(), entry->getTransactionSequenceNumber());
                }
        }
@@ -2678,7 +2678,7 @@ void Table::updateLastMessage(int64_t machineId, int64_t seqNum, Liveness *liven
                // seen yet
 
                SetIterator<RejectedMessage *, RejectedMessage *> *rmit = watchset->iterator();
-               while(rmit->hasNext()) {
+               while (rmit->hasNext()) {
                        RejectedMessage *rm = rmit->next();
                        // If this machine Id has seen this rejected message->->->
                        if (rm->getSequenceNumber() <= seqNum) {
@@ -2692,10 +2692,10 @@ void Table::updateLastMessage(int64_t machineId, int64_t seqNum, Liveness *liven
        }
 
        // Set dead the abort
-       SetIterator<Pair<int64_t, int64_t> *, Abort *, uintptr_t, 0, pairHashFunction, pairEquals> * abortit = getKeyIterator(liveAbortTable);
+       SetIterator<Pair<int64_t, int64_t> *, Abort *, uintptr_t, 0, pairHashFunction, pairEquals> *abortit = getKeyIterator(liveAbortTable);
 
-       while(abortit->hasNext()) {
-               Pair<int64_t, int64_t> * key = abortit->next();
+       while (abortit->hasNext()) {
+               Pair<int64_t, int64_t> *key = abortit->next();
                Abort *abort = liveAbortTable->get(key);
                if ((abort->getTransactionMachineId() == machineId) && (abort->getSequenceNumber() <= seqNum)) {
                        abort->setDead();
@@ -2709,7 +2709,7 @@ void Table::updateLastMessage(int64_t machineId, int64_t seqNum, Liveness *liven
        if (machineId == localMachineId) {
                // Our own messages are immediately dead->
                char livenessType = liveness->getType();
-               if (livenessType==TypeLastMessage) {
+               if (livenessType == TypeLastMessage) {
                        ((LastMessage *)liveness)->setDead();
                } else if (livenessType == TypeSlot) {
                        ((Slot *)liveness)->setDead();
@@ -2718,7 +2718,7 @@ void Table::updateLastMessage(int64_t machineId, int64_t seqNum, Liveness *liven
                }
        }
        // Get the old last message for this device
-       Pair<int64_t, Liveness *> * lastMessageEntry = lastMessageTable->put(machineId, new Pair<int64_t, Liveness *>(seqNum, liveness));
+       Pair<int64_t, Liveness *> *lastMessageEntry = lastMessageTable->put(machineId, new Pair<int64_t, Liveness *>(seqNum, liveness));
        if (lastMessageEntry == NULL) {
                // If no last message then there is nothing else to process
                return;
@@ -2727,11 +2727,11 @@ void Table::updateLastMessage(int64_t machineId, int64_t seqNum, Liveness *liven
        int64_t lastMessageSeqNum = lastMessageEntry->getFirst();
        Liveness *lastEntry = lastMessageEntry->getSecond();
        delete lastMessageEntry;
-       
+
        // If it is not our machine Id since we already set ours to dead
        if (machineId != localMachineId) {
                char lastEntryType = lastEntry->getType();
-               
+
                if (lastEntryType == TypeLastMessage) {
                        ((LastMessage *)lastEntry)->setDead();
                } else if (lastEntryType == TypeSlot) {
index d9dbf916156bcff2c151c7f48da9160515470f93..0c2bed3a37e46ae77f062626ecadcf0b6f473310 100644 (file)
@@ -205,8 +205,8 @@ bool Transaction::isComplete() {
        return fldisComplete;
 }
 
-Pair<int64_t, int64_t> * Transaction::getId() {
-       return & transactionId;
+Pair<int64_t, int64_t> *Transaction::getId() {
+       return &transactionId;
 }
 
 void Transaction::setDead() {
index 240c535251c8221df99989e72106e273bef76727..f7235d034ca38c54c2d47b455657f78f804de96f 100644 (file)
@@ -50,7 +50,7 @@ public:
        int64_t getMachineId();
        int64_t getArbitrator();
        bool isComplete();
-       Pair<int64_t, int64_t> * getId();
+       Pair<int64_t, int64_t> *getId();
        void setDead();
        TransactionPart *getPart(int32_t index);
        bool evaluateGuard(Hashtable<IoTString *, KeyValue *> *committedKeyValueTable, Hashtable<IoTString *, KeyValue *> *speculatedKeyValueTable, Hashtable<IoTString *, KeyValue *> *pendingTransactionSpeculatedKeyValueTable);
index bfbb6b85d433f9c2766d6d31e7cde6bd0e650a23..a8143dba9fbccc134dcc3f89b175629a50ee674c 100644 (file)
@@ -146,8 +146,8 @@ public:
                return size() == 0;
        }
 
-SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *iterator() {
-       return new SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals>(table->list, table);
+       SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *iterator() {
+               return new SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals>(table->list, table);
        }
 
        /** Override: new operator */
@@ -174,7 +174,7 @@ private:
 };
 
 template<typename _Key, typename _Val, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
-       SetIterator<_Key, _Val ,_KeyInt, _Shift, hash_function, equals> *getKeyIterator(Hashtable<_Key,_Val,_KeyInt,_Shift,hash_function,equals> *table) {
+SetIterator<_Key, _Val,_KeyInt, _Shift, hash_function, equals> *getKeyIterator(Hashtable<_Key,_Val,_KeyInt,_Shift,hash_function,equals> *table) {
        return new SetIterator<_Key, _Val, _KeyInt, _Shift, hash_function, equals>(table->list, table);
 }
 #endif
index aca3361eb912b6e017f97a95bb96f372d242fe14..91d1e5a465c9358364e547a7da55c1ee2b01645a 100644 (file)
@@ -83,15 +83,15 @@ public:
                tail = list = NULL;
        }
 
-Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> * clone() {
-       Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> * ctable = new Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> (capacity, loadfactor);
-       struct Hashlistnode<_Key, _Val> * ptr = list;
-       while (ptr != NULL) {
-               ctable->put(ptr->key, ptr->val);
-               ptr = ptr->next;
+       Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> *clone() {
+               Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> *ctable = new Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> (capacity, loadfactor);
+               struct Hashlistnode<_Key, _Val> *ptr = list;
+               while (ptr != NULL) {
+                       ctable->put(ptr->key, ptr->val);
+                       ptr = ptr->next;
+               }
+               return ctable;
        }
-       return ctable;
-}
 
 
        /** @brief Hash table destructor */
index 1d468a7fc835e723f403fe73d91ec9f841e0be3b..438b2361522308cf661884a1cbed2f3c818ff17f 100644 (file)
@@ -31,9 +31,9 @@ public:
        }
 
        void remove(type t) {
-               for (uint i=0; i<fldsize; i++) {
+               for (uint i = 0; i < fldsize; i++) {
                        if (array[i] == t) {
-                               for (i++; i<fldsize; i++) {
+                               for (i++; i < fldsize; i++) {
                                        array[i - 1] = array[i];
                                }
                                fldsize--;
@@ -41,14 +41,14 @@ public:
                        }
                }
        }
-       
+
        void removeIndex(uint i) {
-               for (i++; i<fldsize; i++) {
+               for (i++; i < fldsize; i++) {
                        array[i - 1] = array[i];
                }
                fldsize--;
        }
-       
+
        type last() const {
                return array[fldsize - 1];
        }
@@ -81,7 +81,7 @@ public:
        }
 
        type lastElement() {
-               return get(size()-1);
+               return get(size() - 1);
        }
 
        type firstElement() {