Committed by
Gerrit Code Review
Initial work on Intent API (ONOS-618)
Change-Id: I2b4aa0befabbf0b4dce8b2c991e38411709b2e80
Showing
12 changed files
with
61 additions
and
1 deletions
... | @@ -34,7 +34,10 @@ import static com.google.common.base.Preconditions.checkState; | ... | @@ -34,7 +34,10 @@ import static com.google.common.base.Preconditions.checkState; |
34 | public abstract class Intent { | 34 | public abstract class Intent { |
35 | 35 | ||
36 | private final IntentId id; | 36 | private final IntentId id; |
37 | + | ||
37 | private final ApplicationId appId; | 38 | private final ApplicationId appId; |
39 | + private final String key; | ||
40 | + | ||
38 | private final Collection<NetworkResource> resources; | 41 | private final Collection<NetworkResource> resources; |
39 | 42 | ||
40 | private static IdGenerator idGenerator; | 43 | private static IdGenerator idGenerator; |
... | @@ -45,6 +48,7 @@ public abstract class Intent { | ... | @@ -45,6 +48,7 @@ public abstract class Intent { |
45 | protected Intent() { | 48 | protected Intent() { |
46 | this.id = null; | 49 | this.id = null; |
47 | this.appId = null; | 50 | this.appId = null; |
51 | + this.key = null; | ||
48 | this.resources = null; | 52 | this.resources = null; |
49 | } | 53 | } |
50 | 54 | ||
... | @@ -54,11 +58,26 @@ public abstract class Intent { | ... | @@ -54,11 +58,26 @@ public abstract class Intent { |
54 | * @param appId application identifier | 58 | * @param appId application identifier |
55 | * @param resources required network resources (optional) | 59 | * @param resources required network resources (optional) |
56 | */ | 60 | */ |
61 | + @Deprecated | ||
62 | + protected Intent(ApplicationId appId, | ||
63 | + Collection<NetworkResource> resources) { | ||
64 | + this(appId, null, resources); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Creates a new intent. | ||
69 | + * | ||
70 | + * @param appId application identifier | ||
71 | + * @param key optional key | ||
72 | + * @param resources required network resources (optional) | ||
73 | + */ | ||
57 | protected Intent(ApplicationId appId, | 74 | protected Intent(ApplicationId appId, |
75 | + String key, | ||
58 | Collection<NetworkResource> resources) { | 76 | Collection<NetworkResource> resources) { |
59 | checkState(idGenerator != null, "Id generator is not bound."); | 77 | checkState(idGenerator != null, "Id generator is not bound."); |
60 | this.id = IntentId.valueOf(idGenerator.getNewId()); | 78 | this.id = IntentId.valueOf(idGenerator.getNewId()); |
61 | this.appId = checkNotNull(appId, "Application ID cannot be null"); | 79 | this.appId = checkNotNull(appId, "Application ID cannot be null"); |
80 | + this.key = (key != null) ? key : id.toString(); //FIXME | ||
62 | this.resources = checkNotNull(resources); | 81 | this.resources = checkNotNull(resources); |
63 | } | 82 | } |
64 | 83 | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent; |
18 | /** | 18 | /** |
19 | * Facade for receiving notifications from the intent batch service. | 19 | * Facade for receiving notifications from the intent batch service. |
20 | */ | 20 | */ |
21 | +@Deprecated | ||
21 | public interface IntentBatchDelegate { | 22 | public interface IntentBatchDelegate { |
22 | 23 | ||
23 | /** | 24 | /** | ... | ... |
... | @@ -21,6 +21,7 @@ import org.onosproject.event.AbstractEvent; | ... | @@ -21,6 +21,7 @@ import org.onosproject.event.AbstractEvent; |
21 | /** | 21 | /** |
22 | * A class to represent an intent related event. | 22 | * A class to represent an intent related event. |
23 | */ | 23 | */ |
24 | +@Deprecated | ||
24 | public class IntentBatchLeaderEvent extends AbstractEvent<IntentBatchLeaderEvent.Type, ApplicationId> { | 25 | public class IntentBatchLeaderEvent extends AbstractEvent<IntentBatchLeaderEvent.Type, ApplicationId> { |
25 | 26 | ||
26 | public enum Type { | 27 | public enum Type { | ... | ... |
... | @@ -20,5 +20,6 @@ import org.onosproject.event.EventListener; | ... | @@ -20,5 +20,6 @@ import org.onosproject.event.EventListener; |
20 | /** | 20 | /** |
21 | * Listener for {@link org.onosproject.net.intent.IntentEvent intent events}. | 21 | * Listener for {@link org.onosproject.net.intent.IntentEvent intent events}. |
22 | */ | 22 | */ |
23 | +@Deprecated | ||
23 | public interface IntentBatchListener extends EventListener<IntentBatchLeaderEvent> { | 24 | public interface IntentBatchListener extends EventListener<IntentBatchLeaderEvent> { |
24 | } | 25 | } | ... | ... |
... | @@ -22,6 +22,7 @@ import java.util.Set; | ... | @@ -22,6 +22,7 @@ import java.util.Set; |
22 | /** | 22 | /** |
23 | * Service for tracking and delegating batches of intent operations. | 23 | * Service for tracking and delegating batches of intent operations. |
24 | */ | 24 | */ |
25 | +@Deprecated | ||
25 | public interface IntentBatchService { | 26 | public interface IntentBatchService { |
26 | 27 | ||
27 | /** | 28 | /** | ... | ... |
... | @@ -29,6 +29,7 @@ public final class IntentOperation { | ... | @@ -29,6 +29,7 @@ public final class IntentOperation { |
29 | private final Type type; | 29 | private final Type type; |
30 | private final IntentId intentId; | 30 | private final IntentId intentId; |
31 | private final Intent intent; | 31 | private final Intent intent; |
32 | + //FIXME consider pulling the key out (we will hash based on key) | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Operation type. | 35 | * Operation type. |
... | @@ -47,11 +48,13 @@ public final class IntentOperation { | ... | @@ -47,11 +48,13 @@ public final class IntentOperation { |
47 | /** | 48 | /** |
48 | * Indicates that an intent should be replaced with another. | 49 | * Indicates that an intent should be replaced with another. |
49 | */ | 50 | */ |
51 | + @Deprecated | ||
50 | REPLACE, | 52 | REPLACE, |
51 | 53 | ||
52 | /** | 54 | /** |
53 | * Indicates that an intent should be updated (i.e. recompiled/reinstalled). | 55 | * Indicates that an intent should be updated (i.e. recompiled/reinstalled). |
54 | */ | 56 | */ |
57 | + @Deprecated | ||
55 | UPDATE, | 58 | UPDATE, |
56 | } | 59 | } |
57 | 60 | ... | ... |
... | @@ -31,6 +31,7 @@ import static org.onosproject.net.intent.IntentOperation.Type.WITHDRAW; | ... | @@ -31,6 +31,7 @@ import static org.onosproject.net.intent.IntentOperation.Type.WITHDRAW; |
31 | /** | 31 | /** |
32 | * Batch of intent submit/withdraw/replace operations. | 32 | * Batch of intent submit/withdraw/replace operations. |
33 | */ | 33 | */ |
34 | +@Deprecated | ||
34 | public final class IntentOperations { | 35 | public final class IntentOperations { |
35 | 36 | ||
36 | private final List<IntentOperation> operations; | 37 | private final List<IntentOperation> operations; | ... | ... |
... | @@ -48,6 +48,7 @@ public interface IntentService { | ... | @@ -48,6 +48,7 @@ public interface IntentService { |
48 | * @param oldIntentId identifier of the old intent being replaced | 48 | * @param oldIntentId identifier of the old intent being replaced |
49 | * @param newIntent new intent replacing the old one | 49 | * @param newIntent new intent replacing the old one |
50 | */ | 50 | */ |
51 | + @Deprecated | ||
51 | void replace(IntentId oldIntentId, Intent newIntent); | 52 | void replace(IntentId oldIntentId, Intent newIntent); |
52 | 53 | ||
53 | /** | 54 | /** |
... | @@ -59,6 +60,7 @@ public interface IntentService { | ... | @@ -59,6 +60,7 @@ public interface IntentService { |
59 | * </p> | 60 | * </p> |
60 | * @param operations batch of intent operations | 61 | * @param operations batch of intent operations |
61 | */ | 62 | */ |
63 | + @Deprecated | ||
62 | void execute(IntentOperations operations); | 64 | void execute(IntentOperations operations); |
63 | 65 | ||
64 | /** | 66 | /** | ... | ... |
... | @@ -37,7 +37,7 @@ public enum IntentState { | ... | @@ -37,7 +37,7 @@ public enum IntentState { |
37 | * This is a transitional state after which the intent will enter either | 37 | * This is a transitional state after which the intent will enter either |
38 | * {@link #FAILED} state or {@link #INSTALLING} state. | 38 | * {@link #FAILED} state or {@link #INSTALLING} state. |
39 | */ | 39 | */ |
40 | - COMPILING, | 40 | + COMPILING, //TODO do we really need this? |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Signifies that the resulting installable intents are being installed | 43 | * Signifies that the resulting installable intents are being installed | ... | ... |
... | @@ -73,4 +73,22 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -73,4 +73,22 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
73 | */ | 73 | */ |
74 | List<Operation> batchWrite(BatchWrite batch); | 74 | List<Operation> batchWrite(BatchWrite batch); |
75 | 75 | ||
76 | + /** | ||
77 | + * Adds a new operation, which should be persisted and delegated. | ||
78 | + * | ||
79 | + * @param op operation | ||
80 | + */ | ||
81 | + default void add(IntentOperation op) {} //FIXME remove when impl. | ||
82 | + | ||
83 | + /** | ||
84 | + * Checks to see whether the calling instance is the master for processing | ||
85 | + * this intent, or more specifically, the key contained in this intent. | ||
86 | + * | ||
87 | + * @param intent intent to check | ||
88 | + * @return true if master; false, otherwise | ||
89 | + */ | ||
90 | + //TODO better name | ||
91 | + default boolean isMaster(Intent intent) { //FIXME remove default when impl. | ||
92 | + return true; | ||
93 | + } | ||
76 | } | 94 | } | ... | ... |
... | @@ -21,4 +21,12 @@ import org.onosproject.store.StoreDelegate; | ... | @@ -21,4 +21,12 @@ import org.onosproject.store.StoreDelegate; |
21 | * Intent store delegate abstraction. | 21 | * Intent store delegate abstraction. |
22 | */ | 22 | */ |
23 | public interface IntentStoreDelegate extends StoreDelegate<IntentEvent> { | 23 | public interface IntentStoreDelegate extends StoreDelegate<IntentEvent> { |
24 | + | ||
25 | + /** | ||
26 | + * Provides an intent operation that should be processed (compiled and | ||
27 | + * installed) by this manager. | ||
28 | + * | ||
29 | + * @param op intent operation | ||
30 | + */ | ||
31 | + void process(IntentOperation op); | ||
24 | } | 32 | } | ... | ... |
... | @@ -380,6 +380,11 @@ public class IntentManager | ... | @@ -380,6 +380,11 @@ public class IntentManager |
380 | public void notify(IntentEvent event) { | 380 | public void notify(IntentEvent event) { |
381 | eventDispatcher.post(event); | 381 | eventDispatcher.post(event); |
382 | } | 382 | } |
383 | + | ||
384 | + @Override | ||
385 | + public void process(IntentOperation op) { | ||
386 | + //FIXME | ||
387 | + } | ||
383 | } | 388 | } |
384 | 389 | ||
385 | private void buildAndSubmitBatches(Iterable<IntentId> intentIds, | 390 | private void buildAndSubmitBatches(Iterable<IntentId> intentIds, | ... | ... |
-
Please register or login to post a comment