blob: 1e6ae00456d3170e2a1fa3fa1c1f732a66b1a45f [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent.runtime;
Toshio Koide4f308732014-02-18 15:19:48 -08002
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.HashMap;
Toshio Koide798bc1b2014-02-20 14:02:40 -08006import java.util.HashSet;
Toshio Koidedf2eab92014-02-20 11:24:59 -08007import java.util.Iterator;
Toshio Koidebf875662014-02-24 12:19:15 -08008import java.util.LinkedList;
Toshio Koide4f308732014-02-18 15:19:48 -08009import java.util.Map;
Toshio Koide066506e2014-02-20 19:52:09 -080010import java.util.Map.Entry;
Toshio Koide93be5d62014-02-23 19:30:57 -080011import java.util.concurrent.locks.ReentrantLock;
Toshio Koide4f308732014-02-18 15:19:48 -080012
13import net.floodlightcontroller.core.module.FloodlightModuleContext;
14import net.floodlightcontroller.core.module.FloodlightModuleException;
15import net.floodlightcontroller.core.module.IFloodlightModule;
16import net.floodlightcontroller.core.module.IFloodlightService;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070017import net.floodlightcontroller.restserver.IRestApiService;
18
Jonathan Hart6df90172014-04-03 10:13:11 -070019import net.onrc.onos.core.datagrid.IDatagridService;
20import net.onrc.onos.core.datagrid.IEventChannel;
21import net.onrc.onos.core.datagrid.IEventChannelListener;
Jonathan Hartaa380972014-04-03 10:24:46 -070022import net.onrc.onos.core.intent.Intent;
Jonathan Harta99ec672014-04-03 11:30:34 -070023import net.onrc.onos.core.intent.Intent.IntentState;
Jonathan Hartaa380972014-04-03 10:24:46 -070024import net.onrc.onos.core.intent.IntentMap;
25import net.onrc.onos.core.intent.IntentOperation;
Jonathan Harta99ec672014-04-03 11:30:34 -070026import net.onrc.onos.core.intent.IntentOperation.Operator;
Jonathan Hartaa380972014-04-03 10:24:46 -070027import net.onrc.onos.core.intent.IntentOperationList;
28import net.onrc.onos.core.intent.PathIntent;
29import net.onrc.onos.core.intent.PathIntentMap;
30import net.onrc.onos.core.intent.ShortestPathIntent;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070031import net.onrc.onos.core.intent.runtime.web.IntentWebRoutable;
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070032import net.onrc.onos.core.registry.IControllerRegistryService;
Jonathan Hart472062d2014-04-03 10:56:48 -070033import net.onrc.onos.core.topology.DeviceEvent;
34import net.onrc.onos.core.topology.INetworkGraphListener;
35import net.onrc.onos.core.topology.INetworkGraphService;
36import net.onrc.onos.core.topology.LinkEvent;
37import net.onrc.onos.core.topology.PortEvent;
38import net.onrc.onos.core.topology.SwitchEvent;
Toshio Koide4f308732014-02-18 15:19:48 -080039
Jonathan Harta99ec672014-04-03 11:30:34 -070040import org.slf4j.Logger;
41import org.slf4j.LoggerFactory;
42
Toshio Koide0c9106d2014-02-19 15:26:38 -080043/**
44 * @author Toshio Koide (t-koide@onlab.us)
45 */
Toshio Koide066506e2014-02-20 19:52:09 -080046public class PathCalcRuntimeModule implements IFloodlightModule, IPathCalcRuntimeService, INetworkGraphListener, IEventChannelListener<Long, IntentStateList> {
Pavlin Radoslavovfee80982014-04-10 12:12:04 -070047 static class PerfLog {
Ray Milkey269ffb92014-04-03 14:43:30 -070048 private String step;
49 private long time;
Toshio Koidebf875662014-02-24 12:19:15 -080050
Ray Milkey269ffb92014-04-03 14:43:30 -070051 public PerfLog(String step) {
52 this.step = step;
53 this.time = System.nanoTime();
54 }
Toshio Koidebf875662014-02-24 12:19:15 -080055
Ray Milkey269ffb92014-04-03 14:43:30 -070056 public void logThis() {
Pavlin Radoslavov964f8ae2014-04-18 16:44:14 -070057 log.debug("Time:{}, Step:{}", time, step);
Ray Milkey269ffb92014-04-03 14:43:30 -070058 }
59 }
Toshio Koidebf875662014-02-24 12:19:15 -080060
Pavlin Radoslavov53ad5e32014-04-10 14:24:26 -070061 static class PerfLogger {
Ray Milkey269ffb92014-04-03 14:43:30 -070062 private LinkedList<PerfLog> logData = new LinkedList<>();
Toshio Koidebf875662014-02-24 12:19:15 -080063
Ray Milkey269ffb92014-04-03 14:43:30 -070064 public PerfLogger(String logPhase) {
65 log("start_" + logPhase);
66 }
Toshio Koidebf875662014-02-24 12:19:15 -080067
Ray Milkey269ffb92014-04-03 14:43:30 -070068 public void log(String step) {
69 logData.add(new PerfLog(step));
70 }
Toshio Koide27ffd412014-02-18 19:15:27 -080071
Ray Milkey269ffb92014-04-03 14:43:30 -070072 public void flushLog() {
73 log("finish");
Ray Milkey5df613b2014-04-15 10:50:56 -070074 for (PerfLog perfLog : logData) {
75 perfLog.logThis();
Ray Milkey269ffb92014-04-03 14:43:30 -070076 }
77 logData.clear();
78 }
79 }
Toshio Koide4f308732014-02-18 15:19:48 -080080
Ray Milkey269ffb92014-04-03 14:43:30 -070081 private PathCalcRuntime runtime;
82 private IDatagridService datagridService;
83 private INetworkGraphService networkGraphService;
84 private IntentMap highLevelIntents;
85 private PathIntentMap pathIntents;
86 private IControllerRegistryService controllerRegistry;
87 private PersistIntent persistIntent;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070088 private IRestApiService restApi;
Toshio Koide798bc1b2014-02-20 14:02:40 -080089
Ray Milkey269ffb92014-04-03 14:43:30 -070090 private IEventChannel<Long, IntentOperationList> opEventChannel;
91 private final ReentrantLock lock = new ReentrantLock();
92 private HashSet<LinkEvent> unmatchedLinkEvents = new HashSet<>();
93 private static final String INTENT_OP_EVENT_CHANNEL_NAME = "onos.pathintent";
94 private static final String INTENT_STATE_EVENT_CHANNEL_NAME = "onos.pathintent_state";
95 private static final Logger log = LoggerFactory.getLogger(PathCalcRuntimeModule.class);
Toshio Koidea10c0372014-02-20 17:28:10 -080096
Ray Milkey269ffb92014-04-03 14:43:30 -070097 // ================================================================================
98 // private methods
99 // ================================================================================
100
101 private void reroutePaths(Collection<Intent> oldPaths) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700102 if (oldPaths == null || oldPaths.isEmpty()) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700103 return;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700104 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700105
106 IntentOperationList reroutingOperation = new IntentOperationList();
107 for (Intent intent : oldPaths) {
108 PathIntent pathIntent = (PathIntent) intent;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700109 if (pathIntent.isPathFrozen()) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700110 continue;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700111 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700112 if (pathIntent.getState().equals(IntentState.INST_ACK) && // XXX: path intents in flight
113 !reroutingOperation.contains(pathIntent.getParentIntent())) {
114 reroutingOperation.add(Operator.ADD, pathIntent.getParentIntent());
115 }
116 }
117 executeIntentOperations(reroutingOperation);
118 }
Toshio Koidea94060f2014-02-21 22:58:32 -0800119
Toshio Koide27ffd412014-02-18 19:15:27 -0800120
Ray Milkey269ffb92014-04-03 14:43:30 -0700121 // ================================================================================
122 // IFloodlightModule implementations
123 // ================================================================================
Toshio Koide798bc1b2014-02-20 14:02:40 -0800124
Ray Milkey269ffb92014-04-03 14:43:30 -0700125 @Override
126 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
127 Collection<Class<? extends IFloodlightService>> l = new ArrayList<>(1);
128 l.add(IPathCalcRuntimeService.class);
129 return l;
130 }
Toshio Koide4f308732014-02-18 15:19:48 -0800131
Ray Milkey269ffb92014-04-03 14:43:30 -0700132 @Override
133 public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
134 Map<Class<? extends IFloodlightService>, IFloodlightService> m = new HashMap<>();
135 m.put(IPathCalcRuntimeService.class, this);
136 return m;
137 }
Toshio Koide4f308732014-02-18 15:19:48 -0800138
Ray Milkey269ffb92014-04-03 14:43:30 -0700139 @Override
140 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
141 Collection<Class<? extends IFloodlightService>> l = new ArrayList<>(2);
142 l.add(IDatagridService.class);
143 l.add(INetworkGraphService.class);
Pavlin Radoslavov13669052014-05-13 10:33:39 -0700144 l.add(IRestApiService.class);
Ray Milkey269ffb92014-04-03 14:43:30 -0700145 return l;
146 }
Toshio Koide4f308732014-02-18 15:19:48 -0800147
Ray Milkey269ffb92014-04-03 14:43:30 -0700148 @Override
149 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
150 datagridService = context.getServiceImpl(IDatagridService.class);
151 networkGraphService = context.getServiceImpl(INetworkGraphService.class);
152 controllerRegistry = context.getServiceImpl(IControllerRegistryService.class);
Pavlin Radoslavov13669052014-05-13 10:33:39 -0700153 restApi = context.getServiceImpl(IRestApiService.class);
Ray Milkey269ffb92014-04-03 14:43:30 -0700154 }
Toshio Koide4f308732014-02-18 15:19:48 -0800155
Ray Milkey269ffb92014-04-03 14:43:30 -0700156 @Override
157 public void startUp(FloodlightModuleContext context) {
158 highLevelIntents = new IntentMap();
159 runtime = new PathCalcRuntime(networkGraphService.getNetworkGraph());
160 pathIntents = new PathIntentMap();
161 opEventChannel = datagridService.createChannel(INTENT_OP_EVENT_CHANNEL_NAME, Long.class, IntentOperationList.class);
162 datagridService.addListener(INTENT_STATE_EVENT_CHANNEL_NAME, this, Long.class, IntentStateList.class);
163 networkGraphService.registerNetworkGraphListener(this);
Pavlin Radoslavov0294e052014-04-10 13:36:45 -0700164 persistIntent = new PersistIntent(controllerRegistry);
Pavlin Radoslavov13669052014-05-13 10:33:39 -0700165 restApi.addRestletRoutable(new IntentWebRoutable());
Ray Milkey269ffb92014-04-03 14:43:30 -0700166 }
Toshio Koide27ffd412014-02-18 19:15:27 -0800167
Ray Milkey269ffb92014-04-03 14:43:30 -0700168 // ================================================================================
169 // IPathCalcRuntimeService implementations
170 // ================================================================================
Toshio Koide798bc1b2014-02-20 14:02:40 -0800171
Ray Milkey269ffb92014-04-03 14:43:30 -0700172 @Override
173 public IntentOperationList executeIntentOperations(IntentOperationList list) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700174 if (list == null || list.size() == 0) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700175 return null;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700176 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700177 PerfLogger p = new PerfLogger("executeIntentOperations_" + list.get(0).operator);
Toshio Koide275d8142014-02-24 16:41:52 -0800178
Ray Milkey269ffb92014-04-03 14:43:30 -0700179 lock.lock(); // TODO optimize locking using smaller steps
180 try {
181 // update the map of high-level intents
182 p.log("begin_updateInMemoryIntents");
183 highLevelIntents.executeOperations(list);
Toshio Koidedf2eab92014-02-20 11:24:59 -0800184
Ray Milkey269ffb92014-04-03 14:43:30 -0700185 // change states of high-level intents
186 IntentStateList states = new IntentStateList();
187 for (IntentOperation op : list) {
188 switch (op.operator) {
189 case ADD:
190 switch (op.intent.getState()) {
191 case CREATED:
192 states.put(op.intent.getId(), IntentState.INST_REQ);
193 break;
194 case INST_ACK:
195 states.put(op.intent.getId(), IntentState.REROUTE_REQ);
196 break;
197 default:
198 break;
199 }
200 break;
201 case REMOVE:
202 switch (op.intent.getState()) {
203 case CREATED:
204 states.put(op.intent.getId(), IntentState.DEL_REQ);
205 break;
206 default:
207 break;
208 }
209 break;
210 default:
211 break;
212 }
213 }
214 highLevelIntents.changeStates(states);
215 p.log("end_updateInMemoryIntents");
Toshio Koidedf2eab92014-02-20 11:24:59 -0800216
Ray Milkey269ffb92014-04-03 14:43:30 -0700217 // calculate path-intents (low-level operations)
218 p.log("begin_calcPathIntents");
219 IntentOperationList pathIntentOperations = runtime.calcPathIntents(list, highLevelIntents, pathIntents);
220 p.log("end_calcPathIntents");
Toshio Koide600ae5f2014-02-20 18:42:00 -0800221
Ray Milkey269ffb92014-04-03 14:43:30 -0700222 // persist calculated low-level operations into data store
223 p.log("begin_persistPathIntents");
224 long key = persistIntent.getKey();
225 persistIntent.persistIfLeader(key, pathIntentOperations);
226 p.log("end_persistPathIntents");
Toshio Koide93be5d62014-02-23 19:30:57 -0800227
Ray Milkey269ffb92014-04-03 14:43:30 -0700228 // remove error-intents and reflect them to high-level intents
229 p.log("begin_removeErrorIntents");
230 states.clear();
231 Iterator<IntentOperation> i = pathIntentOperations.iterator();
232 while (i.hasNext()) {
233 IntentOperation op = i.next();
234 if (op.operator.equals(Operator.ERROR)) {
235 states.put(op.intent.getId(), IntentState.INST_NACK);
236 i.remove();
237 }
238 }
239 highLevelIntents.changeStates(states);
240 p.log("end_removeErrorIntents");
Toshio Koidea94060f2014-02-21 22:58:32 -0800241
Ray Milkey269ffb92014-04-03 14:43:30 -0700242 // update the map of path intents and publish the path operations
243 p.log("begin_updateInMemoryPathIntents");
244 pathIntents.executeOperations(pathIntentOperations);
245 p.log("end_updateInMemoryPathIntents");
Toshio Koide93be5d62014-02-23 19:30:57 -0800246
Ray Milkey269ffb92014-04-03 14:43:30 -0700247 // XXX Demo special: add a complete path to remove operation
248 p.log("begin_addPathToRemoveOperation");
249 for (IntentOperation op : pathIntentOperations) {
250 if (op.operator.equals(Operator.REMOVE)) {
251 op.intent = pathIntents.getIntent(op.intent.getId());
252 }
253 if (op.intent instanceof PathIntent) {
254 log.debug("operation: {}, intent:{}", op.operator, op.intent);
255 }
256 }
257 p.log("end_addPathToRemoveOperation");
Toshio Koide93be5d62014-02-23 19:30:57 -0800258
Ray Milkey269ffb92014-04-03 14:43:30 -0700259 // send notification
260 p.log("begin_sendNotification");
261 // XXX: Send notifications using the same key every time
262 // and receive them by entryAdded() and entryUpdated()
263 opEventChannel.addEntry(0L, pathIntentOperations);
264 p.log("end_sendNotification");
265 //opEventChannel.removeEntry(key);
266 return pathIntentOperations;
267 } finally {
Ray Milkey269ffb92014-04-03 14:43:30 -0700268 lock.unlock();
Pavlin Radoslavovc68974f2014-04-09 17:28:38 -0700269 p.flushLog();
Ray Milkey269ffb92014-04-03 14:43:30 -0700270 }
271 }
Toshio Koide27ffd412014-02-18 19:15:27 -0800272
Ray Milkey269ffb92014-04-03 14:43:30 -0700273 @Override
274 public IntentMap getHighLevelIntents() {
275 return highLevelIntents;
276 }
Toshio Koide27ffd412014-02-18 19:15:27 -0800277
Ray Milkey269ffb92014-04-03 14:43:30 -0700278 @Override
279 public IntentMap getPathIntents() {
280 return pathIntents;
281 }
Toshio Koide27ffd412014-02-18 19:15:27 -0800282
Ray Milkey269ffb92014-04-03 14:43:30 -0700283 @Override
284 public void purgeIntents() {
285 highLevelIntents.purge();
286 pathIntents.purge();
287 }
Toshio Koide0c9106d2014-02-19 15:26:38 -0800288
Ray Milkey269ffb92014-04-03 14:43:30 -0700289 // ================================================================================
290 // INetworkGraphListener implementations
291 // ================================================================================
Toshio Koide798bc1b2014-02-20 14:02:40 -0800292
Ray Milkeya5450cc2014-04-17 14:31:30 -0700293 // CHECKSTYLE:OFF suppress warning about too many parameters
Ray Milkey269ffb92014-04-03 14:43:30 -0700294 @Override
295 public void networkGraphEvents(Collection<SwitchEvent> addedSwitchEvents,
296 Collection<SwitchEvent> removedSwitchEvents,
297 Collection<PortEvent> addedPortEvents,
298 Collection<PortEvent> removedPortEvents,
299 Collection<LinkEvent> addedLinkEvents,
300 Collection<LinkEvent> removedLinkEvents,
301 Collection<DeviceEvent> addedDeviceEvents,
302 Collection<DeviceEvent> removedDeviceEvents) {
Ray Milkeya5450cc2014-04-17 14:31:30 -0700303 // CHECKSTYLE:ON
Toshio Koidea9078af2014-02-21 16:57:04 -0800304
Ray Milkey269ffb92014-04-03 14:43:30 -0700305 PerfLogger p = new PerfLogger("networkGraphEvents");
306 HashSet<Intent> affectedPaths = new HashSet<>();
Toshio Koide93797dc2014-02-27 23:54:26 -0800307
Ray Milkey269ffb92014-04-03 14:43:30 -0700308 boolean rerouteAll = false;
309 for (LinkEvent le : addedLinkEvents) {
310 LinkEvent rev = new LinkEvent(le.getDst().getDpid(), le.getDst().getNumber(), le.getSrc().getDpid(), le.getSrc().getNumber());
311 if (unmatchedLinkEvents.contains(rev)) {
312 rerouteAll = true;
313 unmatchedLinkEvents.remove(rev);
314 log.debug("Found matched LinkEvent: {} {}", rev, le);
315 } else {
316 unmatchedLinkEvents.add(le);
317 log.debug("Adding unmatched LinkEvent: {}", le);
318 }
319 }
320 for (LinkEvent le : removedLinkEvents) {
321 if (unmatchedLinkEvents.contains(le)) {
322 unmatchedLinkEvents.remove(le);
323 log.debug("Removing LinkEvent: {}", le);
324 }
325 }
326 if (unmatchedLinkEvents.size() > 0) {
327 log.debug("Unmatched link events: {} events", unmatchedLinkEvents.size());
328 }
Toshio Koidea9078af2014-02-21 16:57:04 -0800329
Ray Milkey7f1567c2014-04-08 13:53:32 -0700330 if (rerouteAll) { //addedLinkEvents.size() > 0) { // ||
Ray Milkey269ffb92014-04-03 14:43:30 -0700331// addedPortEvents.size() > 0 ||
332// addedSwitchEvents.size() > 0) {
333 p.log("begin_getAllIntents");
334 affectedPaths.addAll(getPathIntents().getAllIntents());
335 p.log("end_getAllIntents");
336 } else if (removedSwitchEvents.size() > 0 ||
337 removedLinkEvents.size() > 0 ||
338 removedPortEvents.size() > 0) {
339 p.log("begin_getIntentsByLink");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700340 for (LinkEvent linkEvent : removedLinkEvents) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700341 affectedPaths.addAll(pathIntents.getIntentsByLink(linkEvent));
Ray Milkeyb29e6262014-04-09 16:02:14 -0700342 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700343 p.log("end_getIntentsByLink");
Toshio Koidea9078af2014-02-21 16:57:04 -0800344
Ray Milkey269ffb92014-04-03 14:43:30 -0700345 p.log("begin_getIntentsByPort");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700346 for (PortEvent portEvent : removedPortEvents) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700347 affectedPaths.addAll(pathIntents.getIntentsByPort(portEvent.getDpid(), portEvent.getNumber()));
Ray Milkeyb29e6262014-04-09 16:02:14 -0700348 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700349 p.log("end_getIntentsByPort");
Toshio Koidea9078af2014-02-21 16:57:04 -0800350
Ray Milkey269ffb92014-04-03 14:43:30 -0700351 p.log("begin_getIntentsByDpid");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700352 for (SwitchEvent switchEvent : removedSwitchEvents) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700353 affectedPaths.addAll(pathIntents.getIntentsByDpid(switchEvent.getDpid()));
Ray Milkeyb29e6262014-04-09 16:02:14 -0700354 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700355 p.log("end_getIntentsByDpid");
356 }
357 p.log("begin_reroutePaths");
358 reroutePaths(affectedPaths);
359 p.log("end_reroutePaths");
360 p.flushLog();
361 }
Toshio Koide066506e2014-02-20 19:52:09 -0800362
Ray Milkey269ffb92014-04-03 14:43:30 -0700363 // ================================================================================
364 // IEventChannelListener implementations
365 // ================================================================================
Toshio Koide066506e2014-02-20 19:52:09 -0800366
Ray Milkey269ffb92014-04-03 14:43:30 -0700367 @Override
368 public void entryAdded(IntentStateList value) {
369 entryUpdated(value);
370 }
Toshio Koide066506e2014-02-20 19:52:09 -0800371
Ray Milkey269ffb92014-04-03 14:43:30 -0700372 @Override
373 public void entryRemoved(IntentStateList value) {
374 // do nothing
375 }
Toshio Koide066506e2014-02-20 19:52:09 -0800376
Ray Milkey269ffb92014-04-03 14:43:30 -0700377 @Override
378 public void entryUpdated(IntentStateList value) {
379 // TODO draw state transition diagram in multiple ONOS instances and update this method
380 PerfLogger p = new PerfLogger("entryUpdated");
381 lock.lock(); // TODO optimize locking using smaller steps
382 try {
383 // reflect state changes of path-level intent into application-level intents
384 p.log("begin_changeStateByNotification");
385 IntentStateList highLevelIntentStates = new IntentStateList();
386 IntentStateList pathIntentStates = new IntentStateList();
387 for (Entry<String, IntentState> entry : value.entrySet()) {
388 PathIntent pathIntent = (PathIntent) pathIntents.getIntent(entry.getKey());
Ray Milkeyb29e6262014-04-09 16:02:14 -0700389 if (pathIntent == null) {
390 continue;
391 }
Toshio Koide8315d7d2014-02-21 22:58:32 -0800392
Ray Milkey269ffb92014-04-03 14:43:30 -0700393 Intent parentIntent = pathIntent.getParentIntent();
394 if (parentIntent == null ||
395 !(parentIntent instanceof ShortestPathIntent) ||
Ray Milkeyb29e6262014-04-09 16:02:14 -0700396 !((ShortestPathIntent) parentIntent).getPathIntentId().equals(pathIntent.getId())) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700397 continue;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700398 }
Toshio Koide066506e2014-02-20 19:52:09 -0800399
Ray Milkey269ffb92014-04-03 14:43:30 -0700400 IntentState state = entry.getValue();
401 switch (state) {
402 //case INST_REQ:
403 case INST_ACK:
404 case INST_NACK:
405 //case DEL_REQ:
406 case DEL_ACK:
407 case DEL_PENDING:
408 highLevelIntentStates.put(parentIntent.getId(), state);
409 pathIntentStates.put(entry.getKey(), entry.getValue());
410 break;
411 default:
412 break;
413 }
414 }
415 highLevelIntents.changeStates(highLevelIntentStates);
416 pathIntents.changeStates(pathIntentStates);
417 p.log("end_changeStateByNotification");
418 } finally {
Ray Milkey269ffb92014-04-03 14:43:30 -0700419 lock.unlock();
Pavlin Radoslavovc68974f2014-04-09 17:28:38 -0700420 p.flushLog();
Ray Milkey269ffb92014-04-03 14:43:30 -0700421 }
422 }
Toshio Koidea9078af2014-02-21 16:57:04 -0800423}