2 import java.nio.ByteBuffer;
5 * Generic class that wraps all the different types of information
6 * that can be stored in a Slot.
7 * @author Brian Demsky <bdemsky@uci.edu>
11 abstract class Entry implements Liveness {
12 static final byte TypeKeyValue = 1;
13 static final byte TypeLastMessage = 2;
14 static final byte TypeRejectedMessage = 3;
15 static final byte TypeTableStatus = 4;
17 /* Records whether the information is still live or has been
18 superceded by a newer update. */
20 private boolean islive = true;
21 private Slot parentslot;
23 Entry(Slot _parentslot) {
24 parentslot = _parentslot;
28 * Static method for decoding byte array into Entry objects. First
29 * byte tells the type of entry.
32 static Entry decode(Slot slot, ByteBuffer bb) {
36 return KeyValue.decode(slot, bb);
39 return LastMessage.decode(slot, bb);
41 case TypeRejectedMessage:
42 return RejectedMessage.decode(slot, bb);
45 return TableStatus.decode(slot, bb);
48 throw new Error("Unrecognized Entry Type: "+type);
53 * Returns true if the Entry object is still live.
61 * Flags the entry object as dead. Also decrements the live count
67 parentslot.decrementLiveCount();
71 * Serializes the Entry object into the byte buffer.
74 abstract void encode(ByteBuffer bb);
77 * Returns the size in bytes the entry object will take in the byte
81 abstract int getSize();
84 * Returns a byte encoding the type of the entry object.
87 abstract byte getType();
90 * Returns a copy of the Entry that can be added to a different slot.
92 abstract Entry getCopy(Slot s);