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 | |
Sho SHIMIZU | 64ae11c | 2014-12-03 15:17:47 -0800 | [diff] [blame] | 18 | import org.onosproject.net.intent.BatchWrite.Operation; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.store.Store; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 20 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 21 | import java.util.List; |
| 22 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Manages inventory of end-station intents; not intended for direct use. |
| 25 | */ |
| 26 | public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 27 | |
| 28 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 29 | * Returns the number of intents in the store. |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 30 | * |
| 31 | * @return the number of intents in the store |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 32 | */ |
| 33 | long getIntentCount(); |
| 34 | |
| 35 | /** |
| 36 | * Returns a collection of all intents in the store. |
| 37 | * |
| 38 | * @return iterable collection of all intents |
| 39 | */ |
| 40 | Iterable<Intent> getIntents(); |
| 41 | |
| 42 | /** |
Toshio Koide | d32809b | 2014-10-09 10:58:54 -0700 | [diff] [blame] | 43 | * Returns the intent with the specified identifier. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 44 | * |
| 45 | * @param intentId intent identification |
| 46 | * @return intent or null if not found |
| 47 | */ |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 48 | @Deprecated |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 49 | default Intent getIntent(IntentId intentId) { |
| 50 | throw new UnsupportedOperationException("deprecated"); |
| 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 | /** |
| 54 | * Returns the state of the specified intent. |
| 55 | * |
| 56 | * @param intentId intent identification |
| 57 | * @return current intent state |
| 58 | */ |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 59 | @Deprecated |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 60 | default IntentState getIntentState(IntentId intentId) { |
| 61 | throw new UnsupportedOperationException("deprecated"); |
| 62 | } |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 65 | * Returns the list of the installable events associated with the specified |
| 66 | * original intent. |
| 67 | * |
| 68 | * @param intentId original intent identifier |
| 69 | * @return compiled installable intents |
| 70 | */ |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 71 | @Deprecated |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 72 | default List<Intent> getInstallableIntents(IntentId intentId) { |
| 73 | throw new UnsupportedOperationException("deprecated"); |
| 74 | } |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 75 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 76 | /** |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 77 | * Execute writes in a batch. |
Sho SHIMIZU | 2bb988b | 2015-01-20 13:45:35 -0800 | [diff] [blame] | 78 | * If the specified BatchWrite is empty, write will not be executed. |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 79 | * |
| 80 | * @param batch BatchWrite to execute |
| 81 | * @return failed operations |
| 82 | */ |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 83 | @Deprecated |
Sho SHIMIZU | 4c464fb | 2014-12-03 15:12:21 -0800 | [diff] [blame] | 84 | List<Operation> batchWrite(BatchWrite batch); |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 85 | default void write(IntentData newData) {} |
| 86 | default void batchWrite(Iterable<IntentData> updates) {} |
Yuta HIGUCHI | a94c6e8 | 2014-11-28 18:49:54 -0800 | [diff] [blame] | 87 | |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 88 | /** |
Brian O'Connor | b499b35 | 2015-02-03 16:46:15 -0800 | [diff] [blame] | 89 | * Returns the intent with the specified identifier. |
| 90 | * |
| 91 | * @param key key |
| 92 | * @return intent or null if not found |
| 93 | */ |
| 94 | default Intent getIntent(String key) { //FIXME remove when impl. |
| 95 | return null; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Returns the intent data object associated with the specified key. |
| 100 | * |
| 101 | * @param key key to look up |
| 102 | * @return intent data object |
| 103 | */ |
| 104 | default IntentData getIntentData(String key) { //FIXME remove when impl. |
| 105 | return null; |
| 106 | } |
| 107 | |
| 108 | /** |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 109 | * Adds a new operation, which should be persisted and delegated. |
| 110 | * |
Brian O'Connor | cff0332 | 2015-02-03 15:28:59 -0800 | [diff] [blame] | 111 | * @param intent operation |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 112 | */ |
Brian O'Connor | cff0332 | 2015-02-03 15:28:59 -0800 | [diff] [blame] | 113 | default void addPending(IntentData intent) {} //FIXME remove when impl. |
Brian O'Connor | ea4d7d1 | 2015-01-28 16:37:46 -0800 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Checks to see whether the calling instance is the master for processing |
| 117 | * this intent, or more specifically, the key contained in this intent. |
| 118 | * |
| 119 | * @param intent intent to check |
| 120 | * @return true if master; false, otherwise |
| 121 | */ |
| 122 | //TODO better name |
| 123 | default boolean isMaster(Intent intent) { //FIXME remove default when impl. |
| 124 | return true; |
| 125 | } |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 126 | } |