tom

Fixed some javadocs and added a listener to the FooComponent to show what intent…

… events are perceptible externally.
...@@ -11,6 +11,9 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -11,6 +11,9 @@ import org.onlab.onos.cluster.ClusterService;
11 import org.onlab.onos.net.device.DeviceEvent; 11 import org.onlab.onos.net.device.DeviceEvent;
12 import org.onlab.onos.net.device.DeviceListener; 12 import org.onlab.onos.net.device.DeviceListener;
13 import org.onlab.onos.net.device.DeviceService; 13 import org.onlab.onos.net.device.DeviceService;
14 +import org.onlab.onos.net.intent.IntentEvent;
15 +import org.onlab.onos.net.intent.IntentListener;
16 +import org.onlab.onos.net.intent.IntentService;
14 import org.slf4j.Logger; 17 import org.slf4j.Logger;
15 18
16 import static org.slf4j.LoggerFactory.getLogger; 19 import static org.slf4j.LoggerFactory.getLogger;
...@@ -29,13 +32,18 @@ public class FooComponent { ...@@ -29,13 +32,18 @@ public class FooComponent {
29 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 32 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
30 protected DeviceService deviceService; 33 protected DeviceService deviceService;
31 34
35 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 + protected IntentService intentService;
37 +
32 private final ClusterEventListener clusterListener = new InnerClusterListener(); 38 private final ClusterEventListener clusterListener = new InnerClusterListener();
33 private final DeviceListener deviceListener = new InnerDeviceListener(); 39 private final DeviceListener deviceListener = new InnerDeviceListener();
40 + private final IntentListener intentListener = new InnerIntentListener();
34 41
35 @Activate 42 @Activate
36 public void activate() { 43 public void activate() {
37 clusterService.addListener(clusterListener); 44 clusterService.addListener(clusterListener);
38 deviceService.addListener(deviceListener); 45 deviceService.addListener(deviceListener);
46 + intentService.addListener(intentListener);
39 log.info("Started"); 47 log.info("Started");
40 } 48 }
41 49
...@@ -43,6 +51,7 @@ public class FooComponent { ...@@ -43,6 +51,7 @@ public class FooComponent {
43 public void deactivate() { 51 public void deactivate() {
44 clusterService.removeListener(clusterListener); 52 clusterService.removeListener(clusterListener);
45 deviceService.removeListener(deviceListener); 53 deviceService.removeListener(deviceListener);
54 + intentService.removeListener(intentListener);
46 log.info("Stopped"); 55 log.info("Stopped");
47 } 56 }
48 57
...@@ -59,6 +68,23 @@ public class FooComponent { ...@@ -59,6 +68,23 @@ public class FooComponent {
59 log.info("YEEEEHAAAAW! {}", event); 68 log.info("YEEEEHAAAAW! {}", event);
60 } 69 }
61 } 70 }
71 +
72 + private class InnerIntentListener implements IntentListener {
73 + @Override
74 + public void event(IntentEvent event) {
75 + String message;
76 + if (event.type() == IntentEvent.Type.SUBMITTED) {
77 + message = "WOW! It looks like someone has some intentions: {}";
78 + } else if (event.type() == IntentEvent.Type.INSTALLED) {
79 + message = "AWESOME! So far things are going great: {}";
80 + } else if (event.type() == IntentEvent.Type.WITHDRAWN) {
81 + message = "HMMM! Ambitions are fading apparently: {}";
82 + } else {
83 + message = "CRAP!!! Things are not turning out as intended: {}";
84 + }
85 + log.info(message, event.subject());
86 + }
87 + }
62 } 88 }
63 89
64 90
......
...@@ -10,12 +10,12 @@ public interface TopologyChangeDelegate { ...@@ -10,12 +10,12 @@ public interface TopologyChangeDelegate {
10 /** 10 /**
11 * Notifies that topology has changed in such a way that the specified 11 * Notifies that topology has changed in such a way that the specified
12 * intents should be recompiled. If the {@code compileAllFailed} parameter 12 * intents should be recompiled. If the {@code compileAllFailed} parameter
13 - * is true, the all intents in {@link org.onlab.onos.net.intent.IntentState#FAILED} 13 + * is true, then all intents in {@link org.onlab.onos.net.intent.IntentState#FAILED}
14 * state should be compiled as well. 14 * state should be compiled as well.
15 * 15 *
16 * @param intentIds intents that should be recompiled 16 * @param intentIds intents that should be recompiled
17 - * @param compileAllFailed true implies full compile is required; false for 17 + * @param compileAllFailed true implies full compile of all failed intents
18 - * selective recompile only 18 + * is required; false for selective recompile only
19 */ 19 */
20 void triggerCompile(Iterable<IntentId> intentIds, boolean compileAllFailed); 20 void triggerCompile(Iterable<IntentId> intentIds, boolean compileAllFailed);
21 21
......