blob: fc9d788cfd1c83c852115cfdb12dcefe61c0d007 [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.api.intent;
2
3import java.util.Collection;
4import java.util.EventListener;
5
6import net.onrc.onos.api.batchoperation.BatchOperation;
7import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
8import 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 */
20public interface IIntentRuntimeService {
21 /**
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070022 * Installs the specified intent synchronously.
Toshio Koidea03915e2014-07-01 18:39:52 -070023 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070024 * <p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070025 * This method blocks until the installation succeeds or fails.
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070026 * </p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070027 *
28 * @param intent the intent to be installed.
29 * @return true if the intent is successfully installed. Otherwise, false.
Toshio Koidea03915e2014-07-01 18:39:52 -070030 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070031 public boolean install(Intent intent);
Toshio Koidea03915e2014-07-01 18:39:52 -070032
33 /**
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070034 * Removes the specified intent synchronously.
Toshio Koidea03915e2014-07-01 18:39:52 -070035 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070036 * <p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070037 * This method blocks until the removal succeeds or fails.
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070038 * </p>
Toshio Koidea03915e2014-07-01 18:39:52 -070039 *
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070040 * @param id the ID of the intent to be uninstalled.
41 * @return true if the intent is successfully uninstalled. Otherwise, false.
Toshio Koidea03915e2014-07-01 18:39:52 -070042 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070043 public boolean remove(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070044
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 Koide025a9152014-07-21 11:00:34 -070051 Intent getIntent(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070052
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 SHIMIZU113c0272014-07-22 22:07:26 -070069 * 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 SHIMIZU308a45a2014-07-23 11:27:04 -070086 * Adds an IntentInstaller associated with a given intent type.
87 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070088 * <p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -070089 * 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 SHIMIZU9beddc02014-08-04 11:32:11 -070092 * </p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -070093 *
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 SHIMIZU9beddc02014-08-04 11:32:11 -0700105 * <p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -0700106 * 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 SHIMIZU9beddc02014-08-04 11:32:11 -0700109 * </p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -0700110 *
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 Koidea03915e2014-07-01 18:39:52 -0700119 * 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}