Yoonseon Han | 9e04379 | 2017-05-03 15:43:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Yoonseon Han | 9e04379 | 2017-05-03 15:43:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.incubator.net.virtual; |
| 18 | |
| 19 | import org.onosproject.net.intent.Intent; |
| 20 | import org.onosproject.net.intent.IntentData; |
| 21 | import org.onosproject.net.intent.IntentEvent; |
| 22 | import org.onosproject.net.intent.IntentState; |
| 23 | import org.onosproject.net.intent.IntentStoreDelegate; |
| 24 | import org.onosproject.net.intent.Key; |
| 25 | |
| 26 | import java.util.List; |
| 27 | |
| 28 | public interface VirtualNetworkIntentStore |
| 29 | extends VirtualStore<IntentEvent, IntentStoreDelegate> { |
| 30 | |
| 31 | /** |
| 32 | * Returns the number of intents in the store. |
| 33 | * |
| 34 | * @param networkId the virtual network identifier |
| 35 | * @return the number of intents in the store |
| 36 | */ |
| 37 | long getIntentCount(NetworkId networkId); |
| 38 | |
| 39 | /** |
| 40 | * Returns an iterable of all intents in the store. |
| 41 | * |
| 42 | * @param networkId the virtual network identifier |
| 43 | * @return iterable of all intents |
| 44 | */ |
| 45 | Iterable<Intent> getIntents(NetworkId networkId); |
| 46 | |
| 47 | /** |
| 48 | * Returns an iterable of all intent data objects in the store. |
| 49 | * |
| 50 | * @param networkId the virtual network identifier |
| 51 | * @param localOnly should only intents for which this instance is master |
| 52 | * be returned |
| 53 | * @param olderThan specified duration in milliseconds (0 for "now") |
| 54 | * @return iterable of all intent data objects |
| 55 | */ |
| 56 | Iterable<IntentData> getIntentData(NetworkId networkId, boolean localOnly, |
| 57 | long olderThan); |
| 58 | |
| 59 | /** |
| 60 | * Returns the state of the specified intent. |
| 61 | * |
| 62 | * @param networkId the virtual network identifier |
| 63 | * @param intentKey intent identification |
| 64 | * @return current intent state |
| 65 | */ |
| 66 | IntentState getIntentState(NetworkId networkId, Key intentKey); |
| 67 | |
| 68 | /** |
| 69 | * Returns the list of the installable events associated with the specified |
| 70 | * original intent. |
| 71 | * |
| 72 | * @param networkId the virtual network identifier |
| 73 | * @param intentKey original intent identifier |
| 74 | * @return compiled installable intents, or null if no installables exist |
| 75 | */ |
| 76 | List<Intent> getInstallableIntents(NetworkId networkId, Key intentKey); |
| 77 | |
| 78 | /** |
| 79 | * Writes an IntentData object to the store. |
| 80 | * |
| 81 | * @param networkId the virtual network identifier |
| 82 | * @param newData new intent data to write |
| 83 | */ |
| 84 | void write(NetworkId networkId, IntentData newData); |
| 85 | |
| 86 | /** |
| 87 | * Writes a batch of IntentData objects to the store. A batch has no |
| 88 | * semantics, this is simply a convenience API. |
| 89 | * |
| 90 | * @param networkId the virtual network identifier |
| 91 | * @param updates collection of intent data objects to write |
| 92 | */ |
| 93 | void batchWrite(NetworkId networkId, Iterable<IntentData> updates); |
| 94 | |
| 95 | /** |
| 96 | * Returns the intent with the specified identifier. |
| 97 | * |
| 98 | * @param networkId the virtual network identifier |
| 99 | * @param key key |
| 100 | * @return intent or null if not found |
| 101 | */ |
| 102 | Intent getIntent(NetworkId networkId, Key key); |
| 103 | |
| 104 | /** |
| 105 | * Returns the intent data object associated with the specified key. |
| 106 | * |
| 107 | * @param networkId the virtual network identifier |
| 108 | * @param key key to look up |
| 109 | * @return intent data object |
| 110 | */ |
| 111 | IntentData getIntentData(NetworkId networkId, Key key); |
| 112 | |
| 113 | /** |
| 114 | * Adds a new operation, which should be persisted and delegated. |
| 115 | * |
| 116 | * @param networkId the virtual network identifier |
| 117 | * @param intent operation |
| 118 | */ |
| 119 | void addPending(NetworkId networkId, IntentData intent); |
| 120 | |
| 121 | /** |
| 122 | * Checks to see whether the calling instance is the master for processing |
| 123 | * this intent, or more specifically, the key contained in this intent. |
| 124 | * |
| 125 | * @param networkId the virtual network identifier |
| 126 | * @param intentKey intentKey to check |
| 127 | * @return true if master; false, otherwise |
| 128 | */ |
| 129 | //TODO better name |
| 130 | boolean isMaster(NetworkId networkId, Key intentKey); |
| 131 | |
| 132 | /** |
| 133 | * Returns the intent requests pending processing. |
| 134 | * |
| 135 | * @param networkId the virtual network identifier |
| 136 | * @return pending intents |
| 137 | */ |
| 138 | Iterable<Intent> getPending(NetworkId networkId); |
| 139 | |
| 140 | /** |
| 141 | * Returns the intent data objects that are pending processing. |
| 142 | * |
| 143 | * @param networkId the virtual network identifier |
| 144 | * @return pending intent data objects |
| 145 | */ |
| 146 | Iterable<IntentData> getPendingData(NetworkId networkId); |
| 147 | |
| 148 | /** |
| 149 | * Returns the intent data object that are pending processing for a specfied |
| 150 | * key. |
| 151 | * |
| 152 | * @param networkId the virtual network identifier |
| 153 | * @param intentKey key to look up |
| 154 | * @return pending intent data object |
| 155 | */ |
| 156 | IntentData getPendingData(NetworkId networkId, Key intentKey); |
| 157 | |
| 158 | /** |
| 159 | * Returns the intent data objects that are pending processing for longer |
| 160 | * than the specified duration. |
| 161 | * |
| 162 | * @param networkId the virtual network identifier |
| 163 | * @param localOnly should only intents for which this instance is master |
| 164 | * be returned |
| 165 | * @param olderThan specified duration in milliseconds (0 for "now") |
| 166 | * @return pending intent data objects |
| 167 | */ |
| 168 | Iterable<IntentData> getPendingData(NetworkId networkId, boolean localOnly, long olderThan); |
| 169 | |
| 170 | } |