Skip to content
Browse files

exposing number of purges and resizings

  • Loading branch information...
1 parent a04f125 commit 0339543662679c7335c86ac8f95450befbbb8cb9 @belaban committed Dec 14, 2010
View
3 src/org/jgroups/protocols/pbcast/NAKACK.java
@@ -479,7 +479,8 @@ public String printRetransmitTableSizes() {
for(Map.Entry<Address,NakReceiverWindow> entry: xmit_table.entrySet()) {
NakReceiverWindow win=entry.getValue();
sb.append(entry.getKey() + ": ").append(win.getRetransmiTableSize())
- .append(" (capacity=" + win.getRetransmitTableCapacity() + ")\n");
+ .append(" (capacity=" + win.getRetransmitTableCapacity() + ", purges=" + win.getRetransmitTablePurges() +
+ ", resizes=" + win.getRetransmitTableResizings() + "\n");
}
return sb.toString();
}
View
4 src/org/jgroups/stack/NakReceiverWindow.java
@@ -208,6 +208,10 @@ private void setSmoothedLossRate() {
public int getRetransmitTableCapacity() {return xmit_table.capacity();}
+ public int getRetransmitTableResizings() {return xmit_table.getResizings();}
+
+ public int getRetransmitTablePurges() {return xmit_table.getPurges();}
+
/**
* Adds a message according to its seqno (sequence number).
View
32 src/org/jgroups/util/RetransmitTable.java
@@ -24,6 +24,22 @@
protected long offset;
protected volatile int size=0;
+ protected volatile int num_resizes=0;
+ protected volatile int num_purges=0;
+
+
+ /** Returns the total capacity in the matrix */
+ public int capacity() {return matrix.length * msgs_per_row;}
+
+ /** Returns the numbers of messages in the table */
+ public int size() {return size;}
+
+ public int getResizings() {return num_resizes;}
+
+ public int getPurges() {return num_purges;}
+
+ public boolean isEmpty() {return size <= 0;}
+
public RetransmitTable() {
@@ -63,6 +79,8 @@ public boolean put(long seqno, Message msg) {
*/
public Message putIfAbsent(long seqno, Message msg) {
int row_index=computeRow(seqno);
+ if(row_index >= matrix.length)
+ resize(row_index +1);
Message[] row=getRow(row_index);
int index=computeIndex(seqno);
Message existing_msg=row[index];
@@ -108,7 +126,7 @@ public Message remove(long seqno) {
* it is not used anymore after returning */
public void clear() {
matrix=new Message[num_rows][];
- size=0;
+ size=num_resizes=num_purges=0;
offset=1;
}
@@ -130,17 +148,10 @@ public void purge(long seqno) {
offset+=(num_rows_to_remove * msgs_per_row);
size=computeSize();
+ num_purges++;
}
- /** Returns the total capacity in the matrix */
- public int capacity() {return matrix.length * msgs_per_row;}
-
- /** Returns the numbers of messages in the table */
- public int size() {return size;}
-
- public boolean isEmpty() {return size <= 0;}
-
/** A more expensive way to compute the size, done by iterating through the entire table and adding up non-null values */
public int computeSize() {
int retval=0;
@@ -228,8 +239,6 @@ public String dumpMatrix() {
* @return A row
*/
protected Message[] getRow(int index) {
- if(index >= matrix.length)
- resize(index +1);
Message[] row=matrix[index];
if(row == null) {
row=new Message[msgs_per_row];
@@ -244,6 +253,7 @@ protected void resize(int new_capacity) {
Message[][] new_matrix=new Message[new_size][];
System.arraycopy(matrix, 0, new_matrix, 0, matrix.length);
matrix=new_matrix;
+ num_resizes++;
}

0 comments on commit 0339543

Please sign in to comment.
Something went wrong with that request. Please try again.