Ray Milkey

Add priority to Intents

Change-Id: Ibe63356f5b15a6aa6ca7731dba3382c3317a95ec
Showing 33 changed files with 156 additions and 59 deletions
...@@ -210,7 +210,8 @@ public class IntentPerfInstaller { ...@@ -210,7 +210,8 @@ public class IntentPerfInstaller {
210 Intent intent = new PointToPointIntent(appId, key, 210 Intent intent = new PointToPointIntent(appId, key,
211 selector, treatment, 211 selector, treatment,
212 ingress, egress, 212 ingress, egress,
213 - Collections.emptyList()); 213 + Collections.emptyList(),
214 + Intent.DEFAULT_INTENT_PRIORITY);
214 result.add(intent); 215 result.add(intent);
215 216
216 // Bump up the counter and remember this as the last key used. 217 // Bump up the counter and remember this as the last key used.
......
...@@ -75,7 +75,8 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC ...@@ -75,7 +75,8 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC
75 Intent intent = new MultiPointToSinglePointIntent(appId(), key(), 75 Intent intent = new MultiPointToSinglePointIntent(appId(), key(),
76 selector, treatment, 76 selector, treatment,
77 ingressPoints, egress, 77 ingressPoints, egress,
78 - constraints); 78 + constraints,
79 + priority());
79 service.submit(intent); 80 service.submit(intent);
80 print("Multipoint to single point intent submitted:\n%s", intent.toString()); 81 print("Multipoint to single point intent submitted:\n%s", intent.toString());
81 } 82 }
......
...@@ -70,7 +70,8 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { ...@@ -70,7 +70,8 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
70 Intent intent = new PointToPointIntent(appId(), 70 Intent intent = new PointToPointIntent(appId(),
71 key(), 71 key(),
72 selector, treatment, 72 selector, treatment,
73 - ingress, egress, constraints); 73 + ingress, egress, constraints,
74 + priority());
74 service.submit(intent); 75 service.submit(intent);
75 print("Point to point intent submitted:\n%s", intent.toString()); 76 print("Point to point intent submitted:\n%s", intent.toString());
76 } 77 }
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
15 */ 15 */
16 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
17 17
18 +import java.util.HashSet;
19 +import java.util.List;
20 +import java.util.Set;
21 +
18 import org.apache.karaf.shell.commands.Argument; 22 import org.apache.karaf.shell.commands.Argument;
19 import org.apache.karaf.shell.commands.Command; 23 import org.apache.karaf.shell.commands.Command;
20 import org.onosproject.net.ConnectPoint; 24 import org.onosproject.net.ConnectPoint;
...@@ -27,10 +31,6 @@ import org.onosproject.net.intent.Constraint; ...@@ -27,10 +31,6 @@ import org.onosproject.net.intent.Constraint;
27 import org.onosproject.net.intent.IntentService; 31 import org.onosproject.net.intent.IntentService;
28 import org.onosproject.net.intent.SinglePointToMultiPointIntent; 32 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
29 33
30 -import java.util.HashSet;
31 -import java.util.List;
32 -import java.util.Set;
33 -
34 import static org.onosproject.net.DeviceId.deviceId; 34 import static org.onosproject.net.DeviceId.deviceId;
35 import static org.onosproject.net.PortNumber.portNumber; 35 import static org.onosproject.net.PortNumber.portNumber;
36 36
...@@ -79,7 +79,8 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC ...@@ -79,7 +79,8 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC
79 treatment, 79 treatment,
80 ingressPoint, 80 ingressPoint,
81 egressPoints, 81 egressPoints,
82 - constraints); 82 + constraints,
83 + priority());
83 service.submit(intent); 84 service.submit(intent);
84 print("Single point to multipoint intent submitted:\n%s", intent.toString()); 85 print("Single point to multipoint intent submitted:\n%s", intent.toString());
85 } 86 }
......
...@@ -28,6 +28,7 @@ import org.onosproject.net.flow.DefaultTrafficSelector; ...@@ -28,6 +28,7 @@ import org.onosproject.net.flow.DefaultTrafficSelector;
28 import org.onosproject.net.flow.TrafficSelector; 28 import org.onosproject.net.flow.TrafficSelector;
29 import org.onosproject.net.flow.TrafficTreatment; 29 import org.onosproject.net.flow.TrafficTreatment;
30 import org.onosproject.net.intent.Constraint; 30 import org.onosproject.net.intent.Constraint;
31 +import org.onosproject.net.intent.Intent;
31 import org.onosproject.net.intent.Key; 32 import org.onosproject.net.intent.Key;
32 import org.onosproject.net.intent.constraint.BandwidthConstraint; 33 import org.onosproject.net.intent.constraint.BandwidthConstraint;
33 import org.onosproject.net.intent.constraint.LambdaConstraint; 34 import org.onosproject.net.intent.constraint.LambdaConstraint;
...@@ -96,6 +97,11 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { ...@@ -96,6 +97,11 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
96 required = false, multiValued = false) 97 required = false, multiValued = false)
97 private String setEthDstString = null; 98 private String setEthDstString = null;
98 99
100 + // Priorities
101 + @Option(name = "-p", aliases = "--priority", description = "Priority",
102 + required = false, multiValued = false)
103 + private int priority = Intent.DEFAULT_INTENT_PRIORITY;
104 +
99 /** 105 /**
100 * Constructs a traffic selector based on the command line arguments 106 * Constructs a traffic selector based on the command line arguments
101 * presented to the command. 107 * presented to the command.
...@@ -200,4 +206,13 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { ...@@ -200,4 +206,13 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
200 } 206 }
201 return key; 207 return key;
202 } 208 }
209 +
210 + /**
211 + * Gets the priority to use for the intent.
212 + *
213 + * @return priority
214 + */
215 + protected int priority() {
216 + return priority;
217 + }
203 } 218 }
......
...@@ -130,7 +130,8 @@ public class IntentCycleCommand extends AbstractShellCommand ...@@ -130,7 +130,8 @@ public class IntentCycleCommand extends AbstractShellCommand
130 intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()), 130 intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()),
131 selector, treatment, 131 selector, treatment,
132 ingress, egress, 132 ingress, egress,
133 - Collections.emptyList())); 133 + Collections.emptyList(),
134 + Intent.DEFAULT_INTENT_PRIORITY));
134 135
135 } 136 }
136 return intents; 137 return intents;
......
...@@ -139,7 +139,8 @@ public class IntentPushTestCommand extends AbstractShellCommand ...@@ -139,7 +139,8 @@ public class IntentPushTestCommand extends AbstractShellCommand
139 intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()), 139 intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()),
140 selector, treatment, 140 selector, treatment,
141 ingress, egress, 141 ingress, egress,
142 - Collections.emptyList())); 142 + Collections.emptyList(),
143 + Intent.DEFAULT_INTENT_PRIORITY));
143 144
144 } 145 }
145 return intents; 146 return intents;
......
...@@ -61,7 +61,8 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -61,7 +61,8 @@ public abstract class ConnectivityIntent extends Intent {
61 Collection<NetworkResource> resources, 61 Collection<NetworkResource> resources,
62 TrafficSelector selector, 62 TrafficSelector selector,
63 TrafficTreatment treatment) { 63 TrafficTreatment treatment) {
64 - this(appId, null, resources, selector, treatment, Collections.emptyList()); 64 + this(appId, null, resources, selector, treatment, Collections.emptyList(),
65 + DEFAULT_INTENT_PRIORITY);
65 } 66 }
66 67
67 /** 68 /**
...@@ -83,7 +84,8 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -83,7 +84,8 @@ public abstract class ConnectivityIntent extends Intent {
83 Collection<NetworkResource> resources, 84 Collection<NetworkResource> resources,
84 TrafficSelector selector, 85 TrafficSelector selector,
85 TrafficTreatment treatment) { 86 TrafficTreatment treatment) {
86 - this(appId, key, resources, selector, treatment, Collections.emptyList()); 87 + this(appId, key, resources, selector, treatment, Collections.emptyList(),
88 + DEFAULT_INTENT_PRIORITY);
87 } 89 }
88 90
89 /** 91 /**
...@@ -99,6 +101,7 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -99,6 +101,7 @@ public abstract class ConnectivityIntent extends Intent {
99 * @param selector traffic selector 101 * @param selector traffic selector
100 * @param treatment treatment 102 * @param treatment treatment
101 * @param constraints optional prioritized list of constraints 103 * @param constraints optional prioritized list of constraints
104 + * @param priority priority to use for flows generated by this intent
102 * @throws NullPointerException if the selector or treatment is null 105 * @throws NullPointerException if the selector or treatment is null
103 */ 106 */
104 107
...@@ -107,8 +110,9 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -107,8 +110,9 @@ public abstract class ConnectivityIntent extends Intent {
107 Collection<NetworkResource> resources, 110 Collection<NetworkResource> resources,
108 TrafficSelector selector, 111 TrafficSelector selector,
109 TrafficTreatment treatment, 112 TrafficTreatment treatment,
110 - List<Constraint> constraints) { 113 + List<Constraint> constraints,
111 - super(appId, key, resources); 114 + int priority) {
115 + super(appId, key, resources, priority);
112 this.selector = checkNotNull(selector); 116 this.selector = checkNotNull(selector);
113 this.treatment = checkNotNull(treatment); 117 this.treatment = checkNotNull(treatment);
114 this.constraints = checkNotNull(constraints); 118 this.constraints = checkNotNull(constraints);
...@@ -126,6 +130,7 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -126,6 +130,7 @@ public abstract class ConnectivityIntent extends Intent {
126 * @param selector traffic selector 130 * @param selector traffic selector
127 * @param treatment treatment 131 * @param treatment treatment
128 * @param constraints optional prioritized list of constraints 132 * @param constraints optional prioritized list of constraints
133 + * @param priority priority to use for flows generated by this intent
129 * @throws NullPointerException if the selector or treatment is null 134 * @throws NullPointerException if the selector or treatment is null
130 */ 135 */
131 136
...@@ -133,8 +138,9 @@ public abstract class ConnectivityIntent extends Intent { ...@@ -133,8 +138,9 @@ public abstract class ConnectivityIntent extends Intent {
133 Collection<NetworkResource> resources, 138 Collection<NetworkResource> resources,
134 TrafficSelector selector, 139 TrafficSelector selector,
135 TrafficTreatment treatment, 140 TrafficTreatment treatment,
136 - List<Constraint> constraints) { 141 + List<Constraint> constraints,
137 - super(appId, null, resources); 142 + int priority) {
143 + super(appId, null, resources, priority);
138 this.selector = checkNotNull(selector); 144 this.selector = checkNotNull(selector);
139 this.treatment = checkNotNull(treatment); 145 this.treatment = checkNotNull(treatment);
140 this.constraints = checkNotNull(constraints); 146 this.constraints = checkNotNull(constraints);
......
...@@ -106,7 +106,8 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -106,7 +106,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
106 TrafficSelector selector, 106 TrafficSelector selector,
107 TrafficTreatment treatment, 107 TrafficTreatment treatment,
108 List<Constraint> constraints) { 108 List<Constraint> constraints) {
109 - super(appId, key, Collections.emptyList(), selector, treatment, constraints); 109 + super(appId, key, Collections.emptyList(), selector, treatment, constraints,
110 + DEFAULT_INTENT_PRIORITY);
110 111
111 // TODO: consider whether the case one and two are same is allowed 112 // TODO: consider whether the case one and two are same is allowed
112 this.one = checkNotNull(one); 113 this.one = checkNotNull(one);
...@@ -146,6 +147,7 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -146,6 +147,7 @@ public final class HostToHostIntent extends ConnectivityIntent {
146 .add("id", id()) 147 .add("id", id())
147 .add("key", key()) 148 .add("key", key())
148 .add("appId", appId()) 149 .add("appId", appId())
150 + .add("priority", priority())
149 .add("resources", resources()) 151 .add("resources", resources())
150 .add("selector", selector()) 152 .add("selector", selector())
151 .add("treatment", treatment()) 153 .add("treatment", treatment())
......
...@@ -22,6 +22,7 @@ import org.onosproject.net.NetworkResource; ...@@ -22,6 +22,7 @@ import org.onosproject.net.NetworkResource;
22 import java.util.Collection; 22 import java.util.Collection;
23 import java.util.Objects; 23 import java.util.Objects;
24 24
25 +import static com.google.common.base.Preconditions.checkArgument;
25 import static com.google.common.base.Preconditions.checkNotNull; 26 import static com.google.common.base.Preconditions.checkNotNull;
26 import static com.google.common.base.Preconditions.checkState; 27 import static com.google.common.base.Preconditions.checkState;
27 28
...@@ -38,6 +39,11 @@ public abstract class Intent { ...@@ -38,6 +39,11 @@ public abstract class Intent {
38 private final ApplicationId appId; 39 private final ApplicationId appId;
39 private final Key key; 40 private final Key key;
40 41
42 + private final int priority;
43 + public static final int DEFAULT_INTENT_PRIORITY = 100;
44 + public static final int MAX_PRIORITY = (1 << 16) - 1;
45 + public static final int MIN_PRIORITY = 1;
46 +
41 private final Collection<NetworkResource> resources; 47 private final Collection<NetworkResource> resources;
42 48
43 private static IdGenerator idGenerator; 49 private static IdGenerator idGenerator;
...@@ -50,6 +56,7 @@ public abstract class Intent { ...@@ -50,6 +56,7 @@ public abstract class Intent {
50 this.appId = null; 56 this.appId = null;
51 this.key = null; 57 this.key = null;
52 this.resources = null; 58 this.resources = null;
59 + this.priority = DEFAULT_INTENT_PRIORITY;
53 } 60 }
54 61
55 /** 62 /**
...@@ -60,7 +67,7 @@ public abstract class Intent { ...@@ -60,7 +67,7 @@ public abstract class Intent {
60 */ 67 */
61 protected Intent(ApplicationId appId, 68 protected Intent(ApplicationId appId,
62 Collection<NetworkResource> resources) { 69 Collection<NetworkResource> resources) {
63 - this(appId, null, resources); 70 + this(appId, null, resources, DEFAULT_INTENT_PRIORITY);
64 } 71 }
65 72
66 /** 73 /**
...@@ -72,11 +79,14 @@ public abstract class Intent { ...@@ -72,11 +79,14 @@ public abstract class Intent {
72 */ 79 */
73 protected Intent(ApplicationId appId, 80 protected Intent(ApplicationId appId,
74 Key key, 81 Key key,
75 - Collection<NetworkResource> resources) { 82 + Collection<NetworkResource> resources,
83 + int priority) {
76 checkState(idGenerator != null, "Id generator is not bound."); 84 checkState(idGenerator != null, "Id generator is not bound.");
85 + checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY);
77 this.id = IntentId.valueOf(idGenerator.getNewId()); 86 this.id = IntentId.valueOf(idGenerator.getNewId());
78 this.appId = checkNotNull(appId, "Application ID cannot be null"); 87 this.appId = checkNotNull(appId, "Application ID cannot be null");
79 this.key = (key != null) ? key : Key.of(id.fingerprint(), appId); 88 this.key = (key != null) ? key : Key.of(id.fingerprint(), appId);
89 + this.priority = priority;
80 this.resources = checkNotNull(resources); 90 this.resources = checkNotNull(resources);
81 } 91 }
82 92
...@@ -99,6 +109,15 @@ public abstract class Intent { ...@@ -99,6 +109,15 @@ public abstract class Intent {
99 } 109 }
100 110
101 /** 111 /**
112 + * Returns the priority of the intent.
113 + *
114 + * @return intent priority
115 + */
116 + public int priority() {
117 + return priority;
118 + }
119 +
120 + /**
102 * Returns the collection of resources required for this intent. 121 * Returns the collection of resources required for this intent.
103 * 122 *
104 * @return collection of resources; may be null 123 * @return collection of resources; may be null
......
...@@ -59,7 +59,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -59,7 +59,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
59 ConnectPoint ingressPoint, 59 ConnectPoint ingressPoint,
60 ConnectPoint egressPoint) { 60 ConnectPoint egressPoint) {
61 this(appId, selector, treatment, links, ingressPoint, egressPoint, 61 this(appId, selector, treatment, links, ingressPoint, egressPoint,
62 - Collections.emptyList()); 62 + Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
63 } 63 }
64 64
65 /** 65 /**
...@@ -74,6 +74,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -74,6 +74,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
74 * @param ingressPoint ingress point 74 * @param ingressPoint ingress point
75 * @param egressPoint egress point 75 * @param egressPoint egress point
76 * @param constraints optional list of constraints 76 * @param constraints optional list of constraints
77 + * @param priority priority to use for the flows generated by this intent
77 * @throws NullPointerException {@code path} is null 78 * @throws NullPointerException {@code path} is null
78 */ 79 */
79 public LinkCollectionIntent(ApplicationId appId, 80 public LinkCollectionIntent(ApplicationId appId,
...@@ -82,8 +83,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -82,8 +83,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
82 Set<Link> links, 83 Set<Link> links,
83 ConnectPoint ingressPoint, 84 ConnectPoint ingressPoint,
84 ConnectPoint egressPoint, 85 ConnectPoint egressPoint,
85 - List<Constraint> constraints) { 86 + List<Constraint> constraints,
86 - super(appId, resources(links), selector, treatment, constraints); 87 + int priority) {
88 + super(appId, resources(links), selector, treatment, constraints, priority);
87 this.links = links; 89 this.links = links;
88 this.ingressPoints = ImmutableSet.of(ingressPoint); 90 this.ingressPoints = ImmutableSet.of(ingressPoint);
89 this.egressPoints = ImmutableSet.of(egressPoint); 91 this.egressPoints = ImmutableSet.of(egressPoint);
...@@ -101,6 +103,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -101,6 +103,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
101 * @param ingressPoints Set of ingress points 103 * @param ingressPoints Set of ingress points
102 * @param egressPoints Set of egress points 104 * @param egressPoints Set of egress points
103 * @param constraints the constraints 105 * @param constraints the constraints
106 + * @param priority priority to use for the flows generated by this intent
104 * @throws NullPointerException {@code path} is null 107 * @throws NullPointerException {@code path} is null
105 */ 108 */
106 public LinkCollectionIntent(ApplicationId appId, 109 public LinkCollectionIntent(ApplicationId appId,
...@@ -109,8 +112,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -109,8 +112,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
109 Set<Link> links, 112 Set<Link> links,
110 Set<ConnectPoint> ingressPoints, 113 Set<ConnectPoint> ingressPoints,
111 Set<ConnectPoint> egressPoints, 114 Set<ConnectPoint> egressPoints,
112 - List<Constraint> constraints) { 115 + List<Constraint> constraints,
113 - super(appId, resources(links), selector, treatment, constraints); 116 + int priority) {
117 + super(appId, resources(links), selector, treatment, constraints, priority);
114 118
115 this.links = links; 119 this.links = links;
116 this.ingressPoints = ImmutableSet.copyOf(ingressPoints); 120 this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
...@@ -166,6 +170,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -166,6 +170,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
166 .add("id", id()) 170 .add("id", id())
167 .add("key", key()) 171 .add("key", key())
168 .add("appId", appId()) 172 .add("appId", appId())
173 + .add("priority", priority())
169 .add("resources", resources()) 174 .add("resources", resources())
170 .add("selector", selector()) 175 .add("selector", selector())
171 .add("treatment", treatment()) 176 .add("treatment", treatment())
......
...@@ -74,7 +74,8 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -74,7 +74,8 @@ public final class MplsIntent extends ConnectivityIntent {
74 Optional<MplsLabel> egressLabel, 74 Optional<MplsLabel> egressLabel,
75 List<Constraint> constraints) { 75 List<Constraint> constraints) {
76 76
77 - super(appId, Collections.emptyList(), selector, treatment, constraints); 77 + super(appId, Collections.emptyList(), selector, treatment, constraints,
78 + DEFAULT_INTENT_PRIORITY);
78 79
79 checkNotNull(ingressPoint); 80 checkNotNull(ingressPoint);
80 checkNotNull(egressPoint); 81 checkNotNull(egressPoint);
...@@ -144,6 +145,7 @@ public final class MplsIntent extends ConnectivityIntent { ...@@ -144,6 +145,7 @@ public final class MplsIntent extends ConnectivityIntent {
144 return MoreObjects.toStringHelper(getClass()) 145 return MoreObjects.toStringHelper(getClass())
145 .add("id", id()) 146 .add("id", id())
146 .add("appId", appId()) 147 .add("appId", appId())
148 + .add("priority", priority())
147 .add("selector", selector()) 149 .add("selector", selector())
148 .add("treatment", treatment()) 150 .add("treatment", treatment())
149 .add("ingressPoint", ingressPoint) 151 .add("ingressPoint", ingressPoint)
......
...@@ -59,7 +59,8 @@ public final class MplsPathIntent extends PathIntent { ...@@ -59,7 +59,8 @@ public final class MplsPathIntent extends PathIntent {
59 public MplsPathIntent(ApplicationId appId, TrafficSelector selector, 59 public MplsPathIntent(ApplicationId appId, TrafficSelector selector,
60 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, 60 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
61 Optional<MplsLabel> egressLabel, List<Constraint> constraints) { 61 Optional<MplsLabel> egressLabel, List<Constraint> constraints) {
62 - super(appId, selector, treatment, path, constraints); 62 + super(appId, selector, treatment, path, constraints,
63 + DEFAULT_INTENT_PRIORITY);
63 64
64 checkNotNull(ingressLabel); 65 checkNotNull(ingressLabel);
65 checkNotNull(egressLabel); 66 checkNotNull(egressLabel);
......
...@@ -56,7 +56,8 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -56,7 +56,8 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
56 TrafficTreatment treatment, 56 TrafficTreatment treatment,
57 Set<ConnectPoint> ingressPoints, 57 Set<ConnectPoint> ingressPoints,
58 ConnectPoint egressPoint) { 58 ConnectPoint egressPoint) {
59 - this(appId, selector, treatment, ingressPoints, egressPoint, Collections.emptyList()); 59 + this(appId, selector, treatment, ingressPoints, egressPoint,
60 + Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
60 } 61 }
61 62
62 /** 63 /**
...@@ -70,6 +71,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -70,6 +71,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
70 * @param ingressPoints set of ports from which ingress traffic originates 71 * @param ingressPoints set of ports from which ingress traffic originates
71 * @param egressPoint port to which traffic will egress 72 * @param egressPoint port to which traffic will egress
72 * @param constraints constraints to apply to the intent 73 * @param constraints constraints to apply to the intent
74 + * @param priority priority to use for flows generated by this intent
73 * @throws NullPointerException if {@code ingressPoints} or 75 * @throws NullPointerException if {@code ingressPoints} or
74 * {@code egressPoint} is null. 76 * {@code egressPoint} is null.
75 * @throws IllegalArgumentException if the size of {@code ingressPoints} is 77 * @throws IllegalArgumentException if the size of {@code ingressPoints} is
...@@ -81,8 +83,10 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -81,8 +83,10 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
81 TrafficTreatment treatment, 83 TrafficTreatment treatment,
82 Set<ConnectPoint> ingressPoints, 84 Set<ConnectPoint> ingressPoints,
83 ConnectPoint egressPoint, 85 ConnectPoint egressPoint,
84 - List<Constraint> constraints) { 86 + List<Constraint> constraints,
85 - super(appId, key, Collections.emptyList(), selector, treatment, constraints); 87 + int priority) {
88 + super(appId, key, Collections.emptyList(), selector, treatment, constraints,
89 + priority);
86 90
87 checkNotNull(ingressPoints); 91 checkNotNull(ingressPoints);
88 checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty"); 92 checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
...@@ -104,6 +108,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -104,6 +108,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
104 * @param ingressPoints set of ports from which ingress traffic originates 108 * @param ingressPoints set of ports from which ingress traffic originates
105 * @param egressPoint port to which traffic will egress 109 * @param egressPoint port to which traffic will egress
106 * @param constraints constraints to apply to the intent 110 * @param constraints constraints to apply to the intent
111 + * @param priority priority to use for flows generated by this intent
107 * @throws NullPointerException if {@code ingressPoints} or 112 * @throws NullPointerException if {@code ingressPoints} or
108 * {@code egressPoint} is null. 113 * {@code egressPoint} is null.
109 * @throws IllegalArgumentException if the size of {@code ingressPoints} is 114 * @throws IllegalArgumentException if the size of {@code ingressPoints} is
...@@ -114,8 +119,10 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -114,8 +119,10 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
114 TrafficTreatment treatment, 119 TrafficTreatment treatment,
115 Set<ConnectPoint> ingressPoints, 120 Set<ConnectPoint> ingressPoints,
116 ConnectPoint egressPoint, 121 ConnectPoint egressPoint,
117 - List<Constraint> constraints) { 122 + List<Constraint> constraints,
118 - this(appId, null, selector, treatment, ingressPoints, egressPoint, constraints); 123 + int priority) {
124 + this(appId, null, selector, treatment, ingressPoints, egressPoint,
125 + constraints, priority);
119 } 126 }
120 127
121 /** 128 /**
...@@ -152,6 +159,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -152,6 +159,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
152 .add("id", id()) 159 .add("id", id())
153 .add("key", key()) 160 .add("key", key())
154 .add("appId", appId()) 161 .add("appId", appId())
162 + .add("priority", priority())
155 .add("resources", resources()) 163 .add("resources", resources())
156 .add("selector", selector()) 164 .add("selector", selector())
157 .add("treatment", treatment()) 165 .add("treatment", treatment())
......
...@@ -54,7 +54,7 @@ public final class OpticalConnectivityIntent extends Intent { ...@@ -54,7 +54,7 @@ public final class OpticalConnectivityIntent extends Intent {
54 public OpticalConnectivityIntent(ApplicationId appId, 54 public OpticalConnectivityIntent(ApplicationId appId,
55 Key key, 55 Key key,
56 ConnectPoint src, ConnectPoint dst) { 56 ConnectPoint src, ConnectPoint dst) {
57 - super(appId, key, Collections.emptyList()); 57 + super(appId, key, Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
58 this.src = src; 58 this.src = src;
59 this.dst = dst; 59 this.dst = dst;
60 } 60 }
......
...@@ -48,7 +48,8 @@ public class PathIntent extends ConnectivityIntent { ...@@ -48,7 +48,8 @@ public class PathIntent extends ConnectivityIntent {
48 */ 48 */
49 public PathIntent(ApplicationId appId, TrafficSelector selector, 49 public PathIntent(ApplicationId appId, TrafficSelector selector,
50 TrafficTreatment treatment, Path path) { 50 TrafficTreatment treatment, Path path) {
51 - this(appId, selector, treatment, path, Collections.emptyList()); 51 + this(appId, selector, treatment, path, Collections.emptyList(),
52 + DEFAULT_INTENT_PRIORITY);
52 } 53 }
53 54
54 /** 55 /**
...@@ -60,11 +61,14 @@ public class PathIntent extends ConnectivityIntent { ...@@ -60,11 +61,14 @@ public class PathIntent extends ConnectivityIntent {
60 * @param treatment treatment 61 * @param treatment treatment
61 * @param path traversed links 62 * @param path traversed links
62 * @param constraints optional list of constraints 63 * @param constraints optional list of constraints
64 + * @param priority priority to use for the generated flows
63 * @throws NullPointerException {@code path} is null 65 * @throws NullPointerException {@code path} is null
64 */ 66 */
65 public PathIntent(ApplicationId appId, TrafficSelector selector, 67 public PathIntent(ApplicationId appId, TrafficSelector selector,
66 - TrafficTreatment treatment, Path path, List<Constraint> constraints) { 68 + TrafficTreatment treatment, Path path, List<Constraint> constraints,
67 - super(appId, resources(path.links()), selector, treatment, constraints); 69 + int priority) {
70 + super(appId, resources(path.links()), selector, treatment, constraints,
71 + priority);
68 PathIntent.validate(path.links()); 72 PathIntent.validate(path.links());
69 this.path = path; 73 this.path = path;
70 } 74 }
...@@ -123,6 +127,7 @@ public class PathIntent extends ConnectivityIntent { ...@@ -123,6 +127,7 @@ public class PathIntent extends ConnectivityIntent {
123 return MoreObjects.toStringHelper(getClass()) 127 return MoreObjects.toStringHelper(getClass())
124 .add("id", id()) 128 .add("id", id())
125 .add("appId", appId()) 129 .add("appId", appId())
130 + .add("priority", priority())
126 .add("resources", resources()) 131 .add("resources", resources())
127 .add("selector", selector()) 132 .add("selector", selector())
128 .add("treatment", treatment()) 133 .add("treatment", treatment())
......
...@@ -49,6 +49,7 @@ public final class PointToPointIntent extends ConnectivityIntent { ...@@ -49,6 +49,7 @@ public final class PointToPointIntent extends ConnectivityIntent {
49 * @param ingressPoint ingress port 49 * @param ingressPoint ingress port
50 * @param egressPoint egress port 50 * @param egressPoint egress port
51 * @param constraints optional list of constraints 51 * @param constraints optional list of constraints
52 + * @param priority priority to use for flows generated by this intent
52 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. 53 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
53 */ 54 */
54 public PointToPointIntent(ApplicationId appId, 55 public PointToPointIntent(ApplicationId appId,
...@@ -57,8 +58,10 @@ public final class PointToPointIntent extends ConnectivityIntent { ...@@ -57,8 +58,10 @@ public final class PointToPointIntent extends ConnectivityIntent {
57 TrafficTreatment treatment, 58 TrafficTreatment treatment,
58 ConnectPoint ingressPoint, 59 ConnectPoint ingressPoint,
59 ConnectPoint egressPoint, 60 ConnectPoint egressPoint,
60 - List<Constraint> constraints) { 61 + List<Constraint> constraints,
61 - super(appId, key, Collections.emptyList(), selector, treatment, constraints); 62 + int priority) {
63 + super(appId, key, Collections.emptyList(), selector, treatment, constraints,
64 + priority);
62 65
63 checkNotNull(ingressPoint); 66 checkNotNull(ingressPoint);
64 checkNotNull(egressPoint); 67 checkNotNull(egressPoint);
...@@ -85,7 +88,8 @@ public final class PointToPointIntent extends ConnectivityIntent { ...@@ -85,7 +88,8 @@ public final class PointToPointIntent extends ConnectivityIntent {
85 ConnectPoint ingressPoint, 88 ConnectPoint ingressPoint,
86 ConnectPoint egressPoint) { 89 ConnectPoint egressPoint) {
87 this(appId, null, selector, treatment, ingressPoint, egressPoint, 90 this(appId, null, selector, treatment, ingressPoint, egressPoint,
88 - ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); 91 + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)),
92 + DEFAULT_INTENT_PRIORITY);
89 } 93 }
90 94
91 /** 95 /**
...@@ -98,14 +102,17 @@ public final class PointToPointIntent extends ConnectivityIntent { ...@@ -98,14 +102,17 @@ public final class PointToPointIntent extends ConnectivityIntent {
98 * @param ingressPoint ingress port 102 * @param ingressPoint ingress port
99 * @param egressPoint egress port 103 * @param egressPoint egress port
100 * @param constraints optional list of constraints 104 * @param constraints optional list of constraints
105 + * @param priority priority to use for flows generated by this intent
101 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. 106 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
102 */ 107 */
103 public PointToPointIntent(ApplicationId appId, TrafficSelector selector, 108 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
104 TrafficTreatment treatment, 109 TrafficTreatment treatment,
105 ConnectPoint ingressPoint, 110 ConnectPoint ingressPoint,
106 ConnectPoint egressPoint, 111 ConnectPoint egressPoint,
107 - List<Constraint> constraints) { 112 + List<Constraint> constraints,
108 - super(appId, null, Collections.emptyList(), selector, treatment, constraints); 113 + int priority) {
114 + super(appId, null, Collections.emptyList(), selector, treatment,
115 + constraints, priority);
109 116
110 checkNotNull(ingressPoint); 117 checkNotNull(ingressPoint);
111 checkNotNull(egressPoint); 118 checkNotNull(egressPoint);
...@@ -150,6 +157,7 @@ public final class PointToPointIntent extends ConnectivityIntent { ...@@ -150,6 +157,7 @@ public final class PointToPointIntent extends ConnectivityIntent {
150 .add("id", id()) 157 .add("id", id())
151 .add("key", key()) 158 .add("key", key())
152 .add("appId", appId()) 159 .add("appId", appId())
160 + .add("priority", priority())
153 .add("resources", resources()) 161 .add("resources", resources())
154 .add("selector", selector()) 162 .add("selector", selector())
155 .add("treatment", treatment()) 163 .add("treatment", treatment())
......
...@@ -54,7 +54,9 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -54,7 +54,9 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
54 public SinglePointToMultiPointIntent(ApplicationId appId, 54 public SinglePointToMultiPointIntent(ApplicationId appId,
55 TrafficSelector selector, TrafficTreatment treatment, 55 TrafficSelector selector, TrafficTreatment treatment,
56 ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints) { 56 ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints) {
57 - this(appId, null, selector, treatment, ingressPoint, egressPoints, Collections.emptyList()); 57 + this(appId, null, selector, treatment, ingressPoint, egressPoints,
58 + Collections.emptyList(),
59 + DEFAULT_INTENT_PRIORITY);
58 } 60 }
59 61
60 /** 62 /**
...@@ -67,6 +69,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -67,6 +69,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
67 * @param ingressPoint port on which traffic will ingress 69 * @param ingressPoint port on which traffic will ingress
68 * @param egressPoints set of ports on which traffic will egress 70 * @param egressPoints set of ports on which traffic will egress
69 * @param constraints constraints to apply to the intent 71 * @param constraints constraints to apply to the intent
72 + * @param priority priority to use for flows generated by this intent
70 * @throws NullPointerException if {@code ingressPoint} or 73 * @throws NullPointerException if {@code ingressPoint} or
71 * {@code egressPoints} is null 74 * {@code egressPoints} is null
72 * @throws IllegalArgumentException if the size of {@code egressPoints} is 75 * @throws IllegalArgumentException if the size of {@code egressPoints} is
...@@ -76,8 +79,10 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -76,8 +79,10 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
76 Key key, 79 Key key,
77 TrafficSelector selector, TrafficTreatment treatment, 80 TrafficSelector selector, TrafficTreatment treatment,
78 ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints, 81 ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints,
79 - List<Constraint> constraints) { 82 + List<Constraint> constraints,
80 - super(appId, key, Collections.emptyList(), selector, treatment, constraints); 83 + int priority) {
84 + super(appId, key, Collections.emptyList(), selector, treatment, constraints,
85 + priority);
81 checkNotNull(egressPoints); 86 checkNotNull(egressPoints);
82 checkNotNull(ingressPoint); 87 checkNotNull(ingressPoint);
83 checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty"); 88 checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty");
...@@ -122,6 +127,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -122,6 +127,7 @@ public final class SinglePointToMultiPointIntent extends ConnectivityIntent {
122 .add("id", id()) 127 .add("id", id())
123 .add("key", key()) 128 .add("key", key())
124 .add("appId", appId()) 129 .add("appId", appId())
130 + .add("priority", priority())
125 .add("resources", resources()) 131 .add("resources", resources())
126 .add("selector", selector()) 132 .add("selector", selector())
127 .add("treatment", treatment()) 133 .add("treatment", treatment())
......
...@@ -107,7 +107,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -107,7 +107,8 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
107 TrafficSelector selector, 107 TrafficSelector selector,
108 TrafficTreatment treatment, 108 TrafficTreatment treatment,
109 List<Constraint> constraints) { 109 List<Constraint> constraints) {
110 - super(appId, key, Collections.emptyList(), selector, treatment, constraints); 110 + super(appId, key, Collections.emptyList(), selector, treatment, constraints,
111 + DEFAULT_INTENT_PRIORITY);
111 112
112 // TODO: consider whether the case one and two are same is allowed 113 // TODO: consider whether the case one and two are same is allowed
113 this.one = checkNotNull(one); 114 this.one = checkNotNull(one);
...@@ -147,6 +148,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent { ...@@ -147,6 +148,7 @@ public final class TwoWayP2PIntent extends ConnectivityIntent {
147 .add("id", id()) 148 .add("id", id())
148 .add("key", key()) 149 .add("key", key())
149 .add("appId", appId()) 150 .add("appId", appId())
151 + .add("priority", priority())
150 .add("resources", resources()) 152 .add("resources", resources())
151 .add("selector", selector()) 153 .add("selector", selector())
152 .add("treatment", treatment()) 154 .add("treatment", treatment())
......
...@@ -134,7 +134,8 @@ public class LinkCollectionIntentTest extends IntentTest { ...@@ -134,7 +134,8 @@ public class LinkCollectionIntentTest extends IntentTest {
134 links1, 134 links1,
135 ingress, 135 ingress,
136 egress, 136 egress,
137 - constraints); 137 + constraints,
138 + 8888);
138 139
139 final Set<Link> createdLinks = collectionIntent.links(); 140 final Set<Link> createdLinks = collectionIntent.links();
140 assertThat(createdLinks, hasSize(1)); 141 assertThat(createdLinks, hasSize(1));
......
...@@ -98,7 +98,8 @@ public class HostToHostIntentCompiler ...@@ -98,7 +98,8 @@ public class HostToHostIntentCompiler
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 new PathIntent(intent.appId(), selector, intent.treatment(),
101 - path, intent.constraints()); 101 + path, intent.constraints(),
102 + intent.priority());
102 } 103 }
103 104
104 } 105 }
......
...@@ -89,12 +89,14 @@ public class MultiPointToSinglePointIntentCompiler ...@@ -89,12 +89,14 @@ public class MultiPointToSinglePointIntentCompiler
89 } 89 }
90 } 90 }
91 91
92 + Set<ConnectPoint> egress = ImmutableSet.of(intent.egressPoint());
92 Intent result = new LinkCollectionIntent(intent.appId(), 93 Intent result = new LinkCollectionIntent(intent.appId(),
93 intent.selector(), intent.treatment(), 94 intent.selector(), intent.treatment(),
94 Sets.newHashSet(links.values()), 95 Sets.newHashSet(links.values()),
95 intent.ingressPoints(), 96 intent.ingressPoints(),
96 ImmutableSet.of(intent.egressPoint()), 97 ImmutableSet.of(intent.egressPoint()),
97 - Collections.emptyList()); 98 + Collections.emptyList(),
99 + intent.priority());
98 return Arrays.asList(result); 100 return Arrays.asList(result);
99 } 101 }
100 102
......
...@@ -93,7 +93,8 @@ public class PointToPointIntentCompiler ...@@ -93,7 +93,8 @@ public class PointToPointIntentCompiler
93 PointToPointIntent intent) { 93 PointToPointIntent intent) {
94 return new PathIntent(intent.appId(), 94 return new PathIntent(intent.appId(),
95 intent.selector(), intent.treatment(), path, 95 intent.selector(), intent.treatment(), path,
96 - intent.constraints()); 96 + intent.constraints(),
97 + intent.priority());
97 } 98 }
98 99
99 } 100 }
......
...@@ -70,7 +70,9 @@ public class SinglePointToMultiPointIntentCompiler ...@@ -70,7 +70,9 @@ public class SinglePointToMultiPointIntentCompiler
70 intent.selector(), 70 intent.selector(),
71 intent.treatment(), links, 71 intent.treatment(), links,
72 ImmutableSet.of(intent.ingressPoint()), 72 ImmutableSet.of(intent.ingressPoint()),
73 - intent.egressPoints(), Collections.emptyList()); 73 + intent.egressPoints(),
74 + Collections.emptyList(),
75 + intent.priority());
74 76
75 return Arrays.asList(result); 77 return Arrays.asList(result);
76 } 78 }
......
...@@ -51,11 +51,11 @@ public class TwoWayP2PIntentCompiler ...@@ -51,11 +51,11 @@ public class TwoWayP2PIntentCompiler
51 new PointToPointIntent(intent.appId(), intent.key(), 51 new PointToPointIntent(intent.appId(), intent.key(),
52 intent.selector(), intent.treatment(), 52 intent.selector(), intent.treatment(),
53 intent.one(), intent.two(), 53 intent.one(), intent.two(),
54 - intent.constraints()), 54 + intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY),
55 new PointToPointIntent(intent.appId(), intent.key(), 55 new PointToPointIntent(intent.appId(), intent.key(),
56 intent.selector(), intent.treatment(), 56 intent.selector(), intent.treatment(),
57 intent.two(), intent.one(), 57 intent.two(), intent.one(),
58 - intent.constraints())); 58 + intent.constraints(), Intent.DEFAULT_INTENT_PRIORITY));
59 59
60 } 60 }
61 } 61 }
......
...@@ -186,7 +186,7 @@ public class LinkCollectionIntentInstaller ...@@ -186,7 +186,7 @@ public class LinkCollectionIntentInstaller
186 treatment = intentTreatment; 186 treatment = intentTreatment;
187 } 187 }
188 FlowRule rule = new DefaultFlowRule(deviceId, 188 FlowRule rule = new DefaultFlowRule(deviceId,
189 - selector, treatment, 123, appId, 189 + selector, treatment, intent.priority(), appId,
190 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 190 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)),
191 0, true); 191 0, true);
192 result.add(new FlowRuleOperation(rule, operation)); 192 result.add(new FlowRuleOperation(rule, operation));
......
...@@ -280,7 +280,7 @@ public class MplsPathIntentInstaller implements IntentInstaller<MplsPathIntent> ...@@ -280,7 +280,7 @@ public class MplsPathIntentInstaller implements IntentInstaller<MplsPathIntent>
280 deviceId, 280 deviceId,
281 selector, 281 selector,
282 treat, 282 treat,
283 - 123, // FIXME 123 283 + intent.priority(),
284 appId, 284 appId,
285 0, 285 0,
286 true); 286 true);
......
...@@ -99,7 +99,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -99,7 +99,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
99 .setOutput(link.src().port()).build(); 99 .setOutput(link.src().port()).build();
100 100
101 FlowRule rule = new DefaultFlowRule(link.src().deviceId(), 101 FlowRule rule = new DefaultFlowRule(link.src().deviceId(),
102 - builder.build(), treatment, 123, //FIXME 123 102 + builder.build(), treatment, intent.priority(),
103 appId, 103 appId,
104 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 104 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)),
105 0, true); 105 0, true);
...@@ -127,7 +127,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -127,7 +127,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
127 (links.hasNext() ? builder() : builder(intent.treatment())) 127 (links.hasNext() ? builder() : builder(intent.treatment()))
128 .setOutput(link.src().port()).build(); 128 .setOutput(link.src().port()).build();
129 FlowRule rule = new DefaultFlowRule(link.src().deviceId(), 129 FlowRule rule = new DefaultFlowRule(link.src().deviceId(),
130 - builder.build(), treatment, 123, appId, 130 + builder.build(), treatment, intent.priority(), appId,
131 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 131 new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)),
132 0, true); 132 0, true);
133 rules.add(new FlowRuleOperation(rule, FlowRuleOperation.Type.REMOVE)); 133 rules.add(new FlowRuleOperation(rule, FlowRuleOperation.Type.REMOVE));
......
...@@ -90,7 +90,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { ...@@ -90,7 +90,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
90 return new PointToPointIntent(APPID, selector, treatment, 90 return new PointToPointIntent(APPID, selector, treatment,
91 connectPoint(ingressIdString, 1), 91 connectPoint(ingressIdString, 1),
92 connectPoint(egressIdString, 1), 92 connectPoint(egressIdString, 1),
93 - constraints); 93 + constraints, Intent.DEFAULT_INTENT_PRIORITY);
94 } 94 }
95 95
96 /** 96 /**
......
...@@ -74,7 +74,7 @@ public class PathConstraintCalculationTest extends AbstractIntentTest { ...@@ -74,7 +74,7 @@ public class PathConstraintCalculationTest extends AbstractIntentTest {
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 new PathIntent(APP_ID, selector, treatment,
77 - new DefaultPath(PID, links, hops), constraints); 77 + new DefaultPath(PID, links, hops), constraints, 333);
78 } 78 }
79 79
80 /** 80 /**
......
...@@ -62,7 +62,8 @@ public class PathIntentInstallerTest extends IntentInstallerTest { ...@@ -62,7 +62,8 @@ public class PathIntentInstallerTest extends IntentInstallerTest {
62 installer.coreService = testCoreService; 62 installer.coreService = testCoreService;
63 installer.intentManager = new MockIntentManager(PathIntent.class); 63 installer.intentManager = new MockIntentManager(PathIntent.class);
64 intent = new PathIntent(APP_ID, selector, treatment, 64 intent = new PathIntent(APP_ID, selector, treatment,
65 - new DefaultPath(PID, links, hops), ImmutableList.of()); 65 + new DefaultPath(PID, links, hops), ImmutableList.of(),
66 + 77);
66 } 67 }
67 68
68 /** 69 /**
......
...@@ -52,6 +52,8 @@ public final class ConnectivityIntentCodec extends JsonCodec<ConnectivityIntent> ...@@ -52,6 +52,8 @@ public final class ConnectivityIntentCodec extends JsonCodec<ConnectivityIntent>
52 result.set("treatment", treatmentCodec.encode(intent.treatment(), context)); 52 result.set("treatment", treatmentCodec.encode(intent.treatment(), context));
53 } 53 }
54 54
55 + result.put("priority", intent.priority());
56 +
55 if (intent.constraints() != null) { 57 if (intent.constraints() != null) {
56 final ArrayNode jsonConstraints = result.putArray("constraints"); 58 final ArrayNode jsonConstraints = result.putArray("constraints");
57 59
......
...@@ -38,6 +38,7 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -38,6 +38,7 @@ import org.onosproject.net.flow.TrafficTreatment;
38 import org.onosproject.net.intent.Constraint; 38 import org.onosproject.net.intent.Constraint;
39 import org.onosproject.net.intent.HostToHostIntent; 39 import org.onosproject.net.intent.HostToHostIntent;
40 import org.onosproject.net.intent.AbstractIntentTest; 40 import org.onosproject.net.intent.AbstractIntentTest;
41 +import org.onosproject.net.intent.Intent;
41 import org.onosproject.net.intent.PointToPointIntent; 42 import org.onosproject.net.intent.PointToPointIntent;
42 import org.onosproject.net.intent.constraint.AnnotationConstraint; 43 import org.onosproject.net.intent.constraint.AnnotationConstraint;
43 import org.onosproject.net.intent.constraint.AsymmetricPathConstraint; 44 import org.onosproject.net.intent.constraint.AsymmetricPathConstraint;
...@@ -147,7 +148,8 @@ public class IntentCodecTest extends AbstractIntentTest { ...@@ -147,7 +148,8 @@ public class IntentCodecTest extends AbstractIntentTest {
147 148
148 final PointToPointIntent intent = 149 final PointToPointIntent intent =
149 new PointToPointIntent(appId, selector, treatment, 150 new PointToPointIntent(appId, selector, treatment,
150 - ingress, egress, constraints); 151 + ingress, egress, constraints,
152 + Intent.DEFAULT_INTENT_PRIORITY);
151 153
152 final CodecContext context = new MockCodecContext(); 154 final CodecContext context = new MockCodecContext();
153 final JsonCodec<PointToPointIntent> intentCodec = 155 final JsonCodec<PointToPointIntent> intentCodec =
......