Work toward ONOS-1451: Separate Event Key space per instance
Misc changes and cleanup (Step 2):
* Added OnosInstanceId field to class TopologyEvent. For now it is
just assigned, but is not used.
* Minor refactoring of class TopologyEvent so it will be easier to make it
immutable after its its internals and usage are inalized.
* Modified the signature of method PathIntentMap.getIntentsByLink()
to use LinkTuple for the lookup instead of LinkEvent.
* Replaced (only inside onos/core/topology) the usage of Apache's
Validate with Google's Preconditions for null-checking and assignment.
With Apache's Validate we have to use two statements:
Validate.notNull(foo);
this.foo = foo;
With Google's Preconditions we can do it with a single statement:
this.foo = checkNotNull(foo);
NOTE: Apache's commons-lang version 3.x adds Google's semantics.
In the future, we need to decide (across all ONOS code) whether
to use Google's Preconditions or Apache's Validate 3.x
* Removed one of the LinkEvent convenience constructors, because it is used
only in 1-2 places in the unit tests, and nowhere in the main code.
* Few other (minor) cleanup changes
Change-Id: I05dae593ae1244a0af23515e7c73911f21275479
diff --git a/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java b/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
index 2469f99..d784439 100644
--- a/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
+++ b/src/main/java/net/onrc/onos/core/intent/PathIntentMap.java
@@ -8,6 +8,7 @@
import net.onrc.onos.core.topology.Link;
import net.onrc.onos.core.topology.LinkEvent;
import net.onrc.onos.core.util.Dpid;
+import net.onrc.onos.core.util.LinkTuple;
import net.onrc.onos.core.util.PortNumber;
import net.onrc.onos.core.util.SwitchPort;
@@ -97,13 +98,13 @@
/**
* Retrieve all intents that use a particular link.
*
- * @param linkEvent the link to look up
+ * @param linkTuple the link tuple to look up
* @return a collection of PathIntents that use the link
*/
- public Collection<PathIntent> getIntentsByLink(LinkEvent linkEvent) {
+ public Collection<PathIntent> getIntentsByLink(LinkTuple linkTuple) {
return getIntentsByPort(
- linkEvent.getSrc().getDpid(),
- linkEvent.getSrc().getPortNumber());
+ linkTuple.getSrc().getDpid(),
+ linkTuple.getSrc().getPortNumber());
}
/**
@@ -152,9 +153,8 @@
return null;
}
Double bandwidth = link.getCapacity();
- LinkEvent linkEvent = new LinkEvent(link);
if (!bandwidth.isInfinite()) {
- for (PathIntent intent : getIntentsByLink(linkEvent)) {
+ for (PathIntent intent : getIntentsByLink(link.getLinkTuple())) {
Double intentBandwidth = intent.getBandwidth();
if (intentBandwidth == null || intentBandwidth.isInfinite() || intentBandwidth.isNaN()) {
continue;