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