Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.store.Store; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 19 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 20 | import java.util.List; |
| 21 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Manages inventory of end-station intents; not intended for direct use. |
| 24 | */ |
| 25 | public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 26 | |
| 27 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 28 | * Returns the number of intents in the store. |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 29 | * |
| 30 | * @return the number of intents in the store |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 31 | */ |
| 32 | long getIntentCount(); |
| 33 | |
| 34 | /** |
Brian O'Connor | 3c58e96 | 2015-04-28 23:21:51 -0700 | [diff] [blame] | 35 | * Returns an iterable of all intents in the store. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 36 | * |
Brian O'Connor | 3c58e96 | 2015-04-28 23:21:51 -0700 | [diff] [blame] | 37 | * @return iterable of all intents |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 38 | */ |
| 39 | Iterable<Intent> getIntents(); |
| 40 | |
Brian O'Connor | 3c58e96 | 2015-04-28 23:21:51 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Returns an iterable of all intent data objects in the store. |
| 44 | * |
| 45 | * @param localOnly should only intents for which this instance is master |
Brian O'Connor | a6c9b5c | 2015-04-29 22:38:29 -0700 | [diff] [blame] | 46 | * be returned |
| 47 | * @param olderThan specified duration in milliseconds (0 for "now") |
Brian O'Connor | 3c58e96 | 2015-04-28 23:21:51 -0700 | [diff] [blame] | 48 | * @return iterable of all intent data objects |
| 49 | */ |
Brian O'Connor | a6c9b5c | 2015-04-29 22:38:29 -0700 | [diff] [blame] | 50 | Iterable<IntentData> getIntentData(boolean localOnly, long olderThan); |
Brian O'Connor | 3c58e96 | 2015-04-28 23:21:51 -0700 | [diff] [blame] | 51 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 52 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 53 | * Returns the state of the specified intent. |
| 54 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 55 | * @param intentKey intent identification |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 56 | * @return current intent state |
| 57 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 58 | IntentState getIntentState(Key intentKey); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 61 | * Returns the list of the installable events associated with the specified |
| 62 | * original intent. |
| 63 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 64 | * @param intentKey original intent identifier |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 65 | * @return compiled installable intents, or null if no installables exist |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 66 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 67 | List<Intent> getInstallableIntents(Key intentKey); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 68 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 69 | /** |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 70 | * Writes an IntentData object to the store. |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 71 | * |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 72 | * @param newData new intent data to write |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 73 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 74 | void write(IntentData newData); |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Writes a batch of IntentData objects to the store. A batch has no |
| 78 | * semantics, this is simply a convenience API. |
| 79 | * |
| 80 | * @param updates collection of intent data objects to write |
| 81 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 82 | void batchWrite(Iterable<IntentData> updates); |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 83 | |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 84 | /** |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 85 | * Returns the intent with the specified identifier. |
| 86 | * |
| 87 | * @param key key |
| 88 | * @return intent or null if not found |
| 89 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 90 | Intent getIntent(Key key); |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Returns the intent data object associated with the specified key. |
| 94 | * |
| 95 | * @param key key to look up |
| 96 | * @return intent data object |
| 97 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 98 | IntentData getIntentData(Key key); |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 99 | |
| 100 | /** |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 101 | * Adds a new operation, which should be persisted and delegated. |
| 102 | * |
Brian O'Connor | cff0332 | 2015-02-03 15:28:59 -0800 | [diff] [blame] | 103 | * @param intent operation |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 104 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 105 | void addPending(IntentData intent); |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Checks to see whether the calling instance is the master for processing |
| 109 | * this intent, or more specifically, the key contained in this intent. |
| 110 | * |
Brian O'Connor | be28a87 | 2015-02-19 21:44:37 -0800 | [diff] [blame] | 111 | * @param intentKey intentKey to check |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 112 | * @return true if master; false, otherwise |
| 113 | */ |
| 114 | //TODO better name |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 115 | boolean isMaster(Key intentKey); |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Returns the intent requests pending processing. |
| 119 | * |
| 120 | * @return pending intents |
| 121 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 122 | Iterable<Intent> getPending(); |
Brian O'Connor | a6c9b5c | 2015-04-29 22:38:29 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Returns the intent data objects that are pending processing. |
| 126 | * |
| 127 | * @return pending intent data objects |
| 128 | */ |
| 129 | Iterable<IntentData> getPendingData(); |
| 130 | |
| 131 | /** |
| 132 | * Returns the intent data objects that are pending processing for longer |
| 133 | * than the specified duration. |
| 134 | * |
| 135 | * @param localOnly should only intents for which this instance is master |
| 136 | * be returned |
| 137 | * @param olderThan specified duration in milliseconds (0 for "now") |
| 138 | * @return pending intent data objects |
| 139 | */ |
| 140 | Iterable<IntentData> getPendingData(boolean localOnly, long olderThan); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 141 | } |