more bug fixes
[iotcloud.git] / src / java / iotcloud / Table.java
index d4a62c6abda0576fcd9e0dd04180ce3cc43cb47b..ced979d29c89fbe46f9cb6d06e0677d4d6f38d2f 100644 (file)
@@ -31,6 +31,11 @@ final public class Table {
                cloud=_cloud;
        }
 
+       public void rebuild() {
+               Slot[] newslots=cloud.getSlots(sequencenumber+1);
+               validateandupdate(newslots, true);
+       }
+       
        public void update() {
                Slot[] newslots=cloud.getSlots(sequencenumber+1);
 
@@ -150,7 +155,7 @@ search:
        }
 
 
-       private void validateandupdate(Slot[] newslots, boolean isput) {
+       private void validateandupdate(Slot[] newslots, boolean acceptupdatestolocal) {
                //The cloud communication layer has checked slot HMACs already
                //before decoding
                if (newslots.length==0)
@@ -166,7 +171,7 @@ search:
                initExpectedSize();
                for(Slot slot: newslots) {
                        updateExpectedSize();
-                       processSlot(indexer, slot, isput);
+                       processSlot(indexer, slot, acceptupdatestolocal);
                }
 
                //If there is a gap, check to see if the server sent us everything
@@ -249,7 +254,7 @@ search:
                lastTableStatus = entry;
        }
 
-       private void updateLastMessage(long machineid, long seqnum, Liveness liveness, boolean isput) {
+       private void updateLastMessage(long machineid, long seqnum, Liveness liveness, boolean acceptupdatestolocal) {
                Pair<Long, Liveness> lastmsgentry = lastmessagetable.put(machineid, new Pair<Long, Liveness>(seqnum, liveness));
                if (lastmsgentry == null)
                        return;
@@ -265,7 +270,7 @@ search:
                }
 
                if (machineid == localmachineid) {
-                       if (lastmsgseqnum != seqnum && !isput)
+                       if (lastmsgseqnum != seqnum && !acceptupdatestolocal)
                                throw new Error("Server Error: Mismatch on local machine sequence number");
                } else {
                        if (lastmsgseqnum > seqnum)
@@ -273,8 +278,8 @@ search:
                }
        }
 
-       private void processSlot(SlotIndexer indexer, Slot slot, boolean isput) {
-               updateLastMessage(slot.getMachineID(), slot.getSequenceNumber(), slot, isput);
+       private void processSlot(SlotIndexer indexer, Slot slot, boolean acceptupdatestolocal) {
+               updateLastMessage(slot.getMachineID(), slot.getSequenceNumber(), slot, acceptupdatestolocal);
 
                for(Entry entry : slot.getEntries()) {
                        switch(entry.getType()) {