Package org.jgroups.util
Class SeqnoList
- java.lang.Object
-
- org.jgroups.util.FixedSizeBitSet
-
- org.jgroups.util.SeqnoList
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Long>
,Constructable<SeqnoList>
,SizeStreamable
,Streamable
public class SeqnoList extends FixedSizeBitSet implements SizeStreamable, java.lang.Iterable<java.lang.Long>, Constructable<SeqnoList>
A bitset of missing messages with a fixed size. The index (in the bit set) of a seqno is computed as seqno - offset.- Since:
- 3.1
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
SeqnoList.SeqnoListIterator
-
Field Summary
Fields Modifier and Type Field Description protected long
offset
-
Fields inherited from class org.jgroups.util.FixedSizeBitSet
ADDRESS_BITS_PER_WORD, BITS_PER_WORD, size, WORD_MASK, words
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SeqnoList
add(long seqno)
Adds a single seqnoSeqnoList
add(long... seqnos)
SeqnoList
add(long from, long to)
Adds a seqno rangejava.util.function.Supplier<? extends SeqnoList>
create()
Creates an instance of the class implementing this interfacelong
getLast()
Returns the last seqno, this should also be the highest seqno in the list as we're supposed to add seqnos in orderprotected int
index(long seqno)
boolean
isEmpty()
java.util.Iterator<java.lang.Long>
iterator()
void
readFrom(java.io.DataInput in)
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedvoid
removeHigherThan(long max_seqno)
Removes all seqnos > seqnoprotected long
seqno(int index)
int
serializedSize()
Returns the size (in bytes) of the marshalled objectint
size()
java.lang.String
toString()
Returns a string representation of this bit set.void
writeTo(java.io.DataOutput out)
Write the entire state of the current object (including superclasses) to outstream.-
Methods inherited from class org.jgroups.util.FixedSizeBitSet
cardinality, clear, clear, flip, get, nextClearBit, nextSetBit, previousSetBit, set, set, wordIndex
-
-
-
-
Constructor Detail
-
SeqnoList
public SeqnoList()
Only to be used by serialization
-
SeqnoList
public SeqnoList(int size, long offset)
Creates a SeqnoList with a capacity for size elements.- Parameters:
size
- The max number of seqnos in the bitsetoffset
- Lowest seqno. Used to compute the index of a given seqno into the bitset: seqno - offset
-
SeqnoList
public SeqnoList(int size)
-
-
Method Detail
-
create
public java.util.function.Supplier<? extends SeqnoList> create()
Description copied from interface:Constructable
Creates an instance of the class implementing this interface- Specified by:
create
in interfaceConstructable<SeqnoList>
-
add
public SeqnoList add(long seqno)
Adds a single seqno
-
add
public SeqnoList add(long... seqnos)
-
add
public SeqnoList add(long from, long to)
Adds a seqno range
-
removeHigherThan
public void removeHigherThan(long max_seqno)
Removes all seqnos > seqno
-
getLast
public long getLast()
Returns the last seqno, this should also be the highest seqno in the list as we're supposed to add seqnos in order- Returns:
-
serializedSize
public int serializedSize()
Description copied from interface:SizeStreamable
Returns the size (in bytes) of the marshalled object- Specified by:
serializedSize
in interfaceSizeStreamable
-
writeTo
public void writeTo(java.io.DataOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeTo
in interfaceStreamable
- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInput in) throws java.io.IOException
Description copied from interface:Streamable
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFrom
in interfaceStreamable
- Throws:
java.io.IOException
-
size
public int size()
- Overrides:
size
in classFixedSizeBitSet
-
isEmpty
public boolean isEmpty()
-
toString
public java.lang.String toString()
Description copied from class:FixedSizeBitSet
Returns a string representation of this bit set. For every index for which thisBitSet
contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.Overrides the
toString
method ofObject
.Example:
BitSet drPepper = new BitSet();
NowdrPepper.toString()
returns "{}
".drPepper.set(2);
NowdrPepper.toString()
returns "{2}
".drPepper.set(4); drPepper.set(10);
NowdrPepper.toString()
returns "{2, 4, 10}
".- Overrides:
toString
in classFixedSizeBitSet
- Returns:
- a string representation of this bit set.
-
iterator
public java.util.Iterator<java.lang.Long> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Long>
-
index
protected int index(long seqno)
-
seqno
protected long seqno(int index)
-
-