projects
/
iotcloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more js
[iotcloud.git]
/
src
/
java
/
iotcloud
/
Slot.java
diff --git
a/src/java/iotcloud/Slot.java
b/src/java/iotcloud/Slot.java
index 1d84baad65331227ffaab78c1a89932f35658c53..c114a8762c0eba7f83fdfe03178fc89000ffca5a 100644
(file)
--- a/
src/java/iotcloud/Slot.java
+++ b/
src/java/iotcloud/Slot.java
@@
-13,8
+13,6
@@
import java.util.Arrays;
class Slot implements Liveness {
/** Sets the slot size. */
static final int SLOT_SIZE=2048;
class Slot implements Liveness {
/** Sets the slot size. */
static final int SLOT_SIZE=2048;
- /** Sets how many bytes we reserve. */
- static final int RESERVED_SPACE=64;
/** Sets the size for the HMAC. */
static final int HMAC_SIZE=32;
/** Sets the size for the HMAC. */
static final int HMAC_SIZE=32;
@@
-35,8
+33,10
@@
class Slot implements Liveness {
private boolean seqnumlive;//
/** Number of bytes of free space. */
private int freespace;
private boolean seqnumlive;//
/** Number of bytes of free space. */
private int freespace;
+ /** Reference to Table */
+ private Table table;
- Slot(long _seqnum, long _machineid, byte[] _prevhmac, byte[] _hmac) {
+ Slot(
Table _table,
long _seqnum, long _machineid, byte[] _prevhmac, byte[] _hmac) {
seqnum=_seqnum;
machineid=_machineid;
prevhmac=_prevhmac;
seqnum=_seqnum;
machineid=_machineid;
prevhmac=_prevhmac;
@@
-45,14
+45,20
@@
class Slot implements Liveness {
livecount=1;
seqnumlive=true;
freespace = SLOT_SIZE - getBaseSize();
livecount=1;
seqnumlive=true;
freespace = SLOT_SIZE - getBaseSize();
+ table=_table;
}
}
- Slot(long _seqnum, long _machineid, byte[] _prevhmac) {
- this(_seqnum, _machineid, _prevhmac, null);
+ Slot(
Table _table,
long _seqnum, long _machineid, byte[] _prevhmac) {
+ this(_
table, _
seqnum, _machineid, _prevhmac, null);
}
}
+<<<<<<< HEAD
Slot(long _seqnum, long _machineid) {
this(_seqnum, _machineid, new byte[ HMAC_SIZE], null);
Slot(long _seqnum, long _machineid) {
this(_seqnum, _machineid, new byte[ HMAC_SIZE], null);
+=======
+ Slot(Table _table, long _seqnum, long _machineid) {
+ this(_table, _seqnum, _machineid, new byte[HMAC_SIZE], null);
+>>>>>>> f80cc30f294899f47cef3507334f8ca357862e5e
}
byte[] getHMAC() {
}
byte[] getHMAC() {
@@
-81,15
+87,6
@@
class Slot implements Liveness {
* using its reserved space. */
boolean hasSpace(Entry e) {
* using its reserved space. */
boolean hasSpace(Entry e) {
- int newfreespace = freespace - e.getSize();
- return newfreespace > RESERVED_SPACE;
- }
-
- /**
- * Returns true if the slot can fit the entry potentially using the
- * reserved space. */
-
- boolean canFit(Entry e) {
int newfreespace = freespace - e.getSize();
return newfreespace >= 0;
}
int newfreespace = freespace - e.getSize();
return newfreespace >= 0;
}
@@
-98,7
+95,7
@@
class Slot implements Liveness {
return entries;
}
return entries;
}
- static Slot decode(byte[] array, Mac mac) {
+ static Slot decode(
Table table,
byte[] array, Mac mac) {
mac.update(array, HMAC_SIZE, array.length-HMAC_SIZE);
byte[] realmac=mac.doFinal();
mac.update(array, HMAC_SIZE, array.length-HMAC_SIZE);
byte[] realmac=mac.doFinal();
@@
-113,7
+110,7
@@
class Slot implements Liveness {
long seqnum=bb.getLong();
long machineid=bb.getLong();
int numentries=bb.getInt();
long seqnum=bb.getLong();
long machineid=bb.getLong();
int numentries=bb.getInt();
- Slot slot=new Slot(seqnum, machineid, prevhmac, hmac);
+ Slot slot=new Slot(
table,
seqnum, machineid, prevhmac, hmac);
for(int i=0; i<numentries; i++) {
slot.addShallowEntry(Entry.decode(slot, bb));
for(int i=0; i<numentries; i++) {
slot.addShallowEntry(Entry.decode(slot, bb));
@@
-157,14
+154,16
@@
class Slot implements Liveness {
* itself.
*/
* itself.
*/
- Vector<Entry> getLiveEntries() {
+ Vector<Entry> getLiveEntries(
boolean resize
) {
Vector<Entry> liveEntries=new Vector<Entry>();
for(Entry entry: entries) {
Vector<Entry> liveEntries=new Vector<Entry>();
for(Entry entry: entries) {
- if (entry.isLive())
- liveEntries.add(entry);
+ if (entry.isLive()) {
+ if (!resize || entry.getType() != Entry.TypeTableStatus)
+ liveEntries.add(entry);
+ }
}
}
- if (seqnumlive)
+ if (seqnumlive
&& !resize
)
liveEntries.add(new LastMessage(this, machineid, seqnum));
return liveEntries;
liveEntries.add(new LastMessage(this, machineid, seqnum));
return liveEntries;
@@
-202,7
+201,8
@@
class Slot implements Liveness {
void decrementLiveCount() {
livecount--;
void decrementLiveCount() {
livecount--;
- Vector<Entry> e=getLiveEntries();
+ if (livecount==0)
+ table.decrementLiveCount();
}
/**
}
/**