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
1295 additions
and
646 deletions
... | @@ -15,7 +15,19 @@ | ... | @@ -15,7 +15,19 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sdnip; | 16 | package org.onosproject.sdnip; |
17 | 17 | ||
18 | -import com.google.common.util.concurrent.ThreadFactoryBuilder; | 18 | +import java.util.Collection; |
19 | +import java.util.HashMap; | ||
20 | +import java.util.HashSet; | ||
21 | +import java.util.LinkedList; | ||
22 | +import java.util.List; | ||
23 | +import java.util.Map; | ||
24 | +import java.util.Objects; | ||
25 | +import java.util.Set; | ||
26 | +import java.util.concurrent.ConcurrentHashMap; | ||
27 | +import java.util.concurrent.ExecutorService; | ||
28 | +import java.util.concurrent.Executors; | ||
29 | +import java.util.concurrent.Semaphore; | ||
30 | + | ||
19 | import org.onlab.packet.Ethernet; | 31 | import org.onlab.packet.Ethernet; |
20 | import org.onlab.packet.IpAddress; | 32 | import org.onlab.packet.IpAddress; |
21 | import org.onlab.packet.IpPrefix; | 33 | import org.onlab.packet.IpPrefix; |
... | @@ -43,19 +55,7 @@ import org.onosproject.routing.config.RoutingConfigurationService; | ... | @@ -43,19 +55,7 @@ import org.onosproject.routing.config.RoutingConfigurationService; |
43 | import org.slf4j.Logger; | 55 | import org.slf4j.Logger; |
44 | import org.slf4j.LoggerFactory; | 56 | import org.slf4j.LoggerFactory; |
45 | 57 | ||
46 | -import java.util.Collection; | 58 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; |
47 | -import java.util.Collections; | ||
48 | -import java.util.HashMap; | ||
49 | -import java.util.HashSet; | ||
50 | -import java.util.LinkedList; | ||
51 | -import java.util.List; | ||
52 | -import java.util.Map; | ||
53 | -import java.util.Objects; | ||
54 | -import java.util.Set; | ||
55 | -import java.util.concurrent.ConcurrentHashMap; | ||
56 | -import java.util.concurrent.ExecutorService; | ||
57 | -import java.util.concurrent.Executors; | ||
58 | -import java.util.concurrent.Semaphore; | ||
59 | 59 | ||
60 | import static com.google.common.base.Preconditions.checkArgument; | 60 | import static com.google.common.base.Preconditions.checkArgument; |
61 | 61 | ||
... | @@ -340,11 +340,15 @@ public class IntentSynchronizer implements FibListener { | ... | @@ -340,11 +340,15 @@ public class IntentSynchronizer implements FibListener { |
340 | int priority = | 340 | int priority = |
341 | prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET; | 341 | prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET; |
342 | Key key = Key.of(prefix.toString(), appId); | 342 | Key key = Key.of(prefix.toString(), appId); |
343 | - return new MultiPointToSinglePointIntent(appId, key, selector.build(), | 343 | + return MultiPointToSinglePointIntent.builder() |
344 | - treatment.build(), | 344 | + .appId(appId) |
345 | - ingressPorts, egressPort, | 345 | + .key(key) |
346 | - Collections.emptyList(), | 346 | + .selector(selector.build()) |
347 | - priority); | 347 | + .treatment(treatment.build()) |
348 | + .ingressPoints(ingressPorts) | ||
349 | + .egressPoint(egressPort) | ||
350 | + .priority(priority) | ||
351 | + .build(); | ||
348 | } | 352 | } |
349 | 353 | ||
350 | @Override | 354 | @Override | ... | ... |
... | @@ -233,9 +233,13 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -233,9 +233,13 @@ public class IntentSyncTest extends AbstractIntentTest { |
233 | ingressPoints.add(SW4_ETH1); | 233 | ingressPoints.add(SW4_ETH1); |
234 | 234 | ||
235 | MultiPointToSinglePointIntent intent = | 235 | MultiPointToSinglePointIntent intent = |
236 | - new MultiPointToSinglePointIntent(APPID, | 236 | + MultiPointToSinglePointIntent.builder() |
237 | - selectorBuilder.build(), treatmentBuilder.build(), | 237 | + .appId(APPID) |
238 | - ingressPoints, SW1_ETH1); | 238 | + .selector(selectorBuilder.build()) |
239 | + .treatment(treatmentBuilder.build()) | ||
240 | + .ingressPoints(ingressPoints) | ||
241 | + .egressPoint(SW1_ETH1) | ||
242 | + .build(); | ||
239 | 243 | ||
240 | // Setup the expected intents | 244 | // Setup the expected intents |
241 | intentService.submit(eqExceptId(intent)); | 245 | intentService.submit(eqExceptId(intent)); |
... | @@ -291,9 +295,13 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -291,9 +295,13 @@ public class IntentSyncTest extends AbstractIntentTest { |
291 | ingressPoints.add(SW3_ETH1); | 295 | ingressPoints.add(SW3_ETH1); |
292 | 296 | ||
293 | MultiPointToSinglePointIntent intent = | 297 | MultiPointToSinglePointIntent intent = |
294 | - new MultiPointToSinglePointIntent(APPID, | 298 | + MultiPointToSinglePointIntent.builder() |
295 | - selectorBuilder.build(), treatmentBuilder.build(), | 299 | + .appId(APPID) |
296 | - ingressPoints, SW4_ETH1); | 300 | + .selector(selectorBuilder.build()) |
301 | + .treatment(treatmentBuilder.build()) | ||
302 | + .ingressPoints(ingressPoints) | ||
303 | + .egressPoint(SW4_ETH1) | ||
304 | + .build(); | ||
297 | 305 | ||
298 | // Setup the expected intents | 306 | // Setup the expected intents |
299 | intentService.submit(eqExceptId(intent)); | 307 | intentService.submit(eqExceptId(intent)); |
... | @@ -357,10 +365,13 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -357,10 +365,13 @@ public class IntentSyncTest extends AbstractIntentTest { |
357 | ingressPointsNew.add(SW4_ETH1); | 365 | ingressPointsNew.add(SW4_ETH1); |
358 | 366 | ||
359 | MultiPointToSinglePointIntent intentNew = | 367 | MultiPointToSinglePointIntent intentNew = |
360 | - new MultiPointToSinglePointIntent(APPID, | 368 | + MultiPointToSinglePointIntent.builder() |
361 | - selectorBuilderNew.build(), | 369 | + .appId(APPID) |
362 | - treatmentBuilderNew.build(), | 370 | + .selector(selectorBuilderNew.build()) |
363 | - ingressPointsNew, SW2_ETH1); | 371 | + .treatment(treatmentBuilderNew.build()) |
372 | + .ingressPoints(ingressPointsNew) | ||
373 | + .egressPoint(SW2_ETH1) | ||
374 | + .build(); | ||
364 | 375 | ||
365 | // Set up test expectation | 376 | // Set up test expectation |
366 | reset(intentService); | 377 | reset(intentService); |
... | @@ -592,9 +603,13 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -592,9 +603,13 @@ public class IntentSyncTest extends AbstractIntentTest { |
592 | } | 603 | } |
593 | } | 604 | } |
594 | MultiPointToSinglePointIntent intent = | 605 | MultiPointToSinglePointIntent intent = |
595 | - new MultiPointToSinglePointIntent(APPID, | 606 | + MultiPointToSinglePointIntent.builder() |
596 | - selectorBuilder.build(), treatmentBuilder.build(), | 607 | + .appId(APPID) |
597 | - ingressPoints, egressPoint); | 608 | + .selector(selectorBuilder.build()) |
609 | + .treatment(treatmentBuilder.build()) | ||
610 | + .ingressPoints(ingressPoints) | ||
611 | + .egressPoint(egressPoint) | ||
612 | + .build(); | ||
598 | return intent; | 613 | return intent; |
599 | } | 614 | } |
600 | 615 | ... | ... |
... | @@ -15,19 +15,15 @@ | ... | @@ -15,19 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
17 | 17 | ||
18 | +import java.util.List; | ||
19 | + | ||
18 | import org.apache.karaf.shell.commands.Argument; | 20 | import org.apache.karaf.shell.commands.Argument; |
19 | import org.apache.karaf.shell.commands.Command; | 21 | import org.apache.karaf.shell.commands.Command; |
20 | import org.onosproject.net.HostId; | 22 | import org.onosproject.net.HostId; |
21 | -import org.onosproject.net.flow.DefaultTrafficSelector; | ||
22 | -import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
23 | -import org.onosproject.net.flow.TrafficSelector; | ||
24 | -import org.onosproject.net.flow.TrafficTreatment; | ||
25 | import org.onosproject.net.intent.Constraint; | 23 | import org.onosproject.net.intent.Constraint; |
26 | import org.onosproject.net.intent.HostToHostIntent; | 24 | import org.onosproject.net.intent.HostToHostIntent; |
27 | import org.onosproject.net.intent.IntentService; | 25 | import org.onosproject.net.intent.IntentService; |
28 | 26 | ||
29 | -import java.util.List; | ||
30 | - | ||
31 | /** | 27 | /** |
32 | * Installs host-to-host connectivity intent. | 28 | * Installs host-to-host connectivity intent. |
33 | */ | 29 | */ |
... | @@ -50,14 +46,16 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { | ... | @@ -50,14 +46,16 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { |
50 | HostId oneId = HostId.hostId(one); | 46 | HostId oneId = HostId.hostId(one); |
51 | HostId twoId = HostId.hostId(two); | 47 | HostId twoId = HostId.hostId(two); |
52 | 48 | ||
53 | - TrafficSelector selector = DefaultTrafficSelector.emptySelector(); | ||
54 | - TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); | ||
55 | List<Constraint> constraints = buildConstraints(); | 49 | List<Constraint> constraints = buildConstraints(); |
56 | 50 | ||
57 | - HostToHostIntent intent = new HostToHostIntent(appId(), key(), | 51 | + HostToHostIntent intent = HostToHostIntent.builder() |
58 | - oneId, twoId, | 52 | + .appId(appId()) |
59 | - selector, treatment, | 53 | + .key(key()) |
60 | - constraints, priority()); | 54 | + .one(oneId) |
55 | + .two(twoId) | ||
56 | + .constraints(constraints) | ||
57 | + .priority(priority()) | ||
58 | + .build(); | ||
61 | service.submit(intent); | 59 | service.submit(intent); |
62 | print("Host to Host intent submitted:\n%s", intent.toString()); | 60 | print("Host to Host intent submitted:\n%s", intent.toString()); |
63 | } | 61 | } | ... | ... |
... | @@ -75,10 +75,17 @@ public class AddMplsIntent extends ConnectivityIntentCommand { | ... | @@ -75,10 +75,17 @@ public class AddMplsIntent extends ConnectivityIntentCommand { |
75 | 75 | ||
76 | List<Constraint> constraints = buildConstraints(); | 76 | List<Constraint> constraints = buildConstraints(); |
77 | 77 | ||
78 | - MplsIntent intent = new MplsIntent(appId(), selector, treatment, | 78 | + MplsIntent intent = MplsIntent.builder() |
79 | - ingress, ingressLabel, egress, | 79 | + .appId(appId()) |
80 | - egressLabel, constraints, | 80 | + .selector(selector) |
81 | - priority()); | 81 | + .treatment(treatment) |
82 | + .ingressPoint(ingress) | ||
83 | + .ingressLabel(ingressLabel) | ||
84 | + .egressPoint(egress) | ||
85 | + .egressLabel(egressLabel) | ||
86 | + .constraints(constraints) | ||
87 | + .priority(priority()) | ||
88 | + .build(); | ||
82 | service.submit(intent); | 89 | service.submit(intent); |
83 | } | 90 | } |
84 | 91 | ... | ... |
... | @@ -72,11 +72,16 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC | ... | @@ -72,11 +72,16 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC |
72 | TrafficTreatment treatment = buildTrafficTreatment(); | 72 | TrafficTreatment treatment = buildTrafficTreatment(); |
73 | List<Constraint> constraints = buildConstraints(); | 73 | List<Constraint> constraints = buildConstraints(); |
74 | 74 | ||
75 | - Intent intent = new MultiPointToSinglePointIntent(appId(), key(), | 75 | + Intent intent = MultiPointToSinglePointIntent.builder() |
76 | - selector, treatment, | 76 | + .appId(appId()) |
77 | - ingressPoints, egress, | 77 | + .key(key()) |
78 | - constraints, | 78 | + .selector(selector) |
79 | - priority()); | 79 | + .treatment(treatment) |
80 | + .ingressPoints(ingressPoints) | ||
81 | + .egressPoint(egress) | ||
82 | + .constraints(constraints) | ||
83 | + .priority(priority()) | ||
84 | + .build(); | ||
80 | service.submit(intent); | 85 | service.submit(intent); |
81 | print("Multipoint to single point intent submitted:\n%s", intent.toString()); | 86 | print("Multipoint to single point intent submitted:\n%s", intent.toString()); |
82 | } | 87 | } | ... | ... |
... | @@ -72,15 +72,16 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC | ... | @@ -72,15 +72,16 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC |
72 | List<Constraint> constraints = buildConstraints(); | 72 | List<Constraint> constraints = buildConstraints(); |
73 | 73 | ||
74 | SinglePointToMultiPointIntent intent = | 74 | SinglePointToMultiPointIntent intent = |
75 | - new SinglePointToMultiPointIntent( | 75 | + SinglePointToMultiPointIntent.builder() |
76 | - appId(), | 76 | + .appId(appId()) |
77 | - key(), | 77 | + .key(key()) |
78 | - selector, | 78 | + .selector(selector) |
79 | - treatment, | 79 | + .treatment(treatment) |
80 | - ingressPoint, | 80 | + .ingressPoint(ingressPoint) |
81 | - egressPoints, | 81 | + .egressPoints(egressPoints) |
82 | - constraints, | 82 | + .constraints(constraints) |
83 | - priority()); | 83 | + .priority(priority()) |
84 | + .build(); | ||
84 | service.submit(intent); | 85 | service.submit(intent); |
85 | print("Single point to multipoint intent submitted:\n%s", intent.toString()); | 86 | print("Single point to multipoint intent submitted:\n%s", intent.toString()); |
86 | } | 87 | } | ... | ... |
... | @@ -15,25 +15,22 @@ | ... | @@ -15,25 +15,22 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
17 | 17 | ||
18 | -import com.google.common.collect.Lists; | 18 | +import java.util.Collection; |
19 | +import java.util.Collections; | ||
20 | +import java.util.List; | ||
21 | + | ||
19 | import org.apache.karaf.shell.commands.Argument; | 22 | import org.apache.karaf.shell.commands.Argument; |
20 | import org.apache.karaf.shell.commands.Command; | 23 | import org.apache.karaf.shell.commands.Command; |
21 | import org.onosproject.cli.AbstractShellCommand; | 24 | import org.onosproject.cli.AbstractShellCommand; |
22 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
23 | import org.onosproject.core.CoreService; | 26 | import org.onosproject.core.CoreService; |
24 | import org.onosproject.net.Host; | 27 | import org.onosproject.net.Host; |
25 | -import org.onosproject.net.flow.DefaultTrafficSelector; | ||
26 | -import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
27 | -import org.onosproject.net.flow.TrafficSelector; | ||
28 | -import org.onosproject.net.flow.TrafficTreatment; | ||
29 | import org.onosproject.net.host.HostService; | 28 | import org.onosproject.net.host.HostService; |
30 | import org.onosproject.net.intent.HostToHostIntent; | 29 | import org.onosproject.net.intent.HostToHostIntent; |
31 | import org.onosproject.net.intent.Intent; | 30 | import org.onosproject.net.intent.Intent; |
32 | import org.onosproject.net.intent.IntentService; | 31 | import org.onosproject.net.intent.IntentService; |
33 | 32 | ||
34 | -import java.util.Collection; | 33 | +import com.google.common.collect.Lists; |
35 | -import java.util.Collections; | ||
36 | -import java.util.List; | ||
37 | 34 | ||
38 | /** | 35 | /** |
39 | * Installs point-to-point connectivity intents. | 36 | * Installs point-to-point connectivity intents. |
... | @@ -67,17 +64,16 @@ public class RandomIntentCommand extends AbstractShellCommand { | ... | @@ -67,17 +64,16 @@ public class RandomIntentCommand extends AbstractShellCommand { |
67 | } | 64 | } |
68 | 65 | ||
69 | private Collection<Intent> generateIntents() { | 66 | private Collection<Intent> generateIntents() { |
70 | - TrafficSelector selector = DefaultTrafficSelector.emptySelector(); | ||
71 | - TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); | ||
72 | - | ||
73 | List<Host> hosts = Lists.newArrayList(hostService.getHosts()); | 67 | List<Host> hosts = Lists.newArrayList(hostService.getHosts()); |
74 | List<Intent> fullMesh = Lists.newArrayList(); | 68 | List<Intent> fullMesh = Lists.newArrayList(); |
75 | for (int i = 0; i < hosts.size(); i++) { | 69 | for (int i = 0; i < hosts.size(); i++) { |
76 | for (int j = i + 1; j < hosts.size(); j++) { | 70 | for (int j = i + 1; j < hosts.size(); j++) { |
77 | - fullMesh.add(new HostToHostIntent(appId(), | 71 | + fullMesh.add(HostToHostIntent.builder() |
78 | - hosts.get(i).id(), | 72 | + .appId(appId()) |
79 | - hosts.get(j).id(), | 73 | + .one(hosts.get(i).id()) |
80 | - selector, treatment)); | 74 | + .two(hosts.get(j).id()) |
75 | + .build()); | ||
76 | + | ||
81 | } | 77 | } |
82 | } | 78 | } |
83 | Collections.shuffle(fullMesh); | 79 | Collections.shuffle(fullMesh); | ... | ... |
... | @@ -77,34 +77,6 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -77,34 +77,6 @@ public abstract class ConnectivityIntent extends Intent { |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
80 | - * Creates a connectivity intent that matches on the specified selector | ||
81 | - * and applies the specified treatment. | ||
82 | - * <p> | ||
83 | - * Path will be optimized based on the first constraint if one is given. | ||
84 | - * </p> | ||
85 | - * | ||
86 | - * @param appId application identifier | ||
87 | - * @param resources required network resources (optional) | ||
88 | - * @param selector traffic selector | ||
89 | - * @param treatment treatment | ||
90 | - * @param constraints optional prioritized list of constraints | ||
91 | - * @param priority priority to use for flows generated by this intent | ||
92 | - * @throws NullPointerException if the selector or treatment is null | ||
93 | - */ | ||
94 | - | ||
95 | - protected ConnectivityIntent(ApplicationId appId, | ||
96 | - Collection<NetworkResource> resources, | ||
97 | - TrafficSelector selector, | ||
98 | - TrafficTreatment treatment, | ||
99 | - List<Constraint> constraints, | ||
100 | - int priority) { | ||
101 | - super(appId, null, resources, priority); | ||
102 | - this.selector = checkNotNull(selector); | ||
103 | - this.treatment = checkNotNull(treatment); | ||
104 | - this.constraints = checkNotNull(constraints); | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | * Constructor for serializer. | 80 | * Constructor for serializer. |
109 | */ | 81 | */ |
110 | protected ConnectivityIntent() { | 82 | protected ConnectivityIntent() { | ... | ... |
... | @@ -15,19 +15,15 @@ | ... | @@ -15,19 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | -import com.google.common.base.MoreObjects; | 18 | +import java.util.Collections; |
19 | -import com.google.common.collect.ImmutableList; | 19 | +import java.util.List; |
20 | + | ||
20 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
21 | import org.onosproject.net.HostId; | 22 | import org.onosproject.net.HostId; |
22 | -import org.onosproject.net.Link; | ||
23 | -import org.onosproject.net.flow.DefaultTrafficSelector; | ||
24 | -import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
25 | import org.onosproject.net.flow.TrafficSelector; | 23 | import org.onosproject.net.flow.TrafficSelector; |
26 | import org.onosproject.net.flow.TrafficTreatment; | 24 | import org.onosproject.net.flow.TrafficTreatment; |
27 | -import org.onosproject.net.intent.constraint.LinkTypeConstraint; | ||
28 | 25 | ||
29 | -import java.util.Collections; | 26 | +import com.google.common.base.MoreObjects; |
30 | -import java.util.List; | ||
31 | 27 | ||
32 | import static com.google.common.base.Preconditions.checkNotNull; | 28 | import static com.google.common.base.Preconditions.checkNotNull; |
33 | 29 | ||
... | @@ -40,59 +36,98 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -40,59 +36,98 @@ public final class HostToHostIntent extends ConnectivityIntent { |
40 | private final HostId two; | 36 | private final HostId two; |
41 | 37 | ||
42 | /** | 38 | /** |
43 | - * Creates a new host-to-host intent with the supplied host pair and no | 39 | + * Returns a new host to host intent builder. |
44 | - * other traffic selection or treatment criteria. | ||
45 | * | 40 | * |
46 | - * @param appId application identifier | 41 | + * @return host to host intent builder |
47 | - * @param one first host | ||
48 | - * @param two second host | ||
49 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
50 | */ | 42 | */ |
51 | - public HostToHostIntent(ApplicationId appId, HostId one, HostId two) { | 43 | + public static Builder builder() { |
52 | - this(appId, one, two, | 44 | + return new Builder(); |
53 | - DefaultTrafficSelector.emptySelector(), | ||
54 | - DefaultTrafficTreatment.emptyTreatment(), | ||
55 | - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)), | ||
56 | - DEFAULT_INTENT_PRIORITY); | ||
57 | } | 45 | } |
58 | 46 | ||
59 | /** | 47 | /** |
60 | - * Creates a new host-to-host intent with the supplied host pair. | 48 | + * Builder of a host to host intent. |
61 | - * | ||
62 | - * @param appId application identifier | ||
63 | - * @param one first host | ||
64 | - * @param two second host | ||
65 | - * @param selector action | ||
66 | - * @param treatment ingress port | ||
67 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
68 | */ | 49 | */ |
69 | - public HostToHostIntent(ApplicationId appId, HostId one, HostId two, | 50 | + public static final class Builder extends ConnectivityIntent.Builder { |
70 | - TrafficSelector selector, | 51 | + HostId one; |
71 | - TrafficTreatment treatment) { | 52 | + HostId two; |
72 | - this(appId, one, two, selector, treatment, | 53 | + |
73 | - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)), | 54 | + private Builder() { |
74 | - DEFAULT_INTENT_PRIORITY); | 55 | + // Hide constructor |
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public Builder appId(ApplicationId appId) { | ||
60 | + return (Builder) super.appId(appId); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public Builder key(Key key) { | ||
65 | + return (Builder) super.key(key); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public Builder selector(TrafficSelector selector) { | ||
70 | + return (Builder) super.selector(selector); | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + public Builder treatment(TrafficTreatment treatment) { | ||
75 | + return (Builder) super.treatment(treatment); | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public Builder constraints(List<Constraint> constraints) { | ||
80 | + return (Builder) super.constraints(constraints); | ||
81 | + } | ||
82 | + | ||
83 | + @Override | ||
84 | + public Builder priority(int priority) { | ||
85 | + return (Builder) super.priority(priority); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Sets the first host of the intent that will be built. | ||
90 | + * | ||
91 | + * @param one first host | ||
92 | + * @return this builder | ||
93 | + */ | ||
94 | + public Builder one(HostId one) { | ||
95 | + this.one = one; | ||
96 | + return this; | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Sets the second host of the intent that will be built. | ||
101 | + * | ||
102 | + * @param two second host | ||
103 | + * @return this builder | ||
104 | + */ | ||
105 | + public Builder two(HostId two) { | ||
106 | + this.two = two; | ||
107 | + return this; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * Builds a host to host intent from the accumulated parameters. | ||
112 | + * | ||
113 | + * @return point to point intent | ||
114 | + */ | ||
115 | + public HostToHostIntent build() { | ||
116 | + | ||
117 | + return new HostToHostIntent( | ||
118 | + appId, | ||
119 | + key, | ||
120 | + one, | ||
121 | + two, | ||
122 | + selector, | ||
123 | + treatment, | ||
124 | + constraints, | ||
125 | + priority | ||
126 | + ); | ||
127 | + } | ||
75 | } | 128 | } |
76 | 129 | ||
77 | - /** | 130 | + |
78 | - * Creates a new host-to-host intent with the supplied host pair. | ||
79 | - * | ||
80 | - * @param appId application identifier | ||
81 | - * @param one first host | ||
82 | - * @param two second host | ||
83 | - * @param selector action | ||
84 | - * @param treatment ingress port | ||
85 | - * @param constraints optional prioritized list of path selection constraints | ||
86 | - * @param priority priority to use for flows generated by this intent | ||
87 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
88 | - */ | ||
89 | - public HostToHostIntent(ApplicationId appId, HostId one, HostId two, | ||
90 | - TrafficSelector selector, | ||
91 | - TrafficTreatment treatment, | ||
92 | - List<Constraint> constraints, | ||
93 | - int priority) { | ||
94 | - this(appId, null, one, two, selector, treatment, constraints, priority); | ||
95 | - } | ||
96 | /** | 131 | /** |
97 | * Creates a new host-to-host intent with the supplied host pair. | 132 | * Creates a new host-to-host intent with the supplied host pair. |
98 | * | 133 | * |
... | @@ -106,7 +141,7 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -106,7 +141,7 @@ public final class HostToHostIntent extends ConnectivityIntent { |
106 | * @param priority priority to use for flows generated by this intent | 141 | * @param priority priority to use for flows generated by this intent |
107 | * @throws NullPointerException if {@code one} or {@code two} is null. | 142 | * @throws NullPointerException if {@code one} or {@code two} is null. |
108 | */ | 143 | */ |
109 | - public HostToHostIntent(ApplicationId appId, Key key, | 144 | + private HostToHostIntent(ApplicationId appId, Key key, |
110 | HostId one, HostId two, | 145 | HostId one, HostId two, |
111 | TrafficSelector selector, | 146 | TrafficSelector selector, |
112 | TrafficTreatment treatment, | 147 | TrafficTreatment treatment, |
... | @@ -121,14 +156,6 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -121,14 +156,6 @@ public final class HostToHostIntent extends ConnectivityIntent { |
121 | 156 | ||
122 | } | 157 | } |
123 | 158 | ||
124 | - private static HostId min(HostId one, HostId two) { | ||
125 | - return one.hashCode() < two.hashCode() ? one : two; | ||
126 | - } | ||
127 | - | ||
128 | - private static HostId max(HostId one, HostId two) { | ||
129 | - return one.hashCode() >= two.hashCode() ? one : two; | ||
130 | - } | ||
131 | - | ||
132 | /** | 159 | /** |
133 | * Returns identifier of the first host. | 160 | * Returns identifier of the first host. |
134 | * | 161 | * | ... | ... |
... | @@ -63,17 +63,6 @@ public abstract class Intent { | ... | @@ -63,17 +63,6 @@ public abstract class Intent { |
63 | * Creates a new intent. | 63 | * Creates a new intent. |
64 | * | 64 | * |
65 | * @param appId application identifier | 65 | * @param appId application identifier |
66 | - * @param resources required network resources (optional) | ||
67 | - */ | ||
68 | - protected Intent(ApplicationId appId, | ||
69 | - Collection<NetworkResource> resources) { | ||
70 | - this(appId, null, resources, DEFAULT_INTENT_PRIORITY); | ||
71 | - } | ||
72 | - | ||
73 | - /** | ||
74 | - * Creates a new intent. | ||
75 | - * | ||
76 | - * @param appId application identifier | ||
77 | * @param key optional key | 66 | * @param key optional key |
78 | * @param resources required network resources (optional) | 67 | * @param resources required network resources (optional) |
79 | * @param priority flow rule priority | 68 | * @param priority flow rule priority | ... | ... |
... | @@ -15,8 +15,8 @@ | ... | @@ -15,8 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | -import com.google.common.base.MoreObjects; | 18 | +import java.util.List; |
19 | -import com.google.common.collect.ImmutableSet; | 19 | +import java.util.Set; |
20 | 20 | ||
21 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
22 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
... | @@ -24,9 +24,8 @@ import org.onosproject.net.Link; | ... | @@ -24,9 +24,8 @@ import org.onosproject.net.Link; |
24 | import org.onosproject.net.flow.TrafficSelector; | 24 | import org.onosproject.net.flow.TrafficSelector; |
25 | import org.onosproject.net.flow.TrafficTreatment; | 25 | import org.onosproject.net.flow.TrafficTreatment; |
26 | 26 | ||
27 | -import java.util.Collections; | 27 | +import com.google.common.base.MoreObjects; |
28 | -import java.util.List; | 28 | +import com.google.common.collect.ImmutableSet; |
29 | -import java.util.Set; | ||
30 | 29 | ||
31 | /** | 30 | /** |
32 | * Abstraction of a connectivity intent that is implemented by a set of path | 31 | * Abstraction of a connectivity intent that is implemented by a set of path |
... | @@ -42,71 +41,21 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -42,71 +41,21 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
42 | /** | 41 | /** |
43 | * Creates a new actionable intent capable of funneling the selected | 42 | * Creates a new actionable intent capable of funneling the selected |
44 | * traffic along the specified convergent tree and out the given egress | 43 | * traffic along the specified convergent tree and out the given egress |
45 | - * point. | ||
46 | - * | ||
47 | - * @param appId application identifier | ||
48 | - * @param selector traffic match | ||
49 | - * @param treatment action | ||
50 | - * @param links traversed links | ||
51 | - * @param ingressPoint ingress point | ||
52 | - * @param egressPoint egress point | ||
53 | - * @throws NullPointerException {@code path} is null | ||
54 | - */ | ||
55 | - public LinkCollectionIntent(ApplicationId appId, | ||
56 | - TrafficSelector selector, | ||
57 | - TrafficTreatment treatment, | ||
58 | - Set<Link> links, | ||
59 | - ConnectPoint ingressPoint, | ||
60 | - ConnectPoint egressPoint) { | ||
61 | - this(appId, selector, treatment, links, ingressPoint, egressPoint, | ||
62 | - Collections.emptyList(), DEFAULT_INTENT_PRIORITY); | ||
63 | - } | ||
64 | - | ||
65 | - /** | ||
66 | - * Creates a new actionable intent capable of funneling the selected | ||
67 | - * traffic along the specified convergent tree and out the given egress | ||
68 | * point satisfying the specified constraints. | 44 | * point satisfying the specified constraints. |
69 | * | 45 | * |
70 | * @param appId application identifier | 46 | * @param appId application identifier |
47 | + * @param key key to use for the intent | ||
71 | * @param selector traffic match | 48 | * @param selector traffic match |
72 | * @param treatment action | 49 | * @param treatment action |
73 | * @param links traversed links | 50 | * @param links traversed links |
74 | - * @param ingressPoint ingress point | 51 | + * @param ingressPoints ingress points |
75 | - * @param egressPoint egress point | 52 | + * @param egressPoints egress points |
76 | * @param constraints optional list of constraints | 53 | * @param constraints optional list of constraints |
77 | * @param priority priority to use for the flows generated by this intent | 54 | * @param priority priority to use for the flows generated by this intent |
78 | * @throws NullPointerException {@code path} is null | 55 | * @throws NullPointerException {@code path} is null |
79 | */ | 56 | */ |
80 | - public LinkCollectionIntent(ApplicationId appId, | 57 | + private LinkCollectionIntent(ApplicationId appId, |
81 | - TrafficSelector selector, | 58 | + Key key, |
82 | - TrafficTreatment treatment, | ||
83 | - Set<Link> links, | ||
84 | - ConnectPoint ingressPoint, | ||
85 | - ConnectPoint egressPoint, | ||
86 | - List<Constraint> constraints, | ||
87 | - int priority) { | ||
88 | - super(appId, resources(links), selector, treatment, constraints, priority); | ||
89 | - this.links = links; | ||
90 | - this.ingressPoints = ImmutableSet.of(ingressPoint); | ||
91 | - this.egressPoints = ImmutableSet.of(egressPoint); | ||
92 | - } | ||
93 | - | ||
94 | - /** | ||
95 | - * Creates a new actionable intent capable of funneling the selected | ||
96 | - * traffic along the specified convergent tree and out the given egress | ||
97 | - * point. | ||
98 | - * | ||
99 | - * @param appId application identifier | ||
100 | - * @param selector traffic match | ||
101 | - * @param treatment action | ||
102 | - * @param links traversed links | ||
103 | - * @param ingressPoints Set of ingress points | ||
104 | - * @param egressPoints Set of egress points | ||
105 | - * @param constraints the constraints | ||
106 | - * @param priority priority to use for the flows generated by this intent | ||
107 | - * @throws NullPointerException {@code path} is null | ||
108 | - */ | ||
109 | - public LinkCollectionIntent(ApplicationId appId, | ||
110 | TrafficSelector selector, | 59 | TrafficSelector selector, |
111 | TrafficTreatment treatment, | 60 | TrafficTreatment treatment, |
112 | Set<Link> links, | 61 | Set<Link> links, |
... | @@ -114,11 +63,10 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -114,11 +63,10 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
114 | Set<ConnectPoint> egressPoints, | 63 | Set<ConnectPoint> egressPoints, |
115 | List<Constraint> constraints, | 64 | List<Constraint> constraints, |
116 | int priority) { | 65 | int priority) { |
117 | - super(appId, resources(links), selector, treatment, constraints, priority); | 66 | + super(appId, key, resources(links), selector, treatment, constraints, priority); |
118 | - | ||
119 | this.links = links; | 67 | this.links = links; |
120 | - this.ingressPoints = ImmutableSet.copyOf(ingressPoints); | 68 | + this.ingressPoints = ingressPoints; |
121 | - this.egressPoints = ImmutableSet.copyOf(egressPoints); | 69 | + this.egressPoints = egressPoints; |
122 | } | 70 | } |
123 | 71 | ||
124 | /** | 72 | /** |
... | @@ -132,6 +80,120 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -132,6 +80,120 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
132 | } | 80 | } |
133 | 81 | ||
134 | /** | 82 | /** |
83 | + * Returns a new link collection intent builder. The application id, | ||
84 | + * ingress point and egress points are required fields. If they are | ||
85 | + * not set by calls to the appropriate methods, an exception will | ||
86 | + * be thrown. | ||
87 | + * | ||
88 | + * @return single point to multi point builder | ||
89 | + */ | ||
90 | + public static Builder builder() { | ||
91 | + return new Builder(); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Builder of a single point to multi point intent. | ||
96 | + */ | ||
97 | + public static final class Builder extends ConnectivityIntent.Builder { | ||
98 | + Set<Link> links; | ||
99 | + Set<ConnectPoint> ingressPoints; | ||
100 | + Set<ConnectPoint> egressPoints; | ||
101 | + | ||
102 | + private Builder() { | ||
103 | + // Hide constructor | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public Builder appId(ApplicationId appId) { | ||
108 | + return (Builder) super.appId(appId); | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public Builder key(Key key) { | ||
113 | + return (Builder) super.key(key); | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public Builder selector(TrafficSelector selector) { | ||
118 | + return (Builder) super.selector(selector); | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public Builder treatment(TrafficTreatment treatment) { | ||
123 | + return (Builder) super.treatment(treatment); | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public Builder constraints(List<Constraint> constraints) { | ||
128 | + return (Builder) super.constraints(constraints); | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public Builder priority(int priority) { | ||
133 | + return (Builder) super.priority(priority); | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Sets the ingress point of the single point to multi point intent | ||
138 | + * that will be built. | ||
139 | + * | ||
140 | + * @param ingressPoints ingress connect points | ||
141 | + * @return this builder | ||
142 | + */ | ||
143 | + public Builder ingressPoints(Set<ConnectPoint> ingressPoints) { | ||
144 | + this.ingressPoints = ImmutableSet.copyOf(ingressPoints); | ||
145 | + return this; | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Sets the egress points of the single point to multi point intent | ||
150 | + * that will be built. | ||
151 | + * | ||
152 | + * @param egressPoints egress connect points | ||
153 | + * @return this builder | ||
154 | + */ | ||
155 | + public Builder egressPoints(Set<ConnectPoint> egressPoints) { | ||
156 | + this.egressPoints = ImmutableSet.copyOf(egressPoints); | ||
157 | + return this; | ||
158 | + } | ||
159 | + | ||
160 | + /** | ||
161 | + * Sets the links of the link collection intent | ||
162 | + * that will be built. | ||
163 | + * | ||
164 | + * @param links links for the intent | ||
165 | + * @return this builder | ||
166 | + */ | ||
167 | + public Builder links(Set<Link> links) { | ||
168 | + this.links = ImmutableSet.copyOf(links); | ||
169 | + return this; | ||
170 | + } | ||
171 | + | ||
172 | + | ||
173 | + /** | ||
174 | + * Builds a single point to multi point intent from the | ||
175 | + * accumulated parameters. | ||
176 | + * | ||
177 | + * @return point to point intent | ||
178 | + */ | ||
179 | + public LinkCollectionIntent build() { | ||
180 | + | ||
181 | + return new LinkCollectionIntent( | ||
182 | + appId, | ||
183 | + key, | ||
184 | + selector, | ||
185 | + treatment, | ||
186 | + links, | ||
187 | + ingressPoints, | ||
188 | + egressPoints, | ||
189 | + constraints, | ||
190 | + priority | ||
191 | + ); | ||
192 | + } | ||
193 | + } | ||
194 | + | ||
195 | + | ||
196 | + /** | ||
135 | * Returns the set of links that represent the network connections needed | 197 | * Returns the set of links that represent the network connections needed |
136 | * by this intent. | 198 | * by this intent. |
137 | * | 199 | * | ... | ... |
1 | package org.onosproject.net.intent; | 1 | package org.onosproject.net.intent; |
2 | 2 | ||
3 | -import static com.google.common.base.Preconditions.checkArgument; | ||
4 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
5 | - | ||
6 | import java.util.Collections; | 3 | import java.util.Collections; |
7 | import java.util.List; | 4 | import java.util.List; |
8 | import java.util.Optional; | 5 | import java.util.Optional; |
... | @@ -10,13 +7,13 @@ import java.util.Optional; | ... | @@ -10,13 +7,13 @@ import java.util.Optional; |
10 | import org.onlab.packet.MplsLabel; | 7 | import org.onlab.packet.MplsLabel; |
11 | import org.onosproject.core.ApplicationId; | 8 | import org.onosproject.core.ApplicationId; |
12 | import org.onosproject.net.ConnectPoint; | 9 | import org.onosproject.net.ConnectPoint; |
13 | -import org.onosproject.net.Link; | ||
14 | import org.onosproject.net.flow.TrafficSelector; | 10 | import org.onosproject.net.flow.TrafficSelector; |
15 | import org.onosproject.net.flow.TrafficTreatment; | 11 | import org.onosproject.net.flow.TrafficTreatment; |
16 | -import org.onosproject.net.intent.constraint.LinkTypeConstraint; | ||
17 | 12 | ||
18 | import com.google.common.base.MoreObjects; | 13 | import com.google.common.base.MoreObjects; |
19 | -import com.google.common.collect.ImmutableList; | 14 | + |
15 | +import static com.google.common.base.Preconditions.checkArgument; | ||
16 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
20 | 17 | ||
21 | 18 | ||
22 | /** | 19 | /** |
... | @@ -30,30 +27,6 @@ public final class MplsIntent extends ConnectivityIntent { | ... | @@ -30,30 +27,6 @@ public final class MplsIntent extends ConnectivityIntent { |
30 | private final Optional<MplsLabel> egressLabel; | 27 | private final Optional<MplsLabel> egressLabel; |
31 | 28 | ||
32 | /** | 29 | /** |
33 | - * Creates a new MPLS intent with the supplied ingress/egress | ||
34 | - * ports and labels and with built-in link type constraint to avoid optical links. | ||
35 | - * | ||
36 | - * @param appId application identifier | ||
37 | - * @param selector traffic selector | ||
38 | - * @param treatment treatment | ||
39 | - * @param ingressPoint ingress port | ||
40 | - * @param ingressLabel ingress MPLS label | ||
41 | - * @param egressPoint egress port | ||
42 | - * @param egressLabel egress MPLS label | ||
43 | - * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. | ||
44 | - */ | ||
45 | - public MplsIntent(ApplicationId appId, TrafficSelector selector, | ||
46 | - TrafficTreatment treatment, | ||
47 | - ConnectPoint ingressPoint, | ||
48 | - Optional<MplsLabel> ingressLabel, | ||
49 | - ConnectPoint egressPoint, | ||
50 | - Optional<MplsLabel> egressLabel) { | ||
51 | - this(appId, selector, treatment, ingressPoint, ingressLabel, egressPoint, egressLabel, | ||
52 | - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)), | ||
53 | - DEFAULT_INTENT_PRIORITY); | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | * Creates a new point-to-point intent with the supplied ingress/egress | 30 | * Creates a new point-to-point intent with the supplied ingress/egress |
58 | * ports, labels and constraints. | 31 | * ports, labels and constraints. |
59 | * | 32 | * |
... | @@ -68,31 +41,153 @@ public final class MplsIntent extends ConnectivityIntent { | ... | @@ -68,31 +41,153 @@ public final class MplsIntent extends ConnectivityIntent { |
68 | * @param priority priority to use for flows generated by this intent | 41 | * @param priority priority to use for flows generated by this intent |
69 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. | 42 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. |
70 | */ | 43 | */ |
71 | - public MplsIntent(ApplicationId appId, TrafficSelector selector, | 44 | + private MplsIntent(ApplicationId appId, |
72 | - TrafficTreatment treatment, | 45 | + Key key, |
73 | - ConnectPoint ingressPoint, | 46 | + TrafficSelector selector, |
74 | - Optional<MplsLabel> ingressLabel, | 47 | + TrafficTreatment treatment, |
75 | - ConnectPoint egressPoint, | 48 | + ConnectPoint ingressPoint, |
76 | - Optional<MplsLabel> egressLabel, | 49 | + Optional<MplsLabel> ingressLabel, |
77 | - List<Constraint> constraints, | 50 | + ConnectPoint egressPoint, |
78 | - int priority) { | 51 | + Optional<MplsLabel> egressLabel, |
79 | - | 52 | + List<Constraint> constraints, |
80 | - super(appId, Collections.emptyList(), selector, treatment, constraints, | 53 | + int priority) { |
54 | + | ||
55 | + super(appId, key, Collections.emptyList(), selector, treatment, constraints, | ||
81 | priority); | 56 | priority); |
82 | 57 | ||
83 | - checkNotNull(ingressPoint); | 58 | + this.ingressPoint = checkNotNull(ingressPoint); |
84 | - checkNotNull(egressPoint); | 59 | + this.ingressLabel = checkNotNull(ingressLabel); |
60 | + this.egressPoint = checkNotNull(egressPoint); | ||
61 | + this.egressLabel = checkNotNull(egressLabel); | ||
62 | + | ||
85 | checkArgument(!ingressPoint.equals(egressPoint), | 63 | checkArgument(!ingressPoint.equals(egressPoint), |
86 | - "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint); | 64 | + "ingress and egress should be different (ingress: %s, egress: %s)", |
87 | - checkNotNull(ingressLabel); | 65 | + ingressPoint, egressPoint); |
88 | - checkNotNull(egressLabel); | 66 | + } |
89 | - this.ingressPoint = ingressPoint; | ||
90 | - this.ingressLabel = ingressLabel; | ||
91 | - this.egressPoint = egressPoint; | ||
92 | - this.egressLabel = egressLabel; | ||
93 | 67 | ||
68 | + /** | ||
69 | + * Returns a new MPLS intent builder. The application id, | ||
70 | + * ingress point, egress point, ingress label and egress label are | ||
71 | + * required fields. If they are not set by calls to the appropriate | ||
72 | + * methods, an exception will be thrown. | ||
73 | + * | ||
74 | + * @return point to point builder | ||
75 | + */ | ||
76 | + public static Builder builder() { | ||
77 | + return new Builder(); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Builder of an MPLS intent. | ||
82 | + */ | ||
83 | + public static final class Builder extends ConnectivityIntent.Builder { | ||
84 | + ConnectPoint ingressPoint; | ||
85 | + ConnectPoint egressPoint; | ||
86 | + Optional<MplsLabel> ingressLabel; | ||
87 | + Optional<MplsLabel> egressLabel; | ||
88 | + | ||
89 | + private Builder() { | ||
90 | + // Hide constructor | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public Builder appId(ApplicationId appId) { | ||
95 | + return (Builder) super.appId(appId); | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public Builder key(Key key) { | ||
100 | + return (Builder) super.key(key); | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public Builder selector(TrafficSelector selector) { | ||
105 | + return (Builder) super.selector(selector); | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public Builder treatment(TrafficTreatment treatment) { | ||
110 | + return (Builder) super.treatment(treatment); | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public Builder constraints(List<Constraint> constraints) { | ||
115 | + return (Builder) super.constraints(constraints); | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public Builder priority(int priority) { | ||
120 | + return (Builder) super.priority(priority); | ||
121 | + } | ||
122 | + | ||
123 | + /** | ||
124 | + * Sets the ingress point of the point to point intent that will be built. | ||
125 | + * | ||
126 | + * @param ingressPoint ingress connect point | ||
127 | + * @return this builder | ||
128 | + */ | ||
129 | + public Builder ingressPoint(ConnectPoint ingressPoint) { | ||
130 | + this.ingressPoint = ingressPoint; | ||
131 | + return this; | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * Sets the egress point of the point to point intent that will be built. | ||
136 | + * | ||
137 | + * @param egressPoint egress connect point | ||
138 | + * @return this builder | ||
139 | + */ | ||
140 | + public Builder egressPoint(ConnectPoint egressPoint) { | ||
141 | + this.egressPoint = egressPoint; | ||
142 | + return this; | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * Sets the ingress label of the intent that will be built. | ||
147 | + * | ||
148 | + * @param ingressLabel ingress label | ||
149 | + * @return this builder | ||
150 | + */ | ||
151 | + public Builder ingressLabel(Optional<MplsLabel> ingressLabel) { | ||
152 | + this.ingressLabel = ingressLabel; | ||
153 | + return this; | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * Sets the ingress label of the intent that will be built. | ||
158 | + * | ||
159 | + * @param egressLabel ingress label | ||
160 | + * @return this builder | ||
161 | + */ | ||
162 | + public Builder egressLabel(Optional<MplsLabel> egressLabel) { | ||
163 | + this.egressLabel = egressLabel; | ||
164 | + return this; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * Builds a point to point intent from the accumulated parameters. | ||
169 | + * | ||
170 | + * @return point to point intent | ||
171 | + */ | ||
172 | + public MplsIntent build() { | ||
173 | + | ||
174 | + return new MplsIntent( | ||
175 | + appId, | ||
176 | + key, | ||
177 | + selector, | ||
178 | + treatment, | ||
179 | + ingressPoint, | ||
180 | + ingressLabel, | ||
181 | + egressPoint, | ||
182 | + egressLabel, | ||
183 | + constraints, | ||
184 | + priority | ||
185 | + ); | ||
186 | + } | ||
94 | } | 187 | } |
95 | 188 | ||
189 | + | ||
190 | + | ||
96 | /** | 191 | /** |
97 | * Constructor for serializer. | 192 | * Constructor for serializer. |
98 | */ | 193 | */ |
... | @@ -147,6 +242,7 @@ public final class MplsIntent extends ConnectivityIntent { | ... | @@ -147,6 +242,7 @@ public final class MplsIntent extends ConnectivityIntent { |
147 | return MoreObjects.toStringHelper(getClass()) | 242 | return MoreObjects.toStringHelper(getClass()) |
148 | .add("id", id()) | 243 | .add("id", id()) |
149 | .add("appId", appId()) | 244 | .add("appId", appId()) |
245 | + .add("key", key()) | ||
150 | .add("priority", priority()) | 246 | .add("priority", priority()) |
151 | .add("selector", selector()) | 247 | .add("selector", selector()) |
152 | .add("treatment", treatment()) | 248 | .add("treatment", treatment()) | ... | ... |
1 | package org.onosproject.net.intent; | 1 | package org.onosproject.net.intent; |
2 | 2 | ||
3 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
4 | - | ||
5 | -import java.util.Collections; | ||
6 | import java.util.List; | 3 | import java.util.List; |
7 | import java.util.Optional; | 4 | import java.util.Optional; |
8 | 5 | ||
9 | - | ||
10 | import org.onlab.packet.MplsLabel; | 6 | import org.onlab.packet.MplsLabel; |
11 | import org.onosproject.core.ApplicationId; | 7 | import org.onosproject.core.ApplicationId; |
12 | import org.onosproject.net.Path; | 8 | import org.onosproject.net.Path; |
13 | import org.onosproject.net.flow.TrafficSelector; | 9 | import org.onosproject.net.flow.TrafficSelector; |
14 | import org.onosproject.net.flow.TrafficTreatment; | 10 | import org.onosproject.net.flow.TrafficTreatment; |
15 | 11 | ||
12 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
13 | + | ||
16 | 14 | ||
17 | /** | 15 | /** |
18 | * Abstraction of explicit MPLS label-switched path. | 16 | * Abstraction of explicit MPLS label-switched path. |
... | @@ -33,43 +31,120 @@ public final class MplsPathIntent extends PathIntent { | ... | @@ -33,43 +31,120 @@ public final class MplsPathIntent extends PathIntent { |
33 | * @param path traversed links | 31 | * @param path traversed links |
34 | * @param ingressLabel MPLS egress label | 32 | * @param ingressLabel MPLS egress label |
35 | * @param egressLabel MPLS ingress label | 33 | * @param egressLabel MPLS ingress label |
36 | - * @throws NullPointerException {@code path} is null | ||
37 | - */ | ||
38 | - public MplsPathIntent(ApplicationId appId, TrafficSelector selector, | ||
39 | - TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, | ||
40 | - Optional<MplsLabel> egressLabel) { | ||
41 | - this(appId, selector, treatment, path, ingressLabel, egressLabel, | ||
42 | - Collections.emptyList(), DEFAULT_INTENT_PRIORITY); | ||
43 | - | ||
44 | - } | ||
45 | - | ||
46 | - /** | ||
47 | - * Creates a new point-to-point intent with the supplied ingress/egress | ||
48 | - * ports and using the specified explicit path. | ||
49 | - * | ||
50 | - * @param appId application identifier | ||
51 | - * @param selector traffic selector | ||
52 | - * @param treatment treatment | ||
53 | - * @param path traversed links | ||
54 | - * @param ingressLabel MPLS egress label | ||
55 | - * @param egressLabel MPLS ingress label | ||
56 | * @param constraints optional list of constraints | 34 | * @param constraints optional list of constraints |
57 | * @param priority priority to use for flows generated by this intent | 35 | * @param priority priority to use for flows generated by this intent |
58 | * @throws NullPointerException {@code path} is null | 36 | * @throws NullPointerException {@code path} is null |
59 | */ | 37 | */ |
60 | - public MplsPathIntent(ApplicationId appId, TrafficSelector selector, | 38 | + private MplsPathIntent(ApplicationId appId, TrafficSelector selector, |
61 | TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, | 39 | TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, |
62 | Optional<MplsLabel> egressLabel, List<Constraint> constraints, | 40 | Optional<MplsLabel> egressLabel, List<Constraint> constraints, |
63 | int priority) { | 41 | int priority) { |
64 | super(appId, selector, treatment, path, constraints, | 42 | super(appId, selector, treatment, path, constraints, |
65 | priority); | 43 | priority); |
66 | 44 | ||
67 | - checkNotNull(ingressLabel); | 45 | + this.ingressLabel = checkNotNull(ingressLabel); |
68 | - checkNotNull(egressLabel); | 46 | + this.egressLabel = checkNotNull(egressLabel); |
69 | - this.ingressLabel = ingressLabel; | 47 | + } |
70 | - this.egressLabel = egressLabel; | 48 | + |
49 | + /** | ||
50 | + * Returns a new host to host intent builder. | ||
51 | + * | ||
52 | + * @return host to host intent builder | ||
53 | + */ | ||
54 | + public static Builder builder() { | ||
55 | + return new Builder(); | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Builder of a host to host intent. | ||
60 | + */ | ||
61 | + public static final class Builder extends PathIntent.Builder { | ||
62 | + private Optional<MplsLabel> ingressLabel = Optional.empty(); | ||
63 | + private Optional<MplsLabel> egressLabel = Optional.empty(); | ||
64 | + | ||
65 | + private Builder() { | ||
66 | + // Hide constructor | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public Builder appId(ApplicationId appId) { | ||
71 | + return (Builder) super.appId(appId); | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public Builder key(Key key) { | ||
76 | + return (Builder) super.key(key); | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public Builder selector(TrafficSelector selector) { | ||
81 | + return (Builder) super.selector(selector); | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public Builder treatment(TrafficTreatment treatment) { | ||
86 | + return (Builder) super.treatment(treatment); | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public Builder constraints(List<Constraint> constraints) { | ||
91 | + return (Builder) super.constraints(constraints); | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public Builder priority(int priority) { | ||
96 | + return (Builder) super.priority(priority); | ||
97 | + } | ||
98 | + | ||
99 | + @Override | ||
100 | + public Builder path(Path path) { | ||
101 | + return (Builder) super.path(path); | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * Sets the ingress label of the intent that will be built. | ||
106 | + * | ||
107 | + * @param ingressLabel ingress label | ||
108 | + * @return this builder | ||
109 | + */ | ||
110 | + public Builder ingressLabel(Optional<MplsLabel> ingressLabel) { | ||
111 | + this.ingressLabel = ingressLabel; | ||
112 | + return this; | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * Sets the ingress label of the intent that will be built. | ||
117 | + * | ||
118 | + * @param egressLabel ingress label | ||
119 | + * @return this builder | ||
120 | + */ | ||
121 | + public Builder egressLabel(Optional<MplsLabel> egressLabel) { | ||
122 | + this.egressLabel = egressLabel; | ||
123 | + return this; | ||
124 | + } | ||
125 | + | ||
126 | + | ||
127 | + /** | ||
128 | + * Builds a host to host intent from the accumulated parameters. | ||
129 | + * | ||
130 | + * @return point to point intent | ||
131 | + */ | ||
132 | + public MplsPathIntent build() { | ||
133 | + | ||
134 | + return new MplsPathIntent( | ||
135 | + appId, | ||
136 | + selector, | ||
137 | + treatment, | ||
138 | + path, | ||
139 | + ingressLabel, | ||
140 | + egressLabel, | ||
141 | + constraints, | ||
142 | + priority | ||
143 | + ); | ||
144 | + } | ||
71 | } | 145 | } |
72 | 146 | ||
147 | + | ||
73 | /** | 148 | /** |
74 | * Returns the MPLS label which the ingress traffic should tagged. | 149 | * Returns the MPLS label which the ingress traffic should tagged. |
75 | * | 150 | * | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | +import com.google.common.collect.ImmutableSet; | ||
19 | import com.google.common.collect.Sets; | 20 | import com.google.common.collect.Sets; |
20 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
21 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
... | @@ -42,29 +43,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -42,29 +43,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
42 | * traffic selector and treatment. | 43 | * traffic selector and treatment. |
43 | * | 44 | * |
44 | * @param appId application identifier | 45 | * @param appId application identifier |
45 | - * @param selector traffic selector | ||
46 | - * @param treatment treatment | ||
47 | - * @param ingressPoints set of ports from which ingress traffic originates | ||
48 | - * @param egressPoint port to which traffic will egress | ||
49 | - * @throws NullPointerException if {@code ingressPoints} or | ||
50 | - * {@code egressPoint} is null. | ||
51 | - * @throws IllegalArgumentException if the size of {@code ingressPoints} is | ||
52 | - * not more than 1 | ||
53 | - */ | ||
54 | - public MultiPointToSinglePointIntent(ApplicationId appId, | ||
55 | - TrafficSelector selector, | ||
56 | - TrafficTreatment treatment, | ||
57 | - Set<ConnectPoint> ingressPoints, | ||
58 | - ConnectPoint egressPoint) { | ||
59 | - this(appId, selector, treatment, ingressPoints, egressPoint, | ||
60 | - Collections.emptyList(), DEFAULT_INTENT_PRIORITY); | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * Creates a new multi-to-single point connectivity intent for the specified | ||
65 | - * traffic selector and treatment. | ||
66 | - * | ||
67 | - * @param appId application identifier | ||
68 | * @param key intent key | 46 | * @param key intent key |
69 | * @param selector traffic selector | 47 | * @param selector traffic selector |
70 | * @param treatment treatment | 48 | * @param treatment treatment |
... | @@ -77,7 +55,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -77,7 +55,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
77 | * @throws IllegalArgumentException if the size of {@code ingressPoints} is | 55 | * @throws IllegalArgumentException if the size of {@code ingressPoints} is |
78 | * not more than 1 | 56 | * not more than 1 |
79 | */ | 57 | */ |
80 | - public MultiPointToSinglePointIntent(ApplicationId appId, | 58 | + private MultiPointToSinglePointIntent(ApplicationId appId, |
81 | Key key, | 59 | Key key, |
82 | TrafficSelector selector, | 60 | TrafficSelector selector, |
83 | TrafficTreatment treatment, | 61 | TrafficTreatment treatment, |
... | @@ -99,33 +77,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -99,33 +77,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
99 | } | 77 | } |
100 | 78 | ||
101 | /** | 79 | /** |
102 | - * Creates a new multi-to-single point connectivity intent for the specified | ||
103 | - * traffic selector and treatment. | ||
104 | - * | ||
105 | - * @param appId application identifier | ||
106 | - * @param selector traffic selector | ||
107 | - * @param treatment treatment | ||
108 | - * @param ingressPoints set of ports from which ingress traffic originates | ||
109 | - * @param egressPoint port to which traffic will egress | ||
110 | - * @param constraints constraints to apply to the intent | ||
111 | - * @param priority priority to use for flows generated by this intent | ||
112 | - * @throws NullPointerException if {@code ingressPoints} or | ||
113 | - * {@code egressPoint} is null. | ||
114 | - * @throws IllegalArgumentException if the size of {@code ingressPoints} is | ||
115 | - * not more than 1 | ||
116 | - */ | ||
117 | - public MultiPointToSinglePointIntent(ApplicationId appId, | ||
118 | - TrafficSelector selector, | ||
119 | - TrafficTreatment treatment, | ||
120 | - Set<ConnectPoint> ingressPoints, | ||
121 | - ConnectPoint egressPoint, | ||
122 | - List<Constraint> constraints, | ||
123 | - int priority) { | ||
124 | - this(appId, null, selector, treatment, ingressPoints, egressPoint, | ||
125 | - constraints, priority); | ||
126 | - } | ||
127 | - | ||
128 | - /** | ||
129 | * Constructor for serializer. | 80 | * Constructor for serializer. |
130 | */ | 81 | */ |
131 | protected MultiPointToSinglePointIntent() { | 82 | protected MultiPointToSinglePointIntent() { |
... | @@ -135,6 +86,105 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -135,6 +86,105 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
135 | } | 86 | } |
136 | 87 | ||
137 | /** | 88 | /** |
89 | + * Returns a new multi point to single point intent builder. The application id, | ||
90 | + * ingress points and egress point are required fields. If they are | ||
91 | + * not set by calls to the appropriate methods, an exception will | ||
92 | + * be thrown. | ||
93 | + * | ||
94 | + * @return single point to multi point builder | ||
95 | + */ | ||
96 | + public static Builder builder() { | ||
97 | + return new Builder(); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Builder of a multi point to single point intent. | ||
102 | + */ | ||
103 | + public static final class Builder extends ConnectivityIntent.Builder { | ||
104 | + Set<ConnectPoint> ingressPoints; | ||
105 | + ConnectPoint egressPoint; | ||
106 | + | ||
107 | + private Builder() { | ||
108 | + // Hide constructor | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public Builder appId(ApplicationId appId) { | ||
113 | + return (Builder) super.appId(appId); | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public Builder key(Key key) { | ||
118 | + return (Builder) super.key(key); | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public Builder selector(TrafficSelector selector) { | ||
123 | + return (Builder) super.selector(selector); | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public Builder treatment(TrafficTreatment treatment) { | ||
128 | + return (Builder) super.treatment(treatment); | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public Builder constraints(List<Constraint> constraints) { | ||
133 | + return (Builder) super.constraints(constraints); | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public Builder priority(int priority) { | ||
138 | + return (Builder) super.priority(priority); | ||
139 | + } | ||
140 | + | ||
141 | + /** | ||
142 | + * Sets the ingress point of the single point to multi point intent | ||
143 | + * that will be built. | ||
144 | + * | ||
145 | + * @param ingressPoints ingress connect points | ||
146 | + * @return this builder | ||
147 | + */ | ||
148 | + public Builder ingressPoints(Set<ConnectPoint> ingressPoints) { | ||
149 | + this.ingressPoints = ImmutableSet.copyOf(ingressPoints); | ||
150 | + return this; | ||
151 | + } | ||
152 | + | ||
153 | + /** | ||
154 | + * Sets the egress point of the multi point to single point intent | ||
155 | + * that will be built. | ||
156 | + * | ||
157 | + * @param egressPoint egress connect point | ||
158 | + * @return this builder | ||
159 | + */ | ||
160 | + public Builder egressPoint(ConnectPoint egressPoint) { | ||
161 | + this.egressPoint = egressPoint; | ||
162 | + return this; | ||
163 | + } | ||
164 | + | ||
165 | + /** | ||
166 | + * Builds a multi point to single point intent from the | ||
167 | + * accumulated parameters. | ||
168 | + * | ||
169 | + * @return point to point intent | ||
170 | + */ | ||
171 | + public MultiPointToSinglePointIntent build() { | ||
172 | + | ||
173 | + return new MultiPointToSinglePointIntent( | ||
174 | + appId, | ||
175 | + key, | ||
176 | + selector, | ||
177 | + treatment, | ||
178 | + ingressPoints, | ||
179 | + egressPoint, | ||
180 | + constraints, | ||
181 | + priority | ||
182 | + ); | ||
183 | + } | ||
184 | + } | ||
185 | + | ||
186 | + | ||
187 | + /** | ||
138 | * Returns the set of ports on which ingress traffic should be connected to | 188 | * Returns the set of ports on which ingress traffic should be connected to |
139 | * the egress port. | 189 | * the egress port. |
140 | * | 190 | * | ... | ... |
... | @@ -24,6 +24,8 @@ import org.onosproject.net.Path; | ... | @@ -24,6 +24,8 @@ import org.onosproject.net.Path; |
24 | 24 | ||
25 | import java.util.Collection; | 25 | import java.util.Collection; |
26 | 26 | ||
27 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
28 | + | ||
27 | public final class OpticalPathIntent extends Intent { | 29 | public final class OpticalPathIntent extends Intent { |
28 | 30 | ||
29 | private final ConnectPoint src; | 31 | private final ConnectPoint src; |
... | @@ -35,10 +37,11 @@ public final class OpticalPathIntent extends Intent { | ... | @@ -35,10 +37,11 @@ public final class OpticalPathIntent extends Intent { |
35 | ConnectPoint src, | 37 | ConnectPoint src, |
36 | ConnectPoint dst, | 38 | ConnectPoint dst, |
37 | Path path) { | 39 | Path path) { |
38 | - super(appId, ImmutableSet.copyOf(path.links())); | 40 | + super(appId, null, ImmutableSet.copyOf(path.links()), |
39 | - this.src = src; | 41 | + Intent.DEFAULT_INTENT_PRIORITY); |
40 | - this.dst = dst; | 42 | + this.src = checkNotNull(src); |
41 | - this.path = path; | 43 | + this.dst = checkNotNull(dst); |
44 | + this.path = checkNotNull(path); | ||
42 | } | 45 | } |
43 | 46 | ||
44 | protected OpticalPathIntent() { | 47 | protected OpticalPathIntent() { |
... | @@ -69,6 +72,7 @@ public final class OpticalPathIntent extends Intent { | ... | @@ -69,6 +72,7 @@ public final class OpticalPathIntent extends Intent { |
69 | return MoreObjects.toStringHelper(getClass()) | 72 | return MoreObjects.toStringHelper(getClass()) |
70 | .add("id", id()) | 73 | .add("id", id()) |
71 | .add("appId", appId()) | 74 | .add("appId", appId()) |
75 | + .add("key", key()) | ||
72 | .add("resources", resources()) | 76 | .add("resources", resources()) |
73 | .add("ingressPort", src) | 77 | .add("ingressPort", src) |
74 | .add("egressPort", dst) | 78 | .add("egressPort", dst) | ... | ... |
... | @@ -15,17 +15,17 @@ | ... | @@ -15,17 +15,17 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | -import com.google.common.base.MoreObjects; | 18 | +import java.util.List; |
19 | -import com.google.common.base.Predicate; | 19 | + |
20 | -import com.google.common.collect.Iterables; | ||
21 | import org.onosproject.core.ApplicationId; | 20 | import org.onosproject.core.ApplicationId; |
22 | import org.onosproject.net.Link; | 21 | import org.onosproject.net.Link; |
23 | import org.onosproject.net.Path; | 22 | import org.onosproject.net.Path; |
24 | import org.onosproject.net.flow.TrafficSelector; | 23 | import org.onosproject.net.flow.TrafficSelector; |
25 | import org.onosproject.net.flow.TrafficTreatment; | 24 | import org.onosproject.net.flow.TrafficTreatment; |
26 | 25 | ||
27 | -import java.util.Collections; | 26 | +import com.google.common.base.MoreObjects; |
28 | -import java.util.List; | 27 | +import com.google.common.base.Predicate; |
28 | +import com.google.common.collect.Iterables; | ||
29 | 29 | ||
30 | import static com.google.common.base.Preconditions.checkArgument; | 30 | import static com.google.common.base.Preconditions.checkArgument; |
31 | 31 | ||
... | @@ -44,30 +44,17 @@ public class PathIntent extends ConnectivityIntent { | ... | @@ -44,30 +44,17 @@ public class PathIntent extends ConnectivityIntent { |
44 | * @param selector traffic selector | 44 | * @param selector traffic selector |
45 | * @param treatment treatment | 45 | * @param treatment treatment |
46 | * @param path traversed links | 46 | * @param path traversed links |
47 | - * @throws NullPointerException {@code path} is null | ||
48 | - */ | ||
49 | - public PathIntent(ApplicationId appId, TrafficSelector selector, | ||
50 | - TrafficTreatment treatment, Path path) { | ||
51 | - this(appId, selector, treatment, path, Collections.emptyList(), | ||
52 | - DEFAULT_INTENT_PRIORITY); | ||
53 | - } | ||
54 | - | ||
55 | - /** | ||
56 | - * Creates a new point-to-point intent with the supplied ingress/egress | ||
57 | - * ports and using the specified explicit path. | ||
58 | - * | ||
59 | - * @param appId application identifier | ||
60 | - * @param selector traffic selector | ||
61 | - * @param treatment treatment | ||
62 | - * @param path traversed links | ||
63 | * @param constraints optional list of constraints | 47 | * @param constraints optional list of constraints |
64 | * @param priority priority to use for the generated flows | 48 | * @param priority priority to use for the generated flows |
65 | * @throws NullPointerException {@code path} is null | 49 | * @throws NullPointerException {@code path} is null |
66 | */ | 50 | */ |
67 | - public PathIntent(ApplicationId appId, TrafficSelector selector, | 51 | + protected PathIntent(ApplicationId appId, |
68 | - TrafficTreatment treatment, Path path, List<Constraint> constraints, | 52 | + TrafficSelector selector, |
69 | - int priority) { | 53 | + TrafficTreatment treatment, |
70 | - super(appId, resources(path.links()), selector, treatment, constraints, | 54 | + Path path, |
55 | + List<Constraint> constraints, | ||
56 | + int priority) { | ||
57 | + super(appId, null, resources(path.links()), selector, treatment, constraints, | ||
71 | priority); | 58 | priority); |
72 | PathIntent.validate(path.links()); | 59 | PathIntent.validate(path.links()); |
73 | this.path = path; | 60 | this.path = path; |
... | @@ -81,6 +68,86 @@ public class PathIntent extends ConnectivityIntent { | ... | @@ -81,6 +68,86 @@ public class PathIntent extends ConnectivityIntent { |
81 | this.path = null; | 68 | this.path = null; |
82 | } | 69 | } |
83 | 70 | ||
71 | + /** | ||
72 | + * Returns a new host to host intent builder. | ||
73 | + * | ||
74 | + * @return host to host intent builder | ||
75 | + */ | ||
76 | + public static Builder builder() { | ||
77 | + return new Builder(); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Builder of a host to host intent. | ||
82 | + */ | ||
83 | + public static class Builder extends ConnectivityIntent.Builder { | ||
84 | + Path path; | ||
85 | + | ||
86 | + protected Builder() { | ||
87 | + // Hide default constructor | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public Builder appId(ApplicationId appId) { | ||
92 | + return (Builder) super.appId(appId); | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public Builder key(Key key) { | ||
97 | + return (Builder) super.key(key); | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public Builder selector(TrafficSelector selector) { | ||
102 | + return (Builder) super.selector(selector); | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + public Builder treatment(TrafficTreatment treatment) { | ||
107 | + return (Builder) super.treatment(treatment); | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public Builder constraints(List<Constraint> constraints) { | ||
112 | + return (Builder) super.constraints(constraints); | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public Builder priority(int priority) { | ||
117 | + return (Builder) super.priority(priority); | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * Sets the path of the intent that will be built. | ||
122 | + * | ||
123 | + * @param path path for the intent | ||
124 | + * @return this builder | ||
125 | + */ | ||
126 | + public Builder path(Path path) { | ||
127 | + this.path = path; | ||
128 | + return this; | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Builds a path intent from the accumulated parameters. | ||
133 | + * | ||
134 | + * @return point to point intent | ||
135 | + */ | ||
136 | + public PathIntent build() { | ||
137 | + | ||
138 | + return new PathIntent( | ||
139 | + appId, | ||
140 | + selector, | ||
141 | + treatment, | ||
142 | + path, | ||
143 | + constraints, | ||
144 | + priority | ||
145 | + ); | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + | ||
150 | + | ||
84 | // NOTE: This methods takes linear time with the number of links. | 151 | // NOTE: This methods takes linear time with the number of links. |
85 | /** | 152 | /** |
86 | * Validates that source element ID and destination element ID of a link are | 153 | * Validates that source element ID and destination element ID of a link are | ... | ... |
... | @@ -159,13 +159,11 @@ public final class PointToPointIntent extends ConnectivityIntent { | ... | @@ -159,13 +159,11 @@ public final class PointToPointIntent extends ConnectivityIntent { |
159 | super(appId, key, Collections.emptyList(), selector, treatment, constraints, | 159 | super(appId, key, Collections.emptyList(), selector, treatment, constraints, |
160 | priority); | 160 | priority); |
161 | 161 | ||
162 | - checkNotNull(ingressPoint); | ||
163 | - checkNotNull(egressPoint); | ||
164 | checkArgument(!ingressPoint.equals(egressPoint), | 162 | checkArgument(!ingressPoint.equals(egressPoint), |
165 | "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint); | 163 | "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint); |
166 | 164 | ||
167 | - this.ingressPoint = ingressPoint; | 165 | + this.ingressPoint = checkNotNull(ingressPoint); |
168 | - this.egressPoint = egressPoint; | 166 | + this.egressPoint = checkNotNull(egressPoint); |
169 | } | 167 | } |
170 | 168 | ||
171 | /** | 169 | /** | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | -import com.google.common.collect.Sets; | 19 | +import com.google.common.collect.ImmutableSet; |
20 | 20 | ||
21 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
22 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
... | @@ -42,27 +42,6 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { | ... | @@ -42,27 +42,6 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { |
42 | * Creates a new single-to-multi point connectivity intent. | 42 | * Creates a new single-to-multi point connectivity intent. |
43 | * | 43 | * |
44 | * @param appId application identifier | 44 | * @param appId application identifier |
45 | - * @param selector traffic selector | ||
46 | - * @param treatment treatment | ||
47 | - * @param ingressPoint port on which traffic will ingress | ||
48 | - * @param egressPoints set of ports on which traffic will egress | ||
49 | - * @throws NullPointerException if {@code ingressPoint} or | ||
50 | - * {@code egressPoints} is null | ||
51 | - * @throws IllegalArgumentException if the size of {@code egressPoints} is | ||
52 | - * not more than 1 | ||
53 | - */ | ||
54 | - public SinglePointToMultiPointIntent(ApplicationId appId, | ||
55 | - TrafficSelector selector, TrafficTreatment treatment, | ||
56 | - ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints) { | ||
57 | - this(appId, null, selector, treatment, ingressPoint, egressPoints, | ||
58 | - Collections.emptyList(), | ||
59 | - DEFAULT_INTENT_PRIORITY); | ||
60 | - } | ||
61 | - | ||
62 | - /** | ||
63 | - * Creates a new single-to-multi point connectivity intent. | ||
64 | - * | ||
65 | - * @param appId application identifier | ||
66 | * @param key intent key | 45 | * @param key intent key |
67 | * @param selector traffic selector | 46 | * @param selector traffic selector |
68 | * @param treatment treatment | 47 | * @param treatment treatment |
... | @@ -75,7 +54,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { | ... | @@ -75,7 +54,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { |
75 | * @throws IllegalArgumentException if the size of {@code egressPoints} is | 54 | * @throws IllegalArgumentException if the size of {@code egressPoints} is |
76 | * not more than 1 | 55 | * not more than 1 |
77 | */ | 56 | */ |
78 | - public SinglePointToMultiPointIntent(ApplicationId appId, | 57 | + private SinglePointToMultiPointIntent(ApplicationId appId, |
79 | Key key, | 58 | Key key, |
80 | TrafficSelector selector, TrafficTreatment treatment, | 59 | TrafficSelector selector, TrafficTreatment treatment, |
81 | ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints, | 60 | ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints, |
... | @@ -90,7 +69,105 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { | ... | @@ -90,7 +69,105 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { |
90 | "Set of egresses should not contain ingress (ingress: %s)", ingressPoint); | 69 | "Set of egresses should not contain ingress (ingress: %s)", ingressPoint); |
91 | 70 | ||
92 | this.ingressPoint = checkNotNull(ingressPoint); | 71 | this.ingressPoint = checkNotNull(ingressPoint); |
93 | - this.egressPoints = Sets.newHashSet(egressPoints); | 72 | + this.egressPoints = egressPoints; |
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Returns a new single point to multi point intent builder. The application id, | ||
77 | + * ingress point and egress points are required fields. If they are | ||
78 | + * not set by calls to the appropriate methods, an exception will | ||
79 | + * be thrown. | ||
80 | + * | ||
81 | + * @return single point to multi point builder | ||
82 | + */ | ||
83 | + public static Builder builder() { | ||
84 | + return new Builder(); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * Builder of a single point to multi point intent. | ||
89 | + */ | ||
90 | + public static final class Builder extends ConnectivityIntent.Builder { | ||
91 | + ConnectPoint ingressPoint; | ||
92 | + Set<ConnectPoint> egressPoints; | ||
93 | + | ||
94 | + private Builder() { | ||
95 | + // Hide constructor | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public Builder appId(ApplicationId appId) { | ||
100 | + return (Builder) super.appId(appId); | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public Builder key(Key key) { | ||
105 | + return (Builder) super.key(key); | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public Builder selector(TrafficSelector selector) { | ||
110 | + return (Builder) super.selector(selector); | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public Builder treatment(TrafficTreatment treatment) { | ||
115 | + return (Builder) super.treatment(treatment); | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public Builder constraints(List<Constraint> constraints) { | ||
120 | + return (Builder) super.constraints(constraints); | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public Builder priority(int priority) { | ||
125 | + return (Builder) super.priority(priority); | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Sets the ingress point of the single point to multi point intent | ||
130 | + * that will be built. | ||
131 | + * | ||
132 | + * @param ingressPoint ingress connect point | ||
133 | + * @return this builder | ||
134 | + */ | ||
135 | + public Builder ingressPoint(ConnectPoint ingressPoint) { | ||
136 | + this.ingressPoint = ingressPoint; | ||
137 | + return this; | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * Sets the egress points of the single point to multi point intent | ||
142 | + * that will be built. | ||
143 | + * | ||
144 | + * @param egressPoints egress connect points | ||
145 | + * @return this builder | ||
146 | + */ | ||
147 | + public Builder egressPoints(Set<ConnectPoint> egressPoints) { | ||
148 | + this.egressPoints = ImmutableSet.copyOf(egressPoints); | ||
149 | + return this; | ||
150 | + } | ||
151 | + | ||
152 | + /** | ||
153 | + * Builds a single point to multi point intent from the | ||
154 | + * accumulated parameters. | ||
155 | + * | ||
156 | + * @return point to point intent | ||
157 | + */ | ||
158 | + public SinglePointToMultiPointIntent build() { | ||
159 | + | ||
160 | + return new SinglePointToMultiPointIntent( | ||
161 | + appId, | ||
162 | + key, | ||
163 | + selector, | ||
164 | + treatment, | ||
165 | + ingressPoint, | ||
166 | + egressPoints, | ||
167 | + constraints, | ||
168 | + priority | ||
169 | + ); | ||
170 | + } | ||
94 | } | 171 | } |
95 | 172 | ||
96 | /** | 173 | /** | ... | ... |
... | @@ -15,20 +15,15 @@ | ... | @@ -15,20 +15,15 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | -import com.google.common.base.MoreObjects; | 18 | +import java.util.Collections; |
19 | -import com.google.common.collect.ImmutableList; | 19 | +import java.util.List; |
20 | + | ||
20 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
21 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
22 | -import org.onosproject.net.HostId; | ||
23 | -import org.onosproject.net.Link; | ||
24 | -import org.onosproject.net.flow.DefaultTrafficSelector; | ||
25 | -import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
26 | import org.onosproject.net.flow.TrafficSelector; | 23 | import org.onosproject.net.flow.TrafficSelector; |
27 | import org.onosproject.net.flow.TrafficTreatment; | 24 | import org.onosproject.net.flow.TrafficTreatment; |
28 | -import org.onosproject.net.intent.constraint.LinkTypeConstraint; | ||
29 | 25 | ||
30 | -import java.util.Collections; | 26 | +import com.google.common.base.MoreObjects; |
31 | -import java.util.List; | ||
32 | 27 | ||
33 | import static com.google.common.base.Preconditions.checkNotNull; | 28 | import static com.google.common.base.Preconditions.checkNotNull; |
34 | 29 | ||
... | @@ -40,45 +35,12 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { | ... | @@ -40,45 +35,12 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { |
40 | private final ConnectPoint one; | 35 | private final ConnectPoint one; |
41 | private final ConnectPoint two; | 36 | private final ConnectPoint two; |
42 | 37 | ||
43 | - /** | ||
44 | - * Creates a new two way host-to-host intent with the supplied host pair and no | ||
45 | - * other traffic selection or treatment criteria. | ||
46 | - * | ||
47 | - * @param appId application identifier | ||
48 | - * @param one first host | ||
49 | - * @param two second host | ||
50 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
51 | - */ | ||
52 | - public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two) { | ||
53 | - this(appId, one, two, | ||
54 | - DefaultTrafficSelector.emptySelector(), | ||
55 | - DefaultTrafficTreatment.emptyTreatment(), | ||
56 | - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)), | ||
57 | - DEFAULT_INTENT_PRIORITY); | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * Creates a new host-to-host intent with the supplied host pair. | ||
62 | - * | ||
63 | - * @param appId application identifier | ||
64 | - * @param one first host | ||
65 | - * @param two second host | ||
66 | - * @param selector action | ||
67 | - * @param treatment ingress port | ||
68 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
69 | - */ | ||
70 | - public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two, | ||
71 | - TrafficSelector selector, | ||
72 | - TrafficTreatment treatment) { | ||
73 | - this(appId, one, two, selector, treatment, | ||
74 | - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)), | ||
75 | - DEFAULT_INTENT_PRIORITY); | ||
76 | - } | ||
77 | 38 | ||
78 | /** | 39 | /** |
79 | * Creates a new host-to-host intent with the supplied host pair. | 40 | * Creates a new host-to-host intent with the supplied host pair. |
80 | * | 41 | * |
81 | * @param appId application identifier | 42 | * @param appId application identifier |
43 | + * @param key intent key | ||
82 | * @param one first host | 44 | * @param one first host |
83 | * @param two second host | 45 | * @param two second host |
84 | * @param selector action | 46 | * @param selector action |
... | @@ -87,27 +49,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { | ... | @@ -87,27 +49,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { |
87 | * @param priority priority to use for flows generated by this intent | 49 | * @param priority priority to use for flows generated by this intent |
88 | * @throws NullPointerException if {@code one} or {@code two} is null. | 50 | * @throws NullPointerException if {@code one} or {@code two} is null. |
89 | */ | 51 | */ |
90 | - public TwoWayP2PIntent(ApplicationId appId, ConnectPoint one, ConnectPoint two, | 52 | + private TwoWayP2PIntent(ApplicationId appId, Key key, |
91 | - TrafficSelector selector, | ||
92 | - TrafficTreatment treatment, | ||
93 | - List<Constraint> constraints, | ||
94 | - int priority) { | ||
95 | - this(appId, null, one, two, selector, treatment, constraints, priority); | ||
96 | - } | ||
97 | - /** | ||
98 | - * Creates a new host-to-host intent with the supplied host pair. | ||
99 | - * | ||
100 | - * @param appId application identifier | ||
101 | - * @param key intent key | ||
102 | - * @param one first host | ||
103 | - * @param two second host | ||
104 | - * @param selector action | ||
105 | - * @param treatment ingress port | ||
106 | - * @param constraints optional prioritized list of path selection constraints | ||
107 | - * @param priority priority to use for flows generated by this intent | ||
108 | - * @throws NullPointerException if {@code one} or {@code two} is null. | ||
109 | - */ | ||
110 | - public TwoWayP2PIntent(ApplicationId appId, Key key, | ||
111 | ConnectPoint one, ConnectPoint two, | 53 | ConnectPoint one, ConnectPoint two, |
112 | TrafficSelector selector, | 54 | TrafficSelector selector, |
113 | TrafficTreatment treatment, | 55 | TrafficTreatment treatment, |
... | @@ -122,12 +64,96 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { | ... | @@ -122,12 +64,96 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { |
122 | 64 | ||
123 | } | 65 | } |
124 | 66 | ||
125 | - private static HostId min(HostId one, HostId two) { | 67 | + /** |
126 | - return one.hashCode() < two.hashCode() ? one : two; | 68 | + * Returns a new two way intent builder. |
69 | + * | ||
70 | + * @return two way intent builder | ||
71 | + */ | ||
72 | + public static Builder builder() { | ||
73 | + return new Builder(); | ||
127 | } | 74 | } |
128 | 75 | ||
129 | - private static HostId max(HostId one, HostId two) { | 76 | + /** |
130 | - return one.hashCode() >= two.hashCode() ? one : two; | 77 | + * Builder of a point to point intent. |
78 | + */ | ||
79 | + public static final class Builder extends ConnectivityIntent.Builder { | ||
80 | + ConnectPoint one; | ||
81 | + ConnectPoint two; | ||
82 | + | ||
83 | + private Builder() { | ||
84 | + // Hide constructor | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public Builder appId(ApplicationId appId) { | ||
89 | + return (Builder) super.appId(appId); | ||
90 | + } | ||
91 | + | ||
92 | + @Override | ||
93 | + public Builder key(Key key) { | ||
94 | + return (Builder) super.key(key); | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public Builder selector(TrafficSelector selector) { | ||
99 | + return (Builder) super.selector(selector); | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public Builder treatment(TrafficTreatment treatment) { | ||
104 | + return (Builder) super.treatment(treatment); | ||
105 | + } | ||
106 | + | ||
107 | + @Override | ||
108 | + public Builder constraints(List<Constraint> constraints) { | ||
109 | + return (Builder) super.constraints(constraints); | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public Builder priority(int priority) { | ||
114 | + return (Builder) super.priority(priority); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Sets the first connection point of the two way intent that will be built. | ||
119 | + * | ||
120 | + * @param one first connect point | ||
121 | + * @return this builder | ||
122 | + */ | ||
123 | + public Builder one(ConnectPoint one) { | ||
124 | + this.one = one; | ||
125 | + return this; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Sets the second connection point of the two way intent that will be built. | ||
130 | + * | ||
131 | + * @param two second connect point | ||
132 | + * @return this builder | ||
133 | + */ | ||
134 | + public Builder two(ConnectPoint two) { | ||
135 | + this.two = two; | ||
136 | + return this; | ||
137 | + } | ||
138 | + | ||
139 | + /** | ||
140 | + * Builds a point to point intent from the accumulated parameters. | ||
141 | + * | ||
142 | + * @return point to point intent | ||
143 | + */ | ||
144 | + public TwoWayP2PIntent build() { | ||
145 | + | ||
146 | + return new TwoWayP2PIntent( | ||
147 | + appId, | ||
148 | + key, | ||
149 | + one, | ||
150 | + two, | ||
151 | + selector, | ||
152 | + treatment, | ||
153 | + constraints, | ||
154 | + priority | ||
155 | + ); | ||
156 | + } | ||
131 | } | 157 | } |
132 | 158 | ||
133 | /** | 159 | /** | ... | ... |
... | @@ -27,7 +27,6 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -27,7 +27,6 @@ import static org.hamcrest.MatcherAssert.assertThat; |
27 | import static org.hamcrest.Matchers.equalTo; | 27 | import static org.hamcrest.Matchers.equalTo; |
28 | import static org.hamcrest.Matchers.is; | 28 | import static org.hamcrest.Matchers.is; |
29 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | 29 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
30 | -import static org.onosproject.net.NetTestTools.APP_ID; | ||
31 | import static org.onosproject.net.NetTestTools.hid; | 30 | import static org.onosproject.net.NetTestTools.hid; |
32 | 31 | ||
33 | /** | 32 | /** |
... | @@ -43,7 +42,13 @@ public class HostToHostIntentTest extends IntentTest { | ... | @@ -43,7 +42,13 @@ public class HostToHostIntentTest extends IntentTest { |
43 | private static final ApplicationId APPID = new TestApplicationId("foo"); | 42 | private static final ApplicationId APPID = new TestApplicationId("foo"); |
44 | 43 | ||
45 | private HostToHostIntent makeHostToHost(HostId one, HostId two) { | 44 | private HostToHostIntent makeHostToHost(HostId one, HostId two) { |
46 | - return new HostToHostIntent(APPID, one, two, selector, treatment); | 45 | + return HostToHostIntent.builder() |
46 | + .appId(APPID) | ||
47 | + .one(one) | ||
48 | + .two(two) | ||
49 | + .selector(selector) | ||
50 | + .treatment(treatment) | ||
51 | + .build(); | ||
47 | } | 52 | } |
48 | 53 | ||
49 | /** | 54 | /** |
... | @@ -75,17 +80,21 @@ public class HostToHostIntentTest extends IntentTest { | ... | @@ -75,17 +80,21 @@ public class HostToHostIntentTest extends IntentTest { |
75 | */ | 80 | */ |
76 | @Test | 81 | @Test |
77 | public void testEquals() { | 82 | public void testEquals() { |
78 | - final HostToHostIntent intent1 = new HostToHostIntent(APP_ID, | 83 | + final HostToHostIntent intent1 = HostToHostIntent.builder() |
79 | - id1, | 84 | + .appId(APPID) |
80 | - id2, | 85 | + .one(id1) |
81 | - selector, | 86 | + .two(id2) |
82 | - treatment); | 87 | + .selector(selector) |
88 | + .treatment(treatment) | ||
89 | + .build(); | ||
83 | 90 | ||
84 | - final HostToHostIntent intent2 = new HostToHostIntent(APP_ID, | 91 | + final HostToHostIntent intent2 = HostToHostIntent.builder() |
85 | - id2, | 92 | + .appId(APPID) |
86 | - id3, | 93 | + .one(id2) |
87 | - selector, | 94 | + .two(id3) |
88 | - treatment); | 95 | + .selector(selector) |
96 | + .treatment(treatment) | ||
97 | + .build(); | ||
89 | 98 | ||
90 | new EqualsTester() | 99 | new EqualsTester() |
91 | .addEqualityGroup(intent1) | 100 | .addEqualityGroup(intent1) |
... | @@ -95,11 +104,23 @@ public class HostToHostIntentTest extends IntentTest { | ... | @@ -95,11 +104,23 @@ public class HostToHostIntentTest extends IntentTest { |
95 | 104 | ||
96 | @Override | 105 | @Override |
97 | protected Intent createOne() { | 106 | protected Intent createOne() { |
98 | - return new HostToHostIntent(APP_ID, id1, id2, selector, treatment); | 107 | + return HostToHostIntent.builder() |
108 | + .appId(APPID) | ||
109 | + .one(id1) | ||
110 | + .two(id2) | ||
111 | + .selector(selector) | ||
112 | + .treatment(treatment) | ||
113 | + .build(); | ||
99 | } | 114 | } |
100 | 115 | ||
101 | @Override | 116 | @Override |
102 | protected Intent createAnother() { | 117 | protected Intent createAnother() { |
103 | - return new HostToHostIntent(APP_ID, id1, id3, selector, treatment); | 118 | + return HostToHostIntent.builder() |
119 | + .appId(APPID) | ||
120 | + .one(id1) | ||
121 | + .two(id3) | ||
122 | + .selector(selector) | ||
123 | + .treatment(treatment) | ||
124 | + .build(); | ||
104 | } | 125 | } |
105 | } | 126 | } | ... | ... |
... | @@ -419,12 +419,13 @@ public class IntentTestsMocks { | ... | @@ -419,12 +419,13 @@ public class IntentTestsMocks { |
419 | private final Long number; | 419 | private final Long number; |
420 | 420 | ||
421 | public MockIntent(Long number) { | 421 | public MockIntent(Long number) { |
422 | - super(NetTestTools.APP_ID, Collections.emptyList()); | 422 | + super(NetTestTools.APP_ID, null, Collections.emptyList(), |
423 | + Intent.DEFAULT_INTENT_PRIORITY); | ||
423 | this.number = number; | 424 | this.number = number; |
424 | } | 425 | } |
425 | 426 | ||
426 | public MockIntent(Long number, Collection<NetworkResource> resources) { | 427 | public MockIntent(Long number, Collection<NetworkResource> resources) { |
427 | - super(NetTestTools.APP_ID, resources); | 428 | + super(NetTestTools.APP_ID, null, resources, Intent.DEFAULT_INTENT_PRIORITY); |
428 | this.number = number; | 429 | this.number = number; |
429 | } | 430 | } |
430 | 431 | ... | ... |
... | @@ -67,22 +67,26 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -67,22 +67,26 @@ public class LinkCollectionIntentTest extends IntentTest { |
67 | final HashSet<Link> links1 = new HashSet<>(); | 67 | final HashSet<Link> links1 = new HashSet<>(); |
68 | links1.add(link("src", 1, "dst", 2)); | 68 | links1.add(link("src", 1, "dst", 2)); |
69 | final LinkCollectionIntent collectionIntent1 = | 69 | final LinkCollectionIntent collectionIntent1 = |
70 | - new LinkCollectionIntent(APP_ID, | 70 | + LinkCollectionIntent.builder() |
71 | - selector, | 71 | + .appId(APP_ID) |
72 | - treatment, | 72 | + .selector(selector) |
73 | - links1, | 73 | + .treatment(treatment) |
74 | - ingress, | 74 | + .links(links1) |
75 | - egress); | 75 | + .ingressPoints(ImmutableSet.of(ingress)) |
76 | + .egressPoints(ImmutableSet.of(egress)) | ||
77 | + .build(); | ||
76 | 78 | ||
77 | final HashSet<Link> links2 = new HashSet<>(); | 79 | final HashSet<Link> links2 = new HashSet<>(); |
78 | links2.add(link("src", 1, "dst", 3)); | 80 | links2.add(link("src", 1, "dst", 3)); |
79 | final LinkCollectionIntent collectionIntent2 = | 81 | final LinkCollectionIntent collectionIntent2 = |
80 | - new LinkCollectionIntent(APP_ID, | 82 | + LinkCollectionIntent.builder() |
81 | - selector, | 83 | + .appId(APP_ID) |
82 | - treatment, | 84 | + .selector(selector) |
83 | - links2, | 85 | + .treatment(treatment) |
84 | - ingress, | 86 | + .links(links2) |
85 | - egress); | 87 | + .ingressPoints(ImmutableSet.of(ingress)) |
88 | + .egressPoints(ImmutableSet.of(egress)) | ||
89 | + .build(); | ||
86 | 90 | ||
87 | new EqualsTester() | 91 | new EqualsTester() |
88 | .addEqualityGroup(collectionIntent1) | 92 | .addEqualityGroup(collectionIntent1) |
... | @@ -98,12 +102,14 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -98,12 +102,14 @@ public class LinkCollectionIntentTest extends IntentTest { |
98 | final HashSet<Link> links1 = new HashSet<>(); | 102 | final HashSet<Link> links1 = new HashSet<>(); |
99 | links1.add(link("src", 1, "dst", 2)); | 103 | links1.add(link("src", 1, "dst", 2)); |
100 | final LinkCollectionIntent collectionIntent = | 104 | final LinkCollectionIntent collectionIntent = |
101 | - new LinkCollectionIntent(APP_ID, | 105 | + LinkCollectionIntent.builder() |
102 | - selector, | 106 | + .appId(APP_ID) |
103 | - treatment, | 107 | + .selector(selector) |
104 | - links1, | 108 | + .treatment(treatment) |
105 | - ingress, | 109 | + .links(links1) |
106 | - egress); | 110 | + .ingressPoints(ImmutableSet.of(ingress)) |
111 | + .egressPoints(ImmutableSet.of(egress)) | ||
112 | + .build(); | ||
107 | 113 | ||
108 | final Set<Link> createdLinks = collectionIntent.links(); | 114 | final Set<Link> createdLinks = collectionIntent.links(); |
109 | assertThat(createdLinks, hasSize(1)); | 115 | assertThat(createdLinks, hasSize(1)); |
... | @@ -128,14 +134,16 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -128,14 +134,16 @@ public class LinkCollectionIntentTest extends IntentTest { |
128 | links1.add(link("src", 1, "dst", 2)); | 134 | links1.add(link("src", 1, "dst", 2)); |
129 | constraints.add(new LambdaConstraint(Lambda.valueOf(23))); | 135 | constraints.add(new LambdaConstraint(Lambda.valueOf(23))); |
130 | final LinkCollectionIntent collectionIntent = | 136 | final LinkCollectionIntent collectionIntent = |
131 | - new LinkCollectionIntent(APP_ID, | 137 | + LinkCollectionIntent.builder() |
132 | - selector, | 138 | + .appId(APP_ID) |
133 | - treatment, | 139 | + .selector(selector) |
134 | - links1, | 140 | + .treatment(treatment) |
135 | - ingress, | 141 | + .links(links1) |
136 | - egress, | 142 | + .ingressPoints(ImmutableSet.of(ingress)) |
137 | - constraints, | 143 | + .egressPoints(ImmutableSet.of(egress)) |
138 | - 8888); | 144 | + .constraints(constraints) |
145 | + .priority(8888) | ||
146 | + .build(); | ||
139 | 147 | ||
140 | final Set<Link> createdLinks = collectionIntent.links(); | 148 | final Set<Link> createdLinks = collectionIntent.links(); |
141 | assertThat(createdLinks, hasSize(1)); | 149 | assertThat(createdLinks, hasSize(1)); |
... | @@ -175,23 +183,27 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -175,23 +183,27 @@ public class LinkCollectionIntentTest extends IntentTest { |
175 | protected Intent createOne() { | 183 | protected Intent createOne() { |
176 | HashSet<Link> links1 = new HashSet<>(); | 184 | HashSet<Link> links1 = new HashSet<>(); |
177 | links1.add(link("src", 1, "dst", 2)); | 185 | links1.add(link("src", 1, "dst", 2)); |
178 | - return new LinkCollectionIntent(APP_ID, | 186 | + return LinkCollectionIntent.builder() |
179 | - selector, | 187 | + .appId(APP_ID) |
180 | - treatment, | 188 | + .selector(selector) |
181 | - links1, | 189 | + .treatment(treatment) |
182 | - ingress, | 190 | + .links(links1) |
183 | - egress); | 191 | + .ingressPoints(ImmutableSet.of(ingress)) |
192 | + .egressPoints(ImmutableSet.of(egress)) | ||
193 | + .build(); | ||
184 | } | 194 | } |
185 | 195 | ||
186 | @Override | 196 | @Override |
187 | protected Intent createAnother() { | 197 | protected Intent createAnother() { |
188 | HashSet<Link> links2 = new HashSet<>(); | 198 | HashSet<Link> links2 = new HashSet<>(); |
189 | links2.add(link("src", 1, "dst", 3)); | 199 | links2.add(link("src", 1, "dst", 3)); |
190 | - return new LinkCollectionIntent(APP_ID, | 200 | + return LinkCollectionIntent.builder() |
191 | - selector, | 201 | + .appId(APP_ID) |
192 | - treatment, | 202 | + .selector(selector) |
193 | - links2, | 203 | + .treatment(treatment) |
194 | - ingress, | 204 | + .links(links2) |
195 | - egress); | 205 | + .ingressPoints(ImmutableSet.of(ingress)) |
206 | + .egressPoints(ImmutableSet.of(egress)) | ||
207 | + .build(); | ||
196 | } | 208 | } |
197 | } | 209 | } | ... | ... |
... | @@ -44,11 +44,23 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { | ... | @@ -44,11 +44,23 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | protected MultiPointToSinglePointIntent createOne() { | 46 | protected MultiPointToSinglePointIntent createOne() { |
47 | - return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS1, P2); | 47 | + return MultiPointToSinglePointIntent.builder() |
48 | + .appId(APPID) | ||
49 | + .selector(MATCH) | ||
50 | + .treatment(NOP) | ||
51 | + .ingressPoints(PS1) | ||
52 | + .egressPoint(P2) | ||
53 | + .build(); | ||
48 | } | 54 | } |
49 | 55 | ||
50 | @Override | 56 | @Override |
51 | protected MultiPointToSinglePointIntent createAnother() { | 57 | protected MultiPointToSinglePointIntent createAnother() { |
52 | - return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS2, P1); | 58 | + return MultiPointToSinglePointIntent.builder() |
59 | + .appId(APPID) | ||
60 | + .selector(MATCH) | ||
61 | + .treatment(NOP) | ||
62 | + .ingressPoints(PS2) | ||
63 | + .egressPoint(P1) | ||
64 | + .build(); | ||
53 | } | 65 | } |
54 | } | 66 | } | ... | ... |
... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent; | 16 | package org.onosproject.net.intent; |
17 | 17 | ||
18 | +import java.util.Arrays; | ||
19 | + | ||
18 | import org.junit.Test; | 20 | import org.junit.Test; |
19 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
20 | import org.onosproject.net.DefaultLink; | 22 | import org.onosproject.net.DefaultLink; |
... | @@ -25,8 +27,6 @@ import org.onosproject.net.Path; | ... | @@ -25,8 +27,6 @@ import org.onosproject.net.Path; |
25 | import org.onosproject.net.PortNumber; | 27 | import org.onosproject.net.PortNumber; |
26 | import org.onosproject.net.provider.ProviderId; | 28 | import org.onosproject.net.provider.ProviderId; |
27 | 29 | ||
28 | -import java.util.Arrays; | ||
29 | - | ||
30 | import static org.junit.Assert.assertEquals; | 30 | import static org.junit.Assert.assertEquals; |
31 | import static org.onosproject.net.DeviceId.deviceId; | 31 | import static org.onosproject.net.DeviceId.deviceId; |
32 | import static org.onosproject.net.Link.Type.DIRECT; | 32 | import static org.onosproject.net.Link.Type.DIRECT; |
... | @@ -65,12 +65,22 @@ public class PathIntentTest extends ConnectivityIntentTest { | ... | @@ -65,12 +65,22 @@ public class PathIntentTest extends ConnectivityIntentTest { |
65 | 65 | ||
66 | @Override | 66 | @Override |
67 | protected PathIntent createOne() { | 67 | protected PathIntent createOne() { |
68 | - return new PathIntent(APPID, MATCH, NOP, PATH1); | 68 | + return PathIntent.builder() |
69 | + .appId(APPID) | ||
70 | + .selector(MATCH) | ||
71 | + .treatment(NOP) | ||
72 | + .path(PATH1) | ||
73 | + .build(); | ||
69 | } | 74 | } |
70 | 75 | ||
71 | @Override | 76 | @Override |
72 | protected PathIntent createAnother() { | 77 | protected PathIntent createAnother() { |
73 | - return new PathIntent(APPID, MATCH, NOP, PATH2); | 78 | + return PathIntent.builder() |
79 | + .appId(APPID) | ||
80 | + .selector(MATCH) | ||
81 | + .treatment(NOP) | ||
82 | + .path(PATH2) | ||
83 | + .build(); | ||
74 | } | 84 | } |
75 | 85 | ||
76 | /** | 86 | /** |
... | @@ -79,7 +89,12 @@ public class PathIntentTest extends ConnectivityIntentTest { | ... | @@ -79,7 +89,12 @@ public class PathIntentTest extends ConnectivityIntentTest { |
79 | */ | 89 | */ |
80 | @Test(expected = IllegalArgumentException.class) | 90 | @Test(expected = IllegalArgumentException.class) |
81 | public void testRaiseExceptionWhenSameDevices() { | 91 | public void testRaiseExceptionWhenSameDevices() { |
82 | - new PathIntent(APPID, MATCH, NOP, new DefaultPath(provider1, Arrays.asList(link1), cost)); | 92 | + PathIntent.builder() |
93 | + .appId(APPID) | ||
94 | + .selector(MATCH) | ||
95 | + .treatment(NOP) | ||
96 | + .path(new DefaultPath(provider1, Arrays.asList(link1), cost)) | ||
97 | + .build(); | ||
83 | } | 98 | } |
84 | 99 | ||
85 | /** | 100 | /** |
... | @@ -88,7 +103,12 @@ public class PathIntentTest extends ConnectivityIntentTest { | ... | @@ -88,7 +103,12 @@ public class PathIntentTest extends ConnectivityIntentTest { |
88 | */ | 103 | */ |
89 | @Test(expected = IllegalArgumentException.class) | 104 | @Test(expected = IllegalArgumentException.class) |
90 | public void testRaiseExceptionWhenDifferentDevice() { | 105 | public void testRaiseExceptionWhenDifferentDevice() { |
91 | - new PathIntent(APPID, MATCH, NOP, new DefaultPath(provider1, Arrays.asList(link1, link2), cost)); | 106 | + PathIntent.builder() |
107 | + .appId(APPID) | ||
108 | + .selector(MATCH) | ||
109 | + .treatment(NOP) | ||
110 | + .path(new DefaultPath(provider1, Arrays.asList(link1, link2), cost)) | ||
111 | + .build(); | ||
92 | } | 112 | } |
93 | 113 | ||
94 | } | 114 | } | ... | ... |
... | @@ -44,11 +44,23 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest { | ... | @@ -44,11 +44,23 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest { |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | protected SinglePointToMultiPointIntent createOne() { | 46 | protected SinglePointToMultiPointIntent createOne() { |
47 | - return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P1, PS2); | 47 | + return SinglePointToMultiPointIntent.builder() |
48 | + .appId(APPID) | ||
49 | + .selector(MATCH) | ||
50 | + .treatment(NOP) | ||
51 | + .ingressPoint(P1) | ||
52 | + .egressPoints(PS2) | ||
53 | + .build(); | ||
48 | } | 54 | } |
49 | 55 | ||
50 | @Override | 56 | @Override |
51 | protected SinglePointToMultiPointIntent createAnother() { | 57 | protected SinglePointToMultiPointIntent createAnother() { |
52 | - return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P2, PS1); | 58 | + return SinglePointToMultiPointIntent.builder() |
59 | + .appId(APPID) | ||
60 | + .selector(MATCH) | ||
61 | + .treatment(NOP) | ||
62 | + .ingressPoint(P2) | ||
63 | + .egressPoints(PS1) | ||
64 | + .build(); | ||
53 | } | 65 | } |
54 | } | 66 | } | ... | ... |
... | @@ -32,7 +32,8 @@ public class TestInstallableIntent extends Intent { | ... | @@ -32,7 +32,8 @@ public class TestInstallableIntent extends Intent { |
32 | * @param value intent ID | 32 | * @param value intent ID |
33 | */ | 33 | */ |
34 | public TestInstallableIntent(int value) { // FIXME | 34 | public TestInstallableIntent(int value) { // FIXME |
35 | - super(new TestApplicationId("foo"), Collections.emptyList()); | 35 | + super(new TestApplicationId("foo"), null, Collections.emptyList(), |
36 | + Intent.DEFAULT_INTENT_PRIORITY); | ||
36 | this.value = value; | 37 | this.value = value; |
37 | } | 38 | } |
38 | 39 | ... | ... |
... | @@ -32,7 +32,8 @@ public class TestIntent extends Intent { | ... | @@ -32,7 +32,8 @@ public class TestIntent extends Intent { |
32 | * @param value intent ID | 32 | * @param value intent ID |
33 | */ | 33 | */ |
34 | public TestIntent(int value) { // FIXME | 34 | public TestIntent(int value) { // FIXME |
35 | - super(new TestApplicationId("foo"), Collections.emptyList()); | 35 | + super(new TestApplicationId("foo"), null, Collections.emptyList(), |
36 | + Intent.DEFAULT_INTENT_PRIORITY); | ||
36 | this.value = value; | 37 | this.value = value; |
37 | } | 38 | } |
38 | 39 | ... | ... |
... | @@ -78,7 +78,11 @@ public class IntentCodecTest extends AbstractIntentTest { | ... | @@ -78,7 +78,11 @@ public class IntentCodecTest extends AbstractIntentTest { |
78 | @Test | 78 | @Test |
79 | public void hostToHostIntent() { | 79 | public void hostToHostIntent() { |
80 | final HostToHostIntent intent = | 80 | final HostToHostIntent intent = |
81 | - new HostToHostIntent(appId, id1, id2); | 81 | + HostToHostIntent.builder() |
82 | + .appId(appId) | ||
83 | + .one(id1) | ||
84 | + .two(id2) | ||
85 | + .build(); | ||
82 | 86 | ||
83 | final JsonCodec<HostToHostIntent> intentCodec = | 87 | final JsonCodec<HostToHostIntent> intentCodec = |
84 | context.codec(HostToHostIntent.class); | 88 | context.codec(HostToHostIntent.class); | ... | ... |
... | @@ -97,9 +97,14 @@ public class HostToHostIntentCompiler | ... | @@ -97,9 +97,14 @@ public class HostToHostIntentCompiler |
97 | HostToHostIntent intent) { | 97 | HostToHostIntent intent) { |
98 | TrafficSelector selector = builder(intent.selector()) | 98 | TrafficSelector selector = builder(intent.selector()) |
99 | .matchEthSrc(src.mac()).matchEthDst(dst.mac()).build(); | 99 | .matchEthSrc(src.mac()).matchEthDst(dst.mac()).build(); |
100 | - return new PathIntent(intent.appId(), selector, intent.treatment(), | 100 | + return PathIntent.builder() |
101 | - path, intent.constraints(), | 101 | + .appId(intent.appId()) |
102 | - intent.priority()); | 102 | + .selector(selector) |
103 | + .treatment(intent.treatment()) | ||
104 | + .path(path) | ||
105 | + .constraints(intent.constraints()) | ||
106 | + .priority(intent.priority()) | ||
107 | + .build(); | ||
103 | } | 108 | } |
104 | 109 | ||
105 | } | 110 | } | ... | ... |
... | @@ -75,11 +75,16 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> | ... | @@ -75,11 +75,16 @@ public class MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> |
75 | */ | 75 | */ |
76 | private Intent createPathIntent(Path path, | 76 | private Intent createPathIntent(Path path, |
77 | MplsIntent intent) { | 77 | MplsIntent intent) { |
78 | - return new MplsPathIntent(intent.appId(), | 78 | + return MplsPathIntent.builder() |
79 | - intent.selector(), intent.treatment(), path, | 79 | + .appId(intent.appId()) |
80 | - intent.ingressLabel(), intent.egressLabel(), | 80 | + .selector(intent.selector()) |
81 | - intent.constraints(), | 81 | + .treatment(intent.treatment()) |
82 | - intent.priority()); | 82 | + .path(path) |
83 | + .ingressLabel(intent.ingressLabel()) | ||
84 | + .egressLabel(intent.egressLabel()) | ||
85 | + .constraints(intent.constraints()) | ||
86 | + .priority(intent.priority()) | ||
87 | + .build(); | ||
83 | } | 88 | } |
84 | 89 | ||
85 | 90 | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.net.intent.impl.compiler; | 16 | package org.onosproject.net.intent.impl.compiler; |
17 | 17 | ||
18 | import java.util.Arrays; | 18 | import java.util.Arrays; |
19 | -import java.util.Collections; | ||
20 | import java.util.HashMap; | 19 | import java.util.HashMap; |
21 | import java.util.List; | 20 | import java.util.List; |
22 | import java.util.Map; | 21 | import java.util.Map; |
... | @@ -89,14 +88,16 @@ public class MultiPointToSinglePointIntentCompiler | ... | @@ -89,14 +88,16 @@ public class MultiPointToSinglePointIntentCompiler |
89 | } | 88 | } |
90 | } | 89 | } |
91 | 90 | ||
92 | - Set<ConnectPoint> egress = ImmutableSet.of(intent.egressPoint()); | 91 | + Intent result = LinkCollectionIntent.builder() |
93 | - Intent result = new LinkCollectionIntent(intent.appId(), | 92 | + .appId(intent.appId()) |
94 | - intent.selector(), intent.treatment(), | 93 | + .selector(intent.selector()) |
95 | - Sets.newHashSet(links.values()), | 94 | + .treatment(intent.treatment()) |
96 | - intent.ingressPoints(), | 95 | + .links(Sets.newHashSet(links.values())) |
97 | - ImmutableSet.of(intent.egressPoint()), | 96 | + .ingressPoints(intent.ingressPoints()) |
98 | - Collections.emptyList(), | 97 | + .egressPoints(ImmutableSet.of(intent.egressPoint())) |
99 | - intent.priority()); | 98 | + .priority(intent.priority()) |
99 | + .build(); | ||
100 | + | ||
100 | return Arrays.asList(result); | 101 | return Arrays.asList(result); |
101 | } | 102 | } |
102 | 103 | ... | ... |
... | @@ -91,10 +91,14 @@ public class PointToPointIntentCompiler | ... | @@ -91,10 +91,14 @@ public class PointToPointIntentCompiler |
91 | */ | 91 | */ |
92 | private Intent createPathIntent(Path path, | 92 | private Intent createPathIntent(Path path, |
93 | PointToPointIntent intent) { | 93 | PointToPointIntent intent) { |
94 | - return new PathIntent(intent.appId(), | 94 | + return PathIntent.builder() |
95 | - intent.selector(), intent.treatment(), path, | 95 | + .appId(intent.appId()) |
96 | - intent.constraints(), | 96 | + .selector(intent.selector()) |
97 | - intent.priority()); | 97 | + .treatment(intent.treatment()) |
98 | + .path(path) | ||
99 | + .constraints(intent.constraints()) | ||
100 | + .priority(intent.priority()) | ||
101 | + .build(); | ||
98 | } | 102 | } |
99 | 103 | ||
100 | } | 104 | } | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.net.intent.impl.compiler; | 16 | package org.onosproject.net.intent.impl.compiler; |
17 | 17 | ||
18 | import java.util.Arrays; | 18 | import java.util.Arrays; |
19 | -import java.util.Collections; | ||
20 | import java.util.HashSet; | 19 | import java.util.HashSet; |
21 | import java.util.List; | 20 | import java.util.List; |
22 | import java.util.Set; | 21 | import java.util.Set; |
... | @@ -66,13 +65,16 @@ public class SinglePointToMultiPointIntentCompiler | ... | @@ -66,13 +65,16 @@ public class SinglePointToMultiPointIntentCompiler |
66 | links.addAll(path.links()); | 65 | links.addAll(path.links()); |
67 | } | 66 | } |
68 | 67 | ||
69 | - Intent result = new LinkCollectionIntent(intent.appId(), | 68 | + Intent result = LinkCollectionIntent.builder() |
70 | - intent.selector(), | 69 | + .appId(intent.appId()) |
71 | - intent.treatment(), links, | 70 | + .key(intent.key()) |
72 | - ImmutableSet.of(intent.ingressPoint()), | 71 | + .selector(intent.selector()) |
73 | - intent.egressPoints(), | 72 | + .treatment(intent.treatment()) |
74 | - Collections.emptyList(), | 73 | + .links(links) |
75 | - intent.priority()); | 74 | + .ingressPoints(ImmutableSet.of(intent.ingressPoint())) |
75 | + .egressPoints(intent.egressPoints()) | ||
76 | + .priority(intent.priority()) | ||
77 | + .build(); | ||
76 | 78 | ||
77 | return Arrays.asList(result); | 79 | return Arrays.asList(result); |
78 | } | 80 | } | ... | ... |
... | @@ -502,7 +502,8 @@ public class IntentManagerTest { | ... | @@ -502,7 +502,8 @@ public class IntentManagerTest { |
502 | public void intentWithoutCompiler() { | 502 | public void intentWithoutCompiler() { |
503 | class IntentNoCompiler extends Intent { | 503 | class IntentNoCompiler extends Intent { |
504 | IntentNoCompiler() { | 504 | IntentNoCompiler() { |
505 | - super(APPID, Collections.emptyList()); | 505 | + super(APPID, null, Collections.emptyList(), |
506 | + Intent.DEFAULT_INTENT_PRIORITY); | ||
506 | } | 507 | } |
507 | } | 508 | } |
508 | 509 | ... | ... |
... | @@ -90,8 +90,13 @@ public class HostToHostIntentCompilerTest extends AbstractIntentTest { | ... | @@ -90,8 +90,13 @@ public class HostToHostIntentCompilerTest extends AbstractIntentTest { |
90 | * @return HostToHostIntent for the two hosts | 90 | * @return HostToHostIntent for the two hosts |
91 | */ | 91 | */ |
92 | private HostToHostIntent makeIntent(String oneIdString, String twoIdString) { | 92 | private HostToHostIntent makeIntent(String oneIdString, String twoIdString) { |
93 | - return new HostToHostIntent(APPID, hid(oneIdString), hid(twoIdString), | 93 | + return HostToHostIntent.builder() |
94 | - selector, treatment); | 94 | + .appId(APPID) |
95 | + .one(hid(oneIdString)) | ||
96 | + .two(hid(twoIdString)) | ||
97 | + .selector(selector) | ||
98 | + .treatment(treatment) | ||
99 | + .build(); | ||
95 | } | 100 | } |
96 | 101 | ||
97 | /** | 102 | /** | ... | ... |
... | @@ -55,11 +55,14 @@ public class MplsIntentCompilerTest extends AbstractIntentTest { | ... | @@ -55,11 +55,14 @@ public class MplsIntentCompilerTest extends AbstractIntentTest { |
55 | private MplsIntent makeIntent(String ingressIdString, Optional<MplsLabel> ingressLabel, | 55 | private MplsIntent makeIntent(String ingressIdString, Optional<MplsLabel> ingressLabel, |
56 | String egressIdString, Optional<MplsLabel> egressLabel) { | 56 | String egressIdString, Optional<MplsLabel> egressLabel) { |
57 | 57 | ||
58 | - return new MplsIntent(APPID, selector, treatment, | 58 | + return MplsIntent.builder() |
59 | - connectPoint(ingressIdString, 1), | 59 | + .appId(APPID) |
60 | - ingressLabel, | 60 | + .selector(selector) |
61 | - connectPoint(egressIdString, 1), | 61 | + .treatment(treatment) |
62 | - egressLabel); | 62 | + .ingressPoint(connectPoint(ingressIdString, 1)) |
63 | + .ingressLabel(ingressLabel) | ||
64 | + .egressPoint(connectPoint(egressIdString, 1)) | ||
65 | + .egressLabel(egressLabel).build(); | ||
63 | } | 66 | } |
64 | /** | 67 | /** |
65 | * Creates a compiler for HostToHost intents. | 68 | * Creates a compiler for HostToHost intents. |
... | @@ -157,7 +160,15 @@ public class MplsIntentCompilerTest extends AbstractIntentTest { | ... | @@ -157,7 +160,15 @@ public class MplsIntentCompilerTest extends AbstractIntentTest { |
157 | public void testSameSwitchDifferentPortsIntentCompilation() { | 160 | public void testSameSwitchDifferentPortsIntentCompilation() { |
158 | ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1)); | 161 | ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1)); |
159 | ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2)); | 162 | ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2)); |
160 | - MplsIntent intent = new MplsIntent(APP_ID, selector, treatment, src, Optional.empty(), dst, Optional.empty()); | 163 | + MplsIntent intent = MplsIntent.builder() |
164 | + .appId(APP_ID) | ||
165 | + .selector(selector) | ||
166 | + .treatment(treatment) | ||
167 | + .ingressPoint(src) | ||
168 | + .ingressLabel(Optional.empty()) | ||
169 | + .egressPoint(dst) | ||
170 | + .egressLabel(Optional.empty()) | ||
171 | + .build(); | ||
161 | 172 | ||
162 | String[] hops = {"1"}; | 173 | String[] hops = {"1"}; |
163 | MplsIntentCompiler sut = makeCompiler(hops); | 174 | MplsIntentCompiler sut = makeCompiler(hops); | ... | ... |
... | @@ -104,8 +104,13 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes | ... | @@ -104,8 +104,13 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes |
104 | ingressPoints.add(connectPoint(ingressId, 1)); | 104 | ingressPoints.add(connectPoint(ingressId, 1)); |
105 | } | 105 | } |
106 | 106 | ||
107 | - return new MultiPointToSinglePointIntent(APPID, selector, treatment, | 107 | + return MultiPointToSinglePointIntent.builder() |
108 | - ingressPoints, egressPoint); | 108 | + .appId(APPID) |
109 | + .selector(selector) | ||
110 | + .treatment(treatment) | ||
111 | + .ingressPoints(ingressPoints) | ||
112 | + .egressPoint(egressPoint) | ||
113 | + .build(); | ||
109 | } | 114 | } |
110 | 115 | ||
111 | /** | 116 | /** | ... | ... |
... | @@ -56,7 +56,14 @@ public class LinkCollectionIntentInstallerTest extends IntentInstallerTest { | ... | @@ -56,7 +56,14 @@ public class LinkCollectionIntentInstallerTest extends IntentInstallerTest { |
56 | installer.coreService = testCoreService; | 56 | installer.coreService = testCoreService; |
57 | installer.intentManager = | 57 | installer.intentManager = |
58 | new IntentInstallerTest.MockIntentManager(LinkCollectionIntent.class); | 58 | new IntentInstallerTest.MockIntentManager(LinkCollectionIntent.class); |
59 | - intent = new LinkCollectionIntent(APP_ID, selector, treatment, links, d1p1, d3p1); | 59 | + intent = LinkCollectionIntent.builder() |
60 | + .appId(APP_ID) | ||
61 | + .selector(selector) | ||
62 | + .treatment(treatment) | ||
63 | + .links(links) | ||
64 | + .ingressPoints(ImmutableSet.of(d1p1)) | ||
65 | + .egressPoints(ImmutableSet.of(d3p1)) | ||
66 | + .build(); | ||
60 | } | 67 | } |
61 | 68 | ||
62 | private FlowRuleOperation findOperation(Collection<FlowRuleOperation> ops, | 69 | private FlowRuleOperation findOperation(Collection<FlowRuleOperation> ops, | ... | ... |
... | @@ -31,8 +31,6 @@ import org.onosproject.net.intent.IntentTestsMocks; | ... | @@ -31,8 +31,6 @@ import org.onosproject.net.intent.IntentTestsMocks; |
31 | import org.onosproject.net.intent.MplsPathIntent; | 31 | import org.onosproject.net.intent.MplsPathIntent; |
32 | import org.onosproject.store.trivial.impl.SimpleLinkStore; | 32 | import org.onosproject.store.trivial.impl.SimpleLinkStore; |
33 | 33 | ||
34 | -import com.google.common.collect.ImmutableList; | ||
35 | - | ||
36 | import static org.hamcrest.MatcherAssert.assertThat; | 34 | import static org.hamcrest.MatcherAssert.assertThat; |
37 | import static org.hamcrest.Matchers.hasSize; | 35 | import static org.hamcrest.Matchers.hasSize; |
38 | import static org.hamcrest.Matchers.notNullValue; | 36 | import static org.hamcrest.Matchers.notNullValue; |
... | @@ -70,12 +68,15 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest { | ... | @@ -70,12 +68,15 @@ public class MplsPathIntentInstallerTest extends IntentInstallerTest { |
70 | installer.linkStore = new SimpleLinkStore(); | 68 | installer.linkStore = new SimpleLinkStore(); |
71 | installer.resourceService = new IntentTestsMocks.MockResourceService(); | 69 | installer.resourceService = new IntentTestsMocks.MockResourceService(); |
72 | 70 | ||
73 | - intent = new MplsPathIntent(APP_ID, selector, treatment, | 71 | + intent = MplsPathIntent.builder() |
74 | - new DefaultPath(PID, links, hops), | 72 | + .appId(APP_ID) |
75 | - ingressLabel, | 73 | + .selector(selector) |
76 | - egressLabel, | 74 | + .treatment(treatment) |
77 | - ImmutableList.of(), | 75 | + .path(new DefaultPath(PID, links, hops)) |
78 | - 55); | 76 | + .ingressLabel(ingressLabel) |
77 | + .egressLabel(egressLabel) | ||
78 | + .priority(55) | ||
79 | + .build(); | ||
79 | } | 80 | } |
80 | 81 | ||
81 | /** | 82 | /** | ... | ... |
... | @@ -73,8 +73,14 @@ public class PathConstraintCalculationTest extends AbstractIntentTest { | ... | @@ -73,8 +73,14 @@ public class PathConstraintCalculationTest extends AbstractIntentTest { |
73 | 73 | ||
74 | private PathIntent createPathIntent(List<Link> links, List<Constraint> constraints) { | 74 | private PathIntent createPathIntent(List<Link> links, List<Constraint> constraints) { |
75 | int hops = links.size() - 1; | 75 | int hops = links.size() - 1; |
76 | - return new PathIntent(APP_ID, selector, treatment, | 76 | + return PathIntent.builder() |
77 | - new DefaultPath(PID, links, hops), constraints, 333); | 77 | + .appId(APP_ID) |
78 | + .selector(selector) | ||
79 | + .treatment(treatment) | ||
80 | + .path(new DefaultPath(PID, links, hops)) | ||
81 | + .constraints(constraints) | ||
82 | + .priority(333) | ||
83 | + .build(); | ||
78 | } | 84 | } |
79 | 85 | ||
80 | /** | 86 | /** | ... | ... |
... | @@ -27,8 +27,6 @@ import org.onosproject.net.Link; | ... | @@ -27,8 +27,6 @@ import org.onosproject.net.Link; |
27 | import org.onosproject.net.flow.FlowRuleOperation; | 27 | import org.onosproject.net.flow.FlowRuleOperation; |
28 | import org.onosproject.net.intent.PathIntent; | 28 | import org.onosproject.net.intent.PathIntent; |
29 | 29 | ||
30 | -import com.google.common.collect.ImmutableList; | ||
31 | - | ||
32 | import static org.hamcrest.MatcherAssert.assertThat; | 30 | import static org.hamcrest.MatcherAssert.assertThat; |
33 | import static org.hamcrest.Matchers.hasSize; | 31 | import static org.hamcrest.Matchers.hasSize; |
34 | import static org.hamcrest.Matchers.notNullValue; | 32 | import static org.hamcrest.Matchers.notNullValue; |
... | @@ -61,9 +59,13 @@ public class PathIntentInstallerTest extends IntentInstallerTest { | ... | @@ -61,9 +59,13 @@ public class PathIntentInstallerTest extends IntentInstallerTest { |
61 | installer = new PathIntentInstaller(); | 59 | installer = new PathIntentInstaller(); |
62 | installer.coreService = testCoreService; | 60 | installer.coreService = testCoreService; |
63 | installer.intentManager = new MockIntentManager(PathIntent.class); | 61 | installer.intentManager = new MockIntentManager(PathIntent.class); |
64 | - intent = new PathIntent(APP_ID, selector, treatment, | 62 | + intent = PathIntent.builder() |
65 | - new DefaultPath(PID, links, hops), ImmutableList.of(), | 63 | + .appId(APP_ID) |
66 | - 77); | 64 | + .selector(selector) |
65 | + .treatment(treatment) | ||
66 | + .path(new DefaultPath(PID, links, hops)) | ||
67 | + .priority(77) | ||
68 | + .build(); | ||
67 | } | 69 | } |
68 | 70 | ||
69 | /** | 71 | /** | ... | ... |
... | @@ -97,7 +97,12 @@ public class CompilingTest { | ... | @@ -97,7 +97,12 @@ public class CompilingTest { |
97 | .ingressPoint(cp1) | 97 | .ingressPoint(cp1) |
98 | .egressPoint(cp3) | 98 | .egressPoint(cp3) |
99 | .build(); | 99 | .build(); |
100 | - compiled = new PathIntent(appId, selector, treatment, path); | 100 | + compiled = PathIntent.builder() |
101 | + .appId(appId) | ||
102 | + .selector(selector) | ||
103 | + .treatment(treatment) | ||
104 | + .path(path) | ||
105 | + .build(); | ||
101 | } | 106 | } |
102 | 107 | ||
103 | 108 | ... | ... |
... | @@ -98,7 +98,12 @@ public class InstallCoordinatingTest { | ... | @@ -98,7 +98,12 @@ public class InstallCoordinatingTest { |
98 | .ingressPoint(cp1) | 98 | .ingressPoint(cp1) |
99 | .egressPoint(cp3) | 99 | .egressPoint(cp3) |
100 | .build(); | 100 | .build(); |
101 | - compiled = new PathIntent(appId, selector, treatment, path); | 101 | + compiled = PathIntent.builder() |
102 | + .appId(appId) | ||
103 | + .selector(selector) | ||
104 | + .treatment(treatment) | ||
105 | + .path(path) | ||
106 | + .build(); | ||
102 | } | 107 | } |
103 | 108 | ||
104 | 109 | ... | ... |
... | @@ -98,7 +98,12 @@ public class InstallingTest { | ... | @@ -98,7 +98,12 @@ public class InstallingTest { |
98 | .ingressPoint(cp1) | 98 | .ingressPoint(cp1) |
99 | .egressPoint(cp3) | 99 | .egressPoint(cp3) |
100 | .build(); | 100 | .build(); |
101 | - compiled = new PathIntent(appId, selector, treatment, path); | 101 | + compiled = PathIntent.builder() |
102 | + .appId(appId) | ||
103 | + .selector(selector) | ||
104 | + .treatment(treatment) | ||
105 | + .path(path) | ||
106 | + .build(); | ||
102 | } | 107 | } |
103 | 108 | ||
104 | 109 | ... | ... |
... | @@ -99,7 +99,12 @@ public class WithdrawCoordinatingTest { | ... | @@ -99,7 +99,12 @@ public class WithdrawCoordinatingTest { |
99 | .ingressPoint(cp1) | 99 | .ingressPoint(cp1) |
100 | .egressPoint(cp3) | 100 | .egressPoint(cp3) |
101 | .build(); | 101 | .build(); |
102 | - compiled = new PathIntent(appId, selector, treatment, path); | 102 | + compiled = PathIntent.builder() |
103 | + .appId(appId) | ||
104 | + .selector(selector) | ||
105 | + .treatment(treatment) | ||
106 | + .path(path) | ||
107 | + .build(); | ||
103 | } | 108 | } |
104 | 109 | ||
105 | 110 | ... | ... |
... | @@ -97,7 +97,12 @@ public class WithdrawingTest { | ... | @@ -97,7 +97,12 @@ public class WithdrawingTest { |
97 | .ingressPoint(cp1) | 97 | .ingressPoint(cp1) |
98 | .egressPoint(cp3) | 98 | .egressPoint(cp3) |
99 | .build(); | 99 | .build(); |
100 | - compiled = new PathIntent(appId, selector, treatment, path); | 100 | + compiled = PathIntent.builder() |
101 | + .appId(appId) | ||
102 | + .selector(selector) | ||
103 | + .treatment(treatment) | ||
104 | + .path(path) | ||
105 | + .build(); | ||
101 | } | 106 | } |
102 | 107 | ||
103 | 108 | ... | ... |
... | @@ -311,9 +311,11 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -311,9 +311,11 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
311 | HostId two = hostId(string(payload, "two")); | 311 | HostId two = hostId(string(payload, "two")); |
312 | 312 | ||
313 | HostToHostIntent intent = | 313 | HostToHostIntent intent = |
314 | - new HostToHostIntent(appId, one, two, | 314 | + HostToHostIntent.builder() |
315 | - DefaultTrafficSelector.emptySelector(), | 315 | + .appId(appId) |
316 | - DefaultTrafficTreatment.emptyTreatment()); | 316 | + .one(one) |
317 | + .two(two) | ||
318 | + .build(); | ||
317 | 319 | ||
318 | intentService.submit(intent); | 320 | intentService.submit(intent); |
319 | startMonitoringIntent(event, intent); | 321 | startMonitoringIntent(event, intent); |
... | @@ -336,8 +338,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -336,8 +338,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
336 | TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); | 338 | TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); |
337 | 339 | ||
338 | MultiPointToSinglePointIntent intent = | 340 | MultiPointToSinglePointIntent intent = |
339 | - new MultiPointToSinglePointIntent(appId, selector, treatment, | 341 | + MultiPointToSinglePointIntent.builder() |
340 | - ingressPoints, dstHost.location()); | 342 | + .appId(appId) |
343 | + .selector(selector) | ||
344 | + .treatment(treatment) | ||
345 | + .ingressPoints(ingressPoints) | ||
346 | + .egressPoint(dstHost.location()) | ||
347 | + .build(); | ||
341 | 348 | ||
342 | intentService.submit(intent); | 349 | intentService.submit(intent); |
343 | startMonitoringIntent(event, intent); | 350 | startMonitoringIntent(event, intent); | ... | ... |
... | @@ -15,9 +15,16 @@ | ... | @@ -15,9 +15,16 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ui.impl; | 16 | package org.onosproject.ui.impl; |
17 | 17 | ||
18 | -import com.fasterxml.jackson.databind.JsonNode; | 18 | +import java.io.IOException; |
19 | -import com.fasterxml.jackson.databind.node.ArrayNode; | 19 | +import java.util.ArrayList; |
20 | -import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | +import java.util.Collections; |
21 | +import java.util.Comparator; | ||
22 | +import java.util.HashSet; | ||
23 | +import java.util.List; | ||
24 | +import java.util.Set; | ||
25 | +import java.util.Timer; | ||
26 | +import java.util.TimerTask; | ||
27 | + | ||
21 | import org.eclipse.jetty.websocket.WebSocket; | 28 | import org.eclipse.jetty.websocket.WebSocket; |
22 | import org.onlab.osgi.ServiceDirectory; | 29 | import org.onlab.osgi.ServiceDirectory; |
23 | import org.onlab.util.AbstractAccumulator; | 30 | import org.onlab.util.AbstractAccumulator; |
... | @@ -55,15 +62,9 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; | ... | @@ -55,15 +62,9 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
55 | import org.onosproject.net.link.LinkEvent; | 62 | import org.onosproject.net.link.LinkEvent; |
56 | import org.onosproject.net.link.LinkListener; | 63 | import org.onosproject.net.link.LinkListener; |
57 | 64 | ||
58 | -import java.io.IOException; | 65 | +import com.fasterxml.jackson.databind.JsonNode; |
59 | -import java.util.ArrayList; | 66 | +import com.fasterxml.jackson.databind.node.ArrayNode; |
60 | -import java.util.Collections; | 67 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
61 | -import java.util.Comparator; | ||
62 | -import java.util.HashSet; | ||
63 | -import java.util.List; | ||
64 | -import java.util.Set; | ||
65 | -import java.util.Timer; | ||
66 | -import java.util.TimerTask; | ||
67 | 68 | ||
68 | import static com.google.common.base.Strings.isNullOrEmpty; | 69 | import static com.google.common.base.Strings.isNullOrEmpty; |
69 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; | 70 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; |
... | @@ -349,9 +350,12 @@ public class TopologyViewWebSocket | ... | @@ -349,9 +350,12 @@ public class TopologyViewWebSocket |
349 | HostId two = hostId(string(payload, "two")); | 350 | HostId two = hostId(string(payload, "two")); |
350 | 351 | ||
351 | HostToHostIntent intent = | 352 | HostToHostIntent intent = |
352 | - new HostToHostIntent(appId, one, two, | 353 | + HostToHostIntent.builder() |
353 | - DefaultTrafficSelector.emptySelector(), | 354 | + .appId(appId) |
354 | - DefaultTrafficTreatment.emptyTreatment()); | 355 | + .one(one) |
356 | + .two(two) | ||
357 | + .build(); | ||
358 | + | ||
355 | 359 | ||
356 | intentService.submit(intent); | 360 | intentService.submit(intent); |
357 | startMonitoringIntent(event, intent); | 361 | startMonitoringIntent(event, intent); |
... | @@ -374,8 +378,13 @@ public class TopologyViewWebSocket | ... | @@ -374,8 +378,13 @@ public class TopologyViewWebSocket |
374 | TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); | 378 | TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); |
375 | 379 | ||
376 | MultiPointToSinglePointIntent intent = | 380 | MultiPointToSinglePointIntent intent = |
377 | - new MultiPointToSinglePointIntent(appId, selector, treatment, | 381 | + MultiPointToSinglePointIntent.builder() |
378 | - ingressPoints, dstHost.location()); | 382 | + .appId(appId) |
383 | + .selector(selector) | ||
384 | + .treatment(treatment) | ||
385 | + .ingressPoints(ingressPoints) | ||
386 | + .egressPoint(dstHost.location()) | ||
387 | + .build(); | ||
379 | 388 | ||
380 | intentService.submit(intent); | 389 | intentService.submit(intent); |
381 | startMonitoringIntent(event, intent); | 390 | startMonitoringIntent(event, intent); | ... | ... |
-
Please register or login to post a comment