adding group garbage collection functionality
If a group has a reference count of zero for more than
a configurable timeout, it is garbage collected.
This feature can be deactivated by component config.
Change-Id: I254d62a90ef7ac8d2ce2f406b67957455a5bf4d0
diff --git a/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java b/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
index 97f8aed..edd64e3 100644
--- a/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
+++ b/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
@@ -35,6 +35,7 @@
private long bytes;
private long referenceCount;
private GroupId id;
+ private int age;
/**
* Initializes default values.
@@ -48,6 +49,7 @@
packets = 0;
bytes = 0;
referenceCount = 0;
+ age = 0;
}
/**
@@ -128,6 +130,11 @@
return this.bytes;
}
+ @Override
+ public int age() {
+ return age;
+ }
+
/**
* Sets the new state for this entry.
*
@@ -171,6 +178,11 @@
@Override
public void setReferenceCount(long referenceCount) {
this.referenceCount = referenceCount;
+ if (referenceCount == 0) {
+ age++;
+ } else {
+ age = 0;
+ }
}
@Override
@@ -214,6 +226,7 @@
.add("description", super.toString())
.add("groupid", id)
.add("state", state)
+ .add("age", age)
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/group/Group.java b/core/api/src/main/java/org/onosproject/net/group/Group.java
index 5440775..d053029 100644
--- a/core/api/src/main/java/org/onosproject/net/group/Group.java
+++ b/core/api/src/main/java/org/onosproject/net/group/Group.java
@@ -96,4 +96,12 @@
* @return number of flow rules or other groups pointing to this group
*/
long referenceCount();
+
+ /**
+ * Obtains the age of a group. The age reflects the number of polling rounds
+ * the group has had a reference count of zero.
+ *
+ * @return the age of the group as an integer
+ */
+ int age();
}