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