Fixed some javadocs and added a listener to the FooComponent to show what intent events are perceptible externally.
diff --git a/apps/foo/src/main/java/org/onlab/onos/foo/FooComponent.java b/apps/foo/src/main/java/org/onlab/onos/foo/FooComponent.java
index 1fafc32..473ea6e 100644
--- a/apps/foo/src/main/java/org/onlab/onos/foo/FooComponent.java
+++ b/apps/foo/src/main/java/org/onlab/onos/foo/FooComponent.java
@@ -11,6 +11,9 @@
import org.onlab.onos.net.device.DeviceEvent;
import org.onlab.onos.net.device.DeviceListener;
import org.onlab.onos.net.device.DeviceService;
+import org.onlab.onos.net.intent.IntentEvent;
+import org.onlab.onos.net.intent.IntentListener;
+import org.onlab.onos.net.intent.IntentService;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@@ -29,13 +32,18 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected IntentService intentService;
+
private final ClusterEventListener clusterListener = new InnerClusterListener();
private final DeviceListener deviceListener = new InnerDeviceListener();
+ private final IntentListener intentListener = new InnerIntentListener();
@Activate
public void activate() {
clusterService.addListener(clusterListener);
deviceService.addListener(deviceListener);
+ intentService.addListener(intentListener);
log.info("Started");
}
@@ -43,6 +51,7 @@
public void deactivate() {
clusterService.removeListener(clusterListener);
deviceService.removeListener(deviceListener);
+ intentService.removeListener(intentListener);
log.info("Stopped");
}
@@ -59,6 +68,23 @@
log.info("YEEEEHAAAAW! {}", event);
}
}
+
+ private class InnerIntentListener implements IntentListener {
+ @Override
+ public void event(IntentEvent event) {
+ String message;
+ if (event.type() == IntentEvent.Type.SUBMITTED) {
+ message = "WOW! It looks like someone has some intentions: {}";
+ } else if (event.type() == IntentEvent.Type.INSTALLED) {
+ message = "AWESOME! So far things are going great: {}";
+ } else if (event.type() == IntentEvent.Type.WITHDRAWN) {
+ message = "HMMM! Ambitions are fading apparently: {}";
+ } else {
+ message = "CRAP!!! Things are not turning out as intended: {}";
+ }
+ log.info(message, event.subject());
+ }
+ }
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java
index 7a9fd12..30e6899 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java
@@ -10,12 +10,12 @@
/**
* Notifies that topology has changed in such a way that the specified
* intents should be recompiled. If the {@code compileAllFailed} parameter
- * is true, the all intents in {@link org.onlab.onos.net.intent.IntentState#FAILED}
+ * is true, then all intents in {@link org.onlab.onos.net.intent.IntentState#FAILED}
* state should be compiled as well.
*
* @param intentIds intents that should be recompiled
- * @param compileAllFailed true implies full compile is required; false for
- * selective recompile only
+ * @param compileAllFailed true implies full compile of all failed intents
+ * is required; false for selective recompile only
*/
void triggerCompile(Iterable<IntentId> intentIds, boolean compileAllFailed);