Brian O'Connor

refactoring intent framework installers

installers should return work rather than futures

Change-Id: I664c9ef43279139eaf3bbc3cfc84b258b480eaab
1 package org.onlab.onos.net.intent; 1 package org.onlab.onos.net.intent;
2 2
3 -import java.util.concurrent.Future; 3 +import java.util.List;
4 4
5 -import org.onlab.onos.net.flow.CompletedBatchOperation; 5 +import org.onlab.onos.net.flow.FlowRuleBatchOperation;
6 6
7 /** 7 /**
8 * Abstraction of entity capable of installing intents to the environment. 8 * Abstraction of entity capable of installing intents to the environment.
...@@ -14,7 +14,7 @@ public interface IntentInstaller<T extends InstallableIntent> { ...@@ -14,7 +14,7 @@ public interface IntentInstaller<T extends InstallableIntent> {
14 * @param intent intent to be installed 14 * @param intent intent to be installed
15 * @throws IntentException if issues are encountered while installing the intent 15 * @throws IntentException if issues are encountered while installing the intent
16 */ 16 */
17 - Future<CompletedBatchOperation> install(T intent); 17 + List<FlowRuleBatchOperation> install(T intent);
18 18
19 /** 19 /**
20 * Uninstalls the specified intent from the environment. 20 * Uninstalls the specified intent from the environment.
...@@ -22,5 +22,5 @@ public interface IntentInstaller<T extends InstallableIntent> { ...@@ -22,5 +22,5 @@ public interface IntentInstaller<T extends InstallableIntent> {
22 * @param intent intent to be uninstalled 22 * @param intent intent to be uninstalled
23 * @throws IntentException if issues are encountered while uninstalling the intent 23 * @throws IntentException if issues are encountered while uninstalling the intent
24 */ 24 */
25 - Future<CompletedBatchOperation> uninstall(T intent); 25 + List<FlowRuleBatchOperation> uninstall(T intent);
26 } 26 }
......
...@@ -14,12 +14,11 @@ import java.util.Arrays; ...@@ -14,12 +14,11 @@ import java.util.Arrays;
14 import java.util.Collections; 14 import java.util.Collections;
15 import java.util.Iterator; 15 import java.util.Iterator;
16 import java.util.List; 16 import java.util.List;
17 -import java.util.concurrent.Future;
18 17
19 import org.junit.After; 18 import org.junit.After;
20 import org.junit.Before; 19 import org.junit.Before;
21 import org.junit.Test; 20 import org.junit.Test;
22 -import org.onlab.onos.net.flow.CompletedBatchOperation; 21 +import org.onlab.onos.net.flow.FlowRuleBatchOperation;
23 22
24 /** 23 /**
25 * Suite of tests for the intent service contract. 24 * Suite of tests for the intent service contract.
...@@ -298,7 +297,7 @@ public class IntentServiceTest { ...@@ -298,7 +297,7 @@ public class IntentServiceTest {
298 } 297 }
299 298
300 @Override 299 @Override
301 - public Future<CompletedBatchOperation> install(TestInstallableIntent intent) { 300 + public List<FlowRuleBatchOperation> install(TestInstallableIntent intent) {
302 if (fail) { 301 if (fail) {
303 throw new IntentException("install failed by design"); 302 throw new IntentException("install failed by design");
304 } 303 }
...@@ -306,7 +305,7 @@ public class IntentServiceTest { ...@@ -306,7 +305,7 @@ public class IntentServiceTest {
306 } 305 }
307 306
308 @Override 307 @Override
309 - public Future<CompletedBatchOperation> uninstall(TestInstallableIntent intent) { 308 + public List<FlowRuleBatchOperation> uninstall(TestInstallableIntent intent) {
310 if (fail) { 309 if (fail) {
311 throw new IntentException("remove failed by design"); 310 throw new IntentException("remove failed by design");
312 } 311 }
......
...@@ -34,6 +34,8 @@ import org.apache.felix.scr.annotations.Service; ...@@ -34,6 +34,8 @@ import org.apache.felix.scr.annotations.Service;
34 import org.onlab.onos.event.AbstractListenerRegistry; 34 import org.onlab.onos.event.AbstractListenerRegistry;
35 import org.onlab.onos.event.EventDeliveryService; 35 import org.onlab.onos.event.EventDeliveryService;
36 import org.onlab.onos.net.flow.CompletedBatchOperation; 36 import org.onlab.onos.net.flow.CompletedBatchOperation;
37 +import org.onlab.onos.net.flow.FlowRuleBatchOperation;
38 +import org.onlab.onos.net.flow.FlowRuleService;
37 import org.onlab.onos.net.intent.InstallableIntent; 39 import org.onlab.onos.net.intent.InstallableIntent;
38 import org.onlab.onos.net.intent.Intent; 40 import org.onlab.onos.net.intent.Intent;
39 import org.onlab.onos.net.intent.IntentCompiler; 41 import org.onlab.onos.net.intent.IntentCompiler;
...@@ -90,6 +92,9 @@ public class IntentManager ...@@ -90,6 +92,9 @@ public class IntentManager
90 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 92 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
91 protected EventDeliveryService eventDispatcher; 93 protected EventDeliveryService eventDispatcher;
92 94
95 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
96 + protected FlowRuleService flowRuleService;
97 +
93 @Activate 98 @Activate
94 public void activate() { 99 public void activate() {
95 store.setDelegate(delegate); 100 store.setDelegate(delegate);
...@@ -283,7 +288,7 @@ public class IntentManager ...@@ -283,7 +288,7 @@ public class IntentManager
283 // Indicate that the intent is entering the installing phase. 288 // Indicate that the intent is entering the installing phase.
284 store.setState(intent, INSTALLING); 289 store.setState(intent, INSTALLING);
285 290
286 - List<Future<CompletedBatchOperation>> installFutures = Lists.newArrayList(); 291 + List<FlowRuleBatchOperation> installWork = Lists.newArrayList();
287 try { 292 try {
288 List<InstallableIntent> installables = store.getInstallableIntents(intent.id()); 293 List<InstallableIntent> installables = store.getInstallableIntents(intent.id());
289 if (installables != null) { 294 if (installables != null) {
...@@ -291,13 +296,13 @@ public class IntentManager ...@@ -291,13 +296,13 @@ public class IntentManager
291 registerSubclassInstallerIfNeeded(installable); 296 registerSubclassInstallerIfNeeded(installable);
292 trackerService.addTrackedResources(intent.id(), 297 trackerService.addTrackedResources(intent.id(),
293 installable.requiredLinks()); 298 installable.requiredLinks());
294 - Future<CompletedBatchOperation> future = getInstaller(installable).install(installable); 299 + List<FlowRuleBatchOperation> batch = getInstaller(installable).install(installable);
295 - installFutures.add(future); 300 + installWork.addAll(batch);
296 } 301 }
297 } 302 }
298 // FIXME we have to wait for the installable intents 303 // FIXME we have to wait for the installable intents
299 //eventDispatcher.post(store.setState(intent, INSTALLED)); 304 //eventDispatcher.post(store.setState(intent, INSTALLED));
300 - monitorExecutor.execute(new IntentInstallMonitor(intent, installFutures, INSTALLED)); 305 + monitorExecutor.execute(new IntentInstallMonitor(intent, installWork, INSTALLED));
301 } catch (Exception e) { 306 } catch (Exception e) {
302 log.warn("Unable to install intent {} due to: {}", intent.id(), e); 307 log.warn("Unable to install intent {} due to: {}", intent.id(), e);
303 uninstallIntent(intent, RECOMPILING); 308 uninstallIntent(intent, RECOMPILING);
...@@ -369,16 +374,16 @@ public class IntentManager ...@@ -369,16 +374,16 @@ public class IntentManager
369 * @param intent intent to be uninstalled 374 * @param intent intent to be uninstalled
370 */ 375 */
371 private void uninstallIntent(Intent intent, IntentState nextState) { 376 private void uninstallIntent(Intent intent, IntentState nextState) {
372 - List<Future<CompletedBatchOperation>> uninstallFutures = Lists.newArrayList(); 377 + List<FlowRuleBatchOperation> uninstallWork = Lists.newArrayList();
373 try { 378 try {
374 List<InstallableIntent> installables = store.getInstallableIntents(intent.id()); 379 List<InstallableIntent> installables = store.getInstallableIntents(intent.id());
375 if (installables != null) { 380 if (installables != null) {
376 for (InstallableIntent installable : installables) { 381 for (InstallableIntent installable : installables) {
377 - Future<CompletedBatchOperation> future = getInstaller(installable).uninstall(installable); 382 + List<FlowRuleBatchOperation> batches = getInstaller(installable).uninstall(installable);
378 - uninstallFutures.add(future); 383 + uninstallWork.addAll(batches);
379 } 384 }
380 } 385 }
381 - monitorExecutor.execute(new IntentInstallMonitor(intent, uninstallFutures, nextState)); 386 + monitorExecutor.execute(new IntentInstallMonitor(intent, uninstallWork, nextState));
382 } catch (IntentException e) { 387 } catch (IntentException e) {
383 log.warn("Unable to uninstall intent {} due to: {}", intent.id(), e); 388 log.warn("Unable to uninstall intent {} due to: {}", intent.id(), e);
384 } 389 }
...@@ -495,17 +500,27 @@ public class IntentManager ...@@ -495,17 +500,27 @@ public class IntentManager
495 private class IntentInstallMonitor implements Runnable { 500 private class IntentInstallMonitor implements Runnable {
496 501
497 private final Intent intent; 502 private final Intent intent;
503 + private final List<FlowRuleBatchOperation> work;
498 private final List<Future<CompletedBatchOperation>> futures; 504 private final List<Future<CompletedBatchOperation>> futures;
499 private final IntentState nextState; 505 private final IntentState nextState;
500 506
501 public IntentInstallMonitor(Intent intent, 507 public IntentInstallMonitor(Intent intent,
502 - List<Future<CompletedBatchOperation>> futures, IntentState nextState) { 508 + List<FlowRuleBatchOperation> work,
509 + IntentState nextState) {
503 this.intent = intent; 510 this.intent = intent;
504 - this.futures = futures; 511 + this.work = work;
512 + // TODO how many Futures can be outstanding? one?
513 + this.futures = Lists.newLinkedList();
505 this.nextState = nextState; 514 this.nextState = nextState;
515 +
516 + // TODO need to kick off the first batch sometime, why not now?
517 + futures.add(applyNextBatch());
506 } 518 }
507 519
508 - private void updateIntent(Intent intent) { 520 + /**
521 + * Update the intent store with the next status for this intent.
522 + */
523 + private void updateIntent() {
509 if (nextState == RECOMPILING) { 524 if (nextState == RECOMPILING) {
510 executor.execute(new IntentTask(nextState, intent)); 525 executor.execute(new IntentTask(nextState, intent));
511 } else if (nextState == INSTALLED || nextState == WITHDRAWN) { 526 } else if (nextState == INSTALLED || nextState == WITHDRAWN) {
...@@ -515,22 +530,55 @@ public class IntentManager ...@@ -515,22 +530,55 @@ public class IntentManager
515 } 530 }
516 } 531 }
517 532
518 - @Override 533 + /**
519 - public void run() { 534 + * Apply a list of FlowRules.
535 + *
536 + * @param rules rules to apply
537 + */
538 + private Future<CompletedBatchOperation> applyNextBatch() {
539 + if (work.isEmpty()) {
540 + return null;
541 + }
542 + FlowRuleBatchOperation batch = work.remove(0);
543 + return flowRuleService.applyBatch(batch);
544 + }
545 +
546 + /**
547 + * Iterate through the pending futures, and remove them when they have completed.
548 + */
549 + private void processFutures() {
550 + List<Future<CompletedBatchOperation>> newFutures = Lists.newArrayList();
520 for (Iterator<Future<CompletedBatchOperation>> i = futures.iterator(); i.hasNext();) { 551 for (Iterator<Future<CompletedBatchOperation>> i = futures.iterator(); i.hasNext();) {
521 Future<CompletedBatchOperation> future = i.next(); 552 Future<CompletedBatchOperation> future = i.next();
522 try { 553 try {
523 // TODO: we may want to get the future here and go back to the future. 554 // TODO: we may want to get the future here and go back to the future.
524 CompletedBatchOperation completed = future.get(100, TimeUnit.NANOSECONDS); 555 CompletedBatchOperation completed = future.get(100, TimeUnit.NANOSECONDS);
556 + if (completed.isSuccess()) {
557 + Future<CompletedBatchOperation> newFuture = applyNextBatch();
558 + if (newFuture != null) {
559 + // we'll add this later so that we don't get a ConcurrentModException
560 + newFutures.add(newFuture);
561 + }
562 + } else {
525 // TODO check if future succeeded and if not report fail items 563 // TODO check if future succeeded and if not report fail items
564 + log.warn("Failed items: {}", completed.failedItems());
565 + // TODO revert....
566 + //uninstallIntent(intent, RECOMPILING);
567 + }
526 i.remove(); 568 i.remove();
527 -
528 } catch (TimeoutException | InterruptedException | ExecutionException te) { 569 } catch (TimeoutException | InterruptedException | ExecutionException te) {
529 log.debug("Intallations of intent {} is still pending", intent); 570 log.debug("Intallations of intent {} is still pending", intent);
530 } 571 }
531 } 572 }
573 + futures.addAll(newFutures);
574 + }
575 +
576 + @Override
577 + public void run() {
578 + processFutures();
532 if (futures.isEmpty()) { 579 if (futures.isEmpty()) {
533 - updateIntent(intent); 580 + // woohoo! we are done!
581 + updateIntent();
534 } else { 582 } else {
535 // resubmit ourselves if we are not done yet 583 // resubmit ourselves if we are not done yet
536 monitorExecutor.submit(this); 584 monitorExecutor.submit(this);
......
...@@ -4,7 +4,6 @@ import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; ...@@ -4,7 +4,6 @@ import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
5 5
6 import java.util.List; 6 import java.util.List;
7 -import java.util.concurrent.Future;
8 7
9 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
10 import org.apache.felix.scr.annotations.Component; 9 import org.apache.felix.scr.annotations.Component;
...@@ -16,14 +15,12 @@ import org.onlab.onos.CoreService; ...@@ -16,14 +15,12 @@ import org.onlab.onos.CoreService;
16 import org.onlab.onos.net.DeviceId; 15 import org.onlab.onos.net.DeviceId;
17 import org.onlab.onos.net.Link; 16 import org.onlab.onos.net.Link;
18 import org.onlab.onos.net.PortNumber; 17 import org.onlab.onos.net.PortNumber;
19 -import org.onlab.onos.net.flow.CompletedBatchOperation;
20 import org.onlab.onos.net.flow.DefaultFlowRule; 18 import org.onlab.onos.net.flow.DefaultFlowRule;
21 import org.onlab.onos.net.flow.DefaultTrafficSelector; 19 import org.onlab.onos.net.flow.DefaultTrafficSelector;
22 import org.onlab.onos.net.flow.FlowRule; 20 import org.onlab.onos.net.flow.FlowRule;
23 import org.onlab.onos.net.flow.FlowRuleBatchEntry; 21 import org.onlab.onos.net.flow.FlowRuleBatchEntry;
24 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; 22 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
25 import org.onlab.onos.net.flow.FlowRuleBatchOperation; 23 import org.onlab.onos.net.flow.FlowRuleBatchOperation;
26 -import org.onlab.onos.net.flow.FlowRuleService;
27 import org.onlab.onos.net.flow.TrafficSelector; 24 import org.onlab.onos.net.flow.TrafficSelector;
28 import org.onlab.onos.net.flow.TrafficTreatment; 25 import org.onlab.onos.net.flow.TrafficTreatment;
29 import org.onlab.onos.net.intent.IntentExtensionService; 26 import org.onlab.onos.net.intent.IntentExtensionService;
...@@ -47,9 +44,6 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -47,9 +44,6 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
47 protected IntentExtensionService intentManager; 44 protected IntentExtensionService intentManager;
48 45
49 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 46 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
50 - protected FlowRuleService flowRuleService;
51 -
52 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
53 protected CoreService coreService; 47 protected CoreService coreService;
54 48
55 private ApplicationId appId; 49 private ApplicationId appId;
...@@ -65,18 +59,8 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -65,18 +59,8 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
65 intentManager.unregisterInstaller(PathIntent.class); 59 intentManager.unregisterInstaller(PathIntent.class);
66 } 60 }
67 61
68 - /**
69 - * Apply a list of FlowRules.
70 - *
71 - * @param rules rules to apply
72 - */
73 - private Future<CompletedBatchOperation> applyBatch(List<FlowRuleBatchEntry> rules) {
74 - FlowRuleBatchOperation batch = new FlowRuleBatchOperation(rules);
75 - return flowRuleService.applyBatch(batch);
76 - }
77 -
78 @Override 62 @Override
79 - public Future<CompletedBatchOperation> install(LinkCollectionIntent intent) { 63 + public List<FlowRuleBatchOperation> install(LinkCollectionIntent intent) {
80 TrafficSelector.Builder builder = 64 TrafficSelector.Builder builder =
81 DefaultTrafficSelector.builder(intent.selector()); 65 DefaultTrafficSelector.builder(intent.selector());
82 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 66 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
...@@ -92,11 +76,11 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -92,11 +76,11 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
92 intent.egressPoint().deviceId(), 76 intent.egressPoint().deviceId(),
93 intent.egressPoint().port())); 77 intent.egressPoint().port()));
94 78
95 - return applyBatch(rules); 79 + return Lists.newArrayList(new FlowRuleBatchOperation(rules));
96 } 80 }
97 81
98 @Override 82 @Override
99 - public Future<CompletedBatchOperation> uninstall(LinkCollectionIntent intent) { 83 + public List<FlowRuleBatchOperation> uninstall(LinkCollectionIntent intent) {
100 TrafficSelector.Builder builder = 84 TrafficSelector.Builder builder =
101 DefaultTrafficSelector.builder(intent.selector()); 85 DefaultTrafficSelector.builder(intent.selector());
102 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 86 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
...@@ -113,7 +97,7 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -113,7 +97,7 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
113 intent.egressPoint().deviceId(), 97 intent.egressPoint().deviceId(),
114 intent.egressPoint().port())); 98 intent.egressPoint().port()));
115 99
116 - return applyBatch(rules); 100 + return Lists.newArrayList(new FlowRuleBatchOperation(rules));
117 } 101 }
118 102
119 /** 103 /**
......
...@@ -5,7 +5,6 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -5,7 +5,6 @@ import static org.slf4j.LoggerFactory.getLogger;
5 5
6 import java.util.Iterator; 6 import java.util.Iterator;
7 import java.util.List; 7 import java.util.List;
8 -import java.util.concurrent.Future;
9 8
10 import org.apache.felix.scr.annotations.Activate; 9 import org.apache.felix.scr.annotations.Activate;
11 import org.apache.felix.scr.annotations.Component; 10 import org.apache.felix.scr.annotations.Component;
...@@ -16,14 +15,12 @@ import org.onlab.onos.ApplicationId; ...@@ -16,14 +15,12 @@ import org.onlab.onos.ApplicationId;
16 import org.onlab.onos.CoreService; 15 import org.onlab.onos.CoreService;
17 import org.onlab.onos.net.ConnectPoint; 16 import org.onlab.onos.net.ConnectPoint;
18 import org.onlab.onos.net.Link; 17 import org.onlab.onos.net.Link;
19 -import org.onlab.onos.net.flow.CompletedBatchOperation;
20 import org.onlab.onos.net.flow.DefaultFlowRule; 18 import org.onlab.onos.net.flow.DefaultFlowRule;
21 import org.onlab.onos.net.flow.DefaultTrafficSelector; 19 import org.onlab.onos.net.flow.DefaultTrafficSelector;
22 import org.onlab.onos.net.flow.FlowRule; 20 import org.onlab.onos.net.flow.FlowRule;
23 import org.onlab.onos.net.flow.FlowRuleBatchEntry; 21 import org.onlab.onos.net.flow.FlowRuleBatchEntry;
24 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; 22 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
25 import org.onlab.onos.net.flow.FlowRuleBatchOperation; 23 import org.onlab.onos.net.flow.FlowRuleBatchOperation;
26 -import org.onlab.onos.net.flow.FlowRuleService;
27 import org.onlab.onos.net.flow.TrafficSelector; 24 import org.onlab.onos.net.flow.TrafficSelector;
28 import org.onlab.onos.net.flow.TrafficTreatment; 25 import org.onlab.onos.net.flow.TrafficTreatment;
29 import org.onlab.onos.net.intent.IntentExtensionService; 26 import org.onlab.onos.net.intent.IntentExtensionService;
...@@ -45,9 +42,6 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -45,9 +42,6 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
45 protected IntentExtensionService intentManager; 42 protected IntentExtensionService intentManager;
46 43
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 44 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 - protected FlowRuleService flowRuleService;
49 -
50 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 protected CoreService coreService; 45 protected CoreService coreService;
52 46
53 private ApplicationId appId; 47 private ApplicationId appId;
...@@ -63,31 +57,14 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -63,31 +57,14 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
63 intentManager.unregisterInstaller(PathIntent.class); 57 intentManager.unregisterInstaller(PathIntent.class);
64 } 58 }
65 59
66 - /**
67 - * Apply a list of FlowRules.
68 - *
69 - * @param rules rules to apply
70 - */
71 - private Future<CompletedBatchOperation> applyBatch(List<FlowRuleBatchEntry> rules) {
72 - FlowRuleBatchOperation batch = new FlowRuleBatchOperation(rules);
73 - Future<CompletedBatchOperation> future = flowRuleService.applyBatch(batch);
74 - return future;
75 -// try {
76 -// //FIXME don't do this here
77 -// future.get();
78 -// } catch (InterruptedException | ExecutionException e) {
79 -// // TODO Auto-generated catch block
80 -// e.printStackTrace();
81 -// }
82 - }
83 -
84 @Override 60 @Override
85 - public Future<CompletedBatchOperation> install(PathIntent intent) { 61 + public List<FlowRuleBatchOperation> install(PathIntent intent) {
86 TrafficSelector.Builder builder = 62 TrafficSelector.Builder builder =
87 DefaultTrafficSelector.builder(intent.selector()); 63 DefaultTrafficSelector.builder(intent.selector());
88 Iterator<Link> links = intent.path().links().iterator(); 64 Iterator<Link> links = intent.path().links().iterator();
89 ConnectPoint prev = links.next().dst(); 65 ConnectPoint prev = links.next().dst();
90 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 66 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
67 + // TODO Generate multiple batches
91 while (links.hasNext()) { 68 while (links.hasNext()) {
92 builder.matchInport(prev.port()); 69 builder.matchInport(prev.port());
93 Link link = links.next(); 70 Link link = links.next();
...@@ -100,18 +77,17 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -100,18 +77,17 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
100 rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); 77 rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule));
101 prev = link.dst(); 78 prev = link.dst();
102 } 79 }
103 - 80 + return Lists.newArrayList(new FlowRuleBatchOperation(rules));
104 - return applyBatch(rules);
105 } 81 }
106 82
107 @Override 83 @Override
108 - public Future<CompletedBatchOperation> uninstall(PathIntent intent) { 84 + public List<FlowRuleBatchOperation> uninstall(PathIntent intent) {
109 TrafficSelector.Builder builder = 85 TrafficSelector.Builder builder =
110 DefaultTrafficSelector.builder(intent.selector()); 86 DefaultTrafficSelector.builder(intent.selector());
111 Iterator<Link> links = intent.path().links().iterator(); 87 Iterator<Link> links = intent.path().links().iterator();
112 ConnectPoint prev = links.next().dst(); 88 ConnectPoint prev = links.next().dst();
113 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 89 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
114 - 90 + // TODO Generate multiple batches
115 while (links.hasNext()) { 91 while (links.hasNext()) {
116 builder.matchInport(prev.port()); 92 builder.matchInport(prev.port());
117 Link link = links.next(); 93 Link link = links.next();
...@@ -123,7 +99,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { ...@@ -123,7 +99,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> {
123 rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule)); 99 rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule));
124 prev = link.dst(); 100 prev = link.dst();
125 } 101 }
126 - return applyBatch(rules); 102 + return Lists.newArrayList(new FlowRuleBatchOperation(rules));
127 } 103 }
128 104
129 // TODO refactor below this line... ---------------------------- 105 // TODO refactor below this line... ----------------------------
......