Bug fixes + tabbing
[iotcloud.git] / version2 / src / C / Table.cc
index df6099acdc3c0df093a53366cc749bd360e2126b..152b3778cb81003ece942947f1e20d95227d986a 100644 (file)
@@ -46,6 +46,7 @@ Table::Table(IoTString *baseurl, IoTString *password, int64_t _localMachineId, i
        oldestLiveSlotSequenceNumver(1),
        localMachineId(_localMachineId),
        sequenceNumber(0),
+       localSequenceNumber(0),
        localTransactionSequenceNumber(0),
        lastTransactionSequenceNumberSpeculatedOn(0),
        oldestTransactionSequenceNumberSpeculatedOn(0),
@@ -108,6 +109,7 @@ Table::Table(CloudComm *_cloud, int64_t _localMachineId) :
        oldestLiveSlotSequenceNumver(1),
        localMachineId(_localMachineId),
        sequenceNumber(0),
+       localSequenceNumber(0),
        localTransactionSequenceNumber(0),
        lastTransactionSequenceNumberSpeculatedOn(0),
        oldestTransactionSequenceNumberSpeculatedOn(0),
@@ -205,7 +207,7 @@ void Table::init() {
        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> *>();
@@ -384,7 +386,7 @@ bool Table::update()  {
 
 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;
                }
@@ -1157,7 +1159,7 @@ ThreeTuple<bool, bool, Array<Slot *> *> Table::sendSlotsToServer(Slot *slot, int
 
        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;