public class RetransmitTable
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected boolean |
automatic_purging
By default, rows are only nulled and highest_seqno_purged is adjusted when
purge(long) is called. |
protected static long |
DEFAULT_MAX_COMPACTION_TIME |
protected static double |
DEFAULT_RESIZE_FACTOR |
protected long |
highest_seqno
The highest seqno in the table
|
protected long |
highest_seqno_purged
The highest seqno purged
|
protected long |
last_compaction_timestamp
The time when the last compaction took place.
|
protected static Log |
log |
protected Message[][] |
matrix |
protected long |
max_compaction_time
Time (in ms) after which a compaction should take place. 0 disables compaction
|
protected int |
msgs_per_row
Must be a power of 2 for efficient modular arithmetic
|
protected int |
num_rows |
protected long |
offset
The first seqno, at matrix[0][0]
|
protected double |
resize_factor |
protected int |
size |
构造器和说明 |
---|
RetransmitTable() |
RetransmitTable(int num_rows,
int msgs_per_row,
long offset) |
RetransmitTable(int num_rows,
int msgs_per_row,
long offset,
double resize_factor) |
RetransmitTable(int num_rows,
int msgs_per_row,
long offset,
double resize_factor,
long max_compaction_time,
boolean automatic_purging) |
限定符和类型 | 方法和说明 |
---|---|
int |
capacity()
Returns the total capacity in the matrix
|
void |
clear()
Removes all elements.
|
void |
compact()
Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly.
|
protected int |
computeIndex(long seqno)
Computes and returns the index within a row for seqno
|
protected int |
computeRow(long seqno)
Computes and returns the row index for seqno
|
int |
computeSize()
Iterate from highest_seqno_purged to highest_seqno and add up non-null values
|
java.lang.String |
dump()
Dumps the seqnos in the table as a list
|
java.lang.String |
dumpMatrix()
Dumps the non-null in the table in a pseudo graphic way
|
Message |
get(long seqno) |
java.util.List<Message> |
get(long from,
long to) |
double |
getFillFactor()
Returns the ratio between size and capacity, as a percentage
|
long |
getHighest() |
long |
getHighestPurged() |
int |
getLength() |
long |
getMaxCompactionTime() |
int |
getNullMessages(long from,
long to)
Returns the number of null elements in the range [from .. to], excluding 'from' and 'to'
|
long |
getOffset() |
protected Message[] |
getRow(int index)
Returns a row.
|
boolean |
isAutomaticPurging() |
boolean |
isEmpty() |
protected void |
move(int num_rows)
Moves contents of matrix num_rows down.
|
void |
purge(long seqno)
Removes all messages less than or equal to seqno from the table.
|
boolean |
put(long seqno,
Message msg)
Adds a new message to the index computed as a function of seqno
|
Message |
putIfAbsent(long seqno,
Message msg)
Adds a message if the element at the given index is null.
|
Message |
remove(long seqno)
Removes the message with seqno from the table, nulls the index
|
protected void |
resize(long seqno)
Moves rows down the matrix, by removing purged rows.
|
void |
setAutomaticPurging(boolean automatic_purging) |
void |
setMaxCompactionTime(long max_compaction_time) |
int |
size()
Returns the numbers of messages in the table
|
long |
sizeOfAllMessages(boolean include_headers)
Computes the size of all messages currently in the table.
|
java.lang.String |
toString() |
protected final int num_rows
protected final int msgs_per_row
protected final double resize_factor
protected Message[][] matrix
protected long offset
protected int size
protected long highest_seqno_purged
protected long highest_seqno
protected long max_compaction_time
protected long last_compaction_timestamp
compact()
takes place and sees that the
last compaction is more than max_compaction_time ms ago, a compaction will take placeprotected boolean automatic_purging
purge(long)
is called.
When automatic_purging is enabled (default is off), rows are purged and highest_seqno_purged is adjusted
on remove(long)
protected static final long DEFAULT_MAX_COMPACTION_TIME
protected static final double DEFAULT_RESIZE_FACTOR
protected static final Log log
public RetransmitTable()
public RetransmitTable(int num_rows, int msgs_per_row, long offset)
public RetransmitTable(int num_rows, int msgs_per_row, long offset, double resize_factor)
public RetransmitTable(int num_rows, int msgs_per_row, long offset, double resize_factor, long max_compaction_time, boolean automatic_purging)
public int getLength()
public long getOffset()
public int capacity()
public int size()
public boolean isEmpty()
public long getHighest()
public long getHighestPurged()
public long getMaxCompactionTime()
public void setMaxCompactionTime(long max_compaction_time)
public boolean isAutomaticPurging()
public void setAutomaticPurging(boolean automatic_purging)
public double getFillFactor()
public boolean put(long seqno, Message msg)
seqno
- msg
- public Message putIfAbsent(long seqno, Message msg)
seqno
- msg
- public Message get(long seqno)
public java.util.List<Message> get(long from, long to)
public Message remove(long seqno)
public void clear()
public void purge(long seqno)
seqno
- protected void resize(long seqno)
protected void move(int num_rows)
public void compact()
public int computeSize()
public int getNullMessages(long from, long to)
public java.lang.String toString()
toString
在类中 java.lang.Object
public java.lang.String dump()
public java.lang.String dumpMatrix()
public long sizeOfAllMessages(boolean include_headers)
include_headers
- If true, Message.size()
is used, which will include the size of all
headers and the dest and src addresses. Else Message.getLength()
is used to compute.
Note that the latter is way more efficient.protected Message[] getRow(int index)
index
- protected int computeRow(long seqno)
protected int computeIndex(long seqno)