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 | 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 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 19 | import java.util.List; |
| 20 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Service for application submitting or withdrawing their intents. |
| 23 | */ |
| 24 | public interface IntentService { |
| 25 | /** |
| 26 | * Submits an intent into the system. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 27 | * <p> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 28 | * This is an asynchronous request meaning that any compiling or |
| 29 | * installation activities may be done at later time. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 30 | * </p> |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 31 | * @param intent intent to be submitted |
| 32 | */ |
| 33 | void submit(Intent intent); |
| 34 | |
| 35 | /** |
| 36 | * Withdraws an intent from the system. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 37 | * <p> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 38 | * This is an asynchronous request meaning that the environment may be |
| 39 | * affected at later time. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 40 | * </p> |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 41 | * @param intent intent to be withdrawn |
| 42 | */ |
| 43 | void withdraw(Intent intent); |
| 44 | |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 45 | /** |
Ray Milkey | 8c6d00e | 2015-03-13 14:14:34 -0700 | [diff] [blame] | 46 | * Purges a specific intent from the system if it is <b>FAILED</b> or |
| 47 | * <b>WITHDRAWN</b>. Otherwise, the intent remains in its current state. |
| 48 | * |
| 49 | * @param intent intent to purge |
| 50 | */ |
| 51 | void purge(Intent intent); |
| 52 | |
| 53 | /** |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 54 | * Fetches an intent based on its key. |
| 55 | * |
| 56 | * @param key key of the intent |
| 57 | * @return intent object if the key is found, null otherwise |
| 58 | */ |
Brian O'Connor | f211499 | 2015-03-17 16:03:14 -0700 | [diff] [blame] | 59 | Intent getIntent(Key key); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 60 | |
| 61 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 62 | * Returns an iterable of intents currently in the system. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 63 | * |
| 64 | * @return set of intents |
| 65 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 66 | Iterable<Intent> getIntents(); |
| 67 | |
| 68 | /** |
Thomas Vachuska | c46af20 | 2015-06-03 16:43:27 -0700 | [diff] [blame] | 69 | * Returns an iterable of intent data objects currently in the system. |
| 70 | * |
| 71 | * @return set of intent data objects |
| 72 | */ |
| 73 | Iterable<IntentData> getIntentData(); |
| 74 | |
| 75 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 76 | * Returns the number of intents currently in the system. |
| 77 | * |
| 78 | * @return number of intents |
| 79 | */ |
| 80 | long getIntentCount(); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 83 | * Retrieves the state of an intent by its identifier. |
| 84 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 85 | * @param intentKey intent identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 86 | * @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] | 87 | * found |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 88 | */ |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 89 | IntentState getIntentState(Key intentKey); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 92 | * Returns the list of the installable events associated with the specified |
| 93 | * top-level intent. |
| 94 | * |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 95 | * @param intentKey top-level intent identifier |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 96 | * @return compiled installable intents |
| 97 | */ |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 98 | List<Intent> getInstallableIntents(Key intentKey); |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 99 | |
Jonathan Hart | 13d3dd9 | 2015-02-25 16:09:42 -0800 | [diff] [blame] | 100 | /** |
| 101 | * Signifies whether the local node is responsible for processing the given |
| 102 | * intent key. |
| 103 | * |
| 104 | * @param intentKey intent key to check |
| 105 | * @return true if the local node is responsible for the intent key, |
| 106 | * otherwise false |
| 107 | */ |
| 108 | boolean isLocal(Key intentKey); |
Brian O'Connor | be28a87 | 2015-02-19 21:44:37 -0800 | [diff] [blame] | 109 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 110 | /** |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 111 | * Returns the list of intent requests pending processing. |
| 112 | * |
| 113 | * @return intents pending processing |
| 114 | */ |
Jonathan Hart | 13d3dd9 | 2015-02-25 16:09:42 -0800 | [diff] [blame] | 115 | Iterable<Intent> getPending(); |
Jonathan Hart | 34f1e38 | 2015-02-24 16:52:23 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 118 | * Adds the specified listener for intent events. |
| 119 | * |
| 120 | * @param listener listener to be added |
| 121 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 122 | void addListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Removes the specified listener for intent events. |
| 126 | * |
| 127 | * @param listener listener to be removed |
| 128 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 129 | void removeListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 130 | } |