Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 3 | import org.onlab.onos.store.Store; |
| 4 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 5 | import java.util.List; |
| 6 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 7 | /** |
| 8 | * Manages inventory of end-station intents; not intended for direct use. |
| 9 | */ |
| 10 | public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 11 | |
| 12 | /** |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 13 | * Submits a new intent into the store. If the returned event is not |
| 14 | * null, the manager is expected to dispatch the event and then to kick |
| 15 | * off intent compilation process. Otherwise, another node has been elected |
| 16 | * to perform the compilation process and the node will learn about |
| 17 | * the submittal and results of the intent compilation via the delegate |
| 18 | * mechanism. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 19 | * |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 20 | * @param intent intent to be submitted |
| 21 | * @return event indicating the intent was submitted or null if no |
| 22 | * change resulted, e.g. duplicate intent |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 23 | */ |
| 24 | IntentEvent createIntent(Intent intent); |
| 25 | |
| 26 | /** |
| 27 | * Removes the specified intent from the inventory. |
| 28 | * |
| 29 | * @param intentId intent identification |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 30 | * @return removed state transition event or null if intent was not found |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 31 | */ |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 32 | IntentEvent removeIntent(IntentId intentId); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Returns the number of intents in the store. |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 36 | * |
| 37 | * @return the number of intents in the store |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 38 | */ |
| 39 | long getIntentCount(); |
| 40 | |
| 41 | /** |
| 42 | * Returns a collection of all intents in the store. |
| 43 | * |
| 44 | * @return iterable collection of all intents |
| 45 | */ |
| 46 | Iterable<Intent> getIntents(); |
| 47 | |
| 48 | /** |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 49 | * Returns the intent with the specified identifier. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 50 | * |
| 51 | * @param intentId intent identification |
| 52 | * @return intent or null if not found |
| 53 | */ |
| 54 | Intent getIntent(IntentId intentId); |
| 55 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Returns the state of the specified intent. |
| 58 | * |
| 59 | * @param intentId intent identification |
| 60 | * @return current intent state |
| 61 | */ |
| 62 | IntentState getIntentState(IntentId intentId); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * Sets the state of the specified intent to the new state. |
| 66 | * |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 67 | * @param intent intent whose state is to be changed |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 68 | * @param newState new state |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 69 | * @return state transition event |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 70 | */ |
| 71 | IntentEvent setState(Intent intent, IntentState newState); |
| 72 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Adds the installable intents which resulted from compilation of the |
| 75 | * specified original intent. |
| 76 | * |
| 77 | * @param intentId original intent identifier |
| 78 | * @param installableIntents compiled installable intents |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 79 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 80 | void addInstallableIntents(IntentId intentId, |
| 81 | List<InstallableIntent> installableIntents); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 82 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 83 | /** |
| 84 | * Returns the list of the installable events associated with the specified |
| 85 | * original intent. |
| 86 | * |
| 87 | * @param intentId original intent identifier |
| 88 | * @return compiled installable intents |
| 89 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 90 | List<InstallableIntent> getInstallableIntents(IntentId intentId); |
| 91 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 92 | // TODO: this should be triggered from with the store as a result of removeIntent call |
| 93 | |
| 94 | /** |
| 95 | * Removes any installable intents which resulted from compilation of the |
| 96 | * specified original intent. |
| 97 | * |
| 98 | * @param intentId original intent identifier |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 99 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 100 | void removeInstalledIntents(IntentId intentId); |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 101 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 102 | } |