X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fbackup%2Fsrc%2Fjava%2Fiotcloud%2FNewKey.java;fp=version2%2Fbackup%2Fsrc%2Fjava%2Fiotcloud%2FNewKey.java;h=0970016c322595bcc342e9c1ba0c863c8393e805;hp=0000000000000000000000000000000000000000;hb=8f2cd2d576d466dd791db72a6c54348d69af8541;hpb=a1fd28d4b49b14e9ee970cb6acaeeba3e069d541 diff --git a/version2/backup/src/java/iotcloud/NewKey.java b/version2/backup/src/java/iotcloud/NewKey.java new file mode 100644 index 0000000..0970016 --- /dev/null +++ b/version2/backup/src/java/iotcloud/NewKey.java @@ -0,0 +1,57 @@ +package iotcloud; + +import java.nio.ByteBuffer; + +/** + * This Entry records the abort sent by a given machine. + * @author Ali Younis + * @version 1.0 + */ + + +class NewKey extends Entry { + private IoTString key; + private long machineid; + + public NewKey(Slot slot, IoTString _key, long _machineid) { + super(slot); + key = _key; + machineid = _machineid; + } + + public long getMachineID() { + return machineid; + } + + public IoTString getKey() { + return key; + } + + static Entry decode(Slot slot, ByteBuffer bb) { + int keylength = bb.getInt(); + byte[] key = new byte[keylength]; + bb.get(key); + long machineid = bb.getLong(); + + return new NewKey(slot, IoTString.shallow(key), machineid); + } + + public void encode(ByteBuffer bb) { + bb.put(Entry.TypeNewKey); + bb.putInt(key.length()); + bb.put(key.internalBytes()); + bb.putLong(machineid); + } + + public int getSize() { + return Long.BYTES + Byte.BYTES + Integer.BYTES + key.length(); + } + + public byte getType() { + return Entry.TypeNewKey; + } + + public Entry getCopy(Slot s) { + return new NewKey(s, key, machineid); + } +} \ No newline at end of file