blob: 890bb7fdd416b1f1618030d23f79cc67b23777cd [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
Toshio Koidea03915e2014-07-01 18:39:52 -07006import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
7import 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 */
19public interface IIntentRuntimeService {
20 /**
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070021 * Installs the specified intent synchronously.
Toshio Koidea03915e2014-07-01 18:39:52 -070022 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070023 * <p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070024 * This method blocks until the installation succeeds or fails.
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070025 * </p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070026 *
27 * @param intent the intent to be installed.
28 * @return true if the intent is successfully installed. Otherwise, false.
Toshio Koidea03915e2014-07-01 18:39:52 -070029 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070030 public boolean install(Intent intent);
Toshio Koidea03915e2014-07-01 18:39:52 -070031
32 /**
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070033 * Removes the specified intent synchronously.
Toshio Koidea03915e2014-07-01 18:39:52 -070034 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070035 * <p>
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070036 * This method blocks until the removal succeeds or fails.
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070037 * </p>
Toshio Koidea03915e2014-07-01 18:39:52 -070038 *
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070039 * @param id the ID of the intent to be uninstalled.
40 * @return true if the intent is successfully uninstalled. Otherwise, false.
Toshio Koidea03915e2014-07-01 18:39:52 -070041 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070042 public boolean remove(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070043
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 Koide025a9152014-07-21 11:00:34 -070050 Intent getIntent(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070051
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 Koide4ea84192014-07-31 12:10:12 -070065 boolean executeBatch(IntentBatchOperation ops);
Toshio Koidea03915e2014-07-01 18:39:52 -070066
67 /**
Sho SHIMIZU113c0272014-07-22 22:07:26 -070068 * 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 SHIMIZU308a45a2014-07-23 11:27:04 -070085 * Adds an IntentInstaller associated with a given intent type.
86 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070087 * <p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -070088 * 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 SHIMIZU9beddc02014-08-04 11:32:11 -070091 * </p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -070092 *
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 SHIMIZU9beddc02014-08-04 11:32:11 -0700104 * <p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -0700105 * 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 SHIMIZU9beddc02014-08-04 11:32:11 -0700108 * </p>
Sho SHIMIZU308a45a2014-07-23 11:27:04 -0700109 *
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 Koidea03915e2014-07-01 18:39:52 -0700118 * 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}