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 | /** |
| 22 | * Adds specified intent. |
| 23 | * |
| 24 | * @param intent Intent to be added. |
| 25 | * @return true if succeeded, false otherwise. |
| 26 | */ |
| 27 | boolean addIntent(Intent intent); |
| 28 | |
| 29 | /** |
| 30 | * Removes specified intent. |
| 31 | * |
| 32 | * @param id ID of the intent to be removed. |
| 33 | * @return true if succeeded, false otherwise. |
| 34 | */ |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 35 | boolean removeIntent(IntentId id); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Overwrites existing intent by new specified intent. |
| 39 | * |
| 40 | * @param id ID of the existing intent to be overwritten. |
| 41 | * @param intent The new intent to be added. |
| 42 | * @return true if succeeded, false otherwise. |
| 43 | */ |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 44 | boolean updateIntent(IntentId id, Intent intent); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Gets specific intent. |
| 48 | * |
| 49 | * @param id ID of the intent should be retrieved |
| 50 | * @return Intent if it exists, null otherwise. |
| 51 | */ |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 52 | Intent getIntent(IntentId id); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Gets all intents. |
| 56 | * |
| 57 | * @return collection of intents. |
| 58 | */ |
| 59 | Collection<Intent> getIntents(); |
| 60 | |
| 61 | /** |
| 62 | * Executes batch operation of intents. |
| 63 | * |
| 64 | * @param ops BatchOperations to be executed. |
| 65 | * @return true if succeeded, false otherwise. |
| 66 | */ |
| 67 | boolean executeBatch(BatchOperation<Intent> ops); |
| 68 | |
| 69 | /** |
Sho SHIMIZU | 113c027 | 2014-07-22 22:07:26 -0700 | [diff] [blame^] | 70 | * Adds an IntentResolver associated with a given intent type. |
| 71 | * |
| 72 | * @param type the class instance of the intent type. |
| 73 | * @param resolver the resolver of the given intent type. |
| 74 | * @param <T> the type of the intent. |
| 75 | */ |
| 76 | public <T extends Intent> void addResolver(Class<T> type, IntentResolver<T> resolver); |
| 77 | |
| 78 | /** |
| 79 | * Removes the IntentResolver associated with the intent type. |
| 80 | * |
| 81 | * @param type the class instance of the intent type. |
| 82 | * @param <T> the type of the intent. |
| 83 | */ |
| 84 | public <T extends Intent> void removeResolver(Class<T> type); |
| 85 | |
| 86 | /** |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 87 | * Gets IFlow objects managed by the specified intent. |
| 88 | * |
| 89 | * @param intentId ID of the target Intent. |
| 90 | * @return Collection of IFlow objects if exists, null otherwise. |
| 91 | */ |
| 92 | Collection<IFlow> getFlows(String intentId); |
| 93 | |
| 94 | /** |
| 95 | * Gets Intent object which manages the specified IFlow object. |
| 96 | * |
| 97 | * @param flowId ID of the target IFlow object. |
| 98 | * @return Intent which manages the specified IFlow object, null otherwise. |
| 99 | */ |
| 100 | Intent getIntentByFlow(String flowId); |
| 101 | |
| 102 | /** |
| 103 | * Sets a conflict detection policy. |
| 104 | * |
| 105 | * @param policy ConflictDetectionPolicy object to be set. |
| 106 | */ |
| 107 | void setConflictDetectionPolicy(ConflictDetectionPolicy policy); |
| 108 | |
| 109 | /** |
| 110 | * Gets the conflict detection policy. |
| 111 | * |
| 112 | * @return ConflictDetectionPolicy object being applied currently. |
| 113 | */ |
| 114 | ConflictDetectionPolicy getConflictDetectionPolicy(); |
| 115 | |
| 116 | /** |
| 117 | * Adds event listener to this service. |
| 118 | * |
| 119 | * @param listener EventListener to be added. |
| 120 | */ |
| 121 | void addEventListener(EventListener listener); |
| 122 | |
| 123 | /** |
| 124 | * Removes event listener from this service. |
| 125 | * |
| 126 | * @param listener EventListener to be removed. |
| 127 | */ |
| 128 | void removeEventListener(EventListener listener); |
| 129 | } |