Refactor connectivity intent creation to use builders
- Each connectivity intent now has only one constructor
- Intent constructors are now private for leaf classes and
protected for classes that can be derived from
- Each intent class has a Builder class that accumulates
parameters for intent creation
- Each intent class has a public static builder() method
to create a builder
- Each Builder class has a build() method to create the
intent from the accumulated parameters
- Added keys to a few intent types that were missing them
- Tightened up usage of checkNotNull(), taking advantage of
the return value to save some lines of code
- Modified callers to use the builders instead of directly
calling the constructors
Change-Id: I713185d5ecbadbf51f87ef7f68fec41102106c78
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
index badad7f..f08e513 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
@@ -15,7 +15,19 @@
*/
package org.onosproject.sdnip;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
+
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
@@ -43,19 +55,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Semaphore;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import static com.google.common.base.Preconditions.checkArgument;
@@ -340,11 +340,15 @@
int priority =
prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
Key key = Key.of(prefix.toString(), appId);
- return new MultiPointToSinglePointIntent(appId, key, selector.build(),
- treatment.build(),
- ingressPorts, egressPort,
- Collections.emptyList(),
- priority);
+ return MultiPointToSinglePointIntent.builder()
+ .appId(appId)
+ .key(key)
+ .selector(selector.build())
+ .treatment(treatment.build())
+ .ingressPoints(ingressPorts)
+ .egressPoint(egressPort)
+ .priority(priority)
+ .build();
}
@Override
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
index 9f29c1b..7625af6 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
@@ -233,9 +233,13 @@
ingressPoints.add(SW4_ETH1);
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, SW1_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(SW1_ETH1)
+ .build();
// Setup the expected intents
intentService.submit(eqExceptId(intent));
@@ -291,9 +295,13 @@
ingressPoints.add(SW3_ETH1);
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, SW4_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(SW4_ETH1)
+ .build();
// Setup the expected intents
intentService.submit(eqExceptId(intent));
@@ -357,10 +365,13 @@
ingressPointsNew.add(SW4_ETH1);
MultiPointToSinglePointIntent intentNew =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilderNew.build(),
- treatmentBuilderNew.build(),
- ingressPointsNew, SW2_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilderNew.build())
+ .treatment(treatmentBuilderNew.build())
+ .ingressPoints(ingressPointsNew)
+ .egressPoint(SW2_ETH1)
+ .build();
// Set up test expectation
reset(intentService);
@@ -592,9 +603,13 @@
}
}
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, egressPoint);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(egressPoint)
+ .build();
return intent;
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
index a4a3a7c..f1554b6 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
@@ -15,19 +15,15 @@
*/
package org.onosproject.cli.net;
+import java.util.List;
+
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.net.HostId;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.HostToHostIntent;
import org.onosproject.net.intent.IntentService;
-import java.util.List;
-
/**
* Installs host-to-host connectivity intent.
*/
@@ -50,14 +46,16 @@
HostId oneId = HostId.hostId(one);
HostId twoId = HostId.hostId(two);
- TrafficSelector selector = DefaultTrafficSelector.emptySelector();
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Constraint> constraints = buildConstraints();
- HostToHostIntent intent = new HostToHostIntent(appId(), key(),
- oneId, twoId,
- selector, treatment,
- constraints, priority());
+ HostToHostIntent intent = HostToHostIntent.builder()
+ .appId(appId())
+ .key(key())
+ .one(oneId)
+ .two(twoId)
+ .constraints(constraints)
+ .priority(priority())
+ .build();
service.submit(intent);
print("Host to Host intent submitted:\n%s", intent.toString());
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java b/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
index 7de49c9..ebaf89b 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
@@ -75,10 +75,17 @@
List<Constraint> constraints = buildConstraints();
- MplsIntent intent = new MplsIntent(appId(), selector, treatment,
- ingress, ingressLabel, egress,
- egressLabel, constraints,
- priority());
+ MplsIntent intent = MplsIntent.builder()
+ .appId(appId())
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(ingress)
+ .ingressLabel(ingressLabel)
+ .egressPoint(egress)
+ .egressLabel(egressLabel)
+ .constraints(constraints)
+ .priority(priority())
+ .build();
service.submit(intent);
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
index abc0c4b..892f819 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
@@ -72,11 +72,16 @@
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
- Intent intent = new MultiPointToSinglePointIntent(appId(), key(),
- selector, treatment,
- ingressPoints, egress,
- constraints,
- priority());
+ Intent intent = MultiPointToSinglePointIntent.builder()
+ .appId(appId())
+ .key(key())
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoints(ingressPoints)
+ .egressPoint(egress)
+ .constraints(constraints)
+ .priority(priority())
+ .build();
service.submit(intent);
print("Multipoint to single point intent submitted:\n%s", intent.toString());
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
index b6193fa..83ef66f 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
@@ -72,15 +72,16 @@
List<Constraint> constraints = buildConstraints();
SinglePointToMultiPointIntent intent =
- new SinglePointToMultiPointIntent(
- appId(),
- key(),
- selector,
- treatment,
- ingressPoint,
- egressPoints,
- constraints,
- priority());
+ SinglePointToMultiPointIntent.builder()
+ .appId(appId())
+ .key(key())
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(ingressPoint)
+ .egressPoints(egressPoints)
+ .constraints(constraints)
+ .priority(priority())
+ .build();
service.submit(intent);
print("Single point to multipoint intent submitted:\n%s", intent.toString());
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java
index 5eb592a..152e659 100644
--- a/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java
@@ -15,25 +15,22 @@
*/
package org.onosproject.cli.net;
-import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.Host;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.HostToHostIntent;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import com.google.common.collect.Lists;
/**
* Installs point-to-point connectivity intents.
@@ -67,17 +64,16 @@
}
private Collection<Intent> generateIntents() {
- TrafficSelector selector = DefaultTrafficSelector.emptySelector();
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
-
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
List<Intent> fullMesh = Lists.newArrayList();
for (int i = 0; i < hosts.size(); i++) {
for (int j = i + 1; j < hosts.size(); j++) {
- fullMesh.add(new HostToHostIntent(appId(),
- hosts.get(i).id(),
- hosts.get(j).id(),
- selector, treatment));
+ fullMesh.add(HostToHostIntent.builder()
+ .appId(appId())
+ .one(hosts.get(i).id())
+ .two(hosts.get(j).id())
+ .build());
+
}
}
Collections.shuffle(fullMesh);
diff --git a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
index 9d0a228..94e3b1a 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
@@ -77,34 +77,6 @@
}
/**
- * Creates a connectivity intent that matches on the specified selector
- * and applies the specified treatment.
- * <p>
- * Path will be optimized based on the first constraint if one is given.
- * </p>
- *
- * @param appId application identifier
- * @param resources required network resources (optional)
- * @param selector traffic selector
- * @param treatment treatment
- * @param constraints optional prioritized list of constraints
- * @param priority priority to use for flows generated by this intent
- * @throws NullPointerException if the selector or treatment is null
- */
-
- protected ConnectivityIntent(ApplicationId appId,
- Collection<NetworkResource> resources,
- TrafficSelector selector,
- TrafficTreatment treatment,
- List<Constraint> constraints,
- int priority) {
- super(appId, null, resources, priority);
- this.selector = checkNotNull(selector);
- this.treatment = checkNotNull(treatment);
- this.constraints = checkNotNull(constraints);
- }
-
- /**
* Constructor for serializer.
*/
protected ConnectivityIntent() {
diff --git a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
index 9b00512..157397a 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
@@ -15,20 +15,16 @@
*/
package org.onosproject.net.intent;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Link;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.constraint.LinkTypeConstraint;
-
import java.util.Collections;
import java.util.List;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.HostId;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+
+import com.google.common.base.MoreObjects;
+
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -40,59 +36,98 @@
private final HostId two;
/**
- * Creates a new host-to-host intent with the supplied host pair and no
- * other traffic selection or treatment criteria.
+ * Returns a new host to host intent builder.
*
- * @param appId application identifier
- * @param one first host
- * @param two second host
- * @throws NullPointerException if {@code one} or {@code two} is null.
+ * @return host to host intent builder
*/
- public HostToHostIntent(ApplicationId appId, HostId one, HostId two) {
- this(appId, one, two,
- DefaultTrafficSelector.emptySelector(),
- DefaultTrafficTreatment.emptyTreatment(),
- ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
- DEFAULT_INTENT_PRIORITY);
+ public static Builder builder() {
+ return new Builder();
}
/**
- * Creates a new host-to-host intent with the supplied host pair.
- *
- * @param appId application identifier
- * @param one first host
- * @param two second host
- * @param selector action
- * @param treatment ingress port
- * @throws NullPointerException if {@code one} or {@code two} is null.
+ * Builder of a host to host intent.
*/
- public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
- TrafficSelector selector,
- TrafficTreatment treatment) {
- this(appId, one, two, selector, treatment,
- ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
- DEFAULT_INTENT_PRIORITY);
+ public static final class Builder extends ConnectivityIntent.Builder {
+ HostId one;
+ HostId two;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the first host of the intent that will be built.
+ *
+ * @param one first host
+ * @return this builder
+ */
+ public Builder one(HostId one) {
+ this.one = one;
+ return this;
+ }
+
+ /**
+ * Sets the second host of the intent that will be built.
+ *
+ * @param two second host
+ * @return this builder
+ */
+ public Builder two(HostId two) {
+ this.two = two;
+ return this;
+ }
+
+ /**
+ * Builds a host to host intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public HostToHostIntent build() {
+
+ return new HostToHostIntent(
+ appId,
+ key,
+ one,
+ two,
+ selector,
+ treatment,
+ constraints,
+ priority
+ );
+ }
}
- /**
- * Creates a new host-to-host intent with the supplied host pair.
- *
- * @param appId application identifier
- * @param one first host
- * @param two second host
- * @param selector action
- * @param treatment ingress port
- * @param constraints optional prioritized list of path selection constraints
- * @param priority priority to use for flows generated by this intent
- * @throws NullPointerException if {@code one} or {@code two} is null.
- */
- public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
- TrafficSelector selector,
- TrafficTreatment treatment,
- List<Constraint> constraints,
- int priority) {
- this(appId, null, one, two, selector, treatment, constraints, priority);
- }
+
/**
* Creates a new host-to-host intent with the supplied host pair.
*
@@ -106,7 +141,7 @@
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
- public HostToHostIntent(ApplicationId appId, Key key,
+ private HostToHostIntent(ApplicationId appId, Key key,
HostId one, HostId two,
TrafficSelector selector,
TrafficTreatment treatment,
@@ -121,14 +156,6 @@
}
- private static HostId min(HostId one, HostId two) {
- return one.hashCode() < two.hashCode() ? one : two;
- }
-
- private static HostId max(HostId one, HostId two) {
- return one.hashCode() >= two.hashCode() ? one : two;
- }
-
/**
* Returns identifier of the first host.
*
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Intent.java b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
index 725fac4..59378f7 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Intent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
@@ -63,17 +63,6 @@
* Creates a new intent.
*
* @param appId application identifier
- * @param resources required network resources (optional)
- */
- protected Intent(ApplicationId appId,
- Collection<NetworkResource> resources) {
- this(appId, null, resources, DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * Creates a new intent.
- *
- * @param appId application identifier
* @param key optional key
* @param resources required network resources (optional)
* @param priority flow rule priority
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 17451cb..8cea253 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
@@ -15,8 +15,8 @@
*/
package org.onosproject.net.intent;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
@@ -24,9 +24,8 @@
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
/**
* Abstraction of a connectivity intent that is implemented by a set of path
@@ -42,71 +41,21 @@
/**
* Creates a new actionable intent capable of funneling the selected
* traffic along the specified convergent tree and out the given egress
- * point.
- *
- * @param appId application identifier
- * @param selector traffic match
- * @param treatment action
- * @param links traversed links
- * @param ingressPoint ingress point
- * @param egressPoint egress point
- * @throws NullPointerException {@code path} is null
- */
- public LinkCollectionIntent(ApplicationId appId,
- TrafficSelector selector,
- TrafficTreatment treatment,
- Set<Link> links,
- ConnectPoint ingressPoint,
- ConnectPoint egressPoint) {
- this(appId, selector, treatment, links, ingressPoint, egressPoint,
- Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * 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 ingressPoint ingress point
- * @param egressPoint egress point
+ * @param ingressPoints ingress points
+ * @param egressPoints egress points
* @param constraints optional list of constraints
* @param priority priority to use for the flows generated by this intent
* @throws NullPointerException {@code path} is null
*/
- public LinkCollectionIntent(ApplicationId appId,
- TrafficSelector selector,
- TrafficTreatment treatment,
- Set<Link> links,
- ConnectPoint ingressPoint,
- ConnectPoint egressPoint,
- List<Constraint> constraints,
- int priority) {
- super(appId, resources(links), selector, treatment, constraints, priority);
- this.links = links;
- this.ingressPoints = ImmutableSet.of(ingressPoint);
- this.egressPoints = ImmutableSet.of(egressPoint);
- }
-
- /**
- * Creates a new actionable intent capable of funneling the selected
- * traffic along the specified convergent tree and out the given egress
- * point.
- *
- * @param appId application identifier
- * @param selector traffic match
- * @param treatment action
- * @param links traversed links
- * @param ingressPoints Set of ingress points
- * @param egressPoints Set of egress points
- * @param constraints the constraints
- * @param priority priority to use for the flows generated by this intent
- * @throws NullPointerException {@code path} is null
- */
- public LinkCollectionIntent(ApplicationId appId,
+ private LinkCollectionIntent(ApplicationId appId,
+ Key key,
TrafficSelector selector,
TrafficTreatment treatment,
Set<Link> links,
@@ -114,11 +63,10 @@
Set<ConnectPoint> egressPoints,
List<Constraint> constraints,
int priority) {
- super(appId, resources(links), selector, treatment, constraints, priority);
-
+ super(appId, key, resources(links), selector, treatment, constraints, priority);
this.links = links;
- this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
- this.egressPoints = ImmutableSet.copyOf(egressPoints);
+ this.ingressPoints = ingressPoints;
+ this.egressPoints = egressPoints;
}
/**
@@ -132,6 +80,120 @@
}
/**
+ * Returns a new link collection intent builder. The application id,
+ * ingress point and egress points are required fields. If they are
+ * not set by calls to the appropriate methods, an exception will
+ * be thrown.
+ *
+ * @return single point to multi point builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * 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;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the ingress point of the single point to multi point intent
+ * that will be built.
+ *
+ * @param ingressPoints ingress connect points
+ * @return this builder
+ */
+ public Builder ingressPoints(Set<ConnectPoint> ingressPoints) {
+ this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
+ return this;
+ }
+
+ /**
+ * Sets the egress points of the single point to multi point intent
+ * that will be built.
+ *
+ * @param egressPoints egress connect points
+ * @return this builder
+ */
+ public Builder egressPoints(Set<ConnectPoint> egressPoints) {
+ this.egressPoints = ImmutableSet.copyOf(egressPoints);
+ return this;
+ }
+
+ /**
+ * Sets the links of the link collection intent
+ * that will be built.
+ *
+ * @param links links for the intent
+ * @return this builder
+ */
+ public Builder links(Set<Link> links) {
+ this.links = ImmutableSet.copyOf(links);
+ return this;
+ }
+
+
+ /**
+ * Builds a single point to multi point intent from the
+ * accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public LinkCollectionIntent build() {
+
+ return new LinkCollectionIntent(
+ appId,
+ key,
+ selector,
+ treatment,
+ links,
+ ingressPoints,
+ egressPoints,
+ constraints,
+ priority
+ );
+ }
+ }
+
+
+ /**
* Returns the set of links that represent the network connections needed
* by this intent.
*
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
index 524b231..1625f58 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
@@ -1,8 +1,5 @@
package org.onosproject.net.intent;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -10,13 +7,13 @@
import org.onlab.packet.MplsLabel;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Link;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.constraint.LinkTypeConstraint;
import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -30,30 +27,6 @@
private final Optional<MplsLabel> egressLabel;
/**
- * Creates a new MPLS intent with the supplied ingress/egress
- * ports and labels and with built-in link type constraint to avoid optical links.
- *
- * @param appId application identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param ingressPoint ingress port
- * @param ingressLabel ingress MPLS label
- * @param egressPoint egress port
- * @param egressLabel egress MPLS label
- * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
- */
- public MplsIntent(ApplicationId appId, TrafficSelector selector,
- TrafficTreatment treatment,
- ConnectPoint ingressPoint,
- Optional<MplsLabel> ingressLabel,
- ConnectPoint egressPoint,
- Optional<MplsLabel> egressLabel) {
- this(appId, selector, treatment, ingressPoint, ingressLabel, egressPoint, egressLabel,
- ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
- DEFAULT_INTENT_PRIORITY);
- }
-
- /**
* Creates a new point-to-point intent with the supplied ingress/egress
* ports, labels and constraints.
*
@@ -68,32 +41,154 @@
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
*/
- public MplsIntent(ApplicationId appId, TrafficSelector selector,
- TrafficTreatment treatment,
- ConnectPoint ingressPoint,
- Optional<MplsLabel> ingressLabel,
- ConnectPoint egressPoint,
- Optional<MplsLabel> egressLabel,
- List<Constraint> constraints,
- int priority) {
+ private MplsIntent(ApplicationId appId,
+ Key key,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ ConnectPoint ingressPoint,
+ Optional<MplsLabel> ingressLabel,
+ ConnectPoint egressPoint,
+ Optional<MplsLabel> egressLabel,
+ List<Constraint> constraints,
+ int priority) {
- super(appId, Collections.emptyList(), selector, treatment, constraints,
+ super(appId, key, Collections.emptyList(), selector, treatment, constraints,
priority);
- checkNotNull(ingressPoint);
- checkNotNull(egressPoint);
- checkArgument(!ingressPoint.equals(egressPoint),
- "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);
- checkNotNull(ingressLabel);
- checkNotNull(egressLabel);
- this.ingressPoint = ingressPoint;
- this.ingressLabel = ingressLabel;
- this.egressPoint = egressPoint;
- this.egressLabel = egressLabel;
+ this.ingressPoint = checkNotNull(ingressPoint);
+ this.ingressLabel = checkNotNull(ingressLabel);
+ this.egressPoint = checkNotNull(egressPoint);
+ this.egressLabel = checkNotNull(egressLabel);
+ checkArgument(!ingressPoint.equals(egressPoint),
+ "ingress and egress should be different (ingress: %s, egress: %s)",
+ ingressPoint, egressPoint);
}
/**
+ * Returns a new MPLS intent builder. The application id,
+ * ingress point, egress point, ingress label and egress label are
+ * required fields. If they are not set by calls to the appropriate
+ * methods, an exception will be thrown.
+ *
+ * @return point to point builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of an MPLS intent.
+ */
+ public static final class Builder extends ConnectivityIntent.Builder {
+ ConnectPoint ingressPoint;
+ ConnectPoint egressPoint;
+ Optional<MplsLabel> ingressLabel;
+ Optional<MplsLabel> egressLabel;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the ingress point of the point to point intent that will be built.
+ *
+ * @param ingressPoint ingress connect point
+ * @return this builder
+ */
+ public Builder ingressPoint(ConnectPoint ingressPoint) {
+ this.ingressPoint = ingressPoint;
+ return this;
+ }
+
+ /**
+ * Sets the egress point of the point to point intent that will be built.
+ *
+ * @param egressPoint egress connect point
+ * @return this builder
+ */
+ public Builder egressPoint(ConnectPoint egressPoint) {
+ this.egressPoint = egressPoint;
+ return this;
+ }
+
+ /**
+ * Sets the ingress label of the intent that will be built.
+ *
+ * @param ingressLabel ingress label
+ * @return this builder
+ */
+ public Builder ingressLabel(Optional<MplsLabel> ingressLabel) {
+ this.ingressLabel = ingressLabel;
+ return this;
+ }
+
+ /**
+ * Sets the ingress label of the intent that will be built.
+ *
+ * @param egressLabel ingress label
+ * @return this builder
+ */
+ public Builder egressLabel(Optional<MplsLabel> egressLabel) {
+ this.egressLabel = egressLabel;
+ return this;
+ }
+
+ /**
+ * Builds a point to point intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public MplsIntent build() {
+
+ return new MplsIntent(
+ appId,
+ key,
+ selector,
+ treatment,
+ ingressPoint,
+ ingressLabel,
+ egressPoint,
+ egressLabel,
+ constraints,
+ priority
+ );
+ }
+ }
+
+
+
+ /**
* Constructor for serializer.
*/
protected MplsIntent() {
@@ -147,6 +242,7 @@
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("appId", appId())
+ .add("key", key())
.add("priority", priority())
.add("selector", selector())
.add("treatment", treatment())
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
index 83e9218..1ea5829 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
@@ -1,18 +1,16 @@
package org.onosproject.net.intent;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
-
import org.onlab.packet.MplsLabel;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.Path;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Abstraction of explicit MPLS label-switched path.
@@ -33,44 +31,121 @@
* @param path traversed links
* @param ingressLabel MPLS egress label
* @param egressLabel MPLS ingress label
- * @throws NullPointerException {@code path} is null
- */
- public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
- TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
- Optional<MplsLabel> egressLabel) {
- this(appId, selector, treatment, path, ingressLabel, egressLabel,
- Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
-
- }
-
- /**
- * Creates a new point-to-point intent with the supplied ingress/egress
- * ports and using the specified explicit path.
- *
- * @param appId application identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param path traversed links
- * @param ingressLabel MPLS egress label
- * @param egressLabel MPLS ingress label
* @param constraints optional list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException {@code path} is null
*/
- public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
+ private MplsPathIntent(ApplicationId appId, TrafficSelector selector,
TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
Optional<MplsLabel> egressLabel, List<Constraint> constraints,
int priority) {
super(appId, selector, treatment, path, constraints,
priority);
- checkNotNull(ingressLabel);
- checkNotNull(egressLabel);
- this.ingressLabel = ingressLabel;
- this.egressLabel = egressLabel;
+ this.ingressLabel = checkNotNull(ingressLabel);
+ this.egressLabel = checkNotNull(egressLabel);
}
/**
+ * Returns a new host to host intent builder.
+ *
+ * @return host to host intent builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of a host to host intent.
+ */
+ public static final class Builder extends PathIntent.Builder {
+ private Optional<MplsLabel> ingressLabel = Optional.empty();
+ private Optional<MplsLabel> egressLabel = Optional.empty();
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ @Override
+ public Builder path(Path path) {
+ return (Builder) super.path(path);
+ }
+
+ /**
+ * Sets the ingress label of the intent that will be built.
+ *
+ * @param ingressLabel ingress label
+ * @return this builder
+ */
+ public Builder ingressLabel(Optional<MplsLabel> ingressLabel) {
+ this.ingressLabel = ingressLabel;
+ return this;
+ }
+
+ /**
+ * Sets the ingress label of the intent that will be built.
+ *
+ * @param egressLabel ingress label
+ * @return this builder
+ */
+ public Builder egressLabel(Optional<MplsLabel> egressLabel) {
+ this.egressLabel = egressLabel;
+ return this;
+ }
+
+
+ /**
+ * Builds a host to host intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public MplsPathIntent build() {
+
+ return new MplsPathIntent(
+ appId,
+ selector,
+ treatment,
+ path,
+ ingressLabel,
+ egressLabel,
+ constraints,
+ priority
+ );
+ }
+ }
+
+
+ /**
* Returns the MPLS label which the ingress traffic should tagged.
*
* @return ingress MPLS label
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 721ff17..c92898e 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
@@ -16,6 +16,7 @@
package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
@@ -42,29 +43,6 @@
* traffic selector and treatment.
*
* @param appId application identifier
- * @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
- * @throws NullPointerException if {@code ingressPoints} or
- * {@code egressPoint} is null.
- * @throws IllegalArgumentException if the size of {@code ingressPoints} is
- * not more than 1
- */
- public MultiPointToSinglePointIntent(ApplicationId appId,
- TrafficSelector selector,
- TrafficTreatment treatment,
- Set<ConnectPoint> ingressPoints,
- ConnectPoint egressPoint) {
- this(appId, selector, treatment, ingressPoints, egressPoint,
- Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * Creates a new multi-to-single point connectivity intent for the specified
- * traffic selector and treatment.
- *
- * @param appId application identifier
* @param key intent key
* @param selector traffic selector
* @param treatment treatment
@@ -77,7 +55,7 @@
* @throws IllegalArgumentException if the size of {@code ingressPoints} is
* not more than 1
*/
- public MultiPointToSinglePointIntent(ApplicationId appId,
+ private MultiPointToSinglePointIntent(ApplicationId appId,
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
@@ -99,33 +77,6 @@
}
/**
- * Creates a new multi-to-single point connectivity intent for the specified
- * traffic selector and treatment.
- *
- * @param appId application identifier
- * @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 constraints constraints to apply to the intent
- * @param priority priority to use for flows generated by this intent
- * @throws NullPointerException if {@code ingressPoints} or
- * {@code egressPoint} is null.
- * @throws IllegalArgumentException if the size of {@code ingressPoints} is
- * not more than 1
- */
- public MultiPointToSinglePointIntent(ApplicationId appId,
- TrafficSelector selector,
- TrafficTreatment treatment,
- Set<ConnectPoint> ingressPoints,
- ConnectPoint egressPoint,
- List<Constraint> constraints,
- int priority) {
- this(appId, null, selector, treatment, ingressPoints, egressPoint,
- constraints, priority);
- }
-
- /**
* Constructor for serializer.
*/
protected MultiPointToSinglePointIntent() {
@@ -135,6 +86,105 @@
}
/**
+ * Returns a new multi point to single point intent builder. The application id,
+ * ingress points and egress point are required fields. If they are
+ * not set by calls to the appropriate methods, an exception will
+ * be thrown.
+ *
+ * @return single point to multi point builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of a multi point to single point intent.
+ */
+ public static final class Builder extends ConnectivityIntent.Builder {
+ Set<ConnectPoint> ingressPoints;
+ ConnectPoint egressPoint;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the ingress point of the single point to multi point intent
+ * that will be built.
+ *
+ * @param ingressPoints ingress connect points
+ * @return this builder
+ */
+ public Builder ingressPoints(Set<ConnectPoint> ingressPoints) {
+ this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
+ return this;
+ }
+
+ /**
+ * Sets the egress point of the multi point to single point intent
+ * that will be built.
+ *
+ * @param egressPoint egress connect point
+ * @return this builder
+ */
+ public Builder egressPoint(ConnectPoint egressPoint) {
+ this.egressPoint = egressPoint;
+ return this;
+ }
+
+ /**
+ * Builds a multi point to single point intent from the
+ * accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public MultiPointToSinglePointIntent build() {
+
+ return new MultiPointToSinglePointIntent(
+ appId,
+ key,
+ selector,
+ treatment,
+ ingressPoints,
+ egressPoint,
+ constraints,
+ priority
+ );
+ }
+ }
+
+
+ /**
* Returns the set of ports on which ingress traffic should be connected to
* the egress port.
*
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
index 6804c86..4843877 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
@@ -24,6 +24,8 @@
import java.util.Collection;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public final class OpticalPathIntent extends Intent {
private final ConnectPoint src;
@@ -35,10 +37,11 @@
ConnectPoint src,
ConnectPoint dst,
Path path) {
- super(appId, ImmutableSet.copyOf(path.links()));
- this.src = src;
- this.dst = dst;
- this.path = path;
+ super(appId, null, ImmutableSet.copyOf(path.links()),
+ Intent.DEFAULT_INTENT_PRIORITY);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.path = checkNotNull(path);
}
protected OpticalPathIntent() {
@@ -69,6 +72,7 @@
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("appId", appId())
+ .add("key", key())
.add("resources", resources())
.add("ingressPort", src)
.add("egressPort", dst)
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
index 13fa61e..1cb960f 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
@@ -15,17 +15,17 @@
*/
package org.onosproject.net.intent;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
+import java.util.List;
+
import org.onosproject.core.ApplicationId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
-import java.util.Collections;
-import java.util.List;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import static com.google.common.base.Preconditions.checkArgument;
@@ -44,30 +44,17 @@
* @param selector traffic selector
* @param treatment treatment
* @param path traversed links
- * @throws NullPointerException {@code path} is null
- */
- public PathIntent(ApplicationId appId, TrafficSelector selector,
- TrafficTreatment treatment, Path path) {
- this(appId, selector, treatment, path, Collections.emptyList(),
- DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * Creates a new point-to-point intent with the supplied ingress/egress
- * ports and using the specified explicit path.
- *
- * @param appId application identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param path traversed links
* @param constraints optional list of constraints
* @param priority priority to use for the generated flows
* @throws NullPointerException {@code path} is null
*/
- public PathIntent(ApplicationId appId, TrafficSelector selector,
- TrafficTreatment treatment, Path path, List<Constraint> constraints,
- int priority) {
- super(appId, resources(path.links()), selector, treatment, constraints,
+ protected PathIntent(ApplicationId appId,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ Path path,
+ List<Constraint> constraints,
+ int priority) {
+ super(appId, null, resources(path.links()), selector, treatment, constraints,
priority);
PathIntent.validate(path.links());
this.path = path;
@@ -81,6 +68,86 @@
this.path = null;
}
+ /**
+ * Returns a new host to host intent builder.
+ *
+ * @return host to host intent builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of a host to host intent.
+ */
+ public static class Builder extends ConnectivityIntent.Builder {
+ Path path;
+
+ protected Builder() {
+ // Hide default constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the path of the intent that will be built.
+ *
+ * @param path path for the intent
+ * @return this builder
+ */
+ public Builder path(Path path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Builds a path intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public PathIntent build() {
+
+ return new PathIntent(
+ appId,
+ selector,
+ treatment,
+ path,
+ constraints,
+ priority
+ );
+ }
+ }
+
+
+
// NOTE: This methods takes linear time with the number of links.
/**
* Validates that source element ID and destination element ID of a link are
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
index 5f80d9a..5439121 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
@@ -159,13 +159,11 @@
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
priority);
- checkNotNull(ingressPoint);
- checkNotNull(egressPoint);
checkArgument(!ingressPoint.equals(egressPoint),
"ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);
- this.ingressPoint = ingressPoint;
- this.egressPoint = egressPoint;
+ this.ingressPoint = checkNotNull(ingressPoint);
+ this.egressPoint = checkNotNull(egressPoint);
}
/**
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 129c4a6..a58d3af 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
@@ -16,7 +16,7 @@
package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
@@ -42,27 +42,6 @@
* Creates a new single-to-multi point connectivity intent.
*
* @param appId application identifier
- * @param selector traffic selector
- * @param treatment treatment
- * @param ingressPoint port on which traffic will ingress
- * @param egressPoints set of ports on which traffic will egress
- * @throws NullPointerException if {@code ingressPoint} or
- * {@code egressPoints} is null
- * @throws IllegalArgumentException if the size of {@code egressPoints} is
- * not more than 1
- */
- public SinglePointToMultiPointIntent(ApplicationId appId,
- TrafficSelector selector, TrafficTreatment treatment,
- ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints) {
- this(appId, null, selector, treatment, ingressPoint, egressPoints,
- Collections.emptyList(),
- DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * Creates a new single-to-multi point connectivity intent.
- *
- * @param appId application identifier
* @param key intent key
* @param selector traffic selector
* @param treatment treatment
@@ -75,7 +54,7 @@
* @throws IllegalArgumentException if the size of {@code egressPoints} is
* not more than 1
*/
- public SinglePointToMultiPointIntent(ApplicationId appId,
+ private SinglePointToMultiPointIntent(ApplicationId appId,
Key key,
TrafficSelector selector, TrafficTreatment treatment,
ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints,
@@ -90,7 +69,105 @@
"Set of egresses should not contain ingress (ingress: %s)", ingressPoint);
this.ingressPoint = checkNotNull(ingressPoint);
- this.egressPoints = Sets.newHashSet(egressPoints);
+ this.egressPoints = egressPoints;
+ }
+
+ /**
+ * Returns a new single point to multi point intent builder. The application id,
+ * ingress point and egress points are required fields. If they are
+ * not set by calls to the appropriate methods, an exception will
+ * be thrown.
+ *
+ * @return single point to multi point builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of a single point to multi point intent.
+ */
+ public static final class Builder extends ConnectivityIntent.Builder {
+ ConnectPoint ingressPoint;
+ Set<ConnectPoint> egressPoints;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the ingress point of the single point to multi point intent
+ * that will be built.
+ *
+ * @param ingressPoint ingress connect point
+ * @return this builder
+ */
+ public Builder ingressPoint(ConnectPoint ingressPoint) {
+ this.ingressPoint = ingressPoint;
+ return this;
+ }
+
+ /**
+ * Sets the egress points of the single point to multi point intent
+ * that will be built.
+ *
+ * @param egressPoints egress connect points
+ * @return this builder
+ */
+ public Builder egressPoints(Set<ConnectPoint> egressPoints) {
+ this.egressPoints = ImmutableSet.copyOf(egressPoints);
+ return this;
+ }
+
+ /**
+ * Builds a single point to multi point intent from the
+ * accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public SinglePointToMultiPointIntent build() {
+
+ return new SinglePointToMultiPointIntent(
+ appId,
+ key,
+ selector,
+ treatment,
+ ingressPoint,
+ egressPoints,
+ constraints,
+ priority
+ );
+ }
}
/**
diff --git a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
index ee95255..a995758 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
@@ -15,21 +15,16 @@
*/
package org.onosproject.net.intent;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Link;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.constraint.LinkTypeConstraint;
-
import java.util.Collections;
import java.util.List;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+
+import com.google.common.base.MoreObjects;
+
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -40,45 +35,12 @@
private final ConnectPoint one;
private final ConnectPoint two;
- /**
- * Creates a new two way host-to-host intent with the supplied host pair and no
- * other traffic selection or treatment criteria.
- *
- * @param appId application identifier
- * @param one first host
- * @param two second host
- * @throws NullPointerException if {@code one} or {@code two} is null.
- */
- public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two) {
- this(appId, one, two,
- DefaultTrafficSelector.emptySelector(),
- DefaultTrafficTreatment.emptyTreatment(),
- ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
- DEFAULT_INTENT_PRIORITY);
- }
-
- /**
- * Creates a new host-to-host intent with the supplied host pair.
- *
- * @param appId application identifier
- * @param one first host
- * @param two second host
- * @param selector action
- * @param treatment ingress port
- * @throws NullPointerException if {@code one} or {@code two} is null.
- */
- public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two,
- TrafficSelector selector,
- TrafficTreatment treatment) {
- this(appId, one, two, selector, treatment,
- ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
- DEFAULT_INTENT_PRIORITY);
- }
/**
* Creates a new host-to-host intent with the supplied host pair.
*
* @param appId application identifier
+ * @param key intent key
* @param one first host
* @param two second host
* @param selector action
@@ -87,27 +49,7 @@
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
- public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two,
- TrafficSelector selector,
- TrafficTreatment treatment,
- List<Constraint> constraints,
- int priority) {
- this(appId, null, one, two, selector, treatment, constraints, priority);
- }
- /**
- * Creates a new host-to-host intent with the supplied host pair.
- *
- * @param appId application identifier
- * @param key intent key
- * @param one first host
- * @param two second host
- * @param selector action
- * @param treatment ingress port
- * @param constraints optional prioritized list of path selection constraints
- * @param priority priority to use for flows generated by this intent
- * @throws NullPointerException if {@code one} or {@code two} is null.
- */
- public TwoWayP2PIntent(ApplicationId appId, Key key,
+ private TwoWayP2PIntent(ApplicationId appId, Key key,
ConnectPoint one, ConnectPoint two,
TrafficSelector selector,
TrafficTreatment treatment,
@@ -122,12 +64,96 @@
}
- private static HostId min(HostId one, HostId two) {
- return one.hashCode() < two.hashCode() ? one : two;
+ /**
+ * Returns a new two way intent builder.
+ *
+ * @return two way intent builder
+ */
+ public static Builder builder() {
+ return new Builder();
}
- private static HostId max(HostId one, HostId two) {
- return one.hashCode() >= two.hashCode() ? one : two;
+ /**
+ * Builder of a point to point intent.
+ */
+ public static final class Builder extends ConnectivityIntent.Builder {
+ ConnectPoint one;
+ ConnectPoint two;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the first connection point of the two way intent that will be built.
+ *
+ * @param one first connect point
+ * @return this builder
+ */
+ public Builder one(ConnectPoint one) {
+ this.one = one;
+ return this;
+ }
+
+ /**
+ * Sets the second connection point of the two way intent that will be built.
+ *
+ * @param two second connect point
+ * @return this builder
+ */
+ public Builder two(ConnectPoint two) {
+ this.two = two;
+ return this;
+ }
+
+ /**
+ * Builds a point to point intent from the accumulated parameters.
+ *
+ * @return point to point intent
+ */
+ public TwoWayP2PIntent build() {
+
+ return new TwoWayP2PIntent(
+ appId,
+ key,
+ one,
+ two,
+ selector,
+ treatment,
+ constraints,
+ priority
+ );
+ }
}
/**
diff --git a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
index c476144..31d6c4d 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
@@ -27,7 +27,6 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.NetTestTools.APP_ID;
import static org.onosproject.net.NetTestTools.hid;
/**
@@ -43,7 +42,13 @@
private static final ApplicationId APPID = new TestApplicationId("foo");
private HostToHostIntent makeHostToHost(HostId one, HostId two) {
- return new HostToHostIntent(APPID, one, two, selector, treatment);
+ return HostToHostIntent.builder()
+ .appId(APPID)
+ .one(one)
+ .two(two)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
}
/**
@@ -75,17 +80,21 @@
*/
@Test
public void testEquals() {
- final HostToHostIntent intent1 = new HostToHostIntent(APP_ID,
- id1,
- id2,
- selector,
- treatment);
+ final HostToHostIntent intent1 = HostToHostIntent.builder()
+ .appId(APPID)
+ .one(id1)
+ .two(id2)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
- final HostToHostIntent intent2 = new HostToHostIntent(APP_ID,
- id2,
- id3,
- selector,
- treatment);
+ final HostToHostIntent intent2 = HostToHostIntent.builder()
+ .appId(APPID)
+ .one(id2)
+ .two(id3)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
new EqualsTester()
.addEqualityGroup(intent1)
@@ -95,11 +104,23 @@
@Override
protected Intent createOne() {
- return new HostToHostIntent(APP_ID, id1, id2, selector, treatment);
+ return HostToHostIntent.builder()
+ .appId(APPID)
+ .one(id1)
+ .two(id2)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
}
@Override
protected Intent createAnother() {
- return new HostToHostIntent(APP_ID, id1, id3, selector, treatment);
+ return HostToHostIntent.builder()
+ .appId(APPID)
+ .one(id1)
+ .two(id3)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
}
}
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 dca1906..4ae09fb 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
@@ -419,12 +419,13 @@
private final Long number;
public MockIntent(Long number) {
- super(NetTestTools.APP_ID, Collections.emptyList());
+ super(NetTestTools.APP_ID, null, Collections.emptyList(),
+ Intent.DEFAULT_INTENT_PRIORITY);
this.number = number;
}
public MockIntent(Long number, Collection<NetworkResource> resources) {
- super(NetTestTools.APP_ID, resources);
+ super(NetTestTools.APP_ID, null, resources, Intent.DEFAULT_INTENT_PRIORITY);
this.number = number;
}
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 a9ae782..4263531 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
@@ -67,22 +67,26 @@
final HashSet<Link> links1 = new HashSet<>();
links1.add(link("src", 1, "dst", 2));
final LinkCollectionIntent collectionIntent1 =
- new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links1,
- ingress,
- egress);
+ LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links1)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .build();
final HashSet<Link> links2 = new HashSet<>();
links2.add(link("src", 1, "dst", 3));
final LinkCollectionIntent collectionIntent2 =
- new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links2,
- ingress,
- egress);
+ LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links2)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .build();
new EqualsTester()
.addEqualityGroup(collectionIntent1)
@@ -98,12 +102,14 @@
final HashSet<Link> links1 = new HashSet<>();
links1.add(link("src", 1, "dst", 2));
final LinkCollectionIntent collectionIntent =
- new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links1,
- ingress,
- egress);
+ LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links1)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .build();
final Set<Link> createdLinks = collectionIntent.links();
assertThat(createdLinks, hasSize(1));
@@ -128,14 +134,16 @@
links1.add(link("src", 1, "dst", 2));
constraints.add(new LambdaConstraint(Lambda.valueOf(23)));
final LinkCollectionIntent collectionIntent =
- new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links1,
- ingress,
- egress,
- constraints,
- 8888);
+ LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links1)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .constraints(constraints)
+ .priority(8888)
+ .build();
final Set<Link> createdLinks = collectionIntent.links();
assertThat(createdLinks, hasSize(1));
@@ -175,23 +183,27 @@
protected Intent createOne() {
HashSet<Link> links1 = new HashSet<>();
links1.add(link("src", 1, "dst", 2));
- return new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links1,
- ingress,
- egress);
+ return LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links1)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .build();
}
@Override
protected Intent createAnother() {
HashSet<Link> links2 = new HashSet<>();
links2.add(link("src", 1, "dst", 3));
- return new LinkCollectionIntent(APP_ID,
- selector,
- treatment,
- links2,
- ingress,
- egress);
+ return LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links2)
+ .ingressPoints(ImmutableSet.of(ingress))
+ .egressPoints(ImmutableSet.of(egress))
+ .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 cab6a8d..2aac906 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
@@ -44,11 +44,23 @@
@Override
protected MultiPointToSinglePointIntent createOne() {
- return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS1, P2);
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .build();
}
@Override
protected MultiPointToSinglePointIntent createAnother() {
- return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS2, P1);
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoints(PS2)
+ .egressPoint(P1)
+ .build();
}
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
index 6db1a35..2149b26 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.net.intent;
+import java.util.Arrays;
+
import org.junit.Test;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultLink;
@@ -25,8 +27,6 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
-import java.util.Arrays;
-
import static org.junit.Assert.assertEquals;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.Link.Type.DIRECT;
@@ -65,12 +65,22 @@
@Override
protected PathIntent createOne() {
- return new PathIntent(APPID, MATCH, NOP, PATH1);
+ return PathIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .path(PATH1)
+ .build();
}
@Override
protected PathIntent createAnother() {
- return new PathIntent(APPID, MATCH, NOP, PATH2);
+ return PathIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .path(PATH2)
+ .build();
}
/**
@@ -79,7 +89,12 @@
*/
@Test(expected = IllegalArgumentException.class)
public void testRaiseExceptionWhenSameDevices() {
- new PathIntent(APPID, MATCH, NOP, new DefaultPath(provider1, Arrays.asList(link1), cost));
+ PathIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .path(new DefaultPath(provider1, Arrays.asList(link1), cost))
+ .build();
}
/**
@@ -88,7 +103,12 @@
*/
@Test(expected = IllegalArgumentException.class)
public void testRaiseExceptionWhenDifferentDevice() {
- new PathIntent(APPID, MATCH, NOP, new DefaultPath(provider1, Arrays.asList(link1, link2), cost));
+ PathIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .path(new DefaultPath(provider1, Arrays.asList(link1, link2), cost))
+ .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 f0f8ebf..325c4f2 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
@@ -44,11 +44,23 @@
@Override
protected SinglePointToMultiPointIntent createOne() {
- return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P1, PS2);
+ return SinglePointToMultiPointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoint(P1)
+ .egressPoints(PS2)
+ .build();
}
@Override
protected SinglePointToMultiPointIntent createAnother() {
- return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P2, PS1);
+ return SinglePointToMultiPointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoint(P2)
+ .egressPoints(PS1)
+ .build();
}
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/TestInstallableIntent.java b/core/api/src/test/java/org/onosproject/net/intent/TestInstallableIntent.java
index 32e5c90..bf3176d 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/TestInstallableIntent.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/TestInstallableIntent.java
@@ -32,7 +32,8 @@
* @param value intent ID
*/
public TestInstallableIntent(int value) { // FIXME
- super(new TestApplicationId("foo"), Collections.emptyList());
+ super(new TestApplicationId("foo"), null, Collections.emptyList(),
+ Intent.DEFAULT_INTENT_PRIORITY);
this.value = value;
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/TestIntent.java b/core/api/src/test/java/org/onosproject/net/intent/TestIntent.java
index b3a8679..af3ea49 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/TestIntent.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/TestIntent.java
@@ -32,7 +32,8 @@
* @param value intent ID
*/
public TestIntent(int value) { // FIXME
- super(new TestApplicationId("foo"), Collections.emptyList());
+ super(new TestApplicationId("foo"), null, Collections.emptyList(),
+ Intent.DEFAULT_INTENT_PRIORITY);
this.value = value;
}
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
index 57274d8..afd1025 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
@@ -78,7 +78,11 @@
@Test
public void hostToHostIntent() {
final HostToHostIntent intent =
- new HostToHostIntent(appId, id1, id2);
+ HostToHostIntent.builder()
+ .appId(appId)
+ .one(id1)
+ .two(id2)
+ .build();
final JsonCodec<HostToHostIntent> intentCodec =
context.codec(HostToHostIntent.class);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
index 60306b2..feea42f 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
@@ -97,9 +97,14 @@
HostToHostIntent intent) {
TrafficSelector selector = builder(intent.selector())
.matchEthSrc(src.mac()).matchEthDst(dst.mac()).build();
- return new PathIntent(intent.appId(), selector, intent.treatment(),
- path, intent.constraints(),
- intent.priority());
+ return PathIntent.builder()
+ .appId(intent.appId())
+ .selector(selector)
+ .treatment(intent.treatment())
+ .path(path)
+ .constraints(intent.constraints())
+ .priority(intent.priority())
+ .build();
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
index 948dbd6..b59d7eb 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
@@ -75,11 +75,16 @@
*/
private Intent createPathIntent(Path path,
MplsIntent intent) {
- return new MplsPathIntent(intent.appId(),
- intent.selector(), intent.treatment(), path,
- intent.ingressLabel(), intent.egressLabel(),
- intent.constraints(),
- intent.priority());
+ return MplsPathIntent.builder()
+ .appId(intent.appId())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .path(path)
+ .ingressLabel(intent.ingressLabel())
+ .egressLabel(intent.egressLabel())
+ .constraints(intent.constraints())
+ .priority(intent.priority())
+ .build();
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index 6403019..fbdfa9c 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -16,7 +16,6 @@
package org.onosproject.net.intent.impl.compiler;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -89,14 +88,16 @@
}
}
- Set<ConnectPoint> egress = ImmutableSet.of(intent.egressPoint());
- Intent result = new LinkCollectionIntent(intent.appId(),
- intent.selector(), intent.treatment(),
- Sets.newHashSet(links.values()),
- intent.ingressPoints(),
- ImmutableSet.of(intent.egressPoint()),
- Collections.emptyList(),
- intent.priority());
+ Intent result = LinkCollectionIntent.builder()
+ .appId(intent.appId())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .links(Sets.newHashSet(links.values()))
+ .ingressPoints(intent.ingressPoints())
+ .egressPoints(ImmutableSet.of(intent.egressPoint()))
+ .priority(intent.priority())
+ .build();
+
return Arrays.asList(result);
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
index 0f897a4..208c8e2 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
@@ -91,10 +91,14 @@
*/
private Intent createPathIntent(Path path,
PointToPointIntent intent) {
- return new PathIntent(intent.appId(),
- intent.selector(), intent.treatment(), path,
- intent.constraints(),
- intent.priority());
+ return PathIntent.builder()
+ .appId(intent.appId())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .path(path)
+ .constraints(intent.constraints())
+ .priority(intent.priority())
+ .build();
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
index 4b2260e..8a97b7b 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
@@ -16,7 +16,6 @@
package org.onosproject.net.intent.impl.compiler;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -66,13 +65,16 @@
links.addAll(path.links());
}
- Intent result = new LinkCollectionIntent(intent.appId(),
- intent.selector(),
- intent.treatment(), links,
- ImmutableSet.of(intent.ingressPoint()),
- intent.egressPoints(),
- Collections.emptyList(),
- intent.priority());
+ Intent result = LinkCollectionIntent.builder()
+ .appId(intent.appId())
+ .key(intent.key())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .links(links)
+ .ingressPoints(ImmutableSet.of(intent.ingressPoint()))
+ .egressPoints(intent.egressPoints())
+ .priority(intent.priority())
+ .build();
return Arrays.asList(result);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
index 5481007..64c963b 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
@@ -502,7 +502,8 @@
public void intentWithoutCompiler() {
class IntentNoCompiler extends Intent {
IntentNoCompiler() {
- super(APPID, Collections.emptyList());
+ super(APPID, null, Collections.emptyList(),
+ Intent.DEFAULT_INTENT_PRIORITY);
}
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
index b154d22..be9ab66 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompilerTest.java
@@ -90,8 +90,13 @@
* @return HostToHostIntent for the two hosts
*/
private HostToHostIntent makeIntent(String oneIdString, String twoIdString) {
- return new HostToHostIntent(APPID, hid(oneIdString), hid(twoIdString),
- selector, treatment);
+ return HostToHostIntent.builder()
+ .appId(APPID)
+ .one(hid(oneIdString))
+ .two(hid(twoIdString))
+ .selector(selector)
+ .treatment(treatment)
+ .build();
}
/**
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java
index 4890e03..76b26f4 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java
@@ -55,11 +55,14 @@
private MplsIntent makeIntent(String ingressIdString, Optional<MplsLabel> ingressLabel,
String egressIdString, Optional<MplsLabel> egressLabel) {
- return new MplsIntent(APPID, selector, treatment,
- connectPoint(ingressIdString, 1),
- ingressLabel,
- connectPoint(egressIdString, 1),
- egressLabel);
+ return MplsIntent.builder()
+ .appId(APPID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(connectPoint(ingressIdString, 1))
+ .ingressLabel(ingressLabel)
+ .egressPoint(connectPoint(egressIdString, 1))
+ .egressLabel(egressLabel).build();
}
/**
* Creates a compiler for HostToHost intents.
@@ -157,7 +160,15 @@
public void testSameSwitchDifferentPortsIntentCompilation() {
ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1));
ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2));
- MplsIntent intent = new MplsIntent(APP_ID, selector, treatment, src, Optional.empty(), dst, Optional.empty());
+ MplsIntent intent = MplsIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(src)
+ .ingressLabel(Optional.empty())
+ .egressPoint(dst)
+ .egressLabel(Optional.empty())
+ .build();
String[] hops = {"1"};
MplsIntentCompiler sut = makeCompiler(hops);
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompilerTest.java
index bbc7ad1..eb6be57 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompilerTest.java
@@ -104,8 +104,13 @@
ingressPoints.add(connectPoint(ingressId, 1));
}
- return new MultiPointToSinglePointIntent(APPID, selector, treatment,
- ingressPoints, egressPoint);
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoints(ingressPoints)
+ .egressPoint(egressPoint)
+ .build();
}
/**
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/LinkCollectionIntentInstallerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/LinkCollectionIntentInstallerTest.java
index 9f88fa6..00ebedf 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/LinkCollectionIntentInstallerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/LinkCollectionIntentInstallerTest.java
@@ -56,7 +56,14 @@
installer.coreService = testCoreService;
installer.intentManager =
new IntentInstallerTest.MockIntentManager(LinkCollectionIntent.class);
- intent = new LinkCollectionIntent(APP_ID, selector, treatment, links, d1p1, d3p1);
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .links(links)
+ .ingressPoints(ImmutableSet.of(d1p1))
+ .egressPoints(ImmutableSet.of(d3p1))
+ .build();
}
private FlowRuleOperation findOperation(Collection<FlowRuleOperation> ops,
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
index 8001eed..e88947c 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/MplsPathIntentInstallerTest.java
@@ -31,8 +31,6 @@
import org.onosproject.net.intent.MplsPathIntent;
import org.onosproject.store.trivial.impl.SimpleLinkStore;
-import com.google.common.collect.ImmutableList;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
@@ -70,12 +68,15 @@
installer.linkStore = new SimpleLinkStore();
installer.resourceService = new IntentTestsMocks.MockResourceService();
- intent = new MplsPathIntent(APP_ID, selector, treatment,
- new DefaultPath(PID, links, hops),
- ingressLabel,
- egressLabel,
- ImmutableList.of(),
- 55);
+ intent = MplsPathIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .path(new DefaultPath(PID, links, hops))
+ .ingressLabel(ingressLabel)
+ .egressLabel(egressLabel)
+ .priority(55)
+ .build();
}
/**
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathConstraintCalculationTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathConstraintCalculationTest.java
index d0bb843..6e7606d 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathConstraintCalculationTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathConstraintCalculationTest.java
@@ -73,8 +73,14 @@
private PathIntent createPathIntent(List<Link> links, List<Constraint> constraints) {
int hops = links.size() - 1;
- return new PathIntent(APP_ID, selector, treatment,
- new DefaultPath(PID, links, hops), constraints, 333);
+ return PathIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .path(new DefaultPath(PID, links, hops))
+ .constraints(constraints)
+ .priority(333)
+ .build();
}
/**
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathIntentInstallerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathIntentInstallerTest.java
index 695f115..9bbd16c 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathIntentInstallerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/installer/PathIntentInstallerTest.java
@@ -27,8 +27,6 @@
import org.onosproject.net.flow.FlowRuleOperation;
import org.onosproject.net.intent.PathIntent;
-import com.google.common.collect.ImmutableList;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
@@ -61,9 +59,13 @@
installer = new PathIntentInstaller();
installer.coreService = testCoreService;
installer.intentManager = new MockIntentManager(PathIntent.class);
- intent = new PathIntent(APP_ID, selector, treatment,
- new DefaultPath(PID, links, hops), ImmutableList.of(),
- 77);
+ intent = PathIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .path(new DefaultPath(PID, links, hops))
+ .priority(77)
+ .build();
}
/**
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
index d450812..a968e4e 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
@@ -97,7 +97,12 @@
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
- compiled = new PathIntent(appId, selector, treatment, path);
+ compiled = PathIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .path(path)
+ .build();
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
index 678bd2d..1938425 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallCoordinatingTest.java
@@ -98,7 +98,12 @@
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
- compiled = new PathIntent(appId, selector, treatment, path);
+ compiled = PathIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .path(path)
+ .build();
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
index b7d063f..8d4b334 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/InstallingTest.java
@@ -98,7 +98,12 @@
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
- compiled = new PathIntent(appId, selector, treatment, path);
+ compiled = PathIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .path(path)
+ .build();
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
index 19c3f6f..5d40516 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawCoordinatingTest.java
@@ -99,7 +99,12 @@
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
- compiled = new PathIntent(appId, selector, treatment, path);
+ compiled = PathIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .path(path)
+ .build();
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
index a1f08ec..6f7f267 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/WithdrawingTest.java
@@ -97,7 +97,12 @@
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
- compiled = new PathIntent(appId, selector, treatment, path);
+ compiled = PathIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .path(path)
+ .build();
}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
index c27772f..13dde08 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
@@ -311,9 +311,11 @@
HostId two = hostId(string(payload, "two"));
HostToHostIntent intent =
- new HostToHostIntent(appId, one, two,
- DefaultTrafficSelector.emptySelector(),
- DefaultTrafficTreatment.emptyTreatment());
+ HostToHostIntent.builder()
+ .appId(appId)
+ .one(one)
+ .two(two)
+ .build();
intentService.submit(intent);
startMonitoringIntent(event, intent);
@@ -336,8 +338,13 @@
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(appId, selector, treatment,
- ingressPoints, dstHost.location());
+ MultiPointToSinglePointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoints(ingressPoints)
+ .egressPoint(dstHost.location())
+ .build();
intentService.submit(intent);
startMonitoringIntent(event, intent);
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewWebSocket.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewWebSocket.java
index 9ef1329..c076078 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewWebSocket.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewWebSocket.java
@@ -15,9 +15,16 @@
*/
package org.onosproject.ui.impl;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
import org.eclipse.jetty.websocket.WebSocket;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.util.AbstractAccumulator;
@@ -55,15 +62,9 @@
import org.onosproject.net.link.LinkEvent;
import org.onosproject.net.link.LinkListener;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED;
@@ -349,9 +350,12 @@
HostId two = hostId(string(payload, "two"));
HostToHostIntent intent =
- new HostToHostIntent(appId, one, two,
- DefaultTrafficSelector.emptySelector(),
- DefaultTrafficTreatment.emptyTreatment());
+ HostToHostIntent.builder()
+ .appId(appId)
+ .one(one)
+ .two(two)
+ .build();
+
intentService.submit(intent);
startMonitoringIntent(event, intent);
@@ -374,8 +378,13 @@
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(appId, selector, treatment,
- ingressPoints, dstHost.location());
+ MultiPointToSinglePointIntent.builder()
+ .appId(appId)
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoints(ingressPoints)
+ .egressPoint(dstHost.location())
+ .build();
intentService.submit(intent);
startMonitoringIntent(event, intent);