public class Table {
int numslots;
HashMap<IoTString, KeyValue> table=new HashMap<IoTString, KeyValue>();
- HashMap<Long, Pair<Long, Liveness>> lastmessagetable=new HashMap<Long, Pair<Long, Liveness>>();
+ HashMap<Long, Pair<Long, Liveness> > lastmessagetable=new HashMap<Long, Pair<Long, Liveness> >();
SlotBuffer buffer;
CloudComm cloud;
private Mac hmac;
long sequencenumber;
long localmachineid;
-
+
public Table(String baseurl, String password, long _localmachineid) {
localmachineid=_localmachineid;
buffer = new SlotBuffer();
public IoTString put(IoTString key, IoTString value) {
return null;
}
-
+
void validateandupdate(Slot[] newslots) {
//The cloud communication layer has checked slot HMACs already
//before decoding
for(Slot slot: newslots) {
processSlot(indexer, slot);
}
-
+
}
void processEntry(KeyValue entry, SlotIndexer indexer) {
long newseqnum=entry.getNewSeqNum();
boolean isequal=entry.getEqual();
long machineid=entry.getMachineID();
- for(long seqnum=oldseqnum;seqnum<=newseqnum;seqnum++) {
+ for(long seqnum=oldseqnum; seqnum<=newseqnum; seqnum++) {
Slot slot=indexer.getSlot(seqnum);
if (slot != null) {
long slotmachineid=slot.getMachineID();
}
}
}
-
+
void processEntry(TableStatus entry, SlotIndexer indexer, Slot slot) {
-
+
}
void updateLastMessage(long machineid, long seqnum, Liveness liveness) {
} else {
throw new Error("Unrecognized type");
}
-
+
//Check that nothing funny happened
if (machineid == localmachineid) {
if (lastmsgseqnum != seqnum)
throw new Error("Server Error: Rolback on remote machine sequence number");
}
}
-
+
void processSlot(SlotIndexer indexer, Slot slot) {
updateLastMessage(slot.getMachineID(), slot.getSequenceNumber(), slot);
case Entry.TypeKeyValue:
processEntry((KeyValue)entry, indexer);
break;
+
case Entry.TypeLastMessage:
processEntry((LastMessage)entry, indexer);
break;
+
case Entry.TypeRejectedMessage:
processEntry((RejectedMessage)entry, indexer);
break;
+
case Entry.TypeTableStatus:
processEntry((TableStatus)entry, indexer, slot);
break;
+
default:
throw new Error("Unrecognized type: "+entry.getType());
}
}
}
-
+
void checkHMACChain(SlotIndexer indexer, Slot[] newslots) {
for(int i=0; i < newslots.length; i++) {
Slot currslot=newslots[i];