Thomas Vachuska

Refactoring intent API.

Showing 31 changed files with 251 additions and 652 deletions
...@@ -3,7 +3,7 @@ package org.onlab.onos.net; ...@@ -3,7 +3,7 @@ package org.onlab.onos.net;
3 /** 3 /**
4 * Abstraction of a network infrastructure link. 4 * Abstraction of a network infrastructure link.
5 */ 5 */
6 -public interface Link extends Annotated, Provided { 6 +public interface Link extends Annotated, Provided, NetworkResource {
7 7
8 /** 8 /**
9 * Coarse representation of the link type. 9 * Coarse representation of the link type.
......
1 -package org.onlab.onos.net.intent;
2 -
3 -/**
4 - * Base intent implementation.
5 - */
6 -public abstract class AbstractIntent implements Intent {
7 -
8 - private final IntentId id;
9 -
10 - /**
11 - * Creates a base intent with the specified identifier.
12 - *
13 - * @param id intent identifier
14 - */
15 - protected AbstractIntent(IntentId id) {
16 - this.id = id;
17 - }
18 -
19 - /**
20 - * Constructor for serializer.
21 - */
22 - protected AbstractIntent() {
23 - this.id = null;
24 - }
25 -
26 - @Override
27 - public IntentId id() {
28 - return id;
29 - }
30 -
31 - @Override
32 - public boolean equals(Object o) {
33 - if (this == o) {
34 - return true;
35 - }
36 - if (o == null || getClass() != o.getClass()) {
37 - return false;
38 - }
39 -
40 - AbstractIntent that = (AbstractIntent) o;
41 - return id.equals(that.id);
42 - }
43 -
44 - @Override
45 - public int hashCode() {
46 - return id.hashCode();
47 - }
48 -
49 -}
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 -import com.google.common.base.Objects; 3 +import com.google.common.collect.ImmutableSet;
4 +import org.onlab.onos.ApplicationId;
5 +import org.onlab.onos.net.Link;
6 +import org.onlab.onos.net.NetworkResource;
4 import org.onlab.onos.net.flow.TrafficSelector; 7 import org.onlab.onos.net.flow.TrafficSelector;
5 import org.onlab.onos.net.flow.TrafficTreatment; 8 import org.onlab.onos.net.flow.TrafficTreatment;
6 9
10 +import java.util.Collection;
11 +
7 import static com.google.common.base.Preconditions.checkNotNull; 12 import static com.google.common.base.Preconditions.checkNotNull;
8 13
9 /** 14 /**
10 * Abstraction of connectivity intent for traffic matching some criteria. 15 * Abstraction of connectivity intent for traffic matching some criteria.
11 */ 16 */
12 -public abstract class ConnectivityIntent extends AbstractIntent { 17 +public abstract class ConnectivityIntent extends Intent {
13 18
14 // TODO: other forms of intents should be considered for this family: 19 // TODO: other forms of intents should be considered for this family:
15 // point-to-point with constraints (waypoints/obstacles) 20 // point-to-point with constraints (waypoints/obstacles)
...@@ -19,24 +24,26 @@ public abstract class ConnectivityIntent extends AbstractIntent { ...@@ -19,24 +24,26 @@ public abstract class ConnectivityIntent extends AbstractIntent {
19 // ... 24 // ...
20 25
21 private final TrafficSelector selector; 26 private final TrafficSelector selector;
22 - // TODO: should consider which is better for multiple actions,
23 - // defining compound action class or using list of actions.
24 private final TrafficTreatment treatment; 27 private final TrafficTreatment treatment;
25 28
26 /** 29 /**
27 - * Creates a connectivity intent that matches on the specified intent 30 + * Creates a connectivity intent that matches on the specified selector
28 - * and applies the specified treatement. 31 + * and applies the specified treatment.
29 * 32 *
30 - * @param intentId intent identifier 33 + * @param id intent identifier
34 + * @param appId application identifier
35 + * @param resources required network resources (optional)
31 * @param selector traffic selector 36 * @param selector traffic selector
32 - * @param treatement treatement 37 + * @param treatment treatment
33 * @throws NullPointerException if the selector or treatement is null 38 * @throws NullPointerException if the selector or treatement is null
34 */ 39 */
35 - protected ConnectivityIntent(IntentId intentId, TrafficSelector selector, 40 + protected ConnectivityIntent(IntentId id, ApplicationId appId,
36 - TrafficTreatment treatement) { 41 + Collection<NetworkResource> resources,
37 - super(intentId); 42 + TrafficSelector selector,
43 + TrafficTreatment treatment) {
44 + super(id, appId, resources);
38 this.selector = checkNotNull(selector); 45 this.selector = checkNotNull(selector);
39 - this.treatment = checkNotNull(treatement); 46 + this.treatment = checkNotNull(treatment);
40 } 47 }
41 48
42 /** 49 /**
...@@ -66,19 +73,9 @@ public abstract class ConnectivityIntent extends AbstractIntent { ...@@ -66,19 +73,9 @@ public abstract class ConnectivityIntent extends AbstractIntent {
66 return treatment; 73 return treatment;
67 } 74 }
68 75
69 - @Override
70 - public boolean equals(Object o) {
71 - if (!super.equals(o)) {
72 - return false;
73 - }
74 - ConnectivityIntent that = (ConnectivityIntent) o;
75 - return Objects.equal(this.selector, that.selector)
76 - && Objects.equal(this.treatment, that.treatment);
77 - }
78 76
79 - @Override 77 + protected static Collection<NetworkResource> resources(Collection<Link> links) {
80 - public int hashCode() { 78 + return ImmutableSet.<NetworkResource>copyOf(links);
81 - return Objects.hashCode(super.hashCode(), selector, treatment);
82 } 79 }
83 80
84 } 81 }
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 import com.google.common.base.MoreObjects; 3 import com.google.common.base.MoreObjects;
4 +import org.onlab.onos.ApplicationId;
4 import org.onlab.onos.net.HostId; 5 import org.onlab.onos.net.HostId;
5 import org.onlab.onos.net.flow.TrafficSelector; 6 import org.onlab.onos.net.flow.TrafficSelector;
6 import org.onlab.onos.net.flow.TrafficTreatment; 7 import org.onlab.onos.net.flow.TrafficTreatment;
7 8
8 -import java.util.Objects;
9 -
10 import static com.google.common.base.Preconditions.checkNotNull; 9 import static com.google.common.base.Preconditions.checkNotNull;
11 10
12 /** 11 /**
...@@ -21,7 +20,7 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -21,7 +20,7 @@ public final class HostToHostIntent extends ConnectivityIntent {
21 * Creates a new point-to-point intent with the supplied ingress/egress 20 * Creates a new point-to-point intent with the supplied ingress/egress
22 * ports. 21 * ports.
23 * 22 *
24 - * @param intentId intent identifier 23 + * @param appId application identifier
25 * @param one first host 24 * @param one first host
26 * @param two second host 25 * @param two second host
27 * @param selector action 26 * @param selector action
...@@ -29,10 +28,11 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -29,10 +28,11 @@ public final class HostToHostIntent extends ConnectivityIntent {
29 * @throws NullPointerException if {@code ingressPort} or {@code egressPort} 28 * @throws NullPointerException if {@code ingressPort} or {@code egressPort}
30 * is null. 29 * is null.
31 */ 30 */
32 - public HostToHostIntent(IntentId intentId, HostId one, HostId two, 31 + public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
33 TrafficSelector selector, 32 TrafficSelector selector,
34 TrafficTreatment treatment) { 33 TrafficTreatment treatment) {
35 - super(intentId, selector, treatment); 34 + super(id(HostToHostIntent.class, one, two, selector, treatment),
35 + appId, null, selector, treatment);
36 this.one = checkNotNull(one); 36 this.one = checkNotNull(one);
37 this.two = checkNotNull(two); 37 this.two = checkNotNull(two);
38 } 38 }
...@@ -56,28 +56,6 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -56,28 +56,6 @@ public final class HostToHostIntent extends ConnectivityIntent {
56 } 56 }
57 57
58 @Override 58 @Override
59 - public boolean equals(Object o) {
60 - if (this == o) {
61 - return true;
62 - }
63 - if (o == null || getClass() != o.getClass()) {
64 - return false;
65 - }
66 - if (!super.equals(o)) {
67 - return false;
68 - }
69 -
70 - HostToHostIntent that = (HostToHostIntent) o;
71 - return Objects.equals(this.one, that.one)
72 - && Objects.equals(this.two, that.two);
73 - }
74 -
75 - @Override
76 - public int hashCode() {
77 - return Objects.hash(super.hashCode(), one, two);
78 - }
79 -
80 - @Override
81 public String toString() { 59 public String toString() {
82 return MoreObjects.toStringHelper(getClass()) 60 return MoreObjects.toStringHelper(getClass())
83 .add("id", id()) 61 .add("id", id())
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 -//TODO is this the right package?
3 2
4 /** 3 /**
5 * A generalized interface for ID generation 4 * A generalized interface for ID generation
6 - * 5 + * <p/>
7 * {@link #getNewId()} generates a globally unique ID instance on 6 * {@link #getNewId()} generates a globally unique ID instance on
8 * each invocation. 7 * each invocation.
9 * 8 *
10 * @param <T> the type of ID 9 * @param <T> the type of ID
11 */ 10 */
12 -// TODO: do we need to define a base marker interface for ID, 11 +@Deprecated
13 -// then changed the type parameter to <T extends BaseId> something
14 -// like that?
15 public interface IdGenerator<T> { 12 public interface IdGenerator<T> {
16 /** 13 /**
17 * Returns a globally unique ID instance. 14 * Returns a globally unique ID instance.
......
1 -package org.onlab.onos.net.intent;
2 -
3 -import org.onlab.onos.net.Link;
4 -
5 -import java.util.Collection;
6 -
7 -/**
8 - * Abstraction of an intent that can be installed into
9 - * the underlying system without additional compilation.
10 - */
11 -public interface InstallableIntent extends Intent {
12 -
13 - /**
14 - * Returns the collection of links that are required for this installable
15 - * intent to exist.
16 - *
17 - * @return collection of links
18 - */
19 - // FIXME: replace this with 'NetworkResource'
20 - Collection<Link> requiredLinks();
21 -
22 -}
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 +import org.onlab.onos.ApplicationId;
4 +import org.onlab.onos.net.NetworkResource;
5 +
6 +import java.util.Collection;
7 +import java.util.Objects;
8 +
9 +import static com.google.common.base.Preconditions.checkNotNull;
10 +
3 /** 11 /**
4 * Abstraction of an application level intent. 12 * Abstraction of an application level intent.
5 * <p/> 13 * <p/>
6 * Make sure that an Intent should be immutable when a new type is defined. 14 * Make sure that an Intent should be immutable when a new type is defined.
7 */ 15 */
8 -public interface Intent extends BatchOperationTarget { 16 +public abstract class Intent implements BatchOperationTarget {
17 +
18 + private final IntentId id;
19 + private final ApplicationId appId;
20 + private final Collection<NetworkResource> resources;
21 +
22 + /**
23 + * Constructor for serializer.
24 + */
25 + protected Intent() {
26 + this.id = null;
27 + this.appId = null;
28 + this.resources = null;
29 + }
30 +
31 + /**
32 + * Creates a new intent.
33 + *
34 + * @param id intent identifier
35 + * @param appId application identifier
36 + * @param resources required network resources (optional)
37 + */
38 + protected Intent(IntentId id, ApplicationId appId,
39 + Collection<NetworkResource> resources) {
40 + this.appId = checkNotNull(appId, "Application ID cannot be null");
41 + this.id = checkNotNull(id, "Fingerprint cannot be null");
42 + this.resources = resources;
43 + }
44 +
9 /** 45 /**
10 * Returns the intent identifier. 46 * Returns the intent identifier.
11 * 47 *
48 + * @return intent fingerprint
49 + */
50 + public IntentId id() {
51 + return id;
52 + }
53 +
54 + /**
55 + * Returns the identifier of the application that requested the intent.
56 + *
57 + * @return application identifier
58 + */
59 + public ApplicationId appId() {
60 + return appId;
61 + }
62 +
63 + /**
64 + * Returns the collection of resources required for this intent.
65 + *
66 + * @return collection of resources; may be null
67 + */
68 + public Collection<NetworkResource> resources() {
69 + return resources;
70 + }
71 +
72 + /**
73 + * Produces an intent identifier backed by hash-like fingerprint for the
74 + * specified class of intent and its constituent fields.
75 + *
76 + * @param fields intent fields
12 * @return intent identifier 77 * @return intent identifier
13 */ 78 */
14 - IntentId id(); 79 + protected static IntentId id(Object... fields) {
80 + return IntentId.valueOf(Objects.hash(fields));
81 + }
82 +
83 + /**
84 + * Indicates whether or not the intent is installable.
85 + *
86 + * @return true if installable
87 + */
88 + public boolean isInstallable() {
89 + return false;
90 + }
91 +
92 + @Override
93 + public int hashCode() {
94 + return Objects.hash(id);
95 + }
96 +
97 + @Override
98 + public boolean equals(Object obj) {
99 + if (this == obj) {
100 + return true;
101 + }
102 + if (obj == null || getClass() != obj.getClass()) {
103 + return false;
104 + }
105 + final Intent other = (Intent) obj;
106 + return Objects.equals(this.id, other.id);
107 + }
108 +
15 } 109 }
......
...@@ -38,7 +38,7 @@ public interface IntentExtensionService { ...@@ -38,7 +38,7 @@ public interface IntentExtensionService {
38 * @param installer intent installer 38 * @param installer intent installer
39 * @param <T> the type of installable intent 39 * @param <T> the type of installable intent
40 */ 40 */
41 - <T extends InstallableIntent> void registerInstaller(Class<T> cls, IntentInstaller<T> installer); 41 + <T extends Intent> void registerInstaller(Class<T> cls, IntentInstaller<T> installer);
42 42
43 /** 43 /**
44 * Unregisters the installer for the given installable intent class. 44 * Unregisters the installer for the given installable intent class.
...@@ -46,12 +46,12 @@ public interface IntentExtensionService { ...@@ -46,12 +46,12 @@ public interface IntentExtensionService {
46 * @param cls installable intent class 46 * @param cls installable intent class
47 * @param <T> the type of installable intent 47 * @param <T> the type of installable intent
48 */ 48 */
49 - <T extends InstallableIntent> void unregisterInstaller(Class<T> cls); 49 + <T extends Intent> void unregisterInstaller(Class<T> cls);
50 50
51 /** 51 /**
52 * Returns immutable set of bindings of currently registered intent installers. 52 * Returns immutable set of bindings of currently registered intent installers.
53 * 53 *
54 * @return the set of installer bindings 54 * @return the set of installer bindings
55 */ 55 */
56 - Map<Class<? extends InstallableIntent>, IntentInstaller<? extends InstallableIntent>> getInstallers(); 56 + Map<Class<? extends Intent>, IntentInstaller<? extends Intent>> getInstallers();
57 } 57 }
......
...@@ -7,43 +7,37 @@ package org.onlab.onos.net.intent; ...@@ -7,43 +7,37 @@ package org.onlab.onos.net.intent;
7 */ 7 */
8 public final class IntentId implements BatchOperationTarget { 8 public final class IntentId implements BatchOperationTarget {
9 9
10 - private static final int DEC = 10; 10 + private final long fingerprint;
11 - private static final int HEX = 16;
12 -
13 - private final long id;
14 11
15 /** 12 /**
16 * Creates an intent identifier from the specified string representation. 13 * Creates an intent identifier from the specified string representation.
17 * 14 *
18 - * @param value long value 15 + * @param fingerprint long value
19 * @return intent identifier 16 * @return intent identifier
20 */ 17 */
21 - public static IntentId valueOf(String value) { 18 + static IntentId valueOf(long fingerprint) {
22 - long id = value.toLowerCase().startsWith("0x") 19 + return new IntentId(fingerprint);
23 - ? Long.parseLong(value.substring(2), HEX)
24 - : Long.parseLong(value, DEC);
25 - return new IntentId(id);
26 } 20 }
27 21
28 /** 22 /**
29 * Constructor for serializer. 23 * Constructor for serializer.
30 */ 24 */
31 - protected IntentId() { 25 + IntentId() {
32 - this.id = 0; 26 + this.fingerprint = 0;
33 } 27 }
34 28
35 /** 29 /**
36 * Constructs the ID corresponding to a given long value. 30 * Constructs the ID corresponding to a given long value.
37 * 31 *
38 - * @param id the underlying value of this ID 32 + * @param fingerprint the underlying value of this ID
39 */ 33 */
40 - public IntentId(long id) { 34 + IntentId(long fingerprint) {
41 - this.id = id; 35 + this.fingerprint = fingerprint;
42 } 36 }
43 37
44 @Override 38 @Override
45 public int hashCode() { 39 public int hashCode() {
46 - return (int) (id ^ (id >>> 32)); 40 + return (int) (fingerprint ^ (fingerprint >>> 32));
47 } 41 }
48 42
49 @Override 43 @Override
...@@ -51,18 +45,16 @@ public final class IntentId implements BatchOperationTarget { ...@@ -51,18 +45,16 @@ public final class IntentId implements BatchOperationTarget {
51 if (obj == this) { 45 if (obj == this) {
52 return true; 46 return true;
53 } 47 }
54 -
55 if (!(obj instanceof IntentId)) { 48 if (!(obj instanceof IntentId)) {
56 return false; 49 return false;
57 } 50 }
58 -
59 IntentId that = (IntentId) obj; 51 IntentId that = (IntentId) obj;
60 - return this.id == that.id; 52 + return this.fingerprint == that.fingerprint;
61 } 53 }
62 54
63 @Override 55 @Override
64 public String toString() { 56 public String toString() {
65 - return "0x" + Long.toHexString(id); 57 + return "0x" + Long.toHexString(fingerprint);
66 } 58 }
67 59
68 } 60 }
......
...@@ -7,7 +7,7 @@ import org.onlab.onos.net.flow.FlowRuleBatchOperation; ...@@ -7,7 +7,7 @@ import org.onlab.onos.net.flow.FlowRuleBatchOperation;
7 /** 7 /**
8 * Abstraction of entity capable of installing intents to the environment. 8 * Abstraction of entity capable of installing intents to the environment.
9 */ 9 */
10 -public interface IntentInstaller<T extends InstallableIntent> { 10 +public interface IntentInstaller<T extends Intent> {
11 /** 11 /**
12 * Installs the specified intent to the environment. 12 * Installs the specified intent to the environment.
13 * 13 *
......
...@@ -77,8 +77,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { ...@@ -77,8 +77,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
77 * @param intentId original intent identifier 77 * @param intentId original intent identifier
78 * @param installableIntents compiled installable intents 78 * @param installableIntents compiled installable intents
79 */ 79 */
80 - void addInstallableIntents(IntentId intentId, 80 + void addInstallableIntents(IntentId intentId, List<Intent> installableIntents);
81 - List<InstallableIntent> installableIntents);
82 81
83 /** 82 /**
84 * Returns the list of the installable events associated with the specified 83 * Returns the list of the installable events associated with the specified
...@@ -87,7 +86,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { ...@@ -87,7 +86,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
87 * @param intentId original intent identifier 86 * @param intentId original intent identifier
88 * @return compiled installable intents 87 * @return compiled installable intents
89 */ 88 */
90 - List<InstallableIntent> getInstallableIntents(IntentId intentId); 89 + List<Intent> getInstallableIntents(IntentId intentId);
91 90
92 // TODO: this should be triggered from with the store as a result of removeIntent call 91 // TODO: this should be triggered from with the store as a result of removeIntent call
93 92
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 -import java.util.Collection; 3 +import com.google.common.base.MoreObjects;
4 -import java.util.Objects; 4 +import org.onlab.onos.ApplicationId;
5 -import java.util.Set;
6 -
7 import org.onlab.onos.net.ConnectPoint; 5 import org.onlab.onos.net.ConnectPoint;
8 import org.onlab.onos.net.Link; 6 import org.onlab.onos.net.Link;
9 import org.onlab.onos.net.flow.TrafficSelector; 7 import org.onlab.onos.net.flow.TrafficSelector;
10 import org.onlab.onos.net.flow.TrafficTreatment; 8 import org.onlab.onos.net.flow.TrafficTreatment;
11 9
12 -import com.google.common.base.MoreObjects; 10 +import java.util.Set;
13 11
14 /** 12 /**
15 * Abstraction of a connectivity intent that is implemented by a set of path 13 * Abstraction of a connectivity intent that is implemented by a set of path
16 * segments. 14 * segments.
17 */ 15 */
18 -public final class LinkCollectionIntent extends ConnectivityIntent implements InstallableIntent { 16 +public final class LinkCollectionIntent extends ConnectivityIntent {
19 17
20 private final Set<Link> links; 18 private final Set<Link> links;
21 19
...@@ -25,34 +23,33 @@ public final class LinkCollectionIntent extends ConnectivityIntent implements In ...@@ -25,34 +23,33 @@ public final class LinkCollectionIntent extends ConnectivityIntent implements In
25 * Creates a new point-to-point intent with the supplied ingress/egress 23 * Creates a new point-to-point intent with the supplied ingress/egress
26 * ports and using the specified explicit path. 24 * ports and using the specified explicit path.
27 * 25 *
28 - * @param id intent identifier 26 + * @param appId application identifier
29 * @param selector traffic match 27 * @param selector traffic match
30 * @param treatment action 28 * @param treatment action
31 * @param links traversed links 29 * @param links traversed links
32 * @param egressPoint egress point 30 * @param egressPoint egress point
33 * @throws NullPointerException {@code path} is null 31 * @throws NullPointerException {@code path} is null
34 */ 32 */
35 - public LinkCollectionIntent(IntentId id, 33 + public LinkCollectionIntent(ApplicationId appId,
36 TrafficSelector selector, 34 TrafficSelector selector,
37 TrafficTreatment treatment, 35 TrafficTreatment treatment,
38 Set<Link> links, 36 Set<Link> links,
39 ConnectPoint egressPoint) { 37 ConnectPoint egressPoint) {
40 - super(id, selector, treatment); 38 + super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint),
39 + appId, resources(links), selector, treatment);
41 this.links = links; 40 this.links = links;
42 this.egressPoint = egressPoint; 41 this.egressPoint = egressPoint;
43 } 42 }
44 43
44 + /**
45 + * Constructor for serializer.
46 + */
45 protected LinkCollectionIntent() { 47 protected LinkCollectionIntent() {
46 super(); 48 super();
47 this.links = null; 49 this.links = null;
48 this.egressPoint = null; 50 this.egressPoint = null;
49 } 51 }
50 52
51 - @Override
52 - public Collection<Link> requiredLinks() {
53 - return links;
54 - }
55 -
56 /** 53 /**
57 * Returns the set of links that represent the network connections needed 54 * Returns the set of links that represent the network connections needed
58 * by this intent. 55 * by this intent.
...@@ -73,27 +70,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent implements In ...@@ -73,27 +70,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent implements In
73 } 70 }
74 71
75 @Override 72 @Override
76 - public boolean equals(Object o) { 73 + public boolean isInstallable() {
77 - if (this == o) {
78 return true; 74 return true;
79 } 75 }
80 - if (o == null || getClass() != o.getClass()) {
81 - return false;
82 - }
83 - if (!super.equals(o)) {
84 - return false;
85 - }
86 -
87 - LinkCollectionIntent that = (LinkCollectionIntent) o;
88 -
89 - return Objects.equals(this.links, that.links) &&
90 - Objects.equals(this.egressPoint, that.egressPoint);
91 - }
92 -
93 - @Override
94 - public int hashCode() {
95 - return Objects.hash(super.hashCode(), links, egressPoint);
96 - }
97 76
98 @Override 77 @Override
99 public String toString() { 78 public String toString() {
......
...@@ -2,11 +2,11 @@ package org.onlab.onos.net.intent; ...@@ -2,11 +2,11 @@ package org.onlab.onos.net.intent;
2 2
3 import com.google.common.base.MoreObjects; 3 import com.google.common.base.MoreObjects;
4 import com.google.common.collect.Sets; 4 import com.google.common.collect.Sets;
5 +import org.onlab.onos.ApplicationId;
5 import org.onlab.onos.net.ConnectPoint; 6 import org.onlab.onos.net.ConnectPoint;
6 import org.onlab.onos.net.flow.TrafficSelector; 7 import org.onlab.onos.net.flow.TrafficSelector;
7 import org.onlab.onos.net.flow.TrafficTreatment; 8 import org.onlab.onos.net.flow.TrafficTreatment;
8 9
9 -import java.util.Objects;
10 import java.util.Set; 10 import java.util.Set;
11 11
12 import static com.google.common.base.Preconditions.checkArgument; 12 import static com.google.common.base.Preconditions.checkArgument;
...@@ -22,11 +22,11 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -22,11 +22,11 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
22 22
23 /** 23 /**
24 * Creates a new multi-to-single point connectivity intent for the specified 24 * Creates a new multi-to-single point connectivity intent for the specified
25 - * traffic match and action. 25 + * traffic selector and treatment.
26 * 26 *
27 - * @param id intent identifier 27 + * @param appId application identifier
28 - * @param match traffic match 28 + * @param selector traffic selector
29 - * @param action action 29 + * @param treatment treatment
30 * @param ingressPoints set of ports from which ingress traffic originates 30 * @param ingressPoints set of ports from which ingress traffic originates
31 * @param egressPoint port to which traffic will egress 31 * @param egressPoint port to which traffic will egress
32 * @throws NullPointerException if {@code ingressPoints} or 32 * @throws NullPointerException if {@code ingressPoints} or
...@@ -34,15 +34,16 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -34,15 +34,16 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
34 * @throws IllegalArgumentException if the size of {@code ingressPoints} is 34 * @throws IllegalArgumentException if the size of {@code ingressPoints} is
35 * not more than 1 35 * not more than 1
36 */ 36 */
37 - public MultiPointToSinglePointIntent(IntentId id, TrafficSelector match, 37 + public MultiPointToSinglePointIntent(ApplicationId appId,
38 - TrafficTreatment action, 38 + TrafficSelector selector,
39 + TrafficTreatment treatment,
39 Set<ConnectPoint> ingressPoints, 40 Set<ConnectPoint> ingressPoints,
40 ConnectPoint egressPoint) { 41 ConnectPoint egressPoint) {
41 - super(id, match, action); 42 + super(id(MultiPointToSinglePointIntent.class, selector, treatment,
43 + ingressPoints, egressPoint), appId, null, selector, treatment);
42 44
43 checkNotNull(ingressPoints); 45 checkNotNull(ingressPoints);
44 - checkArgument(!ingressPoints.isEmpty(), 46 + checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
45 - "there should be at least one ingress port");
46 47
47 this.ingressPoints = Sets.newHashSet(ingressPoints); 48 this.ingressPoints = Sets.newHashSet(ingressPoints);
48 this.egressPoint = checkNotNull(egressPoint); 49 this.egressPoint = checkNotNull(egressPoint);
...@@ -77,28 +78,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { ...@@ -77,28 +78,6 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
77 } 78 }
78 79
79 @Override 80 @Override
80 - public boolean equals(Object o) {
81 - if (this == o) {
82 - return true;
83 - }
84 - if (o == null || getClass() != o.getClass()) {
85 - return false;
86 - }
87 - if (!super.equals(o)) {
88 - return false;
89 - }
90 -
91 - MultiPointToSinglePointIntent that = (MultiPointToSinglePointIntent) o;
92 - return Objects.equals(this.ingressPoints, that.ingressPoints)
93 - && Objects.equals(this.egressPoint, that.egressPoint);
94 - }
95 -
96 - @Override
97 - public int hashCode() {
98 - return Objects.hash(super.hashCode(), ingressPoints, egressPoint);
99 - }
100 -
101 - @Override
102 public String toString() { 81 public String toString() {
103 return MoreObjects.toStringHelper(getClass()) 82 return MoreObjects.toStringHelper(getClass())
104 .add("id", id()) 83 .add("id", id())
......
1 -package org.onlab.onos.net.intent;
2 -
3 -import org.onlab.onos.net.ConnectPoint;
4 -
5 -// TODO: consider if this intent should be sub-class of ConnectivityIntent
6 -
7 -/**
8 - * An optical layer Intent for a connectivity from a transponder port to another
9 - * transponder port.
10 - * <p/>
11 - * This class doesn't accepts lambda specifier. This class computes path between
12 - * ports and assign lambda automatically. The lambda can be specified using
13 - * OpticalPathFlow class.
14 - */
15 -public class OpticalConnectivityIntent extends AbstractIntent {
16 - protected ConnectPoint src;
17 - protected ConnectPoint dst;
18 -
19 - /**
20 - * Constructor.
21 - *
22 - * @param id ID for this new Intent object.
23 - * @param src The source transponder port.
24 - * @param dst The destination transponder port.
25 - */
26 - public OpticalConnectivityIntent(IntentId id, ConnectPoint src, ConnectPoint dst) {
27 - super(id);
28 - this.src = src;
29 - this.dst = dst;
30 - }
31 -
32 - /**
33 - * Constructor for serializer.
34 - */
35 - protected OpticalConnectivityIntent() {
36 - super();
37 - this.src = null;
38 - this.dst = null;
39 - }
40 -
41 - /**
42 - * Gets source transponder port.
43 - *
44 - * @return The source transponder port.
45 - */
46 - public ConnectPoint getSrcConnectPoint() {
47 - return src;
48 - }
49 -
50 - /**
51 - * Gets destination transponder port.
52 - *
53 - * @return The source transponder port.
54 - */
55 - public ConnectPoint getDst() {
56 - return dst;
57 - }
58 -}
1 -package org.onlab.onos.net.intent;
2 -
3 -import java.util.Collection;
4 -import java.util.Collections;
5 -import java.util.HashSet;
6 -import java.util.Set;
7 -
8 -import org.onlab.onos.net.ConnectPoint;
9 -import org.onlab.onos.net.flow.TrafficSelector;
10 -
11 -// TODO: consider if this intent should be sub-class of Connectivity intent
12 -/**
13 - * A packet layer Intent for a connectivity from a set of ports to a set of
14 - * ports.
15 - * <p>
16 - * TODO: Design methods to support the ReactiveForwarding and the SDN-IP. <br>
17 - * NOTE: Should this class support modifier methods? Should this object a
18 - * read-only object?
19 - */
20 -public class PacketConnectivityIntent extends AbstractIntent {
21 - protected Set<ConnectPoint> srcConnectPoints;
22 - protected TrafficSelector selector;
23 - protected Set<ConnectPoint> dstConnectPoints;
24 - protected boolean canSetupOpticalFlow;
25 - protected int idleTimeoutValue;
26 - protected int hardTimeoutValue;
27 -
28 - /**
29 - * Creates a connectivity intent for the packet layer.
30 - * <p>
31 - * When the "canSetupOpticalFlow" option is true, this intent will compute
32 - * the packet/optical converged path, decompose it to the OpticalPathFlow
33 - * and the PacketPathFlow objects, and execute the operations to add them
34 - * considering the dependency between the packet and optical layers.
35 - *
36 - * @param id ID for this new Intent object.
37 - * @param srcConnectPoints The set of source switch ports.
38 - * @param match Traffic specifier for this object.
39 - * @param dstConnectPoints The set of destination switch ports.
40 - * @param canSetupOpticalFlow The flag whether this intent can create
41 - * optical flows if needed.
42 - */
43 - public PacketConnectivityIntent(IntentId id,
44 - Collection<ConnectPoint> srcConnectPoints, TrafficSelector match,
45 - Collection<ConnectPoint> dstConnectPoints, boolean canSetupOpticalFlow) {
46 - super(id);
47 - this.srcConnectPoints = new HashSet<ConnectPoint>(srcConnectPoints);
48 - this.selector = match;
49 - this.dstConnectPoints = new HashSet<ConnectPoint>(dstConnectPoints);
50 - this.canSetupOpticalFlow = canSetupOpticalFlow;
51 - this.idleTimeoutValue = 0;
52 - this.hardTimeoutValue = 0;
53 -
54 - // TODO: check consistency between these parameters.
55 - }
56 -
57 - /**
58 - * Constructor for serializer.
59 - */
60 - protected PacketConnectivityIntent() {
61 - super();
62 - this.srcConnectPoints = null;
63 - this.selector = null;
64 - this.dstConnectPoints = null;
65 - this.canSetupOpticalFlow = false;
66 - this.idleTimeoutValue = 0;
67 - this.hardTimeoutValue = 0;
68 - }
69 -
70 - /**
71 - * Gets the set of source switch ports.
72 - *
73 - * @return the set of source switch ports.
74 - */
75 - public Collection<ConnectPoint> getSrcConnectPoints() {
76 - return Collections.unmodifiableCollection(srcConnectPoints);
77 - }
78 -
79 - /**
80 - * Gets the traffic specifier.
81 - *
82 - * @return The traffic specifier.
83 - */
84 - public TrafficSelector getMatch() {
85 - return selector;
86 - }
87 -
88 - /**
89 - * Gets the set of destination switch ports.
90 - *
91 - * @return the set of destination switch ports.
92 - */
93 - public Collection<ConnectPoint> getDstConnectPoints() {
94 - return Collections.unmodifiableCollection(dstConnectPoints);
95 - }
96 -
97 - /**
98 - * Adds the specified port to the set of source ports.
99 - *
100 - * @param port ConnectPoint object to be added
101 - */
102 - public void addSrcConnectPoint(ConnectPoint port) {
103 - // TODO implement it.
104 - }
105 -
106 - /**
107 - * Adds the specified port to the set of destination ports.
108 - *
109 - * @param port ConnectPoint object to be added
110 - */
111 - public void addDstConnectPoint(ConnectPoint port) {
112 - // TODO implement it.
113 - }
114 -
115 - /**
116 - * Removes the specified port from the set of source ports.
117 - *
118 - * @param port ConnectPoint object to be removed
119 - */
120 - public void removeSrcConnectPoint(ConnectPoint port) {
121 - // TODO implement it.
122 - }
123 -
124 - /**
125 - * Removes the specified port from the set of destination ports.
126 - *
127 - * @param port ConnectPoint object to be removed
128 - */
129 - public void removeDstConnectPoint(ConnectPoint port) {
130 - // TODO implement it.
131 - }
132 -
133 - /**
134 - * Sets idle-timeout value.
135 - *
136 - * @param timeout Idle-timeout value (seconds)
137 - */
138 - public void setIdleTimeout(int timeout) {
139 - idleTimeoutValue = timeout;
140 - }
141 -
142 - /**
143 - * Sets hard-timeout value.
144 - *
145 - * @param timeout Hard-timeout value (seconds)
146 - */
147 - public void setHardTimeout(int timeout) {
148 - hardTimeoutValue = timeout;
149 - }
150 -
151 - /**
152 - * Gets idle-timeout value.
153 - *
154 - * @return Idle-timeout value (seconds)
155 - */
156 - public int getIdleTimeout() {
157 - return idleTimeoutValue;
158 - }
159 -
160 - /**
161 - * Gets hard-timeout value.
162 - *
163 - * @return Hard-timeout value (seconds)
164 - */
165 - public int getHardTimeout() {
166 - return hardTimeoutValue;
167 - }
168 -
169 - /**
170 - * Returns whether this intent can create optical flows if needed.
171 - *
172 - * @return whether this intent can create optical flows.
173 - */
174 - public boolean canSetupOpticalFlow() {
175 - return canSetupOpticalFlow;
176 - }
177 -}
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 import com.google.common.base.MoreObjects; 3 import com.google.common.base.MoreObjects;
4 -import org.onlab.onos.net.ConnectPoint; 4 +import org.onlab.onos.ApplicationId;
5 -import org.onlab.onos.net.Link;
6 import org.onlab.onos.net.Path; 5 import org.onlab.onos.net.Path;
7 import org.onlab.onos.net.flow.TrafficSelector; 6 import org.onlab.onos.net.flow.TrafficSelector;
8 import org.onlab.onos.net.flow.TrafficTreatment; 7 import org.onlab.onos.net.flow.TrafficTreatment;
9 8
10 -import java.util.Collection;
11 -import java.util.Objects;
12 -
13 /** 9 /**
14 * Abstraction of explicitly path specified connectivity intent. 10 * Abstraction of explicitly path specified connectivity intent.
15 */ 11 */
16 -public class PathIntent extends PointToPointIntent implements InstallableIntent { 12 +public class PathIntent extends ConnectivityIntent {
17 13
18 private final Path path; 14 private final Path path;
19 15
...@@ -21,21 +17,22 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent ...@@ -21,21 +17,22 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent
21 * Creates a new point-to-point intent with the supplied ingress/egress 17 * Creates a new point-to-point intent with the supplied ingress/egress
22 * ports and using the specified explicit path. 18 * ports and using the specified explicit path.
23 * 19 *
24 - * @param id intent identifier 20 + * @param appId application identifier
25 - * @param match traffic match 21 + * @param selector traffic selector
26 - * @param action action 22 + * @param treatment treatment
27 - * @param ingressPort ingress port
28 - * @param egressPort egress port
29 * @param path traversed links 23 * @param path traversed links
30 * @throws NullPointerException {@code path} is null 24 * @throws NullPointerException {@code path} is null
31 */ 25 */
32 - public PathIntent(IntentId id, TrafficSelector match, TrafficTreatment action, 26 + public PathIntent(ApplicationId appId, TrafficSelector selector,
33 - ConnectPoint ingressPort, ConnectPoint egressPort, 27 + TrafficTreatment treatment, Path path) {
34 - Path path) { 28 + super(id(PathIntent.class, selector, treatment, path), appId,
35 - super(id, match, action, ingressPort, egressPort); 29 + resources(path.links()), selector, treatment);
36 this.path = path; 30 this.path = path;
37 } 31 }
38 32
33 + /**
34 + * Constructor for serializer.
35 + */
39 protected PathIntent() { 36 protected PathIntent() {
40 super(); 37 super();
41 this.path = null; 38 this.path = null;
...@@ -51,30 +48,9 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent ...@@ -51,30 +48,9 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent
51 } 48 }
52 49
53 @Override 50 @Override
54 - public boolean equals(Object o) { 51 + public boolean isInstallable() {
55 - if (this == o) {
56 return true; 52 return true;
57 } 53 }
58 - if (o == null || getClass() != o.getClass()) {
59 - return false;
60 - }
61 - if (!super.equals(o)) {
62 - return false;
63 - }
64 -
65 - PathIntent that = (PathIntent) o;
66 -
67 - if (!path.equals(that.path)) {
68 - return false;
69 - }
70 -
71 - return true;
72 - }
73 -
74 - @Override
75 - public int hashCode() {
76 - return Objects.hash(super.hashCode(), path);
77 - }
78 54
79 @Override 55 @Override
80 public String toString() { 56 public String toString() {
...@@ -82,15 +58,8 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent ...@@ -82,15 +58,8 @@ public class PathIntent extends PointToPointIntent implements InstallableIntent
82 .add("id", id()) 58 .add("id", id())
83 .add("match", selector()) 59 .add("match", selector())
84 .add("action", treatment()) 60 .add("action", treatment())
85 - .add("ingressPort", ingressPoint())
86 - .add("egressPort", egressPoint())
87 .add("path", path) 61 .add("path", path)
88 .toString(); 62 .toString();
89 } 63 }
90 64
91 - @Override
92 - public Collection<Link> requiredLinks() {
93 - return path.links();
94 - }
95 -
96 } 65 }
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 import com.google.common.base.MoreObjects; 3 import com.google.common.base.MoreObjects;
4 +import org.onlab.onos.ApplicationId;
4 import org.onlab.onos.net.ConnectPoint; 5 import org.onlab.onos.net.ConnectPoint;
5 import org.onlab.onos.net.flow.TrafficSelector; 6 import org.onlab.onos.net.flow.TrafficSelector;
6 import org.onlab.onos.net.flow.TrafficTreatment; 7 import org.onlab.onos.net.flow.TrafficTreatment;
7 8
8 -import java.util.Objects;
9 -
10 import static com.google.common.base.Preconditions.checkNotNull; 9 import static com.google.common.base.Preconditions.checkNotNull;
11 10
12 /** 11 /**
...@@ -21,18 +20,19 @@ public class PointToPointIntent extends ConnectivityIntent { ...@@ -21,18 +20,19 @@ public class PointToPointIntent extends ConnectivityIntent {
21 * Creates a new point-to-point intent with the supplied ingress/egress 20 * Creates a new point-to-point intent with the supplied ingress/egress
22 * ports. 21 * ports.
23 * 22 *
24 - * @param id intent identifier 23 + * @param appId application identifier
25 * @param selector traffic selector 24 * @param selector traffic selector
26 * @param treatment treatment 25 * @param treatment treatment
27 * @param ingressPoint ingress port 26 * @param ingressPoint ingress port
28 * @param egressPoint egress port 27 * @param egressPoint egress port
29 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. 28 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
30 */ 29 */
31 - public PointToPointIntent(IntentId id, TrafficSelector selector, 30 + public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
32 TrafficTreatment treatment, 31 TrafficTreatment treatment,
33 ConnectPoint ingressPoint, 32 ConnectPoint ingressPoint,
34 ConnectPoint egressPoint) { 33 ConnectPoint egressPoint) {
35 - super(id, selector, treatment); 34 + super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint),
35 + appId, null, selector, treatment);
36 this.ingressPoint = checkNotNull(ingressPoint); 36 this.ingressPoint = checkNotNull(ingressPoint);
37 this.egressPoint = checkNotNull(egressPoint); 37 this.egressPoint = checkNotNull(egressPoint);
38 } 38 }
...@@ -66,28 +66,6 @@ public class PointToPointIntent extends ConnectivityIntent { ...@@ -66,28 +66,6 @@ public class PointToPointIntent extends ConnectivityIntent {
66 } 66 }
67 67
68 @Override 68 @Override
69 - public boolean equals(Object o) {
70 - if (this == o) {
71 - return true;
72 - }
73 - if (o == null || getClass() != o.getClass()) {
74 - return false;
75 - }
76 - if (!super.equals(o)) {
77 - return false;
78 - }
79 -
80 - PointToPointIntent that = (PointToPointIntent) o;
81 - return Objects.equals(this.ingressPoint, that.ingressPoint)
82 - && Objects.equals(this.egressPoint, that.egressPoint);
83 - }
84 -
85 - @Override
86 - public int hashCode() {
87 - return Objects.hash(super.hashCode(), ingressPoint, egressPoint);
88 - }
89 -
90 - @Override
91 public String toString() { 69 public String toString() {
92 return MoreObjects.toStringHelper(getClass()) 70 return MoreObjects.toStringHelper(getClass())
93 .add("id", id()) 71 .add("id", id())
......
...@@ -2,11 +2,11 @@ package org.onlab.onos.net.intent; ...@@ -2,11 +2,11 @@ package org.onlab.onos.net.intent;
2 2
3 import com.google.common.base.MoreObjects; 3 import com.google.common.base.MoreObjects;
4 import com.google.common.collect.Sets; 4 import com.google.common.collect.Sets;
5 +import org.onlab.onos.ApplicationId;
5 import org.onlab.onos.net.ConnectPoint; 6 import org.onlab.onos.net.ConnectPoint;
6 import org.onlab.onos.net.flow.TrafficSelector; 7 import org.onlab.onos.net.flow.TrafficSelector;
7 import org.onlab.onos.net.flow.TrafficTreatment; 8 import org.onlab.onos.net.flow.TrafficTreatment;
8 9
9 -import java.util.Objects;
10 import java.util.Set; 10 import java.util.Set;
11 11
12 import static com.google.common.base.Preconditions.checkArgument; 12 import static com.google.common.base.Preconditions.checkArgument;
...@@ -23,7 +23,7 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -23,7 +23,7 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent {
23 /** 23 /**
24 * Creates a new single-to-multi point connectivity intent. 24 * Creates a new single-to-multi point connectivity intent.
25 * 25 *
26 - * @param id intent identifier 26 + * @param appId application identifier
27 * @param selector traffic selector 27 * @param selector traffic selector
28 * @param treatment treatment 28 * @param treatment treatment
29 * @param ingressPoint port on which traffic will ingress 29 * @param ingressPoint port on which traffic will ingress
...@@ -33,16 +33,15 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -33,16 +33,15 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent {
33 * @throws IllegalArgumentException if the size of {@code egressPoints} is 33 * @throws IllegalArgumentException if the size of {@code egressPoints} is
34 * not more than 1 34 * not more than 1
35 */ 35 */
36 - public SinglePointToMultiPointIntent(IntentId id, TrafficSelector selector, 36 + public SinglePointToMultiPointIntent(ApplicationId appId,
37 + TrafficSelector selector,
37 TrafficTreatment treatment, 38 TrafficTreatment treatment,
38 ConnectPoint ingressPoint, 39 ConnectPoint ingressPoint,
39 Set<ConnectPoint> egressPoints) { 40 Set<ConnectPoint> egressPoints) {
40 - super(id, selector, treatment); 41 + super(id(SinglePointToMultiPointIntent.class, selector, treatment,
41 - 42 + ingressPoint, egressPoints), appId, null, selector, treatment);
42 checkNotNull(egressPoints); 43 checkNotNull(egressPoints);
43 - checkArgument(!egressPoints.isEmpty(), 44 + checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty");
44 - "there should be at least one egress port");
45 -
46 this.ingressPoint = checkNotNull(ingressPoint); 45 this.ingressPoint = checkNotNull(ingressPoint);
47 this.egressPoints = Sets.newHashSet(egressPoints); 46 this.egressPoints = Sets.newHashSet(egressPoints);
48 } 47 }
...@@ -75,28 +74,6 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent { ...@@ -75,28 +74,6 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent {
75 } 74 }
76 75
77 @Override 76 @Override
78 - public boolean equals(Object o) {
79 - if (this == o) {
80 - return true;
81 - }
82 - if (o == null || getClass() != o.getClass()) {
83 - return false;
84 - }
85 - if (!super.equals(o)) {
86 - return false;
87 - }
88 -
89 - SinglePointToMultiPointIntent that = (SinglePointToMultiPointIntent) o;
90 - return Objects.equals(this.ingressPoint, that.ingressPoint)
91 - && Objects.equals(this.egressPoints, that.egressPoints);
92 - }
93 -
94 - @Override
95 - public int hashCode() {
96 - return Objects.hash(super.hashCode(), ingressPoint, egressPoints);
97 - }
98 -
99 - @Override
100 public String toString() { 77 public String toString() {
101 return MoreObjects.toStringHelper(getClass()) 78 return MoreObjects.toStringHelper(getClass())
102 .add("id", id()) 79 .add("id", id())
......
...@@ -2,6 +2,8 @@ package org.onlab.onos.net.intent; ...@@ -2,6 +2,8 @@ package org.onlab.onos.net.intent;
2 2
3 import java.util.Set; 3 import java.util.Set;
4 4
5 +import org.onlab.onos.ApplicationId;
6 +import org.onlab.onos.TestApplicationId;
5 import org.onlab.onos.net.ConnectPoint; 7 import org.onlab.onos.net.ConnectPoint;
6 import org.onlab.onos.net.DeviceId; 8 import org.onlab.onos.net.DeviceId;
7 import org.onlab.onos.net.PortNumber; 9 import org.onlab.onos.net.PortNumber;
...@@ -15,6 +17,8 @@ import org.onlab.onos.net.flow.TrafficTreatment; ...@@ -15,6 +17,8 @@ import org.onlab.onos.net.flow.TrafficTreatment;
15 */ 17 */
16 public abstract class ConnectivityIntentTest extends IntentTest { 18 public abstract class ConnectivityIntentTest extends IntentTest {
17 19
20 + public static final ApplicationId APPID = new TestApplicationId("foo");
21 +
18 public static final IntentId IID = new IntentId(123); 22 public static final IntentId IID = new IntentId(123);
19 public static final TrafficSelector MATCH = DefaultTrafficSelector.builder().build(); 23 public static final TrafficSelector MATCH = DefaultTrafficSelector.builder().build();
20 public static final TrafficTreatment NOP = DefaultTrafficTreatment.builder().build(); 24 public static final TrafficTreatment NOP = DefaultTrafficTreatment.builder().build();
......
...@@ -18,11 +18,11 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -18,11 +18,11 @@ public class FakeIntentManager implements TestableIntentService {
18 18
19 private final Map<IntentId, Intent> intents = new HashMap<>(); 19 private final Map<IntentId, Intent> intents = new HashMap<>();
20 private final Map<IntentId, IntentState> intentStates = new HashMap<>(); 20 private final Map<IntentId, IntentState> intentStates = new HashMap<>();
21 - private final Map<IntentId, List<InstallableIntent>> installables = new HashMap<>(); 21 + private final Map<IntentId, List<Intent>> installables = new HashMap<>();
22 private final Set<IntentListener> listeners = new HashSet<>(); 22 private final Set<IntentListener> listeners = new HashSet<>();
23 23
24 private final Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> compilers = new HashMap<>(); 24 private final Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> compilers = new HashMap<>();
25 - private final Map<Class<? extends InstallableIntent>, IntentInstaller<? extends InstallableIntent>> installers 25 + private final Map<Class<? extends Intent>, IntentInstaller<? extends Intent>> installers
26 = new HashMap<>(); 26 = new HashMap<>();
27 27
28 private final ExecutorService executor = Executors.newSingleThreadExecutor(); 28 private final ExecutorService executor = Executors.newSingleThreadExecutor();
...@@ -54,7 +54,7 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -54,7 +54,7 @@ public class FakeIntentManager implements TestableIntentService {
54 @Override 54 @Override
55 public void run() { 55 public void run() {
56 try { 56 try {
57 - List<InstallableIntent> installable = getInstallable(intent.id()); 57 + List<Intent> installable = getInstallable(intent.id());
58 executeWithdrawingPhase(intent, installable); 58 executeWithdrawingPhase(intent, installable);
59 } catch (IntentException e) { 59 } catch (IntentException e) {
60 exceptions.add(e); 60 exceptions.add(e);
...@@ -73,7 +73,7 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -73,7 +73,7 @@ public class FakeIntentManager implements TestableIntentService {
73 return compiler; 73 return compiler;
74 } 74 }
75 75
76 - private <T extends InstallableIntent> IntentInstaller<T> getInstaller(T intent) { 76 + private <T extends Intent> IntentInstaller<T> getInstaller(T intent) {
77 @SuppressWarnings("unchecked") 77 @SuppressWarnings("unchecked")
78 IntentInstaller<T> installer = (IntentInstaller<T>) installers.get(intent 78 IntentInstaller<T> installer = (IntentInstaller<T>) installers.get(intent
79 .getClass()); 79 .getClass());
...@@ -87,9 +87,9 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -87,9 +87,9 @@ public class FakeIntentManager implements TestableIntentService {
87 setState(intent, IntentState.COMPILING); 87 setState(intent, IntentState.COMPILING);
88 try { 88 try {
89 // For the fake, we compile using a single level pass 89 // For the fake, we compile using a single level pass
90 - List<InstallableIntent> installable = new ArrayList<>(); 90 + List<Intent> installable = new ArrayList<>();
91 for (Intent compiled : getCompiler(intent).compile(intent)) { 91 for (Intent compiled : getCompiler(intent).compile(intent)) {
92 - installable.add((InstallableIntent) compiled); 92 + installable.add((Intent) compiled);
93 } 93 }
94 executeInstallingPhase(intent, installable); 94 executeInstallingPhase(intent, installable);
95 95
...@@ -100,10 +100,10 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -100,10 +100,10 @@ public class FakeIntentManager implements TestableIntentService {
100 } 100 }
101 101
102 private void executeInstallingPhase(Intent intent, 102 private void executeInstallingPhase(Intent intent,
103 - List<InstallableIntent> installable) { 103 + List<Intent> installable) {
104 setState(intent, IntentState.INSTALLING); 104 setState(intent, IntentState.INSTALLING);
105 try { 105 try {
106 - for (InstallableIntent ii : installable) { 106 + for (Intent ii : installable) {
107 registerSubclassInstallerIfNeeded(ii); 107 registerSubclassInstallerIfNeeded(ii);
108 getInstaller(ii).install(ii); 108 getInstaller(ii).install(ii);
109 } 109 }
...@@ -118,10 +118,10 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -118,10 +118,10 @@ public class FakeIntentManager implements TestableIntentService {
118 } 118 }
119 119
120 private void executeWithdrawingPhase(Intent intent, 120 private void executeWithdrawingPhase(Intent intent,
121 - List<InstallableIntent> installable) { 121 + List<Intent> installable) {
122 setState(intent, IntentState.WITHDRAWING); 122 setState(intent, IntentState.WITHDRAWING);
123 try { 123 try {
124 - for (InstallableIntent ii : installable) { 124 + for (Intent ii : installable) {
125 getInstaller(ii).uninstall(ii); 125 getInstaller(ii).uninstall(ii);
126 } 126 }
127 removeInstallable(intent.id()); 127 removeInstallable(intent.id());
...@@ -139,7 +139,7 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -139,7 +139,7 @@ public class FakeIntentManager implements TestableIntentService {
139 intentStates.put(intent.id(), state); 139 intentStates.put(intent.id(), state);
140 } 140 }
141 141
142 - private void putInstallable(IntentId id, List<InstallableIntent> installable) { 142 + private void putInstallable(IntentId id, List<Intent> installable) {
143 installables.put(id, installable); 143 installables.put(id, installable);
144 } 144 }
145 145
...@@ -147,8 +147,8 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -147,8 +147,8 @@ public class FakeIntentManager implements TestableIntentService {
147 installables.remove(id); 147 installables.remove(id);
148 } 148 }
149 149
150 - private List<InstallableIntent> getInstallable(IntentId id) { 150 + private List<Intent> getInstallable(IntentId id) {
151 - List<InstallableIntent> installable = installables.get(id); 151 + List<Intent> installable = installables.get(id);
152 if (installable != null) { 152 if (installable != null) {
153 return installable; 153 return installable;
154 } else { 154 } else {
...@@ -228,19 +228,19 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -228,19 +228,19 @@ public class FakeIntentManager implements TestableIntentService {
228 } 228 }
229 229
230 @Override 230 @Override
231 - public <T extends InstallableIntent> void registerInstaller(Class<T> cls, 231 + public <T extends Intent> void registerInstaller(Class<T> cls,
232 IntentInstaller<T> installer) { 232 IntentInstaller<T> installer) {
233 installers.put(cls, installer); 233 installers.put(cls, installer);
234 } 234 }
235 235
236 @Override 236 @Override
237 - public <T extends InstallableIntent> void unregisterInstaller(Class<T> cls) { 237 + public <T extends Intent> void unregisterInstaller(Class<T> cls) {
238 installers.remove(cls); 238 installers.remove(cls);
239 } 239 }
240 240
241 @Override 241 @Override
242 - public Map<Class<? extends InstallableIntent>, 242 + public Map<Class<? extends Intent>,
243 - IntentInstaller<? extends InstallableIntent>> getInstallers() { 243 + IntentInstaller<? extends Intent>> getInstallers() {
244 return Collections.unmodifiableMap(installers); 244 return Collections.unmodifiableMap(installers);
245 } 245 }
246 246
...@@ -261,13 +261,13 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -261,13 +261,13 @@ public class FakeIntentManager implements TestableIntentService {
261 } 261 }
262 } 262 }
263 263
264 - private void registerSubclassInstallerIfNeeded(InstallableIntent intent) { 264 + private void registerSubclassInstallerIfNeeded(Intent intent) {
265 if (!installers.containsKey(intent.getClass())) { 265 if (!installers.containsKey(intent.getClass())) {
266 Class<?> cls = intent.getClass(); 266 Class<?> cls = intent.getClass();
267 while (cls != Object.class) { 267 while (cls != Object.class) {
268 - // As long as we're within the InstallableIntent class 268 + // As long as we're within the Intent class
269 // descendants 269 // descendants
270 - if (InstallableIntent.class.isAssignableFrom(cls)) { 270 + if (Intent.class.isAssignableFrom(cls)) {
271 IntentInstaller<?> installer = installers.get(cls); 271 IntentInstaller<?> installer = installers.get(cls);
272 if (installer != null) { 272 if (installer != null) {
273 installers.put(intent.getClass(), installer); 273 installers.put(intent.getClass(), installer);
......
...@@ -44,14 +44,8 @@ public class IntentIdTest { ...@@ -44,14 +44,8 @@ public class IntentIdTest {
44 44
45 @Test 45 @Test
46 public void valueOf() { 46 public void valueOf() {
47 - IntentId id = new IntentId(12345);
48 - assertEquals("incorrect valueOf", id, IntentId.valueOf("12345"));
49 - }
50 -
51 - @Test
52 - public void valueOfHex() {
53 IntentId id = new IntentId(0xdeadbeefL); 47 IntentId id = new IntentId(0xdeadbeefL);
54 - assertEquals("incorrect valueOf", id, IntentId.valueOf(id.toString())); 48 + assertEquals("incorrect valueOf", id, IntentId.valueOf(0xdeadbeefL));
55 } 49 }
56 50
57 } 51 }
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 -import static org.junit.Assert.assertEquals; 3 +import org.junit.Test;
4 -import static org.junit.Assert.assertFalse;
5 -import static org.junit.Assert.assertTrue;
6 4
7 import java.util.Arrays; 5 import java.util.Arrays;
8 import java.util.HashSet; 6 import java.util.HashSet;
9 import java.util.Set; 7 import java.util.Set;
10 8
11 -import org.junit.Test; 9 +import static org.junit.Assert.*;
12 10
13 /** 11 /**
14 * Base facilities to test various intent tests. 12 * Base facilities to test various intent tests.
...@@ -33,11 +31,7 @@ public abstract class IntentTest { ...@@ -33,11 +31,7 @@ public abstract class IntentTest {
33 31
34 assertTrue("should be equal", one.equals(like)); 32 assertTrue("should be equal", one.equals(like));
35 assertEquals("incorrect hashCode", one.hashCode(), like.hashCode()); 33 assertEquals("incorrect hashCode", one.hashCode(), like.hashCode());
36 -
37 assertFalse("should not be equal", one.equals(another)); 34 assertFalse("should not be equal", one.equals(another));
38 -
39 - assertFalse("should not be equal", one.equals(null));
40 - assertFalse("should not be equal", one.equals("foo"));
41 } 35 }
42 36
43 @Test 37 @Test
......
...@@ -12,7 +12,7 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { ...@@ -12,7 +12,7 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest {
12 @Test 12 @Test
13 public void basics() { 13 public void basics() {
14 MultiPointToSinglePointIntent intent = createOne(); 14 MultiPointToSinglePointIntent intent = createOne();
15 - assertEquals("incorrect id", IID, intent.id()); 15 + assertEquals("incorrect id", APPID, intent.appId());
16 assertEquals("incorrect match", MATCH, intent.selector()); 16 assertEquals("incorrect match", MATCH, intent.selector());
17 assertEquals("incorrect ingress", PS1, intent.ingressPoints()); 17 assertEquals("incorrect ingress", PS1, intent.ingressPoints());
18 assertEquals("incorrect egress", P2, intent.egressPoint()); 18 assertEquals("incorrect egress", P2, intent.egressPoint());
...@@ -20,11 +20,11 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest { ...@@ -20,11 +20,11 @@ public class MultiPointToSinglePointIntentTest extends ConnectivityIntentTest {
20 20
21 @Override 21 @Override
22 protected MultiPointToSinglePointIntent createOne() { 22 protected MultiPointToSinglePointIntent createOne() {
23 - return new MultiPointToSinglePointIntent(IID, MATCH, NOP, PS1, P2); 23 + return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS1, P2);
24 } 24 }
25 25
26 @Override 26 @Override
27 protected MultiPointToSinglePointIntent createAnother() { 27 protected MultiPointToSinglePointIntent createAnother() {
28 - return new MultiPointToSinglePointIntent(IID, MATCH, NOP, PS2, P1); 28 + return new MultiPointToSinglePointIntent(APPID, MATCH, NOP, PS2, P1);
29 } 29 }
30 } 30 }
......
...@@ -16,21 +16,19 @@ public class PathIntentTest extends ConnectivityIntentTest { ...@@ -16,21 +16,19 @@ public class PathIntentTest extends ConnectivityIntentTest {
16 @Test 16 @Test
17 public void basics() { 17 public void basics() {
18 PathIntent intent = createOne(); 18 PathIntent intent = createOne();
19 - assertEquals("incorrect id", IID, intent.id()); 19 + assertEquals("incorrect id", APPID, intent.appId());
20 assertEquals("incorrect match", MATCH, intent.selector()); 20 assertEquals("incorrect match", MATCH, intent.selector());
21 assertEquals("incorrect action", NOP, intent.treatment()); 21 assertEquals("incorrect action", NOP, intent.treatment());
22 - assertEquals("incorrect ingress", P1, intent.ingressPoint());
23 - assertEquals("incorrect egress", P2, intent.egressPoint());
24 assertEquals("incorrect path", PATH1, intent.path()); 22 assertEquals("incorrect path", PATH1, intent.path());
25 } 23 }
26 24
27 @Override 25 @Override
28 protected PathIntent createOne() { 26 protected PathIntent createOne() {
29 - return new PathIntent(IID, MATCH, NOP, P1, P2, PATH1); 27 + return new PathIntent(APPID, MATCH, NOP, PATH1);
30 } 28 }
31 29
32 @Override 30 @Override
33 protected PathIntent createAnother() { 31 protected PathIntent createAnother() {
34 - return new PathIntent(IID, MATCH, NOP, P1, P3, PATH2); 32 + return new PathIntent(APPID, MATCH, NOP, PATH2);
35 } 33 }
36 } 34 }
......
...@@ -12,7 +12,7 @@ public class PointToPointIntentTest extends ConnectivityIntentTest { ...@@ -12,7 +12,7 @@ public class PointToPointIntentTest extends ConnectivityIntentTest {
12 @Test 12 @Test
13 public void basics() { 13 public void basics() {
14 PointToPointIntent intent = createOne(); 14 PointToPointIntent intent = createOne();
15 - assertEquals("incorrect id", IID, intent.id()); 15 + assertEquals("incorrect id", APPID, intent.appId());
16 assertEquals("incorrect match", MATCH, intent.selector()); 16 assertEquals("incorrect match", MATCH, intent.selector());
17 assertEquals("incorrect ingress", P1, intent.ingressPoint()); 17 assertEquals("incorrect ingress", P1, intent.ingressPoint());
18 assertEquals("incorrect egress", P2, intent.egressPoint()); 18 assertEquals("incorrect egress", P2, intent.egressPoint());
...@@ -20,11 +20,11 @@ public class PointToPointIntentTest extends ConnectivityIntentTest { ...@@ -20,11 +20,11 @@ public class PointToPointIntentTest extends ConnectivityIntentTest {
20 20
21 @Override 21 @Override
22 protected PointToPointIntent createOne() { 22 protected PointToPointIntent createOne() {
23 - return new PointToPointIntent(IID, MATCH, NOP, P1, P2); 23 + return new PointToPointIntent(APPID, MATCH, NOP, P1, P2);
24 } 24 }
25 25
26 @Override 26 @Override
27 protected PointToPointIntent createAnother() { 27 protected PointToPointIntent createAnother() {
28 - return new PointToPointIntent(IID, MATCH, NOP, P2, P1); 28 + return new PointToPointIntent(APPID, MATCH, NOP, P2, P1);
29 } 29 }
30 } 30 }
......
...@@ -12,7 +12,7 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest { ...@@ -12,7 +12,7 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest {
12 @Test 12 @Test
13 public void basics() { 13 public void basics() {
14 SinglePointToMultiPointIntent intent = createOne(); 14 SinglePointToMultiPointIntent intent = createOne();
15 - assertEquals("incorrect id", IID, intent.id()); 15 + assertEquals("incorrect id", APPID, intent.appId());
16 assertEquals("incorrect match", MATCH, intent.selector()); 16 assertEquals("incorrect match", MATCH, intent.selector());
17 assertEquals("incorrect ingress", P1, intent.ingressPoint()); 17 assertEquals("incorrect ingress", P1, intent.ingressPoint());
18 assertEquals("incorrect egress", PS2, intent.egressPoints()); 18 assertEquals("incorrect egress", PS2, intent.egressPoints());
...@@ -20,11 +20,11 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest { ...@@ -20,11 +20,11 @@ public class SinglePointToMultiPointIntentTest extends ConnectivityIntentTest {
20 20
21 @Override 21 @Override
22 protected SinglePointToMultiPointIntent createOne() { 22 protected SinglePointToMultiPointIntent createOne() {
23 - return new SinglePointToMultiPointIntent(IID, MATCH, NOP, P1, PS2); 23 + return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P1, PS2);
24 } 24 }
25 25
26 @Override 26 @Override
27 protected SinglePointToMultiPointIntent createAnother() { 27 protected SinglePointToMultiPointIntent createAnother() {
28 - return new SinglePointToMultiPointIntent(IID, MATCH, NOP, P2, PS1); 28 + return new SinglePointToMultiPointIntent(APPID, MATCH, NOP, P2, PS1);
29 } 29 }
30 } 30 }
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 -//TODO is this the right package?
3 2
4 -import org.onlab.onos.net.Link; 3 +import org.onlab.onos.TestApplicationId;
5 -
6 -import java.util.Collection;
7 4
8 /** 5 /**
9 * An installable intent used in the unit test. 6 * An installable intent used in the unit test.
10 - *
11 - * FIXME: we don't want to expose this class publicly, but the current Kryo
12 - * serialization mechanism does not allow this class to be private and placed
13 - * on testing directory.
14 */ 7 */
15 -public class TestInstallableIntent extends AbstractIntent implements InstallableIntent { 8 +public class TestInstallableIntent extends Intent {
16 /** 9 /**
17 * Constructs an instance with the specified intent ID. 10 * Constructs an instance with the specified intent ID.
18 * 11 *
19 * @param id intent ID 12 * @param id intent ID
20 */ 13 */
21 public TestInstallableIntent(IntentId id) { 14 public TestInstallableIntent(IntentId id) {
22 - super(id); 15 + super(id, new TestApplicationId("foo"), null);
23 } 16 }
24 17
25 /** 18 /**
...@@ -30,7 +23,8 @@ public class TestInstallableIntent extends AbstractIntent implements Installable ...@@ -30,7 +23,8 @@ public class TestInstallableIntent extends AbstractIntent implements Installable
30 } 23 }
31 24
32 @Override 25 @Override
33 - public Collection<Link> requiredLinks() { 26 + public boolean isInstallable() {
34 - return null; 27 + return true;
35 } 28 }
29 +
36 } 30 }
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 -//TODO is this the right package? 2 +
3 +import org.onlab.onos.TestApplicationId;
3 4
4 /** 5 /**
5 * An intent used in the unit test. 6 * An intent used in the unit test.
6 - *
7 - * FIXME: we don't want to expose this class publicly, but the current Kryo
8 - * serialization mechanism does not allow this class to be private and placed
9 - * on testing directory.
10 */ 7 */
11 -public class TestIntent extends AbstractIntent { 8 +public class TestIntent extends Intent {
12 /** 9 /**
13 * Constructs an instance with the specified intent ID. 10 * Constructs an instance with the specified intent ID.
14 * 11 *
15 * @param id intent ID 12 * @param id intent ID
16 */ 13 */
17 public TestIntent(IntentId id) { 14 public TestIntent(IntentId id) {
18 - super(id); 15 + super(id, new TestApplicationId("foo"), null);
19 } 16 }
20 17
21 /** 18 /**
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 -//TODO is this the right package?
3 2
4 /** 3 /**
5 * An intent used in the unit test. 4 * An intent used in the unit test.
6 - *
7 - * FIXME: we don't want to expose this class publicly, but the current Kryo
8 - * serialization mechanism does not allow this class to be private and placed
9 - * on testing directory.
10 */ 5 */
11 -public class TestSubclassInstallableIntent extends TestInstallableIntent implements InstallableIntent { 6 +public class TestSubclassInstallableIntent extends TestInstallableIntent {
12 /** 7 /**
13 * Constructs an instance with the specified intent ID. 8 * Constructs an instance with the specified intent ID.
14 * 9 *
......
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 -//TODO is this the right package?
3 2
4 /** 3 /**
5 * An intent used in the unit test. 4 * An intent used in the unit test.
6 - *
7 - * FIXME: we don't want to expose this class publicly, but the current Kryo
8 - * serialization mechanism does not allow this class to be private and placed
9 - * on testing directory.
10 */ 5 */
11 public class TestSubclassIntent extends TestIntent { 6 public class TestSubclassIntent extends TestIntent {
12 /** 7 /**
......
1 package org.onlab.onos.store.trivial.impl; 1 package org.onlab.onos.store.trivial.impl;
2 2
3 -import static org.onlab.onos.net.intent.IntentState.FAILED; 3 +import com.google.common.collect.ImmutableSet;
4 -import static org.onlab.onos.net.intent.IntentState.INSTALLED;
5 -import static org.onlab.onos.net.intent.IntentState.SUBMITTED;
6 -import static org.onlab.onos.net.intent.IntentState.WITHDRAWN;
7 -import static org.slf4j.LoggerFactory.getLogger;
8 -
9 -import java.util.List;
10 -import java.util.Map;
11 -import java.util.concurrent.ConcurrentHashMap;
12 -
13 import org.apache.felix.scr.annotations.Activate; 4 import org.apache.felix.scr.annotations.Activate;
14 import org.apache.felix.scr.annotations.Component; 5 import org.apache.felix.scr.annotations.Component;
15 import org.apache.felix.scr.annotations.Deactivate; 6 import org.apache.felix.scr.annotations.Deactivate;
16 import org.apache.felix.scr.annotations.Service; 7 import org.apache.felix.scr.annotations.Service;
17 -import org.onlab.onos.net.intent.InstallableIntent;
18 import org.onlab.onos.net.intent.Intent; 8 import org.onlab.onos.net.intent.Intent;
19 import org.onlab.onos.net.intent.IntentEvent; 9 import org.onlab.onos.net.intent.IntentEvent;
20 import org.onlab.onos.net.intent.IntentId; 10 import org.onlab.onos.net.intent.IntentId;
...@@ -24,7 +14,12 @@ import org.onlab.onos.net.intent.IntentStoreDelegate; ...@@ -24,7 +14,12 @@ import org.onlab.onos.net.intent.IntentStoreDelegate;
24 import org.onlab.onos.store.AbstractStore; 14 import org.onlab.onos.store.AbstractStore;
25 import org.slf4j.Logger; 15 import org.slf4j.Logger;
26 16
27 -import com.google.common.collect.ImmutableSet; 17 +import java.util.List;
18 +import java.util.Map;
19 +import java.util.concurrent.ConcurrentHashMap;
20 +
21 +import static org.onlab.onos.net.intent.IntentState.*;
22 +import static org.slf4j.LoggerFactory.getLogger;
28 23
29 @Component(immediate = true) 24 @Component(immediate = true)
30 @Service 25 @Service
...@@ -35,7 +30,7 @@ public class SimpleIntentStore ...@@ -35,7 +30,7 @@ public class SimpleIntentStore
35 private final Logger log = getLogger(getClass()); 30 private final Logger log = getLogger(getClass());
36 private final Map<IntentId, Intent> intents = new ConcurrentHashMap<>(); 31 private final Map<IntentId, Intent> intents = new ConcurrentHashMap<>();
37 private final Map<IntentId, IntentState> states = new ConcurrentHashMap<>(); 32 private final Map<IntentId, IntentState> states = new ConcurrentHashMap<>();
38 - private final Map<IntentId, List<InstallableIntent>> installable = 33 + private final Map<IntentId, List<Intent>> installable =
39 new ConcurrentHashMap<>(); 34 new ConcurrentHashMap<>();
40 35
41 @Activate 36 @Activate
...@@ -96,12 +91,12 @@ public class SimpleIntentStore ...@@ -96,12 +91,12 @@ public class SimpleIntentStore
96 } 91 }
97 92
98 @Override 93 @Override
99 - public void addInstallableIntents(IntentId intentId, List<InstallableIntent> result) { 94 + public void addInstallableIntents(IntentId intentId, List<Intent> result) {
100 installable.put(intentId, result); 95 installable.put(intentId, result);
101 } 96 }
102 97
103 @Override 98 @Override
104 - public List<InstallableIntent> getInstallableIntents(IntentId intentId) { 99 + public List<Intent> getInstallableIntents(IntentId intentId) {
105 return installable.get(intentId); 100 return installable.get(intentId);
106 } 101 }
107 102
......