blob: 0e5c36e2eb545010bc4612a7300ee025d4585944 [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 /**
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 Koide025a9152014-07-21 11:00:34 -070035 boolean removeIntent(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070036
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 Koide025a9152014-07-21 11:00:34 -070044 boolean updateIntent(IntentId id, Intent intent);
Toshio Koidea03915e2014-07-01 18:39:52 -070045
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 Koide025a9152014-07-21 11:00:34 -070052 Intent getIntent(IntentId id);
Toshio Koidea03915e2014-07-01 18:39:52 -070053
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 SHIMIZU113c0272014-07-22 22:07:26 -070070 * 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 /**
Sho SHIMIZU308a45a2014-07-23 11:27:04 -070087 * Adds an IntentInstaller associated with a given intent type.
88 *
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.
92 *
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 *
104 * If there is an Intent instance of the specified Intent type in the runtime,
105 * the specified IntentInstaller is not removed. Otherwise, the existing
106 * IntentInstaller is removed from the runtime.
107 *
108 * @param type the class instance of the intent type.
109 * @param <T> the type of the intent.
110 * @return false when there is an Intent instance of the specified intent type
111 * in the runtime. Otherwise, true.
112 */
113 public <T extends Intent> boolean removeInstaller(Class<T> type);
114
115 /**
Toshio Koidea03915e2014-07-01 18:39:52 -0700116 * Gets IFlow objects managed by the specified intent.
117 *
118 * @param intentId ID of the target Intent.
119 * @return Collection of IFlow objects if exists, null otherwise.
120 */
121 Collection<IFlow> getFlows(String intentId);
122
123 /**
124 * Gets Intent object which manages the specified IFlow object.
125 *
126 * @param flowId ID of the target IFlow object.
127 * @return Intent which manages the specified IFlow object, null otherwise.
128 */
129 Intent getIntentByFlow(String flowId);
130
131 /**
132 * Sets a conflict detection policy.
133 *
134 * @param policy ConflictDetectionPolicy object to be set.
135 */
136 void setConflictDetectionPolicy(ConflictDetectionPolicy policy);
137
138 /**
139 * Gets the conflict detection policy.
140 *
141 * @return ConflictDetectionPolicy object being applied currently.
142 */
143 ConflictDetectionPolicy getConflictDetectionPolicy();
144
145 /**
146 * Adds event listener to this service.
147 *
148 * @param listener EventListener to be added.
149 */
150 void addEventListener(EventListener listener);
151
152 /**
153 * Removes event listener from this service.
154 *
155 * @param listener EventListener to be removed.
156 */
157 void removeEventListener(EventListener listener);
158}