Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 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 | /** |
| 35 | * Returns a collection of all intents in the store. |
| 36 | * |
| 37 | * @return iterable collection of all intents |
| 38 | */ |
| 39 | Iterable<Intent> getIntents(); |
| 40 | |
| 41 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 42 | * Returns the state of the specified intent. |
| 43 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 44 | * @param intentKey intent identification |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 45 | * @return current intent state |
| 46 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 47 | IntentState getIntentState(Key intentKey); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 50 | * Returns the list of the installable events associated with the specified |
| 51 | * original intent. |
| 52 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 53 | * @param intentKey original intent identifier |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 54 | * @return compiled installable intents, or null if no installables exist |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 55 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 56 | List<Intent> getInstallableIntents(Key intentKey); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 57 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 58 | /** |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 59 | * Writes an IntentData object to the store. |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 60 | * |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 61 | * @param newData new intent data to write |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 62 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 63 | void write(IntentData newData); |
Jonathan Hart | 2085e07 | 2015-02-12 11:44:03 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Writes a batch of IntentData objects to the store. A batch has no |
| 67 | * semantics, this is simply a convenience API. |
| 68 | * |
| 69 | * @param updates collection of intent data objects to write |
| 70 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 71 | void batchWrite(Iterable<IntentData> updates); |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 72 | |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 73 | /** |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 74 | * Returns the intent with the specified identifier. |
| 75 | * |
| 76 | * @param key key |
| 77 | * @return intent or null if not found |
| 78 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 79 | Intent getIntent(Key key); |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Returns the intent data object associated with the specified key. |
| 83 | * |
| 84 | * @param key key to look up |
| 85 | * @return intent data object |
| 86 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 87 | IntentData getIntentData(Key key); |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 90 | * Adds a new operation, which should be persisted and delegated. |
| 91 | * |
Brian O'Connor | cff0332 | 2015-02-03 15:28:59 -0800 | [diff] [blame] | 92 | * @param intent operation |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 93 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 94 | void addPending(IntentData intent); |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Checks to see whether the calling instance is the master for processing |
| 98 | * this intent, or more specifically, the key contained in this intent. |
| 99 | * |
Brian O'Connor | be28a87 | 2015-02-19 21:44:37 -0800 | [diff] [blame] | 100 | * @param intentKey intentKey to check |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 101 | * @return true if master; false, otherwise |
| 102 | */ |
| 103 | //TODO better name |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 104 | boolean isMaster(Key intentKey); |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Returns the intent requests pending processing. |
| 108 | * |
| 109 | * @return pending intents |
| 110 | */ |
Jonathan Hart | 6a8fd1d | 2015-02-25 15:44:37 -0800 | [diff] [blame] | 111 | Iterable<Intent> getPending(); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 112 | } |