Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.intent; |
| 20 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 21 | import org.onlab.onos.store.Store; |
| 22 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 23 | import java.util.List; |
| 24 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Manages inventory of end-station intents; not intended for direct use. |
| 27 | */ |
| 28 | public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 29 | |
| 30 | /** |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 31 | * Submits a new intent into the store. If the returned event is not |
| 32 | * null, the manager is expected to dispatch the event and then to kick |
| 33 | * off intent compilation process. Otherwise, another node has been elected |
| 34 | * to perform the compilation process and the node will learn about |
| 35 | * the submittal and results of the intent compilation via the delegate |
| 36 | * mechanism. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 37 | * |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 38 | * @param intent intent to be submitted |
| 39 | * @return event indicating the intent was submitted or null if no |
| 40 | * change resulted, e.g. duplicate intent |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 41 | */ |
| 42 | IntentEvent createIntent(Intent intent); |
| 43 | |
| 44 | /** |
| 45 | * Removes the specified intent from the inventory. |
| 46 | * |
| 47 | * @param intentId intent identification |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 48 | * @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] | 49 | */ |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 50 | IntentEvent removeIntent(IntentId intentId); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Returns the number of intents in the store. |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 54 | * |
| 55 | * @return the number of intents in the store |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 56 | */ |
| 57 | long getIntentCount(); |
| 58 | |
| 59 | /** |
| 60 | * Returns a collection of all intents in the store. |
| 61 | * |
| 62 | * @return iterable collection of all intents |
| 63 | */ |
| 64 | Iterable<Intent> getIntents(); |
| 65 | |
| 66 | /** |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 67 | * Returns the intent with the specified identifier. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 68 | * |
| 69 | * @param intentId intent identification |
| 70 | * @return intent or null if not found |
| 71 | */ |
| 72 | Intent getIntent(IntentId intentId); |
| 73 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 74 | /** |
| 75 | * Returns the state of the specified intent. |
| 76 | * |
| 77 | * @param intentId intent identification |
| 78 | * @return current intent state |
| 79 | */ |
| 80 | IntentState getIntentState(IntentId intentId); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Sets the state of the specified intent to the new state. |
| 84 | * |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 85 | * @param intent intent whose state is to be changed |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 86 | * @param newState new state |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 87 | * @return state transition event |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 88 | */ |
| 89 | IntentEvent setState(Intent intent, IntentState newState); |
| 90 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 91 | /** |
| 92 | * Adds the installable intents which resulted from compilation of the |
| 93 | * specified original intent. |
| 94 | * |
| 95 | * @param intentId original intent identifier |
| 96 | * @param installableIntents compiled installable intents |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 97 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 98 | void addInstallableIntents(IntentId intentId, List<Intent> installableIntents); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 99 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 100 | /** |
| 101 | * Returns the list of the installable events associated with the specified |
| 102 | * original intent. |
| 103 | * |
| 104 | * @param intentId original intent identifier |
| 105 | * @return compiled installable intents |
| 106 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 107 | List<Intent> getInstallableIntents(IntentId intentId); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 108 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 109 | // TODO: this should be triggered from with the store as a result of removeIntent call |
| 110 | |
| 111 | /** |
| 112 | * Removes any installable intents which resulted from compilation of the |
| 113 | * specified original intent. |
| 114 | * |
| 115 | * @param intentId original intent identifier |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 116 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 117 | void removeInstalledIntents(IntentId intentId); |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 118 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 119 | } |