edits
authorbdemsky <bdemsky@uci.edu>
Thu, 18 Jan 2018 22:24:37 +0000 (14:24 -0800)
committerbdemsky <bdemsky@uci.edu>
Thu, 18 Jan 2018 22:24:37 +0000 (14:24 -0800)
version2/src/C/RejectedMessage.cc
version2/src/C/RejectedMessage.h
version2/src/C/ServerException.cc [deleted file]
version2/src/C/ServerException.h [deleted file]
version2/src/C/common.h

index b09fbe9..7cbac36 100644 (file)
@@ -1,3 +1,5 @@
+#include "RejectedMessage.h"
+#include "ByteBuffer.h"
 
 /**
  * Entry for tracking messages that the server rejected.  We have to
@@ -7,91 +9,26 @@
  * @version 1.0
  */
 
+Entry * RejectedMessage_decode(Slot * slot, ByteBuffer * bb) {
+       int64_t sequencenum=bb.getLong();
+       int64_t machineid=bb.getLong();
+       int64_t oldseqnum=bb.getLong();
+       int64_t newseqnum=bb.getLong();
+       char equalto=bb.get();
+       return new RejectedMessage(slot,sequencenum, machineid, oldseqnum, newseqnum, equalto==1);
+}
 
-class RejectedMessage extends Entry {
-       /* Sequence number */
-       int64_t sequencenum;
-       
-
-       /* Machine identifier */
-       int64_t machineid;
-       /* Oldest sequence number in range */
-       int64_t oldseqnum;
-       /* Newest sequence number in range */
-       int64_t newseqnum;
-       /* Is the machine identifier of the relevant slots equal to (or not
-        * equal to) the specified machine identifier. */
-       bool equalto;
-       /* Set of machines that have not received notification. */
-       HashSet<Long> watchset;
-
-       RejectedMessage(Slot slot, int64_t _sequencenum, int64_t _machineid, int64_t _oldseqnum, int64_t _newseqnum, bool _equalto) {
-               super(slot);
-               sequencenum = _sequencenum;
-               machineid=_machineid;
-               oldseqnum=_oldseqnum;
-               newseqnum=_newseqnum;
-               equalto=_equalto;
-       }
-
-       int64_t getOldSeqNum() {
-               return oldseqnum;
-       }
-
-       int64_t getNewSeqNum() {
-               return newseqnum;
-       }
-
-       bool getEqual() {
-               return equalto;
-       }
-
-       int64_t getMachineID() {
-               return machineid;
-       }
-
-
-       int64_t getSequenceNumber() {
-               return sequencenum;
-       }
-
-       static Entry decode(Slot slot, ByteBuffer bb) {
-               int64_t sequencenum=bb.getLong();
-               int64_t machineid=bb.getLong();
-               int64_t oldseqnum=bb.getLong();
-               int64_t newseqnum=bb.getLong();
-               char equalto=bb.get();
-               return new RejectedMessage(slot,sequencenum, machineid, oldseqnum, newseqnum, equalto==1);
-       }
-
-       void setWatchSet(HashSet<Long> _watchset) {
-               watchset=_watchset;
-       }
-
-       void removeWatcher(int64_t machineid) {
-               if (watchset.remove(machineid))
-                       if (watchset.isEmpty())
-                               setDead();
-       }
-
-       void encode(ByteBuffer bb) {
-               bb.put(Entry.TypeRejectedMessage);
-               bb.putLong(sequencenum);
-               bb.putLong(machineid);
-               bb.putLong(oldseqnum);
-               bb.putLong(newseqnum);
-               bb.put(equalto?(char)1:(char)0);
-       }
-
-       int getSize() {
-               return 4*sizeof(int64_t) + 2*sizeof(char);
-       }
+void RejectedMessage::removeWatcher(int64_t machineid) {
+       if (watchset.remove(machineid))
+               if (watchset.isEmpty())
+                       setDead();
+}
 
-       char getType() {
-               return Entry.TypeRejectedMessage;
-       }
-       
-       Entry getCopy(Slot s) {
-               return new RejectedMessage(s,sequencenum, machineid, oldseqnum, newseqnum, equalto);
-       }
+void RejectedMessage::encode(ByteBuffer * bb) {
+       bb.put(TypeRejectedMessage);
+       bb->putLong(sequencenum);
+       bb->putLong(machineid);
+       bb->putLong(oldseqnum);
+       bb->putLong(newseqnum);
+       bb->put(equalto?(char)1:(char)0);
 }
index bf2c2c4..f33e40f 100644 (file)
@@ -1,4 +1,5 @@
-
+#ifndef REJECTEDMESSAGE_H
+#define REJECTEDMESSAGE_H
 /**
  * Entry for tracking messages that the server rejected.  We have to
  * make sure that all clients know that this message was rejected to
@@ -6,92 +7,47 @@
  * @author Brian Demsky
  * @version 1.0
  */
+#include "common.h"
+#include "Entry.h"
 
-
-class RejectedMessage extends Entry {
+class RejectedMessage : public Entry {
+ private:
        /* Sequence number */
-       private int64_t sequencenum;
-       
-
+       int64_t sequencenum;
        /* Machine identifier */
-       private int64_t machineid;
+       int64_t machineid;
        /* Oldest sequence number in range */
-       private int64_t oldseqnum;
+       int64_t oldseqnum;
        /* Newest sequence number in range */
-       private int64_t newseqnum;
+       int64_t newseqnum;
        /* Is the machine identifier of the relevant slots equal to (or not
         * equal to) the specified machine identifier. */
-       private bool equalto;
+       bool equalto;
        /* Set of machines that have not received notification. */
-       private HashSet<Long> watchset;
-
-       RejectedMessage(Slot slot, int64_t _sequencenum, int64_t _machineid, int64_t _oldseqnum, int64_t _newseqnum, bool _equalto) {
-               super(slot);
-               sequencenum = _sequencenum;
-               machineid=_machineid;
-               oldseqnum=_oldseqnum;
-               newseqnum=_newseqnum;
-               equalto=_equalto;
-       }
-
-       int64_t getOldSeqNum() {
-               return oldseqnum;
-       }
-
-       int64_t getNewSeqNum() {
-               return newseqnum;
-       }
-
-       bool getEqual() {
-               return equalto;
-       }
-
-       int64_t getMachineID() {
-               return machineid;
-       }
-
-
-       int64_t getSequenceNumber() {
-               return sequencenum;
-       }
-
-       static Entry decode(Slot slot, ByteBuffer bb) {
-               int64_t sequencenum=bb.getLong();
-               int64_t machineid=bb.getLong();
-               int64_t oldseqnum=bb.getLong();
-               int64_t newseqnum=bb.getLong();
-               char equalto=bb.get();
-               return new RejectedMessage(slot,sequencenum, machineid, oldseqnum, newseqnum, equalto==1);
-       }
-
-       void setWatchSet(HashSet<Long> _watchset) {
-               watchset=_watchset;
-       }
-
-       void removeWatcher(int64_t machineid) {
-               if (watchset.remove(machineid))
-                       if (watchset.isEmpty())
-                               setDead();
-       }
-
-       void encode(ByteBuffer bb) {
-               bb.put(Entry.TypeRejectedMessage);
-               bb.putLong(sequencenum);
-               bb.putLong(machineid);
-               bb.putLong(oldseqnum);
-               bb.putLong(newseqnum);
-               bb.put(equalto?(char)1:(char)0);
-       }
-
-       int getSize() {
-               return 4*sizeof(int64_t) + 2*sizeof(char);
-       }
-
-       char getType() {
-               return Entry.TypeRejectedMessage;
-       }
+       Hashset<int64_t> * watchset;
        
-       Entry getCopy(Slot s) {
+ RejectedMessage(Slot * slot, int64_t _sequencenum, int64_t _machineid, int64_t _oldseqnum, int64_t _newseqnum, bool _equalto) : Entry(slot),
+               sequencenum(_sequencenum),
+               machineid(_machineid),
+               oldseqnum(_oldseqnum),
+               newseqnum(_newseqnum),
+               equalto(_equalto) {
+               }
+
+       int64_t getOldSeqNum() { return oldseqnum; }
+       int64_t getNewSeqNum() { return newseqnum; }
+       bool getEqual() { return equalto; }
+       int64_t getMachineID() { return machineid; }
+       int64_t getSequenceNumber() { return sequencenum;       }
+       void setWatchSet(HashSet<int64_t> * _watchset) { watchset=_watchset;    }
+       void removeWatcher(int64_t machineid);
+       void encode(ByteBuffer * bb);
+       int getSize() { return 4*sizeof(int64_t) + 2*sizeof(char); }
+       char getType() { return TypeRejectedMessage; }
+       Entry * getCopy(Slot * s) {
                return new RejectedMessage(s,sequencenum, machineid, oldseqnum, newseqnum, equalto);
        }
-}
+};
+
+Entry * RejectedMessage_decode(Slot * slot, ByteBuffer * bb);
+#ifndef
diff --git a/version2/src/C/ServerException.cc b/version2/src/C/ServerException.cc
deleted file mode 100644 (file)
index a86c1dc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-class ServerException extends Exception {
-
-    static final char TypeConnectTimeout = 1;
-    static final char TypeInputTimeout = 2;
-    static final char TypeIncorrectResponseCode = 3;
-    static final char TypeSalt = 4;
-    char type = -1;
-
-    ServerException(String message, char _type) {
-        super(message);
-        type = _type;
-    }
-
-    char getType() {
-        return type;
-    }
-}
diff --git a/version2/src/C/ServerException.h b/version2/src/C/ServerException.h
deleted file mode 100644 (file)
index f68e194..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-public class ServerException extends Exception {
-
-    public static final char TypeConnectTimeout = 1;
-    public static final char TypeInputTimeout = 2;
-    public static final char TypeIncorrectResponseCode = 3;
-    public static final char TypeSalt = 4;
-    private char type = -1;
-
-    public ServerException(String message, char _type) {
-        super(message);
-        type = _type;
-    }
-
-    public char getType() {
-        return type;
-    }
-}
index 0decdda..4803b60 100644 (file)
@@ -21,5 +21,6 @@ class CommitPart;
 class ArbitrationRound;
 class KeyValue;
 class IoTString;
+class RejectedMessage;
 
 #endif