edits
[iotcloud.git] / version2 / src / C / Table.h
index 1d58776dc44ec2b11113cc261af98dcadf2d6e07..394e6d63e3053ede1658005fbb10e5b2a22c7900 100644 (file)
@@ -65,13 +65,13 @@ private:
        Hashtable<int64_t, Pair<int64_t, Liveness *> *> *lastMessageTable;      // Last message sent by a client machine id -> (Seq Num, Slot or LastMessage);
        Hashtable<int64_t, Hashset<RejectedMessage *> *> *rejectedMessageWatchVectorTable;      // Table of machine Ids and the set of rejected messages they have not seen yet
        Hashtable<IoTString *, int64_t> *arbitratorTable;// Table of keys and their arbitrators
        Hashtable<int64_t, Pair<int64_t, Liveness *> *> *lastMessageTable;      // Last message sent by a client machine id -> (Seq Num, Slot or LastMessage);
        Hashtable<int64_t, Hashset<RejectedMessage *> *> *rejectedMessageWatchVectorTable;      // Table of machine Ids and the set of rejected messages they have not seen yet
        Hashtable<IoTString *, int64_t> *arbitratorTable;// Table of keys and their arbitrators
-       Hashtable<Pair<int64_t, int64_t> *, Abort *> *liveAbortTable;// Table live abort messages
-       Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, TransactionPart *> *> *newTransactionParts;      // transaction parts that are seen in this latest round of slots from the server
-       Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, CommitPart *> *> *newCommitParts;        // commit parts that are seen in this latest round of slots from the server
+       Hashtable<Pair<int64_t, int64_t> *, Abort *, uintptr_t, 0, pairHashFunction, pairEquals> *liveAbortTable;// Table live abort messages
+       Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> *newTransactionParts;  // transaction parts that are seen in this latest round of slots from the server
+       Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *> *newCommitParts;    // commit parts that are seen in this latest round of slots from the server
        Hashtable<int64_t, int64_t> *lastArbitratedTransactionNumberByArbitratorTable;  // Last transaction sequence number that an arbitrator arbitrated on
        Hashtable<int64_t, Transaction *> *liveTransactionBySequenceNumberTable;        // live transaction grouped by the sequence number
        Hashtable<int64_t, int64_t> *lastArbitratedTransactionNumberByArbitratorTable;  // Last transaction sequence number that an arbitrator arbitrated on
        Hashtable<int64_t, Transaction *> *liveTransactionBySequenceNumberTable;        // live transaction grouped by the sequence number
-       Hashtable<Pair<int64_t, int64_t> *, Transaction *> *liveTransactionByTransactionIdTable;        // live transaction grouped by the transaction ID
-       Hashtable<int64_t, Hashtable<int64_t, Commit *> > *liveCommitsTable;
+       Hashtable<Pair<int64_t, int64_t> *, Transaction *, uintptr_t, 0, pairHashFunction, pairEquals> *liveTransactionByTransactionIdTable;    // live transaction grouped by the transaction ID
+       Hashtable<int64_t, Hashtable<int64_t, Commit *> *> *liveCommitsTable;
        Hashtable<IoTString *, Commit *> *liveCommitsByKeyTable;
        Hashtable<int64_t, int64_t> *lastCommitSeenSequenceNumberByArbitratorTable;
        Vector<int64_t> *rejectedSlotVector;    // Vector of rejected slots that have yet to be sent to the server
        Hashtable<IoTString *, Commit *> *liveCommitsByKeyTable;
        Hashtable<int64_t, int64_t> *lastCommitSeenSequenceNumberByArbitratorTable;
        Vector<int64_t> *rejectedSlotVector;    // Vector of rejected slots that have yet to be sent to the server
@@ -81,8 +81,8 @@ private:
        Hashtable<Transaction *, Vector<int32_t> *> *transactionPartsSent;
        Hashtable<int64_t, TransactionStatus *> *outstandingTransactionStatus;
        Hashtable<int64_t, Abort *> *liveAbortsGeneratedByLocal;
        Hashtable<Transaction *, Vector<int32_t> *> *transactionPartsSent;
        Hashtable<int64_t, TransactionStatus *> *outstandingTransactionStatus;
        Hashtable<int64_t, Abort *> *liveAbortsGeneratedByLocal;
-       Hashset<Pair<int64_t, int64_t> *> *offlineTransactionsCommittedAndAtServer;
-       Hashtable<int64_t, Pair<IoTString *, int32_t> > *localCommunicationTable;
+       Hashset<Pair<int64_t, int64_t> *, uintptr_t, 0, pairHashFunction, pairEquals> *offlineTransactionsCommittedAndAtServer;
+       Hashtable<int64_t, Pair<IoTString *, int32_t> *> *localCommunicationTable;
        Hashtable<int64_t, int64_t> *lastTransactionSeenFromMachineFromServer;
        Hashtable<int64_t, int64_t> *lastArbitrationDataLocalSequenceNumberSeenFromArbitrator;
        bool lastInsertedNewKey;
        Hashtable<int64_t, int64_t> *lastTransactionSeenFromMachineFromServer;
        Hashtable<int64_t, int64_t> *lastArbitrationDataLocalSequenceNumberSeenFromArbitrator;
        bool lastInsertedNewKey;
@@ -97,11 +97,11 @@ private:
        bool sendToServer(NewKey *newKey);
        bool updateFromLocal(int64_t machineId);
        Pair<bool, bool> sendTransactionToLocal(Transaction *transaction);
        bool sendToServer(NewKey *newKey);
        bool updateFromLocal(int64_t machineId);
        Pair<bool, bool> sendTransactionToLocal(Transaction *transaction);
-       ThreeTuple<bool, bool, Array<Slot *> *> *sendSlotsToServer(Slot *slot, int newSize, bool isNewKey);
+       ThreeTuple<bool, bool, Array<Slot *> *> sendSlotsToServer(Slot *slot, int newSize, bool isNewKey);
        /**
         * Returns false if a resize was needed
         */
        /**
         * Returns false if a resize was needed
         */
-       ThreeTuple<bool, int32_t, bool> *fillSlot(Slot *slot, bool resize, NewKey *newKeyEntry);
+       ThreeTuple<bool, int32_t, bool> fillSlot(Slot *slot, bool resize, NewKey *newKeyEntry);
        void doRejectedMessages(Slot *s);
 
        ThreeTuple<bool, bool, int64_t> doMandatoryResuce(Slot *slot, bool resize);
        void doRejectedMessages(Slot *s);
 
        ThreeTuple<bool, bool, int64_t> doMandatoryResuce(Slot *slot, bool resize);
@@ -110,7 +110,7 @@ private:
        /**
         * Checks for malicious activity and updates the local copy of the block chain.
         */
        /**
         * Checks for malicious activity and updates the local copy of the block chain.
         */
-       void validateAndUpdate(Array<Slot*> *newSlots, bool acceptUpdatesToLocal);
+       void validateAndUpdate(Array<Slot *> *newSlots, bool acceptUpdatesToLocal);
 
        void updateLiveStateFromServer();
 
 
        void updateLiveStateFromServer();
 
@@ -146,7 +146,7 @@ private:
 
        void arbitrateFromServer();
 
 
        void arbitrateFromServer();
 
-       Pair<bool, bool> arbitrateOnLocalTransaction(Transaction * transaction);
+       Pair<bool, bool> arbitrateOnLocalTransaction(Transaction *transaction);
 
        /**
         * Compacts the arbitration data my merging commits and aggregating aborts so that a single large push of commits can be done instead of many small updates
 
        /**
         * Compacts the arbitration data my merging commits and aggregating aborts so that a single large push of commits can be done instead of many small updates
@@ -186,7 +186,7 @@ private:
        /**
         * Add the new key to the arbitrators table and update the set of live new keys (in case of a rescued new key message)
         */
        /**
         * Add the new key to the arbitrators table and update the set of live new keys (in case of a rescued new key message)
         */
-       void processEntry(NewKey * entry);
+       void processEntry(NewKey *entry);
 
        /**
         * Process new table status entries and set dead the old ones as new ones come in.
 
        /**
         * Process new table status entries and set dead the old ones as new ones come in.
@@ -228,12 +228,12 @@ private:
         * Add a rejected message entry to the watch set to keep track of which clients have seen that
         * rejected message entry and which have not.
         */
         * Add a rejected message entry to the watch set to keep track of which clients have seen that
         * rejected message entry and which have not.
         */
-       void addWatchVector(int64_t machineId, RejectedMessage * entry);
+       void addWatchVector(int64_t machineId, RejectedMessage *entry);
 
        /**
         * Check if the HMAC chain is not violated
         */
 
        /**
         * Check if the HMAC chain is not violated
         */
-       void checkHMACChain(SlotIndexer * indexer, Array<Slot*> *newSlots);
+       void checkHMACChain(SlotIndexer *indexer, Array<Slot *> *newSlots);
 
 
 public:
 
 
 public:
@@ -249,7 +249,7 @@ public:
        /**
         * Rebuild the table from scratch by pulling the latest block chain from the server.
         */
        /**
         * Rebuild the table from scratch by pulling the latest block chain from the server.
         */
-       bool update();
+
        void rebuild();
        void addLocalCommunication(int64_t arbitrator, IoTString *hostName, int portNumber);
        int64_t getArbitrator(IoTString *key);
        void rebuild();
        void addLocalCommunication(int64_t arbitrator, IoTString *hostName, int portNumber);
        int64_t getArbitrator(IoTString *key);
@@ -257,6 +257,8 @@ public:
        IoTString *getCommitted(IoTString *key);
        IoTString *getSpeculative(IoTString *key);
        IoTString *getCommittedAtomic(IoTString *key);
        IoTString *getCommitted(IoTString *key);
        IoTString *getSpeculative(IoTString *key);
        IoTString *getCommittedAtomic(IoTString *key);
+       IoTString *getSpeculativeAtomic(IoTString *key);
+       bool update();
        bool createNewKey(IoTString *keyName, int64_t machineId);
        void startTransaction();
        void addKV(IoTString *key, IoTString *value);
        bool createNewKey(IoTString *keyName, int64_t machineId);
        void startTransaction();
        void addKV(IoTString *key, IoTString *value);