Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.intent; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.EventListener; |
| 5 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 6 | import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy; |
| 7 | import net.onrc.onos.api.flowmanager.IFlow; |
| 8 | |
| 9 | /** |
| 10 | * An interface class for the Intent-Runtime Service. The role of the |
| 11 | * Intent-Runtime Service is to manage a set of IFlow objects based on the |
| 12 | * specified Intent objects. |
| 13 | * <p> |
| 14 | * It compiles accepted Intents to IFlow objects by allocating resources and |
| 15 | * calculating paths based on the constrains described in the Intents, and |
| 16 | * executes installation/uninstallation of the IFlow objects using FlowManager |
| 17 | * Service. |
| 18 | */ |
| 19 | public interface IIntentRuntimeService { |
| 20 | /** |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 21 | * Installs the specified intent synchronously. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 22 | * |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 23 | * <p> |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 24 | * This method blocks until the installation succeeds or fails. |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 25 | * </p> |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 26 | * |
| 27 | * @param intent the intent to be installed. |
| 28 | * @return true if the intent is successfully installed. Otherwise, false. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 29 | */ |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 30 | public boolean install(Intent intent); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 33 | * Removes the specified intent synchronously. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 34 | * |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 35 | * <p> |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 36 | * This method blocks until the removal succeeds or fails. |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 37 | * </p> |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 38 | * |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 39 | * @param id the ID of the intent to be uninstalled. |
| 40 | * @return true if the intent is successfully uninstalled. Otherwise, false. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 41 | */ |
Sho SHIMIZU | 68a052d | 2014-07-24 15:25:14 -0700 | [diff] [blame] | 42 | public boolean remove(IntentId id); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Gets specific intent. |
| 46 | * |
| 47 | * @param id ID of the intent should be retrieved |
| 48 | * @return Intent if it exists, null otherwise. |
| 49 | */ |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 50 | Intent getIntent(IntentId id); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Gets all intents. |
| 54 | * |
| 55 | * @return collection of intents. |
| 56 | */ |
| 57 | Collection<Intent> getIntents(); |
| 58 | |
| 59 | /** |
| 60 | * Executes batch operation of intents. |
| 61 | * |
| 62 | * @param ops BatchOperations to be executed. |
| 63 | * @return true if succeeded, false otherwise. |
| 64 | */ |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame^] | 65 | boolean executeBatch(IntentBatchOperation ops); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
Sho SHIMIZU | 113c027 | 2014-07-22 22:07:26 -0700 | [diff] [blame] | 68 | * Adds an IntentResolver associated with a given intent type. |
| 69 | * |
| 70 | * @param type the class instance of the intent type. |
| 71 | * @param resolver the resolver of the given intent type. |
| 72 | * @param <T> the type of the intent. |
| 73 | */ |
| 74 | public <T extends Intent> void addResolver(Class<T> type, IntentResolver<T> resolver); |
| 75 | |
| 76 | /** |
| 77 | * Removes the IntentResolver associated with the intent type. |
| 78 | * |
| 79 | * @param type the class instance of the intent type. |
| 80 | * @param <T> the type of the intent. |
| 81 | */ |
| 82 | public <T extends Intent> void removeResolver(Class<T> type); |
| 83 | |
| 84 | /** |
Sho SHIMIZU | 308a45a | 2014-07-23 11:27:04 -0700 | [diff] [blame] | 85 | * Adds an IntentInstaller associated with a given intent type. |
| 86 | * |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 87 | * <p> |
Sho SHIMIZU | 308a45a | 2014-07-23 11:27:04 -0700 | [diff] [blame] | 88 | * If there is an Intent instance of the specified Intent type in the runtime, |
| 89 | * the specified IntentInstaller doesn't replace the existing installer. |
| 90 | * Otherwise, the existing installer is replaced with the specified installer. |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 91 | * </p> |
Sho SHIMIZU | 308a45a | 2014-07-23 11:27:04 -0700 | [diff] [blame] | 92 | * |
| 93 | * @param type the class instance of the intent type. |
| 94 | * @param installer the installer of the given intent type. |
| 95 | * @param <T> the type of the intent. |
| 96 | * @return false when there is an Intent instance of the specified intent type |
| 97 | * in the runtime. Otherwise, true. |
| 98 | */ |
| 99 | public <T extends Intent> boolean addInstaller(Class<T> type, IntentInstaller<T> installer); |
| 100 | |
| 101 | /** |
| 102 | * Removes the IntentInstaller associated with a given intent type. |
| 103 | * |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 104 | * <p> |
Sho SHIMIZU | 308a45a | 2014-07-23 11:27:04 -0700 | [diff] [blame] | 105 | * If there is an Intent instance of the specified Intent type in the runtime, |
| 106 | * the specified IntentInstaller is not removed. Otherwise, the existing |
| 107 | * IntentInstaller is removed from the runtime. |
Sho SHIMIZU | 9beddc0 | 2014-08-04 11:32:11 -0700 | [diff] [blame] | 108 | * </p> |
Sho SHIMIZU | 308a45a | 2014-07-23 11:27:04 -0700 | [diff] [blame] | 109 | * |
| 110 | * @param type the class instance of the intent type. |
| 111 | * @param <T> the type of the intent. |
| 112 | * @return false when there is an Intent instance of the specified intent type |
| 113 | * in the runtime. Otherwise, true. |
| 114 | */ |
| 115 | public <T extends Intent> boolean removeInstaller(Class<T> type); |
| 116 | |
| 117 | /** |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 118 | * Gets IFlow objects managed by the specified intent. |
| 119 | * |
| 120 | * @param intentId ID of the target Intent. |
| 121 | * @return Collection of IFlow objects if exists, null otherwise. |
| 122 | */ |
| 123 | Collection<IFlow> getFlows(String intentId); |
| 124 | |
| 125 | /** |
| 126 | * Gets Intent object which manages the specified IFlow object. |
| 127 | * |
| 128 | * @param flowId ID of the target IFlow object. |
| 129 | * @return Intent which manages the specified IFlow object, null otherwise. |
| 130 | */ |
| 131 | Intent getIntentByFlow(String flowId); |
| 132 | |
| 133 | /** |
| 134 | * Sets a conflict detection policy. |
| 135 | * |
| 136 | * @param policy ConflictDetectionPolicy object to be set. |
| 137 | */ |
| 138 | void setConflictDetectionPolicy(ConflictDetectionPolicy policy); |
| 139 | |
| 140 | /** |
| 141 | * Gets the conflict detection policy. |
| 142 | * |
| 143 | * @return ConflictDetectionPolicy object being applied currently. |
| 144 | */ |
| 145 | ConflictDetectionPolicy getConflictDetectionPolicy(); |
| 146 | |
| 147 | /** |
| 148 | * Adds event listener to this service. |
| 149 | * |
| 150 | * @param listener EventListener to be added. |
| 151 | */ |
| 152 | void addEventListener(EventListener listener); |
| 153 | |
| 154 | /** |
| 155 | * Removes event listener from this service. |
| 156 | * |
| 157 | * @param listener EventListener to be removed. |
| 158 | */ |
| 159 | void removeEventListener(EventListener listener); |
| 160 | } |