[ONOS-5264] [ONOS-5242] Intents w/ FilteredConnectPoint
Change-Id: Ibe9062c904ad9a6c3ba001fe57be7cec49eb8a4d
diff --git a/core/api/src/main/java/org/onosproject/net/FilteredConnectPoint.java b/core/api/src/main/java/org/onosproject/net/FilteredConnectPoint.java
new file mode 100644
index 0000000..09d87fc
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/FilteredConnectPoint.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.TrafficSelector;
+
+import java.util.Objects;
+
+/**
+ * Connection point with TrafficSelector field.
+ */
+public class FilteredConnectPoint {
+ private final ConnectPoint connectPoint;
+ private final TrafficSelector trafficSelector;
+
+ /**
+ * Creates filtered connect point with default traffic selector.
+ *
+ * @param connectPoint
+ */
+ public FilteredConnectPoint(ConnectPoint connectPoint) {
+ this.connectPoint = connectPoint;
+ this.trafficSelector = DefaultTrafficSelector.emptySelector();
+ }
+
+ /**
+ * Creates new filtered connection point.
+ *
+ * @param connectPoint connect point
+ * @param trafficSelector traffic selector for this connect point
+ */
+ public FilteredConnectPoint(ConnectPoint connectPoint, TrafficSelector trafficSelector) {
+ this.connectPoint = connectPoint;
+ this.trafficSelector = trafficSelector;
+ }
+
+ /**
+ * Returns the traffic selector for this connect point.
+ *
+ * @return Traffic selector for this connect point
+ */
+ public TrafficSelector trafficSelector() {
+ return trafficSelector;
+ }
+
+ /**
+ * Returns the connection point.
+ * @return
+ */
+ public ConnectPoint connectPoint() {
+ return connectPoint;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(connectPoint, trafficSelector);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("connectPoint", connectPoint)
+ .add("trafficSelector", trafficSelector)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof FilteredConnectPoint) {
+ FilteredConnectPoint other = (FilteredConnectPoint) obj;
+ return other.connectPoint().equals(connectPoint) &&
+ other.trafficSelector().equals(trafficSelector());
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index e8d8089..fbe240a 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -475,6 +475,23 @@
}
@Override
+ public TrafficTreatment.Builder addTreatment(TrafficTreatment treatment) {
+ List<Instruction> previous = current;
+ deferred();
+ treatment.deferred().forEach(i -> add(i));
+
+ immediate();
+ treatment.immediate().stream()
+ // NOACTION will get re-added if there are no other actions
+ .filter(i -> i.type() != Instruction.Type.NOACTION)
+ .forEach(i -> add(i));
+
+ clear = treatment.clearedDeferred();
+ current = previous;
+ return this;
+ }
+
+ @Override
public TrafficTreatment build() {
if (deferred.size() == 0 && immediate.size() == 0
&& table == null && !clear) {
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index 74a9b37..d0de8e4 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -397,6 +397,14 @@
Builder extension(ExtensionTreatment extension, DeviceId deviceId);
/**
+ * Add all instructions from another treatment.
+ *
+ * @param treatment another treatment
+ * @return a treatment builder
+ */
+ Builder addTreatment(TrafficTreatment treatment);
+
+ /**
* Builds an immutable traffic treatment descriptor.
* <p>
* If the treatment is empty when build() is called, it will add a default
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentUtils.java b/core/api/src/main/java/org/onosproject/net/intent/IntentUtils.java
index 322b235..9ddb174 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentUtils.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentUtils.java
@@ -57,19 +57,19 @@
SinglePointToMultiPointIntent intent2 = (SinglePointToMultiPointIntent) two;
return Objects.equals(intent1.selector(), intent2.selector()) &&
- Objects.equals(intent1.treatment(), intent2.treatment()) &&
- Objects.equals(intent1.constraints(), intent2.constraints()) &&
- Objects.equals(intent1.ingressPoint(), intent2.ingressPoint()) &&
- Objects.equals(intent1.egressPoints(), intent2.egressPoints());
+ Objects.equals(intent1.treatment(), intent2.treatment()) &&
+ Objects.equals(intent1.filteredIngressPoint(), intent2.filteredIngressPoint()) &&
+ Objects.equals(intent1.filteredEgressPoints(), intent2.filteredEgressPoints()) &&
+ Objects.equals(intent1.constraints(), intent2.constraints());
} else if (one instanceof MultiPointToSinglePointIntent) {
MultiPointToSinglePointIntent intent1 = (MultiPointToSinglePointIntent) one;
MultiPointToSinglePointIntent intent2 = (MultiPointToSinglePointIntent) two;
return Objects.equals(intent1.selector(), intent2.selector()) &&
- Objects.equals(intent1.treatment(), intent2.treatment()) &&
- Objects.equals(intent1.constraints(), intent2.constraints()) &&
- Objects.equals(intent1.ingressPoints(), intent2.ingressPoints()) &&
- Objects.equals(intent1.egressPoint(), intent2.egressPoint());
+ Objects.equals(intent1.filteredIngressPoints(), intent2.filteredIngressPoints()) &&
+ Objects.equals(intent1.filteredEgressPoint(), intent2.filteredEgressPoint()) &&
+ Objects.equals(intent1.treatment(), intent2.treatment()) &&
+ Objects.equals(intent1.constraints(), intent2.constraints());
} else if (one instanceof PointToPointIntent) {
PointToPointIntent intent1 = (PointToPointIntent) one;
PointToPointIntent intent2 = (PointToPointIntent) two;
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();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
index 2b8398f..3048aac 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
@@ -17,20 +17,21 @@
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
+import org.slf4j.Logger;
import java.util.List;
-import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Abstraction of multiple source to single destination connectivity intent.
@@ -38,26 +39,21 @@
@Beta
public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
- private final Set<ConnectPoint> ingressPoints;
- private final ConnectPoint egressPoint;
- /**
- * To manage multiple selectors use case.
- */
- private final Map<ConnectPoint, TrafficSelector> ingressSelectors;
+ private final Set<FilteredConnectPoint> ingressPoints;
+ private final FilteredConnectPoint egressPoint;
/**
* Creates a new multi-to-single point connectivity intent for the specified
- * traffic selector and treatment.
+ * traffic selector and treatment with filtered connect point.
*
* @param appId application identifier
* @param key intent key
* @param selector traffic selector
* @param treatment treatment
- * @param ingressPoints set of ports from which ingress traffic originates
- * @param egressPoint port to which traffic will egress
+ * @param ingressPoints set of filtered ports from which ingress traffic originates
+ * @param egressPoint filtered port to which traffic will egress
* @param constraints constraints to apply to the intent
* @param priority priority to use for flows generated by this intent
- * @param ingressSelectors map to store the association ingress to selector
* @throws NullPointerException if {@code ingressPoints} or
* {@code egressPoint} is null.
* @throws IllegalArgumentException if the size of {@code ingressPoints} is
@@ -67,24 +63,22 @@
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
- Set<ConnectPoint> ingressPoints,
- ConnectPoint egressPoint,
+ Set<FilteredConnectPoint> ingressPoints,
+ FilteredConnectPoint egressPoint,
List<Constraint> constraints,
- int priority,
- Map<ConnectPoint, TrafficSelector> ingressSelectors
- ) {
+ int priority
+ ) {
super(appId, key, ImmutableSet.of(), selector, treatment, constraints,
- priority);
+ priority);
checkNotNull(ingressPoints);
checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
checkNotNull(egressPoint);
checkArgument(!ingressPoints.contains(egressPoint),
- "Set of ingresses should not contain egress (egress: %s)", egressPoint);
+ "Set of ingresses should not contain egress (egress: %s)", egressPoint);
- this.ingressPoints = Sets.newHashSet(ingressPoints);
+ this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
this.egressPoint = egressPoint;
- this.ingressSelectors = ingressSelectors;
}
/**
@@ -94,7 +88,6 @@
super();
this.ingressPoints = null;
this.egressPoint = null;
- this.ingressSelectors = null;
}
/**
@@ -124,9 +117,9 @@
* Builder of a multi point to single point intent.
*/
public static final class Builder extends ConnectivityIntent.Builder {
- Set<ConnectPoint> ingressPoints;
- ConnectPoint egressPoint;
- Map<ConnectPoint, TrafficSelector> ingressSelectors = ImmutableMap.of();
+ private final Logger log = getLogger(getClass());
+ private Set<FilteredConnectPoint> ingressPoints;
+ private FilteredConnectPoint egressPoint;
private Builder() {
// Hide constructor
@@ -141,8 +134,9 @@
protected Builder(MultiPointToSinglePointIntent intent) {
super(intent);
- this.ingressPoints(intent.ingressPoints())
- .egressPoint(intent.egressPoint());
+ this.filteredIngressPoints(intent.filteredIngressPoints())
+ .filteredEgressPoint(intent.filteredEgressPoint());
+
}
@Override
@@ -182,8 +176,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;
}
@@ -194,20 +195,37 @@
* @param egressPoint egress connect point
* @return this builder
*/
+ @Deprecated
public Builder egressPoint(ConnectPoint egressPoint) {
- this.egressPoint = egressPoint;
+ if (this.egressPoint != null) {
+ log.warn("Egress point is already set, " +
+ "this will override original egress point.");
+ }
+ this.egressPoint = new FilteredConnectPoint(egressPoint);
return this;
}
/**
- * Sets the selectors of the multi point to single point intent
+ * Sets the filtered ingress point of the single point to multi point intent
* that will be built.
*
- * @param ingressSelectors the multiple selectos
+ * @param ingressPoints filtered ingress connect points
* @return this builder
*/
- public Builder selectors(Map<ConnectPoint, TrafficSelector> ingressSelectors) {
- this.ingressSelectors = ImmutableMap.copyOf(ingressSelectors);
+ public Builder filteredIngressPoints(Set<FilteredConnectPoint> ingressPoints) {
+ this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
+ return this;
+ }
+
+ /**
+ * Sets the filtered egress point of the multi point to single point intent
+ * that will be built.
+ *
+ * @param egressPoint filtered egress connect point
+ * @return this builder
+ */
+ public Builder filteredEgressPoint(FilteredConnectPoint egressPoint) {
+ this.egressPoint = egressPoint;
return this;
}
@@ -219,11 +237,6 @@
*/
public MultiPointToSinglePointIntent build() {
- if (selector != null && !selector.criteria().isEmpty() &&
- ingressSelectors != null && !ingressSelectors.isEmpty()) {
- throw new IllegalArgumentException("Selector and Multiple Selectors are both set");
- }
-
return new MultiPointToSinglePointIntent(
appId,
key,
@@ -232,8 +245,7 @@
ingressPoints,
egressPoint,
constraints,
- priority,
- ingressSelectors
+ priority
);
}
}
@@ -246,7 +258,9 @@
* @return set of ingress ports
*/
public Set<ConnectPoint> ingressPoints() {
- return ingressPoints;
+ return ingressPoints.stream()
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet());
}
/**
@@ -255,17 +269,29 @@
* @return egress port
*/
public ConnectPoint egressPoint() {
- return egressPoint;
+ return egressPoint.connectPoint();
}
/**
- * Returns the multiple selectors jointly with their connection points.
- * @return multiple selectors
+ * Returns the set of ports on which ingress traffic should be connected to
+ * the egress port.
+ *
+ * @return set of ingress ports
*/
- public Map<ConnectPoint, TrafficSelector> ingressSelectors() {
- return ingressSelectors;
+ public Set<FilteredConnectPoint> filteredIngressPoints() {
+ return ingressPoints;
}
+ /**
+ * Returns the port on which the traffic should egress.
+ *
+ * @return egress port
+ */
+ public FilteredConnectPoint filteredEgressPoint() {
+ return egressPoint;
+ }
+
+
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
@@ -278,7 +304,8 @@
.add("treatment", treatment())
.add("ingress", ingressPoints())
.add("egress", egressPoint())
- .add("selectors", ingressSelectors())
+ .add("filteredIngressCPs", filteredIngressPoints())
+ .add("filteredEgressCP", filteredEgressPoint())
.add("constraints", constraints())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
index 4b17c66..8431a0a 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
@@ -18,35 +18,31 @@
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
+import org.slf4j.Logger;
-import java.util.Map;
import java.util.Set;
import java.util.List;
+import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Abstraction of single source, multiple destination connectivity intent.
*/
@Beta
public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
-
- private final ConnectPoint ingressPoint;
- private final Set<ConnectPoint> egressPoints;
- /**
- * To manage multiple treatments use case.
- */
- private final Map<ConnectPoint, TrafficTreatment> egressTreatments;
+ private final FilteredConnectPoint ingressPoint;
+ private final Set<FilteredConnectPoint> egressPoints;
/**
* Creates a new single-to-multi point connectivity intent.
@@ -59,7 +55,6 @@
* @param egressPoints set of ports on which traffic will egress
* @param constraints constraints to apply to the intent
* @param priority priority to use for flows generated by this intent
- * @param egressTreatments map to store the association egress to treatment
* @throws NullPointerException if {@code ingressPoint} or
* {@code egressPoints} is null
* @throws IllegalArgumentException if the size of {@code egressPoints} is
@@ -69,22 +64,20 @@
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
- ConnectPoint ingressPoint,
- Set<ConnectPoint> egressPoints,
+ FilteredConnectPoint ingressPoint,
+ Set<FilteredConnectPoint> egressPoints,
List<Constraint> constraints,
- int priority,
- Map<ConnectPoint, TrafficTreatment> egressTreatments) {
+ int priority) {
super(appId, key, ImmutableList.of(), selector, treatment, constraints,
priority);
checkNotNull(egressPoints);
checkNotNull(ingressPoint);
checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty");
checkArgument(!egressPoints.contains(ingressPoint),
- "Set of egresses should not contain ingress (ingress: %s)", ingressPoint);
+ "Set of egresses should not contain ingress (ingress: %s)", ingressPoint);
this.ingressPoint = ingressPoint;
this.egressPoints = Sets.newHashSet(egressPoints);
- this.egressTreatments = egressTreatments;
}
/**
@@ -100,17 +93,42 @@
}
/**
+ * Creates a new builder pre-populated with the information in the given
+ * intent.
+ *
+ * @param intent initial intent
+ * @return intent builder
+ */
+ public static Builder builder(SinglePointToMultiPointIntent intent) {
+ return new Builder(intent);
+ }
+
+ /**
* Builder of a single point to multi point intent.
*/
public static final class Builder extends ConnectivityIntent.Builder {
- ConnectPoint ingressPoint;
- Set<ConnectPoint> egressPoints;
- Map<ConnectPoint, TrafficTreatment> egressTreatments = ImmutableMap.of();
+ private final Logger log = getLogger(getClass());
+ private FilteredConnectPoint ingressPoint;
+ private Set<FilteredConnectPoint> egressPoints;
private Builder() {
// Hide constructor
}
+ /**
+ * Creates a new builder pre-populated with information from the given
+ * intent.
+ *
+ * @param intent initial intent
+ */
+ protected Builder(SinglePointToMultiPointIntent intent) {
+ super(intent);
+
+ this.filteredEgressPoints(intent.filteredEgressPoints())
+ .filteredIngressPoint(intent.filteredIngressPoint());
+
+ }
+
@Override
public Builder appId(ApplicationId appId) {
return (Builder) super.appId(appId);
@@ -148,8 +166,13 @@
* @param ingressPoint ingress connect point
* @return this builder
*/
+ @Deprecated
public Builder ingressPoint(ConnectPoint ingressPoint) {
- this.ingressPoint = ingressPoint;
+ if (this.ingressPoint != null) {
+ log.warn("Ingress point is already set, " +
+ "this will override original ingress point.");
+ }
+ this.ingressPoint = new FilteredConnectPoint(ingressPoint);
return this;
}
@@ -160,24 +183,46 @@
* @param egressPoints egress connect points
* @return this builder
*/
+ @Deprecated
public Builder egressPoints(Set<ConnectPoint> egressPoints) {
- this.egressPoints = ImmutableSet.copyOf(egressPoints);
+ if (this.egressPoints != null) {
+ log.warn("Egress points are already set, " +
+ "this will override original egress points.");
+ }
+ Set<FilteredConnectPoint> filteredConnectPoints =
+ egressPoints.stream()
+ .map(FilteredConnectPoint::new)
+ .collect(Collectors.toSet());
+ this.egressPoints = ImmutableSet.copyOf(filteredConnectPoints);
return this;
}
/**
- * Sets the treatments of the single point to multi point intent
- * that will be built.
+ * Sets the filtered ingress point of the single point to
+ * multi point intent that will be built.
*
- * @param egressTreatments the multiple treatments
+ * @param ingressPoint ingress connect point
* @return this builder
*/
- public Builder treatments(Map<ConnectPoint, TrafficTreatment> egressTreatments) {
- this.egressTreatments = ImmutableMap.copyOf(egressTreatments);
+ public Builder filteredIngressPoint(FilteredConnectPoint ingressPoint) {
+ this.ingressPoint = ingressPoint;
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;
+ }
+
+
+ /**
* Builds a single point to multi point intent from the
* accumulated parameters.
*
@@ -185,12 +230,6 @@
*/
public SinglePointToMultiPointIntent build() {
- if (treatment != null && !treatment.allInstructions().isEmpty() &&
- !treatment.equals(DefaultTrafficTreatment.emptyTreatment()) &&
- egressTreatments != null && !egressTreatments.isEmpty()) {
- throw new IllegalArgumentException("Treatment and Multiple Treatments are both set");
- }
-
return new SinglePointToMultiPointIntent(
appId,
key,
@@ -199,8 +238,7 @@
ingressPoint,
egressPoints,
constraints,
- priority,
- egressTreatments
+ priority
);
}
}
@@ -212,7 +250,6 @@
super();
this.ingressPoint = null;
this.egressPoints = null;
- this.egressTreatments = null;
}
/**
@@ -222,7 +259,7 @@
* @return ingress port
*/
public ConnectPoint ingressPoint() {
- return ingressPoint;
+ return ingressPoint.connectPoint();
}
/**
@@ -231,17 +268,31 @@
* @return set of egress ports
*/
public Set<ConnectPoint> egressPoints() {
- return egressPoints;
+ return egressPoints.stream()
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet());
}
/**
- * Returns the multiple treatments jointly with their connection points.
- * @return multiple treatments
+ * Returns the filtered port on which the ingress traffic should be connected to the
+ * egress.
+ *
+ * @return ingress port
*/
- public Map<ConnectPoint, TrafficTreatment> egressTreatments() {
- return egressTreatments;
+ public FilteredConnectPoint filteredIngressPoint() {
+ return ingressPoint;
}
+ /**
+ * Returns the set of filtered ports on which the traffic should egress.
+ *
+ * @return set of egress ports
+ */
+ public Set<FilteredConnectPoint> filteredEgressPoints() {
+ return egressPoints;
+ }
+
+
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
@@ -254,7 +305,8 @@
.add("treatment", treatment())
.add("ingress", ingressPoint)
.add("egress", egressPoints)
- .add("treatments", egressTreatments)
+ .add("filteredIngressCPs", filteredIngressPoint())
+ .add("filteredEgressCP", filteredEgressPoints())
.add("constraints", constraints())
.toString();
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
index 9cbe99f..bab715f 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.net.intent;
-import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -25,6 +24,7 @@
import org.onosproject.TestApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
@@ -42,8 +42,6 @@
public static final IntentId IID = new IntentId(123);
public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector();
public static final TrafficTreatment NOP = DefaultTrafficTreatment.emptyTreatment();
- public static final Map<ConnectPoint, TrafficSelector> MATCHES = Collections.emptyMap();
- public static final Map<ConnectPoint, TrafficTreatment> TREATMENTS = Collections.emptyMap();
public static final ConnectPoint P1 = new ConnectPoint(DeviceId.deviceId("111"), PortNumber.portNumber(0x1));
public static final ConnectPoint P2 = new ConnectPoint(DeviceId.deviceId("222"), PortNumber.portNumber(0x2));
@@ -52,6 +50,7 @@
public static final Set<ConnectPoint> PS1 = itemSet(new ConnectPoint[]{P1, P3});
public static final Set<ConnectPoint> PS2 = itemSet(new ConnectPoint[]{P2, P3});
+
public static final TrafficSelector VLANMATCH1 = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId("2"))
.build();
@@ -59,6 +58,13 @@
.matchVlanId(VlanId.vlanId("3"))
.build();
+ public static final FilteredConnectPoint FP1 = new FilteredConnectPoint(P1, VLANMATCH1);
+ public static final FilteredConnectPoint FP2 = new FilteredConnectPoint(P2, VLANMATCH1);
+ public static final FilteredConnectPoint FP3 = new FilteredConnectPoint(P3, VLANMATCH2);
+
+ public static final Set<FilteredConnectPoint> FPS1 = itemSet(new FilteredConnectPoint[]{FP1, FP3});
+ public static final Set<FilteredConnectPoint> FPS2 = itemSet(new FilteredConnectPoint[]{FP2, FP3});
+
public static final Map<ConnectPoint, TrafficSelector> VLANMATCHES = Maps.newHashMap();
static {
VLANMATCHES.put(P1, VLANMATCH1);
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index c090fae..931ac72 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -26,7 +26,7 @@
import org.onosproject.net.NetTestTools;
import org.onosproject.net.NetworkResource;
import org.onosproject.net.Path;
-import org.onosproject.net.flow.FlowRule.FlowRemoveReason;
+import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.flow.FlowId;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleExtPayLoad;
@@ -180,6 +180,67 @@
}
}
+ /**
+ * Mock path service for creating paths within the test.
+ *
+ */
+ public static class Mp2MpMockPathService
+ extends PathServiceAdapter {
+
+ final String[] pathHops;
+ final String[] reversePathHops;
+
+ /**
+ * Constructor that provides a set of hops to mock.
+ *
+ * @param pathHops path hops to mock
+ */
+ public Mp2MpMockPathService(String[] pathHops) {
+ this.pathHops = pathHops;
+ String[] reversed = pathHops.clone();
+ Collections.reverse(Arrays.asList(reversed));
+ reversePathHops = reversed;
+ }
+
+ @Override
+ public Set<Path> getPaths(ElementId src, ElementId dst) {
+ Set<Path> result = new HashSet<>();
+
+ String[] allHops = new String[pathHops.length + 2];
+ allHops[0] = src.toString();
+ allHops[allHops.length - 1] = dst.toString();
+
+ if (pathHops.length != 0) {
+ System.arraycopy(pathHops, 0, allHops, 1, pathHops.length);
+ }
+
+ result.add(createPath(allHops));
+
+ return result;
+ }
+
+ @Override
+ public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+ final Set<Path> paths = getPaths(src, dst);
+
+ for (Path path : paths) {
+ final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
+ final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
+ if (srcDevice != null && dstDevice != null) {
+ final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
+ final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
+ final Link link = link(src.toString(), 1, dst.toString(), 1);
+
+ final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
+ if (weightValue < 0) {
+ return new HashSet<>();
+ }
+ }
+ }
+ return paths;
+ }
+ }
+
public static final class MockResourceService implements ResourceService {
private final double bandwidth;
@@ -429,4 +490,14 @@
}
}
+ /**
+ * Mocks the device service so that a device appears available in the test.
+ */
+ public static class MockDeviceService extends DeviceServiceAdapter {
+ @Override
+ public boolean isAvailable(DeviceId deviceId) {
+ return true;
+ }
+ }
+
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
index 006ca57..cb25b3c 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
@@ -21,8 +21,10 @@
import java.util.List;
import java.util.Set;
+import com.google.common.collect.Sets;
import org.junit.Test;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.NetTestTools;
import org.onosproject.net.flow.TrafficSelector;
@@ -49,6 +51,8 @@
final ConnectPoint egress = NetTestTools.connectPoint("egress", 3);
final TrafficSelector selector = new IntentTestsMocks.MockSelector();
final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment();
+ final FilteredConnectPoint filteredIngress = new FilteredConnectPoint(ingress);
+ final FilteredConnectPoint filteredEgress = new FilteredConnectPoint(egress);
/**
* Checks that the LinkCollectionIntent class is immutable.
@@ -179,6 +183,39 @@
assertThat(createdConstraints, hasSize(0));
}
+ /**
+ * Test filtered connection point for LinkCollection intent.
+ */
+ @Test
+ public void testFilteredConnectedPoint() {
+ LinkCollectionIntent intent = createFilteredOne();
+ Set<Link> links = Sets.newHashSet();
+ links.add(link("A", 1, "B", 1));
+ links.add(link("A", 2, "C", 1));
+
+ assertThat(intent.appId(), is(APP_ID));
+ assertThat(intent.treatment(), is(treatment));
+ assertThat(intent.links(), is(links));
+ assertThat(intent.applyTreatmentOnEgress(), is(false));
+ assertThat(intent.filteredIngressPoints(), is(ImmutableSet.of(filteredIngress)));
+ assertThat(intent.filteredEgressPoints(), is(ImmutableSet.of(filteredEgress)));
+
+ intent = createAnotherFiltered();
+ links = Sets.newHashSet();
+ links.add(link("A", 1, "B", 1));
+ links.add(link("A", 2, "C", 1));
+ links.add(link("B", 2, "D", 1));
+ links.add(link("B", 3, "E", 1));
+
+ assertThat(intent.appId(), is(APP_ID));
+ assertThat(intent.treatment(), is(treatment));
+ assertThat(intent.links(), is(links));
+ assertThat(intent.applyTreatmentOnEgress(), is(true));
+ assertThat(intent.filteredIngressPoints(), is(ImmutableSet.of(filteredIngress)));
+ assertThat(intent.filteredEgressPoints(), is(ImmutableSet.of(filteredEgress)));
+
+ }
+
@Override
protected Intent createOne() {
HashSet<Link> links1 = new HashSet<>();
@@ -206,4 +243,33 @@
.egressPoints(ImmutableSet.of(egress))
.build();
}
+
+ protected LinkCollectionIntent createFilteredOne() {
+ Set<Link> links = Sets.newHashSet();
+ links.add(link("A", 1, "B", 1));
+ links.add(link("A", 2, "C", 1));
+ return LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .treatment(treatment)
+ .links(links)
+ .filteredIngressPoints(ImmutableSet.of(filteredIngress))
+ .filteredEgressPoints(ImmutableSet.of(filteredEgress))
+ .build();
+ }
+
+ protected LinkCollectionIntent createAnotherFiltered() {
+ Set<Link> links = Sets.newHashSet();
+ links.add(link("A", 1, "B", 1));
+ links.add(link("A", 2, "C", 1));
+ links.add(link("B", 2, "D", 1));
+ links.add(link("B", 3, "E", 1));
+ return LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .treatment(treatment)
+ .links(links)
+ .applyTreatmentOnEgress(true)
+ .filteredIngressPoints(ImmutableSet.of(filteredIngress))
+ .filteredEgressPoints(ImmutableSet.of(filteredEgress))
+ .build();
+ }
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
index 115af4a..a41214b 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
@@ -16,9 +16,7 @@
package org.onosproject.net.intent;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
@@ -36,6 +34,9 @@
assertThatClassIsImmutable(MultiPointToSinglePointIntent.class);
}
+ /**
+ * Create three intents with normal connect points.
+ */
@Test
public void basics() {
MultiPointToSinglePointIntent intent = createOne();
@@ -43,40 +44,38 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect ingress", PS1, intent.ingressPoints());
assertEquals("incorrect egress", P2, intent.egressPoint());
- }
- @Rule
- public ExpectedException wrongMultiple = ExpectedException.none();
-
- @Test
- public void multipleSelectors() {
-
- MultiPointToSinglePointIntent intent = createFirstMultiple();
+ intent = createAnother();
assertEquals("incorrect id", APPID, intent.appId());
assertEquals("incorrect match", MATCH, intent.selector());
- assertEquals("incorrect ingress", PS1, intent.ingressPoints());
- assertEquals("incorrect egress", P2, intent.egressPoint());
- assertEquals("incorrect selectors", MATCHES, intent.ingressSelectors());
+ assertEquals("incorrect ingress", PS2, intent.ingressPoints());
+ assertEquals("incorrect egress", P1, intent.egressPoint());
- intent = createSecondMultiple();
+ intent = createVlanMatch();
assertEquals("incorrect id", APPID, intent.appId());
assertEquals("incorrect match", VLANMATCH1, intent.selector());
assertEquals("incorrect ingress", PS1, intent.ingressPoints());
assertEquals("incorrect egress", P2, intent.egressPoint());
- assertEquals("incorrect selectors", MATCHES, intent.ingressSelectors());
-
- intent = createThirdMultiple();
- assertEquals("incorrect id", APPID, intent.appId());
- assertEquals("incorrect match", MATCH, intent.selector());
- assertEquals("incorrect ingress", PS1, intent.ingressPoints());
- assertEquals("incorrect egress", P2, intent.egressPoint());
- assertEquals("incorrect selectors", VLANMATCHES, intent.ingressSelectors());
-
- wrongMultiple.expect(IllegalArgumentException.class);
- wrongMultiple.expectMessage("Selector and Multiple Selectors are both set");
- intent = createWrongMultiple();
}
+ /**
+ * Create two intents with filtered connect points.
+ */
+ @Test
+ public void filteredIntent() {
+ MultiPointToSinglePointIntent intent = createFilteredOne();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect filtered ingress", FPS1, intent.filteredIngressPoints());
+ assertEquals("incorrect filtered egress", FP2, intent.filteredEgressPoint());
+
+ intent = createAnotherFiltered();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect filtered ingress", FPS2, intent.filteredIngressPoints());
+ assertEquals("incorrect filtered egress", FP1, intent.filteredEgressPoint());
+
+ }
@Override
protected MultiPointToSinglePointIntent createOne() {
@@ -100,47 +99,42 @@
.build();
}
- protected MultiPointToSinglePointIntent createFirstMultiple() {
- return MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .selector(MATCH)
- .treatment(NOP)
- .ingressPoints(PS1)
- .egressPoint(P2)
- .selectors(MATCHES)
- .build();
- }
-
- protected MultiPointToSinglePointIntent createSecondMultiple() {
+ protected MultiPointToSinglePointIntent createVlanMatch() {
return MultiPointToSinglePointIntent.builder()
.appId(APPID)
.selector(VLANMATCH1)
.treatment(NOP)
.ingressPoints(PS1)
.egressPoint(P2)
- .selectors(MATCHES)
.build();
}
- protected MultiPointToSinglePointIntent createThirdMultiple() {
+
+ protected MultiPointToSinglePointIntent createFilteredOne() {
return MultiPointToSinglePointIntent.builder()
.appId(APPID)
- .selector(MATCH)
.treatment(NOP)
- .ingressPoints(PS1)
- .egressPoint(P2)
- .selectors(VLANMATCHES)
+ .filteredIngressPoints(FPS1)
+ .filteredEgressPoint(FP2)
.build();
}
- protected MultiPointToSinglePointIntent createWrongMultiple() {
+ protected MultiPointToSinglePointIntent createAnotherFiltered() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .treatment(NOP)
+ .filteredIngressPoints(FPS2)
+ .filteredEgressPoint(FP1)
+ .build();
+ }
+
+ protected MultiPointToSinglePointIntent createWrongIntent() {
return MultiPointToSinglePointIntent.builder()
.appId(APPID)
.selector(VLANMATCH1)
.treatment(NOP)
- .ingressPoints(PS1)
- .egressPoint(P2)
- .selectors(VLANMATCHES)
+ .filteredIngressPoints(FPS1)
+ .filteredEgressPoint(FP2)
.build();
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
index f3db2fb..76aaa85 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
@@ -15,9 +15,7 @@
*/
package org.onosproject.net.intent;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
@@ -42,41 +40,28 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect ingress", P1, intent.ingressPoint());
assertEquals("incorrect egress", PS2, intent.egressPoints());
+
+ intent = createAnother();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", P2, intent.ingressPoint());
+ assertEquals("incorrect egress", PS1, intent.egressPoints());
}
- @Rule
- public ExpectedException wrongMultiple = ExpectedException.none();
-
@Test
- public void multipleTreatments() {
-
- SinglePointToMultiPointIntent intent = createFirstMultiple();
+ public void filteredIntent() {
+ SinglePointToMultiPointIntent intent = createFilteredOne();
assertEquals("incorrect id", APPID, intent.appId());
assertEquals("incorrect match", MATCH, intent.selector());
- assertEquals("incorrect ingress", P1, intent.ingressPoint());
- assertEquals("incorrect egress", PS2, intent.egressPoints());
- assertEquals("incorrect treatment", NOP, intent.treatment());
- assertEquals("incorrect treatments", TREATMENTS, intent.egressTreatments());
+ assertEquals("incorrect filtered ingress", FP2, intent.filteredIngressPoint());
+ assertEquals("incorrect filtered egress", FPS1, intent.filteredEgressPoints());
- intent = createSecondMultiple();
+ intent = createAnotherFiltered();
assertEquals("incorrect id", APPID, intent.appId());
assertEquals("incorrect match", MATCH, intent.selector());
- assertEquals("incorrect ingress", P1, intent.ingressPoint());
- assertEquals("incorrect egress", PS2, intent.egressPoints());
- assertEquals("incorrect treatment", VLANACTION1, intent.treatment());
- assertEquals("incorrect selectors", TREATMENTS, intent.egressTreatments());
+ assertEquals("incorrect filtered ingress", FP1, intent.filteredIngressPoint());
+ assertEquals("incorrect filtered egress", FPS2, intent.filteredEgressPoints());
- intent = createThirdMultiple();
- assertEquals("incorrect id", APPID, intent.appId());
- assertEquals("incorrect match", MATCH, intent.selector());
- assertEquals("incorrect ingress", P1, intent.ingressPoint());
- assertEquals("incorrect egress", PS2, intent.egressPoints());
- assertEquals("incorrect treatment", NOP, intent.treatment());
- assertEquals("incorrect selectors", VLANACTIONS, intent.egressTreatments());
-
- wrongMultiple.expect(IllegalArgumentException.class);
- wrongMultiple.expectMessage("Treatment and Multiple Treatments are both set");
- intent = createWrongMultiple();
}
@Override
@@ -101,48 +86,31 @@
.build();
}
-
- protected SinglePointToMultiPointIntent createFirstMultiple() {
+ protected SinglePointToMultiPointIntent createFilteredOne() {
return SinglePointToMultiPointIntent.builder()
.appId(APPID)
- .selector(MATCH)
.treatment(NOP)
- .ingressPoint(P1)
- .egressPoints(PS2)
- .treatments(TREATMENTS)
+ .filteredEgressPoints(FPS1)
+ .filteredIngressPoint(FP2)
.build();
}
- protected SinglePointToMultiPointIntent createSecondMultiple() {
+ protected SinglePointToMultiPointIntent createAnotherFiltered() {
return SinglePointToMultiPointIntent.builder()
.appId(APPID)
- .selector(MATCH)
- .treatment(VLANACTION1)
- .ingressPoint(P1)
- .egressPoints(PS2)
- .treatments(TREATMENTS)
- .build();
- }
-
- protected SinglePointToMultiPointIntent createThirdMultiple() {
- return SinglePointToMultiPointIntent.builder()
- .appId(APPID)
- .selector(MATCH)
.treatment(NOP)
- .ingressPoint(P1)
- .egressPoints(PS2)
- .treatments(VLANACTIONS)
+ .filteredEgressPoints(FPS2)
+ .filteredIngressPoint(FP1)
.build();
}
- protected SinglePointToMultiPointIntent createWrongMultiple() {
+ protected SinglePointToMultiPointIntent createWrongIntent() {
return SinglePointToMultiPointIntent.builder()
.appId(APPID)
- .selector(MATCH)
- .treatment(VLANACTION1)
- .ingressPoint(P1)
- .egressPoints(PS2)
- .treatments(VLANACTIONS)
+ .treatment(NOP)
+ .selector(VLANMATCH1)
+ .filteredEgressPoints(FPS2)
+ .filteredIngressPoint(FP1)
.build();
}