[ONOS-5264] [ONOS-5242] Intents w/ FilteredConnectPoint
Change-Id: Ibe9062c904ad9a6c3ba001fe57be7cec49eb8a4d
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 85bd5df..0893528 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
@@ -17,19 +17,22 @@
package org.onosproject.net.intent;
import java.util.List;
-import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableMap;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Abstraction of a connectivity intent that is implemented by a set of path
@@ -40,17 +43,11 @@
private final Set<Link> links;
- private final Set<ConnectPoint> ingressPoints;
- private final Set<ConnectPoint> egressPoints;
+ private final Set<FilteredConnectPoint> ingressPoints;
+ private final Set<FilteredConnectPoint> egressPoints;
private final boolean egressTreatmentFlag;
- /**
- * To manage multiple selectors use case.
- */
- private final Map<ConnectPoint, TrafficSelector> ingressSelectors;
- /**
- * To manage multiple treatments use case.
- */
- private final Map<ConnectPoint, TrafficTreatment> egressTreatments;
+
+
/**
* Creates a new actionable intent capable of funneling the selected
@@ -62,13 +59,11 @@
* @param selector traffic match
* @param treatment action
* @param links traversed links
- * @param ingressPoints ingress points
- * @param egressPoints egress points
+ * @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 ingressSelectors map to store the association ingress to selector
- * @param egressTreatments map to store the association egress to treatment
* @throws NullPointerException {@code path} is null
*/
private LinkCollectionIntent(ApplicationId appId,
@@ -76,20 +71,16 @@
TrafficSelector selector,
TrafficTreatment treatment,
Set<Link> links,
- Set<ConnectPoint> ingressPoints,
- Set<ConnectPoint> egressPoints,
+ Set<FilteredConnectPoint> ingressPoints,
+ Set<FilteredConnectPoint> egressPoints,
List<Constraint> constraints,
int priority,
- boolean egressTreatment,
- Map<ConnectPoint, TrafficSelector> ingressSelectors,
- Map<ConnectPoint, TrafficTreatment> egressTreatments) {
+ boolean egressTreatment) {
super(appId, key, resources(links), selector, treatment, constraints, priority);
this.links = links;
this.ingressPoints = ingressPoints;
this.egressPoints = egressPoints;
this.egressTreatmentFlag = egressTreatment;
- this.ingressSelectors = ingressSelectors;
- this.egressTreatments = egressTreatments;
}
/**
@@ -101,8 +92,6 @@
this.ingressPoints = null;
this.egressPoints = null;
this.egressTreatmentFlag = false;
- this.ingressSelectors = null;
- this.egressTreatments = null;
}
/**
@@ -121,12 +110,11 @@
* Builder of a single point to multi point intent.
*/
public static final class Builder extends ConnectivityIntent.Builder {
- Set<Link> links;
- Set<ConnectPoint> ingressPoints;
- Set<ConnectPoint> egressPoints;
- Map<ConnectPoint, TrafficSelector> ingressSelectors = ImmutableMap.of();
- Map<ConnectPoint, TrafficTreatment> egressTreatments = ImmutableMap.of();
- boolean egressTreatmentFlag;
+ private final Logger log = getLogger(getClass());
+ private Set<Link> links;
+ private Set<FilteredConnectPoint> ingressPoints;
+ private Set<FilteredConnectPoint> egressPoints;
+ private boolean egressTreatmentFlag;
private Builder() {
// Hide constructor
@@ -169,8 +157,15 @@
* @param ingressPoints ingress connect points
* @return this builder
*/
+ @Deprecated
public Builder ingressPoints(Set<ConnectPoint> ingressPoints) {
- this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
+ if (this.ingressPoints != null) {
+ log.warn("Ingress points are already set, " +
+ "this will override original ingress points.");
+ }
+ this.ingressPoints = ingressPoints.stream()
+ .map(FilteredConnectPoint::new)
+ .collect(Collectors.toSet());
return this;
}
@@ -181,34 +176,43 @@
* @param egressPoints egress connect points
* @return this builder
*/
+ @Deprecated
public Builder egressPoints(Set<ConnectPoint> egressPoints) {
+ if (this.egressPoints != null) {
+ log.warn("Egress points are already set, " +
+ "this will override original egress points.");
+ }
+ this.egressPoints = egressPoints.stream()
+ .map(FilteredConnectPoint::new)
+ .collect(Collectors.toSet());
+ return this;
+ }
+
+ /**
+ * Sets the filtered ingress point of the single point to multi point intent
+ * that will be built.
+ *
+ * @param ingressPoints ingress connect points
+ * @return this builder
+ */
+ public Builder filteredIngressPoints(Set<FilteredConnectPoint> ingressPoints) {
+ this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
+ return this;
+ }
+
+ /**
+ * Sets the filtered egress points of the single point to multi point intent
+ * that will be built.
+ *
+ * @param egressPoints egress connect points
+ * @return this builder
+ */
+ public Builder filteredEgressPoints(Set<FilteredConnectPoint> egressPoints) {
this.egressPoints = ImmutableSet.copyOf(egressPoints);
return this;
}
/**
- * Sets the map ingress selectors to connection points of the intent.
- *
- * @param ingressSelectors maps connection point to traffic selector
- * @return this builder
- */
- public Builder ingressSelectors(Map<ConnectPoint, TrafficSelector> ingressSelectors) {
- this.ingressSelectors = ImmutableMap.copyOf(ingressSelectors);
- return this;
- }
-
- /**
- * Sets the map egress treatments to connection points of the intent.
- *
- * @param egressTreatments maps connection point to traffic treatment
- * @return this builder
- */
- public Builder egressTreatments(Map<ConnectPoint, TrafficTreatment> egressTreatments) {
- this.egressTreatments = ImmutableMap.copyOf(egressTreatments);
- return this;
- }
-
- /**
* Sets the links of the link collection intent
* that will be built.
*
@@ -250,9 +254,7 @@
egressPoints,
constraints,
priority,
- egressTreatmentFlag,
- ingressSelectors,
- egressTreatments
+ egressTreatmentFlag
);
}
}
@@ -273,7 +275,12 @@
* @return the ingress points
*/
public Set<ConnectPoint> ingressPoints() {
- return ingressPoints;
+ if (this.ingressPoints == null) {
+ return null;
+ }
+ return ingressPoints.stream()
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet());
}
/**
@@ -282,26 +289,33 @@
* @return the egress points
*/
public Set<ConnectPoint> egressPoints() {
+ if (this.egressPoints == null) {
+ return null;
+ }
+ return egressPoints.stream()
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet());
+ }
+
+ /**
+ * Returns the filtered ingress points of the intent.
+ *
+ * @return the ingress points
+ */
+ public Set<FilteredConnectPoint> filteredIngressPoints() {
+ return ingressPoints;
+ }
+
+ /**
+ * Returns the egress points of the intent.
+ *
+ * @return the egress points
+ */
+ public Set<FilteredConnectPoint> filteredEgressPoints() {
return egressPoints;
}
/**
- * Returns the multiple selectors jointly with their connection points.
- * @return multiple selectors
- */
- public Map<ConnectPoint, TrafficSelector> ingressSelectors() {
- return ingressSelectors;
- }
-
- /**
- * Returns the multiple treatments jointly with their connection points.
- * @return multiple treatments
- */
- public Map<ConnectPoint, TrafficTreatment> egressTreatments() {
- return egressTreatments;
- }
-
- /**
* Returns whether treatment should be applied on egress.
*
* @return the egress treatment flag
@@ -323,8 +337,6 @@
.add("links", links())
.add("ingress", ingressPoints())
.add("egress", egressPoints())
- .add("selectors", ingressSelectors())
- .add("treatments", egressTreatments())
.add("treatementOnEgress", applyTreatmentOnEgress())
.toString();
}