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