From 7262ffd03fa5a5f9e92977e7e3cc04dd2c2ff6e0 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 19 Jan 2018 13:49:28 -0800 Subject: [PATCH 1/1] edits --- version2/src/C/ByteBuffer.h | 6 +++++- version2/src/C/IoTString.h | 4 ++-- version2/src/C/KeyValue.cc | 6 ++++-- version2/src/C/NewKey.cc | 5 +++-- version2/src/C/NewKey.h | 2 ++ version2/src/C/RejectedMessage.cc | 4 ++-- version2/src/C/RejectedMessage.h | 3 ++- version2/src/C/Slot.cc | 2 +- version2/src/C/Slot.h | 4 ++++ version2/src/C/SlotBuffer.cc | 5 +++-- version2/src/C/SlotIndexer.cc | 4 +++- version2/src/C/SlotIndexer.h | 2 +- version2/src/C/common.h | 2 ++ 13 files changed, 34 insertions(+), 15 deletions(-) diff --git a/version2/src/C/ByteBuffer.h b/version2/src/C/ByteBuffer.h index 92d4f16..a89ca24 100644 --- a/version2/src/C/ByteBuffer.h +++ b/version2/src/C/ByteBuffer.h @@ -5,9 +5,13 @@ class ByteBuffer { public: void put(char c); + void putInt(int32_t l); void putLong(int64_t l); + void put(Array * array); int64_t getLong(); + int32_t getInt(); char get(); -private: + void get(Array * array); + private: }; #endif diff --git a/version2/src/C/IoTString.h b/version2/src/C/IoTString.h index bbd0c77..f22324b 100644 --- a/version2/src/C/IoTString.h +++ b/version2/src/C/IoTString.h @@ -9,7 +9,7 @@ * @version 1.0 */ -public class IoTString { +class IoTString { private: Array *array; IoTString() {} @@ -34,7 +34,7 @@ public: * Returns a copy of the underlying char string. */ - Array *getBytes() { return new Array(&array); } + Array *getBytes() { return new Array(array); } /** * Returns the length in chars of the IoTString. diff --git a/version2/src/C/KeyValue.cc b/version2/src/C/KeyValue.cc index 561ae80..96d740d 100644 --- a/version2/src/C/KeyValue.cc +++ b/version2/src/C/KeyValue.cc @@ -1,4 +1,6 @@ #include "KeyValue.h" +#include "ByteBuffer.h" +#include "IoTString.h" /** * KeyValue entry for Slot. * @author Brian Demsky @@ -8,7 +10,7 @@ KeyValue *KeyValue_decode(ByteBuffer *bb) { int keylength = bb->getInt(); int valuelength = bb->getInt(); - Array *key = new Array *(keylength); + Array *key = new Array(keylength); bb->get(key); if (valuelength != 0) { @@ -41,7 +43,7 @@ int KeyValue::getSize() { return 2 * sizeof(int32_t) + key->length() + value->length(); } - return 2 * sizeof(int32_t) + key.length(); + return 2 * sizeof(int32_t) + key->length(); } KeyValue *KeyValue::getCopy() { diff --git a/version2/src/C/NewKey.cc b/version2/src/C/NewKey.cc index c6afe55..a8a9526 100644 --- a/version2/src/C/NewKey.cc +++ b/version2/src/C/NewKey.cc @@ -1,5 +1,6 @@ #include "NewKey.h" #include "ByteBuffer.h" +#include "IoTString.h" Entry *decode(Slot *slot, ByteBuffer *bb) { int keylength = bb->getInt(); @@ -7,7 +8,7 @@ Entry *decode(Slot *slot, ByteBuffer *bb) { bb->get(key); int64_t machineid = bb->getLong(); - return new NewKey(slot, IoTString.shallow(key), machineid); + return new NewKey(slot, IoTString_shallow(key), machineid); } void NewKey::encode(ByteBuffer *bb) { @@ -18,5 +19,5 @@ void NewKey::encode(ByteBuffer *bb) { } int NewKey::getSize() { - return sizeof(int64_t) + sizeof(char) + sizeof(int32_t) + key.length(); + return sizeof(int64_t) + sizeof(char) + sizeof(int32_t) + key->length(); } diff --git a/version2/src/C/NewKey.h b/version2/src/C/NewKey.h index 74b9dbc..ffb577a 100644 --- a/version2/src/C/NewKey.h +++ b/version2/src/C/NewKey.h @@ -1,5 +1,7 @@ #ifndef NEWKEY_H #define NEWKEY_H +#include "common.h" +#include "Entry.h" /** * This Entry records the abort sent by a given machine. diff --git a/version2/src/C/RejectedMessage.cc b/version2/src/C/RejectedMessage.cc index 05d37f6..da5d574 100644 --- a/version2/src/C/RejectedMessage.cc +++ b/version2/src/C/RejectedMessage.cc @@ -19,8 +19,8 @@ Entry *RejectedMessage_decode(Slot *slot, ByteBuffer *bb) { } void RejectedMessage::removeWatcher(int64_t machineid) { - if (watchset.remove(machineid)) - if (watchset.isEmpty()) + if (watchset->remove(machineid)) + if (watchset->isEmpty()) setDead(); } diff --git a/version2/src/C/RejectedMessage.h b/version2/src/C/RejectedMessage.h index 86a005e..3816d19 100644 --- a/version2/src/C/RejectedMessage.h +++ b/version2/src/C/RejectedMessage.h @@ -26,7 +26,8 @@ private: /* Set of machines that have not received notification. */ Hashset *watchset; - RejectedMessage(Slot *slot, int64_t _sequencenum, int64_t _machineid, int64_t _oldseqnum, int64_t _newseqnum, bool _equalto) : Entry(slot), + public: + 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), diff --git a/version2/src/C/Slot.cc b/version2/src/C/Slot.cc index 982b87b..2ee6981 100644 --- a/version2/src/C/Slot.cc +++ b/version2/src/C/Slot.cc @@ -78,7 +78,7 @@ Slot *Slotdecode(Table *table, char *array, Mac *mac) { return slot; } -char *Slot::encode(Mac mac) { +char *Slot::encode(Mac * mac) { char *array = new char[SLOT_SIZE]; ByteBuffer *bb = ByteBuffer_wrap(array); /* Leave space for the slot HMAC. */ diff --git a/version2/src/C/Slot.h b/version2/src/C/Slot.h index 1138fbf..76e0fb4 100644 --- a/version2/src/C/Slot.h +++ b/version2/src/C/Slot.h @@ -1,6 +1,10 @@ #ifndef SLOT_H #define SLOT_H +#include "common.h" +#include "Liveness.h" + + #define SLOT_SIZE 2048 #define HMAC_SIZE 32 diff --git a/version2/src/C/SlotBuffer.cc b/version2/src/C/SlotBuffer.cc index 4ddf4ba..ad78b3e 100644 --- a/version2/src/C/SlotBuffer.cc +++ b/version2/src/C/SlotBuffer.cc @@ -1,4 +1,5 @@ #include "SlotBuffer.h" +#include "Slot.h" /** * Circular buffer that holds the live set of slots. * @author Brian Demsky @@ -76,7 +77,7 @@ void SlotBuffer::putSlot(Slot *s) { } } -Slot SlotBuffer::getSlot(int64_t seqnum) { +Slot * SlotBuffer::getSlot(int64_t seqnum) { int32_t diff = (int32_t) (seqnum - oldestseqn); int32_t index = diff + tail; @@ -92,7 +93,7 @@ Slot SlotBuffer::getSlot(int64_t seqnum) { index -= array->length(); } - if (index >= array->length) { + if (index >= array->length()) { return NULL; } diff --git a/version2/src/C/SlotIndexer.cc b/version2/src/C/SlotIndexer.cc index 2b4cdf4..e3b7fa7 100644 --- a/version2/src/C/SlotIndexer.cc +++ b/version2/src/C/SlotIndexer.cc @@ -1,5 +1,7 @@ #include "SlotIndexer.h" - +#include "Slot.h" +#include "Error.h" +#include "SlotBuffer.h" /** * Slot indexer allows slots in both the slot buffer and the new * server response to looked up in a consistent fashion. diff --git a/version2/src/C/SlotIndexer.h b/version2/src/C/SlotIndexer.h index d1004d3..9dee2bb 100644 --- a/version2/src/C/SlotIndexer.h +++ b/version2/src/C/SlotIndexer.h @@ -18,4 +18,4 @@ public: SlotIndexer(Array *_updates, SlotBuffer *_buffer); Slot *getSlot(int64_t seqnum); }; -#endif; +#endif diff --git a/version2/src/C/common.h b/version2/src/C/common.h index afa511f..5ce508e 100644 --- a/version2/src/C/common.h +++ b/version2/src/C/common.h @@ -36,6 +36,8 @@ class TimingSingleton; class Transaction; class TransactionPart; class TransactionStatus; +class Mac; +class Error; #define ASSERT(expr) \ do { \ -- 2.34.1