delete speculatedKeyValueTable;
delete pendingTransactionSpeculatedKeyValueTable;
delete liveNewKeyTable;
- delete lastMessageTable;
+ {
+ SetIterator<int64_t, Pair<int64_t, Liveness *> *> *lmit = getKeyIterator(lastMessageTable);
+ while (lmit->hasNext()) {
+ Pair<int64_t, Liveness *> * pair = lastMessageTable->get(lmit->next());
+ }
+ delete lmit;
+ delete lastMessageTable;
+ }
+ if (pendingTransactionBuilder != NULL)
+ delete pendingTransactionBuilder;
{
SetIterator<int64_t, Hashset<RejectedMessage *> *> *rmit = getKeyIterator(rejectedMessageWatchVectorTable);
while(rmit->hasNext()) {
delete liveCommitsByKeyTable;
delete lastCommitSeenSequenceNumberByArbitratorTable;
delete rejectedSlotVector;
- delete pendingTransactionQueue;
+ {
+ uint size = pendingTransactionQueue->size();
+ for (uint iter = 0; iter < size; iter++) {
+ delete pendingTransactionQueue->get(iter);
+ }
+ delete pendingTransactionQueue;
+ }
delete pendingSendArbitrationEntriesToDelete;
delete transactionPartsSent;
delete outstandingTransactionStatus;
delete offlineTransactionsCommittedAndAtServer;
delete localCommunicationTable;
delete lastTransactionSeenFromMachineFromServer;
- delete pendingSendArbitrationRounds;
+ {
+ for(uint i = 0; i < pendingSendArbitrationRounds->size(); i++) {
+ delete pendingSendArbitrationRounds->get(i);
+ }
+ delete pendingSendArbitrationRounds;
+ }
if (lastTransactionPartsSent != NULL)
delete lastTransactionPartsSent;
delete lastArbitrationDataLocalSequenceNumberSeenFromArbitrator;
void Table::startTransaction() {
// Create a new transaction, invalidates any old pending transactions.
+ if (pendingTransactionBuilder != NULL)
+ delete pendingTransactionBuilder;
pendingTransactionBuilder = new PendingTransaction(localMachineId);
}
pendingTransactionQueue->add(newTransaction);
} else {
arbitrateOnLocalTransaction(newTransaction);
+ delete newTransaction;
updateLiveStateFromLocal();
}
-
+ if (pendingTransactionBuilder != NULL)
+ delete pendingTransactionBuilder;
+
pendingTransactionBuilder = new PendingTransaction(localMachineId);
try {
if (sendReturn.getSecond()) {
// did arbitrate
+ delete transaction;
oldindex--;
}
}
}
// Create the slot
- Slot *slot = new Slot(this, sequenceNumber + 1, localMachineId, buffer->getSlot(sequenceNumber)->getHMAC(), localSequenceNumber);
+ Slot *slot = new Slot(this, sequenceNumber + 1, localMachineId, new Array<char>(buffer->getSlot(sequenceNumber)->getHMAC()), localSequenceNumber);
localSequenceNumber++;
// Try to fill the slot with data
//Add part back in
pendingSendArbitrationRounds->set(oldcount++,
pendingSendArbitrationRounds->get(i));
- }
+ } else
+ delete pendingSendArbitrationRounds->get(i);
}
pendingSendArbitrationRounds->setSize(oldcount);
s->addEntry(liveentry);
else {
skipcount++;
- if (skipcount > Table_SKIP_THRESHOLD)
+ if (skipcount > Table_SKIP_THRESHOLD) {
+ delete liveentries;
goto donesearch;
+ }
}
}
+ delete liveentries;
}
donesearch:
;
// must have a last message message-> If not then the server is
// hiding slots
if (!machineSet->isEmpty()) {
+ delete machineSet;
throw new Error("Missing record for machines: ");
}
}
-
+ delete machineSet;
// Update the size of our local block chain->
commitNewMaxSize();
if (transaction == NULL) {
// This is a new transaction that we dont have so make a new one
transaction = new Transaction();
+
+ // Add that part to the transaction
+ transaction->addPartDecode(part);
// Insert this new transaction into the live tables
liveTransactionBySequenceNumberTable->put(part->getSequenceNumber(), transaction);
- liveTransactionByTransactionIdTable->put(new Pair<int64_t, int64_t>(part->getTransactionId()), transaction);
+ liveTransactionByTransactionIdTable->put(transaction->getId(), transaction);
}
-
- // Add that part to the transaction
- transaction->addPartDecode(part);
}
delete ptit;
}
continue;
}
-
if (!transaction->isComplete()) {
// Will arbitrate in incorrect order if we continue so just break
// Most likely this
break;
}
-
// update the largest transaction seen by arbitrator from server
if (!lastTransactionSeenFromMachineFromServer->contains(transaction->getMachineId())) {
lastTransactionSeenFromMachineFromServer->put(transaction->getMachineId(), transaction->getClientLocalSequenceNumber());
if (transaction->evaluateGuard(committedKeyValueTable, speculativeTableTmp, NULL)) {
// Guard evaluated as true
-
// Update the local changes so we can make the commit
SetIterator<KeyValue *, KeyValue *> *kvit = transaction->getKeyValueUpdateSet()->iterator();
while (kvit->hasNext()) {
}
/**
- * Compacts the arbitration data my merging commits and aggregating
+ * Compacts the arbitration data by merging commits and aggregating
* aborts so that a single large push of commits can be done instead
* of many small updates
*/
}
// Set the new compacted part
+ if (lastRound->getCommit() == newCommit)
+ lastRound->setCommit(NULL);
+ if (round->getCommit() == newCommit)
+ round->setCommit(NULL);
+
+ if (lastRound->getCommit() != NULL) {
+ Commit * oldcommit = lastRound->getCommit();
+ lastRound->setCommit(NULL);
+ delete oldcommit;
+ }
lastRound->setCommit(newCommit);
lastRound->addAborts(round->getAborts());
gotNewCommit = true;
if (numberToDelete != 1) {
// If there is a compaction
// Delete the previous pieces that are now in the new compacted piece
- if (numberToDelete == pendingSendArbitrationRounds->size()) {
- pendingSendArbitrationRounds->clear();
- } else {
- for (uint i = 0; i < numberToDelete; i++) {
- pendingSendArbitrationRounds->removeIndex(pendingSendArbitrationRounds->size() - 1);
- }
+ for (uint i = 2; i <= numberToDelete; i++) {
+ delete pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size()-i);
}
+ pendingSendArbitrationRounds->setSize(pendingSendArbitrationRounds->size() - numberToDelete);
- // Add the new compacted into the pending to send list
pendingSendArbitrationRounds->add(lastRound);
// Should reinsert into the commit processor
// We have already seen this commit before so need to do the
// full processing on this commit
if (commit->getSequenceNumber() <= lastCommitSeenSequenceNumber) {
-
// Update the last transaction that was updated if we can
if (commit->getTransactionSequenceNumber() != -1) {
int64_t lastTransactionNumber = lastArbitratedTransactionNumberByArbitratorTable->get(commit->getMachineId());
lastArbitratedTransactionNumberByArbitratorTable->put(commit->getMachineId(), commit->getTransactionSequenceNumber());
}
}
-
continue;
}
}
}
delete commitit;
+ delete commitsToEdit;
// Update the last seen sequence number from this arbitrator
if (lastCommitSeenSequenceNumberByArbitratorTable->contains(commit->getMachineId())) {
SetIterator<KeyValue *, KeyValue *, uintptr_t, 0> *kvit = commit->getKeyValueUpdateSet()->iterator();
while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
+ printf("Commited KeyValue Table update for %p\n", this);
+ kv->getKey()->print();
+ printf("\n");
+ kv->getValue()->print();
+ printf("\n");
committedKeyValueTable->put(kv->getKey(), kv);
liveCommitsByKeyTable->put(kv->getKey(), commit);
}
if (deviceWatchSet->isEmpty()) {
// This rejected message has been seen by all the clients so
entry->setDead();
+ delete deviceWatchSet;
} else {
// We need to watch this rejected message
entry->setWatchSet(deviceWatchSet);
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());
}
}
}
// Update the part and set dead ones we have already seen (got a
// rescued version)
- CommitPart *previouslySeenPart = commitPart->put(new Pair<int64_t, int32_t>(entry->getPartId()), entry);
+ CommitPart *previouslySeenPart = commitPart->put(entry->getPartId(), entry);
if (previouslySeenPart != NULL) {
previouslySeenPart->setDead();
}
rmit->remove();
// Decrement machines that need to see this notification
rm->removeWatcher(machineId);
- delete rm;
}
}
delete rmit;