Slot lastSlotAttemptedToSend = NULL;
bool lastIsNewKey = false;
int lastNewSize = 0;
- Map<Transaction, List<Integer>> lastTransactionPartsSent = NULL;
+ Hashtable<Transaction, List<Integer>> lastTransactionPartsSent = NULL;
List<Entry> lastPendingSendArbitrationEntriesToDelete = NULL;
NewKey lastNewKey = NULL;
/* Data Structures */
- Map<IoTString, KeyValue> committedKeyValueTable = NULL; // Table of committed key value pairs
- Map<IoTString, KeyValue> speculatedKeyValueTable = NULL; // Table of speculated key value pairs, if there is a speculative value
- Map<IoTString, KeyValue> pendingTransactionSpeculatedKeyValueTable = NULL; // Table of speculated key value pairs, if there is a speculative value from the pending transactions
- Map<IoTString, NewKey> liveNewKeyTable = NULL; // Table of live new keys
- HashMap<Long, Pair<Long, Liveness>> lastMessageTable = NULL; // Last message sent by a client machine id -> (Seq Num, Slot or LastMessage);
- HashMap<Long, HashSet<RejectedMessage>> rejectedMessageWatchListTable = NULL; // Table of machine Ids and the set of rejected messages they have not seen yet
- Map<IoTString, Long> arbitratorTable = NULL; // Table of keys and their arbitrators
- Map<Pair<Long, Long>, Abort> liveAbortTable = NULL; // Table live abort messages
- Map<Long, Map<Pair<Long, Integer>, TransactionPart>> newTransactionParts = NULL; // transaction parts that are seen in this latest round of slots from the server
- Map<Long, Map<Pair<Long, Integer>, CommitPart>> newCommitParts = NULL; // commit parts that are seen in this latest round of slots from the server
- Map<Long, Long> lastArbitratedTransactionNumberByArbitratorTable = NULL; // Last transaction sequence number that an arbitrator arbitrated on
- Map<Long, Transaction> liveTransactionBySequenceNumberTable = NULL; // live transaction grouped by the sequence number
- Map<Pair<Long, Long>, Transaction> liveTransactionByTransactionIdTable = NULL; // live transaction grouped by the transaction ID
- Map<Long, Map<Long, Commit>> liveCommitsTable = NULL;
- Map<IoTString, Commit> liveCommitsByKeyTable = NULL;
- Map<Long, Long> lastCommitSeenSequenceNumberByArbitratorTable = NULL;
+ Hashtable<IoTString, KeyValue> committedKeyValueTable = NULL; // Table of committed key value pairs
+ Hashtable<IoTString, KeyValue> speculatedKeyValueTable = NULL; // Table of speculated key value pairs, if there is a speculative value
+ Hashtable<IoTString, KeyValue> pendingTransactionSpeculatedKeyValueTable = NULL; // Table of speculated key value pairs, if there is a speculative value from the pending transactions
+ Hashtable<IoTString, NewKey> liveNewKeyTable = NULL; // Table of live new keys
+ Hashtable<Long, Pair<Long, Liveness>> lastMessageTable = NULL; // Last message sent by a client machine id -> (Seq Num, Slot or LastMessage);
+ Hashtable<Long, HashSet<RejectedMessage>> rejectedMessageWatchListTable = NULL; // Table of machine Ids and the set of rejected messages they have not seen yet
+ Hashtable<IoTString, Long> arbitratorTable = NULL; // Table of keys and their arbitrators
+ Hashtable<Pair<int64_t, int64_t>, Abort> liveAbortTable = NULL; // Table live abort messages
+ Hashtable<Long, Hashtable<Pair<Long, Integer>, TransactionPart>> newTransactionParts = NULL; // transaction parts that are seen in this latest round of slots from the server
+ Hashtable<Long, Hashtable<Pair<Long, Integer>, CommitPart>> newCommitParts = NULL; // commit parts that are seen in this latest round of slots from the server
+ Hashtable<int64_t, int64_t> lastArbitratedTransactionNumberByArbitratorTable = NULL; // Last transaction sequence number that an arbitrator arbitrated on
+ Hashtable<Long, Transaction> liveTransactionBySequenceNumberTable = NULL; // live transaction grouped by the sequence number
+ Hashtable<Pair<int64_t, int64_t>, Transaction> liveTransactionByTransactionIdTable = NULL; // live transaction grouped by the transaction ID
+ Hashtable<Long, Hashtable<Long, Commit>> liveCommitsTable = NULL;
+ Hashtable<IoTString, Commit> liveCommitsByKeyTable = NULL;
+ Hashtable<int64_t, int64_t> lastCommitSeenSequenceNumberByArbitratorTable = NULL;
Vector<Long> rejectedSlotList = NULL; // List of rejected slots that have yet to be sent to the server
List<Transaction> pendingTransactionQueue = NULL;
List<ArbitrationRound> pendingSendArbitrationRounds = NULL;
List<Entry> pendingSendArbitrationEntriesToDelete = NULL;
- Map<Transaction, List<Integer>> transactionPartsSent = NULL;
- Map<Long, TransactionStatus> outstandingTransactionStatus = NULL;
- Map<Long, Abort> liveAbortsGeneratedByLocal = NULL;
- Set<Pair<Long, Long>> offlineTransactionsCommittedAndAtServer = NULL;
- Map<Long, Pair<String, Integer>> localCommunicationTable = NULL;
- Map<Long, Long> lastTransactionSeenFromMachineFromServer = NULL;
- Map<Long, Long> lastArbitrationDataLocalSequenceNumberSeenFromArbitrator = NULL;
+ Hashtable<Transaction, List<Integer>> transactionPartsSent = NULL;
+ Hashtable<Long, TransactionStatus> outstandingTransactionStatus = NULL;
+ Hashtable<Long, Abort> liveAbortsGeneratedByLocal = NULL;
+ Set<Pair<int64_t, int64_t>> offlineTransactionsCommittedAndAtServer = NULL;
+ Hashtable<Long, Pair<String, Integer>> localCommunicationTable = NULL;
+ Hashtable<int64_t, int64_t> lastTransactionSeenFromMachineFromServer = NULL;
+ Hashtable<int64_t, int64_t> lastArbitrationDataLocalSequenceNumberSeenFromArbitrator = NULL;
Table(String baseurl, String password, int64_t _localMachineId, int listeningPort) {
oldestLiveSlotSequenceNumver = 1;
// init data structs
- committedKeyValueTable = new HashMap<IoTString, KeyValue>();
- speculatedKeyValueTable = new HashMap<IoTString, KeyValue>();
- pendingTransactionSpeculatedKeyValueTable = new HashMap<IoTString, KeyValue>();
- liveNewKeyTable = new HashMap<IoTString, NewKey>();
- lastMessageTable = new HashMap<Long, Pair<Long, Liveness>>();
- rejectedMessageWatchListTable = new HashMap<Long, HashSet<RejectedMessage>>();
- arbitratorTable = new HashMap<IoTString, Long>();
- liveAbortTable = new HashMap<Pair<Long, Long>, Abort>();
- newTransactionParts = new HashMap<Long, Map<Pair<Long, Integer>, TransactionPart>>();
- newCommitParts = new HashMap<Long, Map<Pair<Long, Integer>, CommitPart>>();
- lastArbitratedTransactionNumberByArbitratorTable = new HashMap<Long, Long>();
- liveTransactionBySequenceNumberTable = new HashMap<Long, Transaction>();
- liveTransactionByTransactionIdTable = new HashMap<Pair<Long, Long>, Transaction>();
- liveCommitsTable = new HashMap<Long, Map<Long, Commit>>();
- liveCommitsByKeyTable = new HashMap<IoTString, Commit>();
- lastCommitSeenSequenceNumberByArbitratorTable = new HashMap<Long, Long>();
+ committedKeyValueTable = new Hashtable<IoTString, KeyValue>();
+ speculatedKeyValueTable = new Hashtable<IoTString, KeyValue>();
+ pendingTransactionSpeculatedKeyValueTable = new Hashtable<IoTString, KeyValue>();
+ liveNewKeyTable = new Hashtable<IoTString, NewKey>();
+ lastMessageTable = new Hashtable<Long, Pair<Long, Liveness>>();
+ rejectedMessageWatchListTable = new Hashtable<Long, HashSet<RejectedMessage>>();
+ arbitratorTable = new Hashtable<IoTString, Long>();
+ liveAbortTable = new Hashtable<Pair<int64_t, int64_t>, Abort>();
+ newTransactionParts = new Hashtable<Long, Hashtable<Pair<Long, Integer>, TransactionPart>>();
+ newCommitParts = new Hashtable<Long, Hashtable<Pair<Long, Integer>, CommitPart>>();
+ lastArbitratedTransactionNumberByArbitratorTable = new Hashtable<int64_t, int64_t>();
+ liveTransactionBySequenceNumberTable = new Hashtable<Long, Transaction>();
+ liveTransactionByTransactionIdTable = new Hashtable<Pair<int64_t, int64_t>, Transaction>();
+ liveCommitsTable = new Hashtable<Long, Hashtable<Long, Commit>>();
+ liveCommitsByKeyTable = new Hashtable<IoTString, Commit>();
+ lastCommitSeenSequenceNumberByArbitratorTable = new Hashtable<int64_t, int64_t>();
rejectedSlotList = new Vector<Long>();
pendingTransactionQueue = new ArrayList<Transaction>();
pendingSendArbitrationEntriesToDelete = new ArrayList<Entry>();
- transactionPartsSent = new HashMap<Transaction, List<Integer>>();
- outstandingTransactionStatus = new HashMap<Long, TransactionStatus>();
- liveAbortsGeneratedByLocal = new HashMap<Long, Abort>();
- offlineTransactionsCommittedAndAtServer = new HashSet<Pair<Long, Long>>();
- localCommunicationTable = new HashMap<Long, Pair<String, Integer>>();
- lastTransactionSeenFromMachineFromServer = new HashMap<Long, Long>();
+ transactionPartsSent = new Hashtable<Transaction, List<Integer>>();
+ outstandingTransactionStatus = new Hashtable<Long, TransactionStatus>();
+ liveAbortsGeneratedByLocal = new Hashtable<Long, Abort>();
+ offlineTransactionsCommittedAndAtServer = new HashSet<Pair<int64_t, int64_t>>();
+ localCommunicationTable = new Hashtable<Long, Pair<String, Integer>>();
+ lastTransactionSeenFromMachineFromServer = new Hashtable<int64_t, int64_t>();
pendingSendArbitrationRounds = new ArrayList<ArbitrationRound>();
- lastArbitrationDataLocalSequenceNumberSeenFromArbitrator = new HashMap<Long, Long>();
+ lastArbitrationDataLocalSequenceNumberSeenFromArbitrator = new Hashtable<int64_t, int64_t>();
// Other init stuff
lastInsertedNewKey = insertedNewKey;
lastNewSize = newSize;
lastNewKey = newKey;
- lastTransactionPartsSent = new HashMap<Transaction, List<Integer>>(transactionPartsSent);
+ lastTransactionPartsSent = new Hashtable<Transaction, List<Integer>>(transactionPartsSent);
lastPendingSendArbitrationEntriesToDelete = new ArrayList<Entry>(pendingSendArbitrationEntriesToDelete);
// if (!fromRetry) {
- // lastTransactionPartsSent = new HashMap<Transaction, List<Integer>>(transactionPartsSent);
+ // lastTransactionPartsSent = new Hashtable<Transaction, List<Integer>>(transactionPartsSent);
// lastPendingSendArbitrationEntriesToDelete = new ArrayList<Entry>(pendingSendArbitrationEntriesToDelete);
// }
}
// Get the commits to send back
- Map<Long, Commit> commitForClientTable = liveCommitsTable.get(localMachineId);
+ Hashtable<Long, Commit> commitForClientTable = liveCommitsTable.get(localMachineId);
if (commitForClientTable != NULL) {
List<Long> commitLocalSequenceNumbers = new ArrayList<Long>(commitForClientTable.keySet());
Collections.sort(commitLocalSequenceNumbers);
// Iterate through all the machine Ids that we received new parts for
for (Long machineId : newTransactionParts.keySet()) {
- Map<Pair<Long, Integer>, TransactionPart> parts = newTransactionParts.get(machineId);
+ Hashtable<Pair<Long, Integer>, TransactionPart> parts = newTransactionParts.get(machineId);
// Iterate through all the parts for that machine Id
for (Pair<Long, Integer> partId : parts.keySet()) {
Collections.sort(transactionSequenceNumbers);
// Collection of key value pairs that are
- Map<IoTString, KeyValue> speculativeTableTmp = new HashMap<IoTString, KeyValue>();
+ Hashtable<IoTString, KeyValue> speculativeTableTmp = new Hashtable<IoTString, KeyValue>();
// The last transaction arbitrated on
int64_t lastTransactionCommitted = -1;
// Iterate through all the machine Ids that we received new parts for
for (Long machineId : newCommitParts.keySet()) {
- Map<Pair<Long, Integer>, CommitPart> parts = newCommitParts.get(machineId);
+ Hashtable<Pair<Long, Integer>, CommitPart> parts = newCommitParts.get(machineId);
// Iterate through all the parts for that machine Id
for (Pair<Long, Integer> partId : parts.keySet()) {
CommitPart part = parts.get(partId);
// Get the transaction object for that sequence number
- Map<Long, Commit> commitForClientTable = liveCommitsTable.get(part.getMachineId());
+ Hashtable<Long, Commit> commitForClientTable = liveCommitsTable.get(part.getMachineId());
if (commitForClientTable == NULL) {
// This is the first commit from this device
- commitForClientTable = new HashMap<Long, Commit>();
+ commitForClientTable = new Hashtable<Long, Commit>();
liveCommitsTable.put(part.getMachineId(), commitForClientTable);
}
for (Long arbitratorId : liveCommitsTable.keySet()) {
// Get all the commits for a specific arbitrator
- Map<Long, Commit> commitForClientTable = liveCommitsTable.get(arbitratorId);
+ Hashtable<Long, Commit> commitForClientTable = liveCommitsTable.get(arbitratorId);
// Sort the commits in order
List<Long> commitSequenceNumbers = new ArrayList<Long>(commitForClientTable.keySet());
// Set dead a transaction if we can
- Transaction transactionToSetDead = liveTransactionByTransactionIdTable.remove(new Pair<Long, Long>(entry.getTransactionMachineId(), entry.getTransactionClientLocalSequenceNumber()));
+ Transaction transactionToSetDead = liveTransactionByTransactionIdTable.remove(new Pair<int64_t, int64_t>(entry.getTransactionMachineId(), entry.getTransactionClientLocalSequenceNumber()));
if (transactionToSetDead != NULL) {
liveTransactionBySequenceNumberTable.remove(transactionToSetDead.getSequenceNumber());
}
}
// This part is still alive
- Map<Pair<Long, Integer>, TransactionPart> transactionPart = newTransactionParts.get(entry.getMachineId());
+ Hashtable<Pair<Long, Integer>, TransactionPart> transactionPart = newTransactionParts.get(entry.getMachineId());
if (transactionPart == NULL) {
// Dont have a table for this machine Id yet so make one
- transactionPart = new HashMap<Pair<Long, Integer>, TransactionPart>();
+ transactionPart = new Hashtable<Pair<Long, Integer>, TransactionPart>();
newTransactionParts.put(entry.getMachineId(), transactionPart);
}
- Map<Pair<Long, Integer>, CommitPart> commitPart = newCommitParts.get(entry.getMachineId());
+ Hashtable<Pair<Long, Integer>, CommitPart> commitPart = newCommitParts.get(entry.getMachineId());
if (commitPart == NULL) {
// Don't have a table for this machine Id yet so make one
- commitPart = new HashMap<Pair<Long, Integer>, CommitPart>();
+ commitPart = new Hashtable<Pair<Long, Integer>, CommitPart>();
newCommitParts.put(entry.getMachineId(), commitPart);
}
}
// Set dead the abort
- for (Iterator<Map.Entry<Pair<Long, Long>, Abort>> i = liveAbortTable.entrySet().iterator(); i.hasNext();) {
+ for (Iterator<Map.Entry<Pair<int64_t, int64_t>, Abort>> i = liveAbortTable.entrySet().iterator(); i.hasNext();) {
Abort abort = i.next().getValue();
if ((abort.getTransactionMachineId() == machineId) && (abort.getSequenceNumber() <= seqNum)) {