[ONOS-4595] Harmonize the sb of the Intent Framework
Changes:
- Moves PointToPointIntent to LinkCollectionIntent;
- Moves PointToPointIntent to the new FilteredConnectPoint API;
- Updates unit tests;
Change-Id: Iade5090b9289c5b2d9f4ee41aa0d2d01b5e3699c
diff --git a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
index 0893528..11f9f77 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
@@ -46,8 +46,45 @@
private final Set<FilteredConnectPoint> ingressPoints;
private final Set<FilteredConnectPoint> egressPoints;
private final boolean egressTreatmentFlag;
+ private final double cost;
+ private static final int DEFAULT_COST = 1;
-
+ /**
+ * Creates a new actionable intent capable of funneling the selected
+ * traffic along the specified convergent tree and out the given egress
+ * point satisfying the specified constraints.
+ *
+ * @param appId application identifier
+ * @param key key to use for the intent
+ * @param selector traffic match
+ * @param treatment action
+ * @param links traversed links
+ * @param ingressPoints filtered ingress points
+ * @param egressPoints filtered egress points
+ * @param constraints optional list of constraints
+ * @param priority priority to use for the flows generated by this intent
+ * @param egressTreatment true if treatment should be applied by the egress device
+ * @param cost the cost of the links
+ * @throws NullPointerException {@code path} is null
+ */
+ private LinkCollectionIntent(ApplicationId appId,
+ Key key,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ Set<Link> links,
+ Set<FilteredConnectPoint> ingressPoints,
+ Set<FilteredConnectPoint> egressPoints,
+ List<Constraint> constraints,
+ int priority,
+ boolean egressTreatment,
+ double cost) {
+ super(appId, key, resources(links), selector, treatment, constraints, priority);
+ this.links = links;
+ this.ingressPoints = ingressPoints;
+ this.egressPoints = egressPoints;
+ this.egressTreatmentFlag = egressTreatment;
+ this.cost = cost;
+ }
/**
* Creates a new actionable intent capable of funneling the selected
@@ -76,22 +113,19 @@
List<Constraint> constraints,
int priority,
boolean egressTreatment) {
- super(appId, key, resources(links), selector, treatment, constraints, priority);
- this.links = links;
- this.ingressPoints = ingressPoints;
- this.egressPoints = egressPoints;
- this.egressTreatmentFlag = egressTreatment;
+ this(appId, key, selector, treatment, links, ingressPoints, egressPoints, constraints,
+ priority, egressTreatment, DEFAULT_COST);
}
/**
* Constructor for serializer.
*/
protected LinkCollectionIntent() {
- super();
this.links = null;
this.ingressPoints = null;
this.egressPoints = null;
this.egressTreatmentFlag = false;
+ this.cost = DEFAULT_COST;
}
/**
@@ -115,6 +149,8 @@
private Set<FilteredConnectPoint> ingressPoints;
private Set<FilteredConnectPoint> egressPoints;
private boolean egressTreatmentFlag;
+ private double cost;
+
private Builder() {
// Hide constructor
@@ -237,6 +273,17 @@
}
/**
+ * Sets the cost for the links of the Intent.
+ *
+ * @param cost the cost of the links
+ * @return this builder
+ */
+ public Builder cost(double cost) {
+ this.cost = cost;
+ return this;
+ }
+
+ /**
* Builds a single point to multi point intent from the
* accumulated parameters.
*
@@ -254,7 +301,8 @@
egressPoints,
constraints,
priority,
- egressTreatmentFlag
+ egressTreatmentFlag,
+ cost
);
}
}
@@ -324,6 +372,15 @@
return egressTreatmentFlag;
}
+ /**
+ * Returns the cost of the links of this intent.
+ *
+ * @return the cost of the links
+ */
+ public double cost() {
+ return cost;
+ }
+
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
@@ -338,6 +395,7 @@
.add("ingress", ingressPoints())
.add("egress", egressPoints())
.add("treatementOnEgress", applyTreatmentOnEgress())
+ .add("cost", cost())
.toString();
}
}