oldestLiveSlotSequenceNumver(1),
localMachineId(_localMachineId),
sequenceNumber(0),
+ localSequenceNumber(0),
localTransactionSequenceNumber(0),
lastTransactionSequenceNumberSpeculatedOn(0),
oldestTransactionSequenceNumberSpeculatedOn(0),
oldestLiveSlotSequenceNumver(1),
localMachineId(_localMachineId),
sequenceNumber(0),
+ localSequenceNumber(0),
localTransactionSequenceNumber(0),
lastTransactionSequenceNumberSpeculatedOn(0),
oldestTransactionSequenceNumberSpeculatedOn(0),
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
*/
liveNewKeyTable = new Hashtable<IoTString *, NewKey *>();
lastMessageTable = new Hashtable<int64_t, Pair<int64_t, Liveness *> * >();
rejectedMessageWatchVectorTable = new Hashtable<int64_t, Hashset<RejectedMessage *> * >();
- arbitratorTable = new Hashtable<IoTString *, int64_t>();
+ arbitratorTable = new Hashtable<IoTString *, int64_t, uintptr_t, 0, hashString, StringEquals>();
liveAbortTable = new Hashtable<Pair<int64_t, int64_t> *, Abort *, uintptr_t, 0, pairHashFunction, pairEquals>();
newTransactionParts = new Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, TransactionPart *, uintptr_t, 0, pairHashFunction, pairEquals> *>();
newCommitParts = new Hashtable<int64_t, Hashtable<Pair<int64_t, int32_t> *, CommitPart *, uintptr_t, 0, pairHashFunction, pairEquals> *>();
bool Table::createNewKey(IoTString *keyName, int64_t machineId) {
while (true) {
- if (!arbitratorTable->contains(keyName)) {
+ if (arbitratorTable->contains(keyName)) {
// There is already an arbitrator
return false;
}
Array<Slot *> *array = cloud->putSlot(slot, newSize);
if (array == NULL) {
- array = new Array<Slot *>();
+ array = new Array<Slot *>(1);
array->set(0, slot);
rejectedSlotVector->clear();
inserted = true;
// 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());
// 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());
// 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);