blob: 73ed7041d11e86e605d0e5a32078eb8e3c641ccf [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 SHIMIZU68a052d2014-07-24 15:25:14 -070024 * 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 Koidea03915e2014-07-01 18:39:52 -070028 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070029 public boolean install(Intent intent);
Toshio Koidea03915e2014-07-01 18:39:52 -070030
31 /**
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070032 * Removes the specified intent synchronously.
Toshio Koidea03915e2014-07-01 18:39:52 -070033 *
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070034 * This method blocks until the removal succeeds or fails.
Toshio Koidea03915e2014-07-01 18:39:52 -070035 *
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070036 * @param id the ID of the intent to be uninstalled.
37 * @return true if the intent is successfully uninstalled. Otherwise, false.
Toshio Koidea03915e2014-07-01 18:39:52 -070038 */
Sho SHIMIZU68a052d2014-07-24 15:25:14 -070039 public boolean remove(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070040
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 Koide025a9152014-07-21 11:00:34 -070047 Intent getIntent(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070048
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 SHIMIZU113c0272014-07-22 22:07:26 -070065 * 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 SHIMIZU308a45a2014-07-23 11:27:04 -070082 * 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 Koidea03915e2014-07-01 18:39:52 -0700111 * 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}