#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)
// 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())) {
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);
// 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();
}
}
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);
}
}
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 {
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();
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);
}
{
- 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();
}
// 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;
// Mandatory Rescue
for (; currentSequenceNumber < threshold; currentSequenceNumber++) {
- Slot * previousSlot = buffer->getSlot(currentSequenceNumber);
+ Slot *previousSlot = buffer->getSlot(currentSequenceNumber);
// Push slot number forward
if (!seenLiveSlot) {
oldestLiveSlotSequenceNumver = currentSequenceNumber;
// 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);
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 {
}
}
}
- donesearch:
+donesearch:
;
}
// 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;
}
// 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();
// 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++;
// 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())) {
continue;
}
}
-
+
// Get the transaction object for that sequence number
Transaction *transaction = liveTransactionBySequenceNumberTable->get(part->getSequenceNumber());
// 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);
speculativeTableTmp->put(kv->getKey(), kv);
}
delete kvit;
-
+
// Update what the last transaction committed was for use in batch commit
lastTransactionCommitted = transactionSequenceNumber;
} else {
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);
}
}
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);
}
}
newCommit->addKV(kv);
}
delete kvit;
-
+
// create the commit parts
newCommit->createCommitParts();
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);
}
}
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);
}
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);
}
}
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
}
// 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
delete pairit;
}
delete partsit;
-
+
// Clear all the new commits parts in preparation for the next time
// the server sends slots
newCommitParts->clear();
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();
// 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;
}
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);
}
}
// 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)
}
delete kvit;
}
-
+
// if the commit is now dead then remove it
if (!previousCommit->isLive()) {
commitForClientTable->remove(previousCommit->getSequenceNumber());
}
delete kvit;
}
- }
-}
-delete liveit;
+ }
+ }
+ delete liveit;
return didProcessANewCommit;
}
// 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;
// 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
// 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;
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());
}
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();
}
// 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);
* 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);
// 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();
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) {
}
}
delete iter;
-
+
if (deviceWatchSet->isEmpty()) {
// This rejected message has been seen by all the clients so
entry->setDead();
// 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
// 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());
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());
}
}
// 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) {
}
// 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();
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();
}
}
// 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;
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) {