Committed by
Brian O'Connor
Add keys to intents
- use Key class rather than String for intent keys - add CLI option to specify a string key - add key field to constructors for connectivity intents - translate id into a key if no key is specified Change-Id: I69ffbad93bc3daddf06a67cb0cffa2130e781b37
Showing
19 changed files
with
210 additions
and
32 deletions
... | @@ -54,7 +54,8 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { | ... | @@ -54,7 +54,8 @@ public class AddHostToHostIntentCommand extends ConnectivityIntentCommand { |
54 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); | 54 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
55 | List<Constraint> constraints = buildConstraints(); | 55 | List<Constraint> constraints = buildConstraints(); |
56 | 56 | ||
57 | - HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId, | 57 | + HostToHostIntent intent = new HostToHostIntent(appId(), key(), |
58 | + oneId, twoId, | ||
58 | selector, treatment, | 59 | selector, treatment, |
59 | constraints); | 60 | constraints); |
60 | service.submit(intent); | 61 | service.submit(intent); | ... | ... |
... | @@ -72,7 +72,8 @@ public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentC | ... | @@ -72,7 +72,8 @@ 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(), selector, treatment, | 75 | + Intent intent = new MultiPointToSinglePointIntent(appId(), key(), |
76 | + selector, treatment, | ||
76 | ingressPoints, egress, | 77 | ingressPoints, egress, |
77 | constraints); | 78 | constraints); |
78 | service.submit(intent); | 79 | service.submit(intent); | ... | ... |
... | @@ -56,7 +56,7 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -56,7 +56,7 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
56 | PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | 56 | PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); |
57 | ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | 57 | ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); |
58 | 58 | ||
59 | - Intent intent = new OpticalConnectivityIntent(appId(), ingress, egress); | 59 | + Intent intent = new OpticalConnectivityIntent(appId(), key(), ingress, egress); |
60 | service.submit(intent); | 60 | service.submit(intent); |
61 | print("Optical intent submitted:\n%s", intent.toString()); | 61 | print("Optical intent submitted:\n%s", intent.toString()); |
62 | } | 62 | } | ... | ... |
... | @@ -15,9 +15,6 @@ | ... | @@ -15,9 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
17 | 17 | ||
18 | -import static org.onosproject.net.DeviceId.deviceId; | ||
19 | -import static org.onosproject.net.PortNumber.portNumber; | ||
20 | - | ||
21 | import java.util.List; | 18 | import java.util.List; |
22 | 19 | ||
23 | import org.apache.karaf.shell.commands.Argument; | 20 | import org.apache.karaf.shell.commands.Argument; |
... | @@ -32,6 +29,9 @@ import org.onosproject.net.intent.Intent; | ... | @@ -32,6 +29,9 @@ import org.onosproject.net.intent.Intent; |
32 | import org.onosproject.net.intent.IntentService; | 29 | import org.onosproject.net.intent.IntentService; |
33 | import org.onosproject.net.intent.PointToPointIntent; | 30 | import org.onosproject.net.intent.PointToPointIntent; |
34 | 31 | ||
32 | +import static org.onosproject.net.DeviceId.deviceId; | ||
33 | +import static org.onosproject.net.PortNumber.portNumber; | ||
34 | + | ||
35 | /** | 35 | /** |
36 | * Installs point-to-point connectivity intents. | 36 | * Installs point-to-point connectivity intents. |
37 | */ | 37 | */ |
... | @@ -67,7 +67,9 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { | ... | @@ -67,7 +67,9 @@ public class AddPointToPointIntentCommand extends ConnectivityIntentCommand { |
67 | 67 | ||
68 | List<Constraint> constraints = buildConstraints(); | 68 | List<Constraint> constraints = buildConstraints(); |
69 | 69 | ||
70 | - Intent intent = new PointToPointIntent(appId(), selector, treatment, | 70 | + Intent intent = new PointToPointIntent(appId(), |
71 | + key(), | ||
72 | + selector, treatment, | ||
71 | ingress, egress, constraints); | 73 | ingress, egress, constraints); |
72 | service.submit(intent); | 74 | service.submit(intent); |
73 | print("Point to point intent submitted:\n%s", intent.toString()); | 75 | print("Point to point intent submitted:\n%s", intent.toString()); | ... | ... |
... | @@ -71,8 +71,10 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC | ... | @@ -71,8 +71,10 @@ public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentC |
71 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); | 71 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
72 | List<Constraint> constraints = buildConstraints(); | 72 | List<Constraint> constraints = buildConstraints(); |
73 | 73 | ||
74 | - SinglePointToMultiPointIntent intent = new SinglePointToMultiPointIntent( | 74 | + SinglePointToMultiPointIntent intent = |
75 | + new SinglePointToMultiPointIntent( | ||
75 | appId(), | 76 | appId(), |
77 | + key(), | ||
76 | selector, | 78 | selector, |
77 | treatment, | 79 | treatment, |
78 | ingressPoint, | 80 | ingressPoint, | ... | ... |
... | @@ -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.Key; | ||
31 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 32 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
32 | import org.onosproject.net.intent.constraint.LambdaConstraint; | 33 | import org.onosproject.net.intent.constraint.LambdaConstraint; |
33 | import org.onosproject.net.intent.constraint.LinkTypeConstraint; | 34 | import org.onosproject.net.intent.constraint.LinkTypeConstraint; |
... | @@ -81,6 +82,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -81,6 +82,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
81 | required = false, multiValued = false) | 82 | required = false, multiValued = false) |
82 | private boolean lambda = false; | 83 | private boolean lambda = false; |
83 | 84 | ||
85 | + @Option(name = "-k", aliases = "--key", description = "Intent Key", | ||
86 | + required = false, multiValued = false) | ||
87 | + private String intentKey = null; | ||
88 | + | ||
84 | 89 | ||
85 | // Treatments | 90 | // Treatments |
86 | @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address", | 91 | @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address", |
... | @@ -180,4 +185,19 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -180,4 +185,19 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
180 | 185 | ||
181 | return constraints; | 186 | return constraints; |
182 | } | 187 | } |
188 | + | ||
189 | + /** | ||
190 | + * Creates a key for an intent based on command line arguments. If a key | ||
191 | + * has been specified, it is returned. If no key is specified, null | ||
192 | + * is returned. | ||
193 | + * | ||
194 | + * @return intent key if specified, null otherwise | ||
195 | + */ | ||
196 | + protected Key key() { | ||
197 | + Key key = null; | ||
198 | + if (intentKey != null) { | ||
199 | + key = Key.of(intentKey, appId()); | ||
200 | + } | ||
201 | + return key; | ||
202 | + } | ||
183 | } | 203 | } | ... | ... |
... | @@ -61,7 +61,29 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -61,7 +61,29 @@ 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, resources, selector, treatment, Collections.emptyList()); | 64 | + this(appId, null, resources, selector, treatment, Collections.emptyList()); |
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Creates a connectivity intent that matches on the specified selector | ||
69 | + * and applies the specified treatment. | ||
70 | + * <p> | ||
71 | + * Path will be chosen without any constraints. | ||
72 | + * </p> | ||
73 | + * | ||
74 | + * @param appId application identifier | ||
75 | + * @param key intent key | ||
76 | + * @param resources required network resources (optional) | ||
77 | + * @param selector traffic selector | ||
78 | + * @param treatment treatment | ||
79 | + * @throws NullPointerException if the selector or treatment is null | ||
80 | + */ | ||
81 | + protected ConnectivityIntent(ApplicationId appId, | ||
82 | + Key key, | ||
83 | + Collection<NetworkResource> resources, | ||
84 | + TrafficSelector selector, | ||
85 | + TrafficTreatment treatment) { | ||
86 | + this(appId, key, resources, selector, treatment, Collections.emptyList()); | ||
65 | } | 87 | } |
66 | 88 | ||
67 | /** | 89 | /** |
... | @@ -72,18 +94,47 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -72,18 +94,47 @@ public abstract class ConnectivityIntent extends Intent { |
72 | * </p> | 94 | * </p> |
73 | * | 95 | * |
74 | * @param appId application identifier | 96 | * @param appId application identifier |
97 | + * @param key explicit key to use for intent | ||
75 | * @param resources required network resources (optional) | 98 | * @param resources required network resources (optional) |
76 | * @param selector traffic selector | 99 | * @param selector traffic selector |
77 | * @param treatment treatment | 100 | * @param treatment treatment |
78 | * @param constraints optional prioritized list of constraints | 101 | * @param constraints optional prioritized list of constraints |
79 | * @throws NullPointerException if the selector or treatment is null | 102 | * @throws NullPointerException if the selector or treatment is null |
80 | */ | 103 | */ |
104 | + | ||
105 | + protected ConnectivityIntent(ApplicationId appId, | ||
106 | + Key key, | ||
107 | + Collection<NetworkResource> resources, | ||
108 | + TrafficSelector selector, | ||
109 | + TrafficTreatment treatment, | ||
110 | + List<Constraint> constraints) { | ||
111 | + super(appId, key, resources); | ||
112 | + this.selector = checkNotNull(selector); | ||
113 | + this.treatment = checkNotNull(treatment); | ||
114 | + this.constraints = checkNotNull(constraints); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Creates a connectivity intent that matches on the specified selector | ||
119 | + * and applies the specified treatment. | ||
120 | + * <p> | ||
121 | + * Path will be optimized based on the first constraint if one is given. | ||
122 | + * </p> | ||
123 | + * | ||
124 | + * @param appId application identifier | ||
125 | + * @param resources required network resources (optional) | ||
126 | + * @param selector traffic selector | ||
127 | + * @param treatment treatment | ||
128 | + * @param constraints optional prioritized list of constraints | ||
129 | + * @throws NullPointerException if the selector or treatment is null | ||
130 | + */ | ||
131 | + | ||
81 | protected ConnectivityIntent(ApplicationId appId, | 132 | protected ConnectivityIntent(ApplicationId appId, |
82 | Collection<NetworkResource> resources, | 133 | Collection<NetworkResource> resources, |
83 | TrafficSelector selector, | 134 | TrafficSelector selector, |
84 | TrafficTreatment treatment, | 135 | TrafficTreatment treatment, |
85 | List<Constraint> constraints) { | 136 | List<Constraint> constraints) { |
86 | - super(appId, resources); | 137 | + super(appId, null, resources); |
87 | this.selector = checkNotNull(selector); | 138 | this.selector = checkNotNull(selector); |
88 | this.treatment = checkNotNull(treatment); | 139 | this.treatment = checkNotNull(treatment); |
89 | this.constraints = checkNotNull(constraints); | 140 | this.constraints = checkNotNull(constraints); | ... | ... |
... | @@ -87,7 +87,26 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -87,7 +87,26 @@ public final class HostToHostIntent extends ConnectivityIntent { |
87 | TrafficSelector selector, | 87 | TrafficSelector selector, |
88 | TrafficTreatment treatment, | 88 | TrafficTreatment treatment, |
89 | List<Constraint> constraints) { | 89 | List<Constraint> constraints) { |
90 | - super(appId, Collections.emptyList(), selector, treatment, constraints); | 90 | + this(appId, null, one, two, selector, treatment, constraints); |
91 | + } | ||
92 | + /** | ||
93 | + * Creates a new host-to-host intent with the supplied host pair. | ||
94 | + * | ||
95 | + * @param appId application identifier | ||
96 | + * @param key intent key | ||
97 | + * @param one first host | ||
98 | + * @param two second host | ||
99 | + * @param selector action | ||
100 | + * @param treatment ingress port | ||
101 | + * @param constraints optional prioritized list of path selection constraints | ||
102 | + * @throws NullPointerException if {@code one} or {@code two} is null. | ||
103 | + */ | ||
104 | + public HostToHostIntent(ApplicationId appId, Key key, | ||
105 | + HostId one, HostId two, | ||
106 | + TrafficSelector selector, | ||
107 | + TrafficTreatment treatment, | ||
108 | + List<Constraint> constraints) { | ||
109 | + super(appId, key, Collections.emptyList(), selector, treatment, constraints); | ||
91 | 110 | ||
92 | // TODO: consider whether the case one and two are same is allowed | 111 | // TODO: consider whether the case one and two are same is allowed |
93 | this.one = checkNotNull(one); | 112 | this.one = checkNotNull(one); | ... | ... |
... | @@ -36,7 +36,7 @@ public abstract class Intent { | ... | @@ -36,7 +36,7 @@ public abstract class Intent { |
36 | private final IntentId id; | 36 | private final IntentId id; |
37 | 37 | ||
38 | private final ApplicationId appId; | 38 | private final ApplicationId appId; |
39 | - private final String key; // TODO make this a class | 39 | + private final Key key; |
40 | 40 | ||
41 | private final Collection<NetworkResource> resources; | 41 | private final Collection<NetworkResource> resources; |
42 | 42 | ||
... | @@ -71,12 +71,12 @@ public abstract class Intent { | ... | @@ -71,12 +71,12 @@ public abstract class Intent { |
71 | * @param resources required network resources (optional) | 71 | * @param resources required network resources (optional) |
72 | */ | 72 | */ |
73 | protected Intent(ApplicationId appId, | 73 | protected Intent(ApplicationId appId, |
74 | - String key, | 74 | + Key key, |
75 | Collection<NetworkResource> resources) { | 75 | Collection<NetworkResource> resources) { |
76 | checkState(idGenerator != null, "Id generator is not bound."); | 76 | checkState(idGenerator != null, "Id generator is not bound."); |
77 | this.id = IntentId.valueOf(idGenerator.getNewId()); | 77 | this.id = IntentId.valueOf(idGenerator.getNewId()); |
78 | this.appId = checkNotNull(appId, "Application ID cannot be null"); | 78 | this.appId = checkNotNull(appId, "Application ID cannot be null"); |
79 | - this.key = (key != null) ? key : id.toString(); //FIXME | 79 | + this.key = (key != null) ? key : Key.of(id.fingerprint(), appId); |
80 | this.resources = checkNotNull(resources); | 80 | this.resources = checkNotNull(resources); |
81 | } | 81 | } |
82 | 82 | ||
... | @@ -156,7 +156,7 @@ public abstract class Intent { | ... | @@ -156,7 +156,7 @@ public abstract class Intent { |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | - public String key() { | 159 | + public Key key() { |
160 | return key; | 160 | return key; |
161 | } | 161 | } |
162 | } | 162 | } | ... | ... |
... | @@ -52,7 +52,7 @@ public class IntentData { //FIXME need to make this "immutable" | ... | @@ -52,7 +52,7 @@ public class IntentData { //FIXME need to make this "immutable" |
52 | return state; | 52 | return state; |
53 | } | 53 | } |
54 | 54 | ||
55 | - public String key() { | 55 | + public Key key() { |
56 | return intent.key(); | 56 | return intent.key(); |
57 | } | 57 | } |
58 | 58 | ... | ... |
... | @@ -73,7 +73,12 @@ public final class IntentOperation { | ... | @@ -73,7 +73,12 @@ public final class IntentOperation { |
73 | return intent.id(); | 73 | return intent.id(); |
74 | } | 74 | } |
75 | 75 | ||
76 | - public String key() { | 76 | + /** |
77 | + * Returns the key for this intent. | ||
78 | + * | ||
79 | + * @return key value | ||
80 | + */ | ||
81 | + public Key key() { | ||
77 | return intent.key(); | 82 | return intent.key(); |
78 | } | 83 | } |
79 | 84 | ... | ... |
... | @@ -92,7 +92,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -92,7 +92,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
92 | * @param key key | 92 | * @param key key |
93 | * @return intent or null if not found | 93 | * @return intent or null if not found |
94 | */ | 94 | */ |
95 | - default Intent getIntent(String key) { //FIXME remove when impl. | 95 | + default Intent getIntent(Key key) { //FIXME remove when impl. |
96 | return null; | 96 | return null; |
97 | } | 97 | } |
98 | 98 | ||
... | @@ -102,7 +102,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -102,7 +102,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
102 | * @param key key to look up | 102 | * @param key key to look up |
103 | * @return intent data object | 103 | * @return intent data object |
104 | */ | 104 | */ |
105 | - default IntentData getIntentData(String key) { //FIXME remove when impl. | 105 | + default IntentData getIntentData(Key key) { //FIXME remove when impl. |
106 | return null; | 106 | return null; |
107 | } | 107 | } |
108 | 108 | ... | ... |
... | @@ -32,7 +32,7 @@ public class Key { | ... | @@ -32,7 +32,7 @@ public class Key { |
32 | private final long hash; | 32 | private final long hash; |
33 | private static final HashFunction HASH_FN = Hashing.md5(); | 33 | private static final HashFunction HASH_FN = Hashing.md5(); |
34 | 34 | ||
35 | - private Key(long hash) { | 35 | + protected Key(long hash) { |
36 | this.hash = hash; | 36 | this.hash = hash; |
37 | } | 37 | } |
38 | 38 | ||
... | @@ -48,7 +48,7 @@ public class Key { | ... | @@ -48,7 +48,7 @@ public class Key { |
48 | return new LongKey(key, appId); | 48 | return new LongKey(key, appId); |
49 | } | 49 | } |
50 | 50 | ||
51 | - private final static class StringKey extends Key { | 51 | + private static final class StringKey extends Key { |
52 | 52 | ||
53 | private final ApplicationId appId; | 53 | private final ApplicationId appId; |
54 | private final String key; | 54 | private final String key; |
... | @@ -87,7 +87,7 @@ public class Key { | ... | @@ -87,7 +87,7 @@ public class Key { |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | - private final static class LongKey extends Key { | 90 | + private static final class LongKey extends Key { |
91 | 91 | ||
92 | private final ApplicationId appId; | 92 | private final ApplicationId appId; |
93 | private static long key; | 93 | private static long key; | ... | ... |
... | @@ -75,12 +75,13 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -75,12 +75,13 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
75 | * not more than 1 | 75 | * not more than 1 |
76 | */ | 76 | */ |
77 | public MultiPointToSinglePointIntent(ApplicationId appId, | 77 | public MultiPointToSinglePointIntent(ApplicationId appId, |
78 | + Key key, | ||
78 | TrafficSelector selector, | 79 | TrafficSelector selector, |
79 | TrafficTreatment treatment, | 80 | TrafficTreatment treatment, |
80 | Set<ConnectPoint> ingressPoints, | 81 | Set<ConnectPoint> ingressPoints, |
81 | ConnectPoint egressPoint, | 82 | ConnectPoint egressPoint, |
82 | List<Constraint> constraints) { | 83 | List<Constraint> constraints) { |
83 | - super(appId, Collections.emptyList(), selector, treatment, constraints); | 84 | + super(appId, key, Collections.emptyList(), selector, treatment, constraints); |
84 | 85 | ||
85 | checkNotNull(ingressPoints); | 86 | checkNotNull(ingressPoints); |
86 | checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty"); | 87 | checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty"); |
... | @@ -93,6 +94,30 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -93,6 +94,30 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
93 | } | 94 | } |
94 | 95 | ||
95 | /** | 96 | /** |
97 | + * Creates a new multi-to-single point connectivity intent for the specified | ||
98 | + * traffic selector and treatment. | ||
99 | + * | ||
100 | + * @param appId application identifier | ||
101 | + * @param selector traffic selector | ||
102 | + * @param treatment treatment | ||
103 | + * @param ingressPoints set of ports from which ingress traffic originates | ||
104 | + * @param egressPoint port to which traffic will egress | ||
105 | + * @param constraints constraints to apply to the intent | ||
106 | + * @throws NullPointerException if {@code ingressPoints} or | ||
107 | + * {@code egressPoint} is null. | ||
108 | + * @throws IllegalArgumentException if the size of {@code ingressPoints} is | ||
109 | + * not more than 1 | ||
110 | + */ | ||
111 | + public MultiPointToSinglePointIntent(ApplicationId appId, | ||
112 | + TrafficSelector selector, | ||
113 | + TrafficTreatment treatment, | ||
114 | + Set<ConnectPoint> ingressPoints, | ||
115 | + ConnectPoint egressPoint, | ||
116 | + List<Constraint> constraints) { | ||
117 | + this(appId, null, selector, treatment, ingressPoints, egressPoint, constraints); | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
96 | * Constructor for serializer. | 121 | * Constructor for serializer. |
97 | */ | 122 | */ |
98 | protected MultiPointToSinglePointIntent() { | 123 | protected MultiPointToSinglePointIntent() { | ... | ... |
... | @@ -38,11 +38,28 @@ public class OpticalConnectivityIntent extends Intent { | ... | @@ -38,11 +38,28 @@ public class OpticalConnectivityIntent extends Intent { |
38 | */ | 38 | */ |
39 | public OpticalConnectivityIntent(ApplicationId appId, | 39 | public OpticalConnectivityIntent(ApplicationId appId, |
40 | ConnectPoint src, ConnectPoint dst) { | 40 | ConnectPoint src, ConnectPoint dst) { |
41 | - super(appId, Collections.emptyList()); | 41 | + |
42 | + this(appId, null, src, dst); | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * Creates an optical connectivity intent between the specified | ||
47 | + * connection points. | ||
48 | + * | ||
49 | + * @param appId application identification | ||
50 | + * @param key intent key | ||
51 | + * @param src the source transponder port | ||
52 | + * @param dst the destination transponder port | ||
53 | + */ | ||
54 | + public OpticalConnectivityIntent(ApplicationId appId, | ||
55 | + Key key, | ||
56 | + ConnectPoint src, ConnectPoint dst) { | ||
57 | + super(appId, key, Collections.emptyList()); | ||
42 | this.src = src; | 58 | this.src = src; |
43 | this.dst = dst; | 59 | this.dst = dst; |
44 | } | 60 | } |
45 | 61 | ||
62 | + | ||
46 | /** | 63 | /** |
47 | * Constructor for serializer. | 64 | * Constructor for serializer. |
48 | */ | 65 | */ | ... | ... |
... | @@ -40,6 +40,37 @@ public class PointToPointIntent extends ConnectivityIntent { | ... | @@ -40,6 +40,37 @@ public class PointToPointIntent extends ConnectivityIntent { |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Creates a new point-to-point intent with the supplied ingress/egress | 42 | * Creates a new point-to-point intent with the supplied ingress/egress |
43 | + * ports and constraints. | ||
44 | + * | ||
45 | + * @param appId application identifier | ||
46 | + * @param key key of the intent | ||
47 | + * @param selector traffic selector | ||
48 | + * @param treatment treatment | ||
49 | + * @param ingressPoint ingress port | ||
50 | + * @param egressPoint egress port | ||
51 | + * @param constraints optional list of constraints | ||
52 | + * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. | ||
53 | + */ | ||
54 | + public PointToPointIntent(ApplicationId appId, | ||
55 | + Key key, | ||
56 | + TrafficSelector selector, | ||
57 | + TrafficTreatment treatment, | ||
58 | + ConnectPoint ingressPoint, | ||
59 | + ConnectPoint egressPoint, | ||
60 | + List<Constraint> constraints) { | ||
61 | + super(appId, key, Collections.emptyList(), selector, treatment, constraints); | ||
62 | + | ||
63 | + checkNotNull(ingressPoint); | ||
64 | + checkNotNull(egressPoint); | ||
65 | + checkArgument(!ingressPoint.equals(egressPoint), | ||
66 | + "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint); | ||
67 | + | ||
68 | + this.ingressPoint = ingressPoint; | ||
69 | + this.egressPoint = egressPoint; | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Creates a new point-to-point intent with the supplied ingress/egress | ||
43 | * ports and with built-in link type constraint to avoid optical links. | 74 | * ports and with built-in link type constraint to avoid optical links. |
44 | * | 75 | * |
45 | * @param appId application identifier | 76 | * @param appId application identifier |
... | @@ -53,7 +84,7 @@ public class PointToPointIntent extends ConnectivityIntent { | ... | @@ -53,7 +84,7 @@ public class PointToPointIntent extends ConnectivityIntent { |
53 | TrafficTreatment treatment, | 84 | TrafficTreatment treatment, |
54 | ConnectPoint ingressPoint, | 85 | ConnectPoint ingressPoint, |
55 | ConnectPoint egressPoint) { | 86 | ConnectPoint egressPoint) { |
56 | - this(appId, selector, treatment, ingressPoint, egressPoint, | 87 | + this(appId, null, selector, treatment, ingressPoint, egressPoint, |
57 | ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); | 88 | ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); |
58 | } | 89 | } |
59 | 90 | ||
... | @@ -74,7 +105,7 @@ public class PointToPointIntent extends ConnectivityIntent { | ... | @@ -74,7 +105,7 @@ public class PointToPointIntent extends ConnectivityIntent { |
74 | ConnectPoint ingressPoint, | 105 | ConnectPoint ingressPoint, |
75 | ConnectPoint egressPoint, | 106 | ConnectPoint egressPoint, |
76 | List<Constraint> constraints) { | 107 | List<Constraint> constraints) { |
77 | - super(appId, Collections.emptyList(), selector, treatment, constraints); | 108 | + super(appId, null, Collections.emptyList(), selector, treatment, constraints); |
78 | 109 | ||
79 | checkNotNull(ingressPoint); | 110 | checkNotNull(ingressPoint); |
80 | checkNotNull(egressPoint); | 111 | checkNotNull(egressPoint); | ... | ... |
... | @@ -54,13 +54,14 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { | ... | @@ -54,13 +54,14 @@ public 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, selector, treatment, ingressPoint, egressPoints, Collections.emptyList()); | 57 | + this(appId, null, selector, treatment, ingressPoint, egressPoints, Collections.emptyList()); |
58 | } | 58 | } |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Creates a new single-to-multi point connectivity intent. | 61 | * Creates a new single-to-multi point connectivity intent. |
62 | * | 62 | * |
63 | * @param appId application identifier | 63 | * @param appId application identifier |
64 | + * @param key intent key | ||
64 | * @param selector traffic selector | 65 | * @param selector traffic selector |
65 | * @param treatment treatment | 66 | * @param treatment treatment |
66 | * @param ingressPoint port on which traffic will ingress | 67 | * @param ingressPoint port on which traffic will ingress |
... | @@ -72,10 +73,11 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { | ... | @@ -72,10 +73,11 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { |
72 | * not more than 1 | 73 | * not more than 1 |
73 | */ | 74 | */ |
74 | public SinglePointToMultiPointIntent(ApplicationId appId, | 75 | public SinglePointToMultiPointIntent(ApplicationId appId, |
76 | + Key key, | ||
75 | TrafficSelector selector, TrafficTreatment treatment, | 77 | TrafficSelector selector, TrafficTreatment treatment, |
76 | ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints, | 78 | ConnectPoint ingressPoint, Set<ConnectPoint> egressPoints, |
77 | List<Constraint> constraints) { | 79 | List<Constraint> constraints) { |
78 | - super(appId, Collections.emptyList(), selector, treatment, constraints); | 80 | + super(appId, key, Collections.emptyList(), selector, treatment, constraints); |
79 | checkNotNull(egressPoints); | 81 | checkNotNull(egressPoints); |
80 | checkNotNull(ingressPoint); | 82 | checkNotNull(ingressPoint); |
81 | checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty"); | 83 | checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty"); | ... | ... |
... | @@ -19,6 +19,7 @@ import com.google.common.collect.Maps; | ... | @@ -19,6 +19,7 @@ import com.google.common.collect.Maps; |
19 | import org.onlab.util.AbstractAccumulator; | 19 | import org.onlab.util.AbstractAccumulator; |
20 | import org.onosproject.net.intent.IntentBatchDelegate; | 20 | import org.onosproject.net.intent.IntentBatchDelegate; |
21 | import org.onosproject.net.intent.IntentData; | 21 | import org.onosproject.net.intent.IntentData; |
22 | +import org.onosproject.net.intent.Key; | ||
22 | 23 | ||
23 | import java.util.Collection; | 24 | import java.util.Collection; |
24 | import java.util.List; | 25 | import java.util.List; |
... | @@ -57,7 +58,7 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { | ... | @@ -57,7 +58,7 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { |
57 | } | 58 | } |
58 | 59 | ||
59 | private Collection<IntentData> reduce(List<IntentData> ops) { | 60 | private Collection<IntentData> reduce(List<IntentData> ops) { |
60 | - Map<String, IntentData> map = Maps.newHashMap(); | 61 | + Map<Key, IntentData> map = Maps.newHashMap(); |
61 | for (IntentData op : ops) { | 62 | for (IntentData op : ops) { |
62 | map.put(op.key(), op); | 63 | map.put(op.key(), op); |
63 | } | 64 | } | ... | ... |
... | @@ -27,6 +27,7 @@ import org.onosproject.net.intent.IntentData; | ... | @@ -27,6 +27,7 @@ import org.onosproject.net.intent.IntentData; |
27 | import org.onosproject.net.intent.IntentEvent; | 27 | import org.onosproject.net.intent.IntentEvent; |
28 | import org.onosproject.net.intent.IntentStore; | 28 | import org.onosproject.net.intent.IntentStore; |
29 | import org.onosproject.net.intent.IntentStoreDelegate; | 29 | import org.onosproject.net.intent.IntentStoreDelegate; |
30 | +import org.onosproject.net.intent.Key; | ||
30 | import org.onosproject.store.AbstractStore; | 31 | import org.onosproject.store.AbstractStore; |
31 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
32 | 33 | ||
... | @@ -46,8 +47,8 @@ public class SimpleIntentStore | ... | @@ -46,8 +47,8 @@ public class SimpleIntentStore |
46 | private final Logger log = getLogger(getClass()); | 47 | private final Logger log = getLogger(getClass()); |
47 | 48 | ||
48 | // current state maps FIXME.. make this a IntentData map | 49 | // current state maps FIXME.. make this a IntentData map |
49 | - private final Map<String, IntentData> current = Maps.newConcurrentMap(); | 50 | + private final Map<Key, IntentData> current = Maps.newConcurrentMap(); |
50 | - private final Map<String, IntentData> pending = Maps.newConcurrentMap(); //String is "key" | 51 | + private final Map<Key, IntentData> pending = Maps.newConcurrentMap(); //String is "key" |
51 | 52 | ||
52 | @Activate | 53 | @Activate |
53 | public void activate() { | 54 | public void activate() { |
... | @@ -72,7 +73,7 @@ public class SimpleIntentStore | ... | @@ -72,7 +73,7 @@ public class SimpleIntentStore |
72 | } | 73 | } |
73 | 74 | ||
74 | @Override | 75 | @Override |
75 | - public IntentData getIntentData(String key) { | 76 | + public IntentData getIntentData(Key key) { |
76 | return current.get(key); | 77 | return current.get(key); |
77 | } | 78 | } |
78 | 79 | ... | ... |
-
Please register or login to post a comment