Ray Milkey
Committed by Gerrit Code Review

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
Showing 48 changed files with 1273 additions and 624 deletions
......@@ -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.onosproject.routing.config.RoutingConfigurationService;
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 @@ public class IntentSynchronizer implements FibListener {
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
......
......@@ -233,9 +233,13 @@ public class IntentSyncTest extends AbstractIntentTest {
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 @@ public class IntentSyncTest extends AbstractIntentTest {
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 @@ public class IntentSyncTest extends AbstractIntentTest {
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 @@ public class IntentSyncTest extends AbstractIntentTest {
}
}
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;
}
......
......@@ -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 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand {
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());
}
......
......@@ -75,10 +75,17 @@ public class AddMplsIntent extends ConnectivityIntentCommand {
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);
}
......
......@@ -72,11 +72,16 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC
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());
}
......
......@@ -72,15 +72,16 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC
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());
}
......
......@@ -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 @@ public class RandomIntentCommand extends AbstractShellCommand {
}
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);
......
......@@ -77,34 +77,6 @@ public abstract class ConnectivityIntent extends Intent {
}
/**
* 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() {
......
......@@ -15,19 +15,15 @@
*/
package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
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 com.google.common.base.MoreObjects;
import static com.google.common.base.Preconditions.checkNotNull;
......@@ -40,59 +36,98 @@ public final class HostToHostIntent extends ConnectivityIntent {
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.
* Builder of a host to host intent.
*/
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 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.
* @return this builder
*/
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 Builder one(HostId one) {
this.one = one;
return this;
}
/**
* Creates a new host-to-host intent with the supplied host pair.
* Sets the second host of the intent that will be built.
*
* @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.
* @return this builder
*/
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);
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.
*
......@@ -106,7 +141,7 @@ public final class HostToHostIntent extends ConnectivityIntent {
* @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 @@ public final class HostToHostIntent extends ConnectivityIntent {
}
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.
*
......
......@@ -63,17 +63,6 @@ public abstract class Intent {
* 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
......
......@@ -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.Link;
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 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
/**
* 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 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
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 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
}
/**
* 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.
*
......
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 java.util.Optional;
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 @@ public final class MplsIntent extends ConnectivityIntent {
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,7 +41,9 @@ public final class MplsIntent extends ConnectivityIntent {
* @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,
private MplsIntent(ApplicationId appId,
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
ConnectPoint ingressPoint,
Optional<MplsLabel> ingressLabel,
......@@ -77,22 +52,142 @@ public final class MplsIntent extends ConnectivityIntent {
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);
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);
checkNotNull(ingressLabel);
checkNotNull(egressLabel);
"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;
this.ingressLabel = ingressLabel;
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.
*/
......@@ -147,6 +242,7 @@ public final class MplsIntent extends ConnectivityIntent {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("appId", appId())
.add("key", key())
.add("priority", priority())
.add("selector", selector())
.add("treatment", treatment())
......
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,42 +31,119 @@ public final class MplsPathIntent extends PathIntent {
* @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 = 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.
......
......@@ -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 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
* 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 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
* @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 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
}
/**
* 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 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
}
/**
* 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.
*
......
......@@ -24,6 +24,8 @@ import org.onosproject.net.Path;
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 @@ public final class OpticalPathIntent extends Intent {
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 @@ public final class OpticalPathIntent extends Intent {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("appId", appId())
.add("key", key())
.add("resources", resources())
.add("ingressPort", src)
.add("egressPort", dst)
......
......@@ -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 @@ public class PathIntent extends ConnectivityIntent {
* @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,
protected PathIntent(ApplicationId appId,
TrafficSelector selector,
TrafficTreatment treatment,
Path path,
List<Constraint> constraints,
int priority) {
super(appId, resources(path.links()), selector, treatment, constraints,
super(appId, null, resources(path.links()), selector, treatment, constraints,
priority);
PathIntent.validate(path.links());
this.path = path;
......@@ -81,6 +68,86 @@ public class PathIntent extends ConnectivityIntent {
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
......
......@@ -159,13 +159,11 @@ public final class PointToPointIntent extends ConnectivityIntent {
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);
}
/**
......
......@@ -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 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
* 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 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
* @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 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
"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
);
}
}
/**
......
......@@ -15,20 +15,15 @@
*/
package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
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 com.google.common.base.MoreObjects;
import static com.google.common.base.Preconditions.checkNotNull;
......@@ -40,64 +35,11 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
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 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, 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
......@@ -107,7 +49,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
* @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 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
}
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();
}
/**
* 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);
}
private static HostId max(HostId one, HostId two) {
return one.hashCode() >= two.hashCode() ? one : two;
@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
);
}
}
/**
......
......@@ -27,7 +27,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
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 @@ public class HostToHostIntentTest extends IntentTest {
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 @@ public class HostToHostIntentTest extends IntentTest {
*/
@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 @@ public class HostToHostIntentTest extends IntentTest {
@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();
}
}
......
......@@ -419,12 +419,13 @@ public class IntentTestsMocks {
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;
}
......
......@@ -67,22 +67,26 @@ public class LinkCollectionIntentTest extends IntentTest {
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 @@ public class LinkCollectionIntentTest extends IntentTest {
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 @@ public class LinkCollectionIntentTest extends IntentTest {
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 @@ public class LinkCollectionIntentTest extends IntentTest {
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();
}
}
......
......@@ -44,11 +44,23 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest {
@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();
}
}
......
......@@ -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.Path;
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 @@ public class PathIntentTest extends ConnectivityIntentTest {
@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 @@ public class PathIntentTest extends ConnectivityIntentTest {
*/
@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 @@ public class PathIntentTest extends ConnectivityIntentTest {
*/
@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();
}
}
......
......@@ -44,11 +44,23 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest {
@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();
}
}
......
......@@ -32,7 +32,8 @@ public class TestInstallableIntent extends Intent {
* @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;
}
......
......@@ -32,7 +32,8 @@ public class TestIntent extends Intent {
* @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;
}
......
......@@ -78,7 +78,11 @@ public class IntentCodecTest extends AbstractIntentTest {
@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);
......
......@@ -97,9 +97,14 @@ public class HostToHostIntentCompiler
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();
}
}
......
......@@ -75,11 +75,16 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent>
*/
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();
}
......
......@@ -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 @@ public class MultiPointToSinglePointIntentCompiler
}
}
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);
}
......
......@@ -91,10 +91,14 @@ public class PointToPointIntentCompiler
*/
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();
}
}
......
......@@ -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 @@ public class SinglePointToMultiPointIntentCompiler
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);
}
......
......@@ -502,7 +502,8 @@ public class IntentManagerTest {
public void intentWithoutCompiler() {
class IntentNoCompiler extends Intent {
IntentNoCompiler() {
super(APPID, Collections.emptyList());
super(APPID, null, Collections.emptyList(),
Intent.DEFAULT_INTENT_PRIORITY);
}
}
......
......@@ -90,8 +90,13 @@ public class HostToHostIntentCompilerTest extends AbstractIntentTest {
* @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();
}
/**
......
......@@ -55,11 +55,14 @@ public class MplsIntentCompilerTest extends AbstractIntentTest {
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 class MplsIntentCompilerTest extends AbstractIntentTest {
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);
......
......@@ -104,8 +104,13 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes
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();
}
/**
......
......@@ -56,7 +56,14 @@ public class LinkCollectionIntentInstallerTest extends IntentInstallerTest {
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,
......
......@@ -31,8 +31,6 @@ import org.onosproject.net.intent.IntentTestsMocks;
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 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest {
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();
}
/**
......
......@@ -73,8 +73,14 @@ public class PathConstraintCalculationTest extends AbstractIntentTest {
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();
}
/**
......
......@@ -27,8 +27,6 @@ import org.onosproject.net.Link;
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 @@ public class PathIntentInstallerTest extends IntentInstallerTest {
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();
}
/**
......
......@@ -97,7 +97,12 @@ public class CompilingTest {
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = new PathIntent(appId, selector, treatment, path);
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
......
......@@ -98,7 +98,12 @@ public class InstallCoordinatingTest {
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = new PathIntent(appId, selector, treatment, path);
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
......
......@@ -98,7 +98,12 @@ public class InstallingTest {
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = new PathIntent(appId, selector, treatment, path);
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
......
......@@ -99,7 +99,12 @@ public class WithdrawCoordinatingTest {
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = new PathIntent(appId, selector, treatment, path);
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
......
......@@ -97,7 +97,12 @@ public class WithdrawingTest {
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = new PathIntent(appId, selector, treatment, path);
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
......
......@@ -311,9 +311,11 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
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 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
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);
......
......@@ -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.intent.MultiPointToSinglePointIntent;
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 @@ public class TopologyViewWebSocket
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 @@ public class TopologyViewWebSocket
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);
......