updates
[iotcloud.git] / src / java / iotcloud / Table.java
index 679421ec518cb0c739a5de139c4653fc05881fa9..ae4ed164e2823d1ae6afae2d9a1cb1230d2cfb42 100644 (file)
@@ -6,7 +6,7 @@ import javax.crypto.*;
 
 public class Table {
        int numslots;
-       HashMap<IoTString, IoTString> table=new HashMap<IoTString, IoTString>();
+       HashMap<IoTString, KeyValue> table=new HashMap<IoTString, KeyValue>();
        HashMap<Long, Long> lastmessage=new HashMap<Long, Long>();
        SlotBuffer buffer;
        CloudComm cloud;
@@ -71,22 +71,33 @@ public class Table {
        }
 
        void processEntry(KeyValue entry, SlotIndexer indexer, Slot slot) {
-
+               IoTString key=entry.getKey();
+               KeyValue oldvalue=table.get(key);
+               if (oldvalue != null) {
+                       oldvalue.setDead();
+               }
+               table.put(key, entry);
        }
 
        void processEntry(LastMessage entry, SlotIndexer indexer, Slot slot) {
-
+               updateLastMessage(entry.getMachineID(), entry.getSequenceNumber(), null, entry);
        }
 
        void processEntry(RejectedMessage entry, SlotIndexer indexer, Slot slot) {
-
+               
        }
 
        void processEntry(TableStatus entry, SlotIndexer indexer, Slot slot) {
 
+       }
+
+       void updateLastMessage(long machineid, long seqnum, Slot slot, LastMessage entry) {
+               
        }
        
        void processSlot(SlotIndexer indexer, Slot slot) {
+               updateLastMessage(slot.getMachineID(), slot.getSequenceNumber(), slot, null);
+
                for(Entry entry : slot.getEntries()) {
                        switch(entry.getType()) {
                        case Entry.TypeKeyValue: