ilhem fajjari
Committed by Gerrit Code Review

add key parameter to PathIntent and MplsPathIntent constructors

Change-Id: I157c1e3e10dc3e3ebc1dbc6f9a1c9fe769337ee3
...@@ -42,6 +42,7 @@ public final class MplsPathIntent extends PathIntent { ...@@ -42,6 +42,7 @@ public final class MplsPathIntent extends PathIntent {
42 * ports and using the specified explicit path. 42 * ports and using the specified explicit path.
43 * 43 *
44 * @param appId application identifier 44 * @param appId application identifier
45 + * @param key intent key
45 * @param selector traffic selector 46 * @param selector traffic selector
46 * @param treatment treatment 47 * @param treatment treatment
47 * @param path traversed links 48 * @param path traversed links
...@@ -51,11 +52,11 @@ public final class MplsPathIntent extends PathIntent { ...@@ -51,11 +52,11 @@ public final class MplsPathIntent extends PathIntent {
51 * @param priority priority to use for flows generated by this intent 52 * @param priority priority to use for flows generated by this intent
52 * @throws NullPointerException {@code path} is null 53 * @throws NullPointerException {@code path} is null
53 */ 54 */
54 - private MplsPathIntent(ApplicationId appId, TrafficSelector selector, 55 + private MplsPathIntent(ApplicationId appId, Key key, TrafficSelector selector,
55 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel, 56 TrafficTreatment treatment, Path path, Optional<MplsLabel> ingressLabel,
56 Optional<MplsLabel> egressLabel, List<Constraint> constraints, 57 Optional<MplsLabel> egressLabel, List<Constraint> constraints,
57 int priority) { 58 int priority) {
58 - super(appId, selector, treatment, path, constraints, 59 + super(appId, key, selector, treatment, path, constraints,
59 priority); 60 priority);
60 61
61 this.ingressLabel = checkNotNull(ingressLabel); 62 this.ingressLabel = checkNotNull(ingressLabel);
...@@ -149,6 +150,7 @@ public final class MplsPathIntent extends PathIntent { ...@@ -149,6 +150,7 @@ public final class MplsPathIntent extends PathIntent {
149 150
150 return new MplsPathIntent( 151 return new MplsPathIntent(
151 appId, 152 appId,
153 + key,
152 selector, 154 selector,
153 treatment, 155 treatment,
154 path, 156 path,
......
...@@ -42,6 +42,7 @@ public class PathIntent extends ConnectivityIntent { ...@@ -42,6 +42,7 @@ public class PathIntent extends ConnectivityIntent {
42 * ports and using the specified explicit path. 42 * ports and using the specified explicit path.
43 * 43 *
44 * @param appId application identifier 44 * @param appId application identifier
45 + * @param key intent key
45 * @param selector traffic selector 46 * @param selector traffic selector
46 * @param treatment treatment 47 * @param treatment treatment
47 * @param path traversed links 48 * @param path traversed links
...@@ -50,12 +51,13 @@ public class PathIntent extends ConnectivityIntent { ...@@ -50,12 +51,13 @@ public class PathIntent extends ConnectivityIntent {
50 * @throws NullPointerException {@code path} is null 51 * @throws NullPointerException {@code path} is null
51 */ 52 */
52 protected PathIntent(ApplicationId appId, 53 protected PathIntent(ApplicationId appId,
54 + Key key,
53 TrafficSelector selector, 55 TrafficSelector selector,
54 TrafficTreatment treatment, 56 TrafficTreatment treatment,
55 Path path, 57 Path path,
56 List<Constraint> constraints, 58 List<Constraint> constraints,
57 int priority) { 59 int priority) {
58 - super(appId, null, resources(path.links()), selector, treatment, constraints, 60 + super(appId, key, resources(path.links()), selector, treatment, constraints,
59 priority); 61 priority);
60 PathIntent.validate(path.links()); 62 PathIntent.validate(path.links());
61 this.path = path; 63 this.path = path;
...@@ -138,6 +140,7 @@ public class PathIntent extends ConnectivityIntent { ...@@ -138,6 +140,7 @@ public class PathIntent extends ConnectivityIntent {
138 140
139 return new PathIntent( 141 return new PathIntent(
140 appId, 142 appId,
143 + key,
141 selector, 144 selector,
142 treatment, 145 treatment,
143 path, 146 path,
...@@ -184,6 +187,7 @@ public class PathIntent extends ConnectivityIntent { ...@@ -184,6 +187,7 @@ public class PathIntent extends ConnectivityIntent {
184 public String toString() { 187 public String toString() {
185 return MoreObjects.toStringHelper(getClass()) 188 return MoreObjects.toStringHelper(getClass())
186 .add("id", id()) 189 .add("id", id())
190 + .add("key", key())
187 .add("appId", appId()) 191 .add("appId", appId())
188 .add("priority", priority()) 192 .add("priority", priority())
189 .add("resources", resources()) 193 .add("resources", resources())
......
...@@ -33,6 +33,7 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -33,6 +33,7 @@ import org.onosproject.net.flow.TrafficTreatment;
33 public abstract class ConnectivityIntentTest extends IntentTest { 33 public abstract class ConnectivityIntentTest extends IntentTest {
34 34
35 public static final ApplicationId APPID = new TestApplicationId("foo"); 35 public static final ApplicationId APPID = new TestApplicationId("foo");
36 + public static final Key KEY = Key.of(1L, APPID);
36 37
37 public static final IntentId IID = new IntentId(123); 38 public static final IntentId IID = new IntentId(123);
38 public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector(); 39 public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector();
......
...@@ -112,6 +112,5 @@ public class MplsIntentTest extends AbstractIntentTest { ...@@ -112,6 +112,5 @@ public class MplsIntentTest extends AbstractIntentTest {
112 assertThat(intent1.selector(), equalTo(intent2.selector())); 112 assertThat(intent1.selector(), equalTo(intent2.selector()));
113 assertThat(intent1.treatment(), equalTo(intent2.treatment())); 113 assertThat(intent1.treatment(), equalTo(intent2.treatment()));
114 assertThat(intent1.priority(), is(PRIORITY)); 114 assertThat(intent1.priority(), is(PRIORITY));
115 -
116 } 115 }
117 } 116 }
......
...@@ -47,6 +47,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { ...@@ -47,6 +47,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
47 Optional<MplsLabel> label2; 47 Optional<MplsLabel> label2;
48 TrafficSelector selector; 48 TrafficSelector selector;
49 TrafficTreatment treatment; 49 TrafficTreatment treatment;
50 + static final Key KEY1 = Key.of(5L, APP_ID);
50 51
51 @Before 52 @Before
52 public void mplsPathIntentTestSetUp() { 53 public void mplsPathIntentTestSetUp() {
...@@ -58,6 +59,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { ...@@ -58,6 +59,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
58 label2 = Optional.of(MplsLabel.mplsLabel(2)); 59 label2 = Optional.of(MplsLabel.mplsLabel(2));
59 intent1 = MplsPathIntent.builder() 60 intent1 = MplsPathIntent.builder()
60 .appId(APP_ID) 61 .appId(APP_ID)
62 + .key(KEY1)
61 .ingressLabel(label1) 63 .ingressLabel(label1)
62 .egressLabel(label2) 64 .egressLabel(label2)
63 .path(defaultPath) 65 .path(defaultPath)
...@@ -105,6 +107,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { ...@@ -105,6 +107,7 @@ public class MplsPathIntentTest extends AbstractIntentTest {
105 assertThat(intent1.treatment(), equalTo(intent2.treatment())); 107 assertThat(intent1.treatment(), equalTo(intent2.treatment()));
106 assertThat(intent1.priority(), is(PRIORITY)); 108 assertThat(intent1.priority(), is(PRIORITY));
107 assertThat(intent1.path(), is(defaultPath)); 109 assertThat(intent1.path(), is(defaultPath));
110 + assertThat(intent1.key(), equalTo(KEY1));
108 } 111 }
109 112
110 } 113 }
......
...@@ -62,12 +62,14 @@ public class PathIntentTest extends ConnectivityIntentTest { ...@@ -62,12 +62,14 @@ public class PathIntentTest extends ConnectivityIntentTest {
62 assertEquals("incorrect match", MATCH, intent.selector()); 62 assertEquals("incorrect match", MATCH, intent.selector());
63 assertEquals("incorrect action", NOP, intent.treatment()); 63 assertEquals("incorrect action", NOP, intent.treatment());
64 assertEquals("incorrect path", PATH1, intent.path()); 64 assertEquals("incorrect path", PATH1, intent.path());
65 + assertEquals("incorrect key", KEY, intent.key());
65 } 66 }
66 67
67 @Override 68 @Override
68 protected PathIntent createOne() { 69 protected PathIntent createOne() {
69 return PathIntent.builder() 70 return PathIntent.builder()
70 .appId(APPID) 71 .appId(APPID)
72 + .key(KEY)
71 .selector(MATCH) 73 .selector(MATCH)
72 .treatment(NOP) 74 .treatment(NOP)
73 .path(PATH1) 75 .path(PATH1)
......
...@@ -63,6 +63,7 @@ public class PropertyPanelTest { ...@@ -63,6 +63,7 @@ public class PropertyPanelTest {
63 private static final String KEY_C = "C"; 63 private static final String KEY_C = "C";
64 private static final String SEP = "-"; 64 private static final String SEP = "-";
65 private static final String KEY_Z = "Z"; 65 private static final String KEY_Z = "Z";
66 +
66 private static final String VALUE_A = "Hay"; 67 private static final String VALUE_A = "Hay";
67 private static final String VALUE_B = "Bee"; 68 private static final String VALUE_B = "Bee";
68 private static final String VALUE_C = "Sea"; 69 private static final String VALUE_C = "Sea";
......