05834f0770d7e95b4c620f16b1c13079c0c3a4e8
[iotcloud.git] / src2 / java / iotcloud / Commit.java
1 package iotcloud;
2
3 import java.nio.ByteBuffer;
4 import java.util.Set;
5 import java.util.HashSet;
6
7 /**
8  * This Entry records the abort sent by a given machine.
9  * @author Ali Younis <ayounis@uci.edu>
10  * @version 1.0
11  */
12
13
14 class Commit extends Entry {
15         private long seqnum;
16         private Set<KeyValue> keyValueUpdateSet;
17
18
19         public Commit(Slot slot, long _seqnum, long _machineid) {
20                 super(slot);
21                 seqnum=_seqnum;
22                 machineid=_machineid;
23         }
24
25         public long getSequenceNumber() {
26                 return seqnum;
27         }
28
29
30
31
32
33         static Entry decode(Slot slot, ByteBuffer bb) {
34                 long seqnum=bb.getLong();
35                 long machineid=bb.getLong();
36                 return new Abort(slot, seqnum, machineid);
37         }
38
39         public void encode(ByteBuffer bb) {
40                 bb.put(Entry.TypeAbort);
41                 bb.putLong(seqnum);
42                 bb.putLong(machineid);
43         }
44
45         public int getSize() {
46                 return 2*Long.BYTES+Byte.BYTES;
47         }
48
49         public byte getType() {
50                 return Entry.TypeAbort;
51         }
52
53         public Entry getCopy(Slot s) {
54                 return new Abort(s, seqnum, machineid);
55         }
56 }