Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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 | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 18 | |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
David Glantz | dfb3ceb | 2021-10-04 09:10:20 -0500 | [diff] [blame] | 20 | import org.onosproject.core.ApplicationId; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 21 | import org.onosproject.event.ListenerService; |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 22 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 23 | import java.util.List; |
| 24 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Service for application submitting or withdrawing their intents. |
| 27 | */ |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 28 | @Beta |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 29 | public interface IntentService |
| 30 | extends ListenerService<IntentEvent, IntentListener> { |
| 31 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Submits an intent into the system. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 34 | * <p> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 35 | * This is an asynchronous request meaning that any compiling or |
| 36 | * installation activities may be done at later time. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 37 | * </p> |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 38 | * @param intent intent to be submitted |
| 39 | */ |
| 40 | void submit(Intent intent); |
| 41 | |
| 42 | /** |
| 43 | * Withdraws an intent from the system. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 44 | * <p> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 45 | * This is an asynchronous request meaning that the environment may be |
| 46 | * affected at later time. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 47 | * </p> |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 48 | * @param intent intent to be withdrawn |
| 49 | */ |
| 50 | void withdraw(Intent intent); |
| 51 | |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 52 | /** |
Ray Milkey | 8c6d00e | 2015-03-13 14:14:34 -0700 | [diff] [blame] | 53 | * Purges a specific intent from the system if it is <b>FAILED</b> or |
| 54 | * <b>WITHDRAWN</b>. Otherwise, the intent remains in its current state. |
| 55 | * |
| 56 | * @param intent intent to purge |
| 57 | */ |
| 58 | void purge(Intent intent); |
| 59 | |
| 60 | /** |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 61 | * Fetches an intent based on its key. |
| 62 | * |
| 63 | * @param key key of the intent |
| 64 | * @return intent object if the key is found, null otherwise |
| 65 | */ |
Brian O'Connor | f211499 | 2015-03-17 16:03:14 -0700 | [diff] [blame] | 66 | Intent getIntent(Key key); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 69 | * Returns an iterable of intents currently in the system. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 70 | * |
| 71 | * @return set of intents |
| 72 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 73 | Iterable<Intent> getIntents(); |
| 74 | |
| 75 | /** |
David Glantz | dfb3ceb | 2021-10-04 09:10:20 -0500 | [diff] [blame] | 76 | * Returns an iterable of all intents with this application ID. |
| 77 | * |
| 78 | * @param id the application ID to look up |
| 79 | * @return collection of intents |
| 80 | */ |
| 81 | Iterable<Intent> getIntentsByAppId(ApplicationId id); |
| 82 | |
| 83 | /** |
Brian O'Connor | 3822430 | 2016-08-02 22:03:01 -0700 | [diff] [blame] | 84 | * Adds an intent data object to the pending map for processing. |
| 85 | * <p> |
| 86 | * This method is intended to only be called by core components, not |
| 87 | * applications. |
| 88 | * </p> |
| 89 | * |
| 90 | * @param intentData intent data to be added to pending map |
| 91 | */ |
| 92 | void addPending(IntentData intentData); |
| 93 | |
| 94 | /** |
Thomas Vachuska | c46af20 | 2015-06-03 16:43:27 -0700 | [diff] [blame] | 95 | * Returns an iterable of intent data objects currently in the system. |
| 96 | * |
| 97 | * @return set of intent data objects |
| 98 | */ |
| 99 | Iterable<IntentData> getIntentData(); |
| 100 | |
| 101 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 102 | * Returns the number of intents currently in the system. |
| 103 | * |
| 104 | * @return number of intents |
| 105 | */ |
| 106 | long getIntentCount(); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 109 | * Retrieves the state of an intent by its identifier. |
| 110 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 111 | * @param intentKey intent identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 112 | * @return the intent state or null if one with the given identifier is not |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 113 | * found |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 114 | */ |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 115 | IntentState getIntentState(Key intentKey); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 116 | |
| 117 | /** |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 118 | * Returns the list of the installable events associated with the specified |
| 119 | * top-level intent. |
| 120 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 121 | * @param intentKey top-level intent identifier |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 122 | * @return compiled installable intents |
| 123 | */ |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 124 | List<Intent> getInstallableIntents(Key intentKey); |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 125 | |
Jonathan Hart | 13d3dd9 | 2015-02-25 16:09:42 -0800 | [diff] [blame] | 126 | /** |
| 127 | * Signifies whether the local node is responsible for processing the given |
| 128 | * intent key. |
| 129 | * |
| 130 | * @param intentKey intent key to check |
| 131 | * @return true if the local node is responsible for the intent key, |
| 132 | * otherwise false |
| 133 | */ |
| 134 | boolean isLocal(Key intentKey); |
Brian O'Connor | be28a87 | 2015-02-19 21:44:37 -0800 | [diff] [blame] | 135 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 136 | /** |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 137 | * Returns the list of intent requests pending processing. |
| 138 | * |
| 139 | * @return intents pending processing |
| 140 | */ |
Jonathan Hart | 13d3dd9 | 2015-02-25 16:09:42 -0800 | [diff] [blame] | 141 | Iterable<Intent> getPending(); |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 142 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 143 | } |