Adding first set of changes for bug onos-5071
Addressed review comments
Addressed review comments for patch-2
Addressed review comments for patch-3
Fixed broken "show intent" on topo view.
Change-Id: Ie76deca917d6cd6c98d121135e53b9093b5ed8ee
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
index 71c017d..d48a089 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java
@@ -88,6 +88,7 @@
import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED;
import static org.onosproject.ui.JsonUtils.envelope;
+import static org.onosproject.ui.JsonUtils.string;
import static org.onosproject.ui.topo.TopoJson.highlightsMessage;
import static org.onosproject.ui.topo.TopoJson.json;
@@ -100,6 +101,7 @@
private static final String REQ_DETAILS = "requestDetails";
private static final String UPDATE_META = "updateMeta";
private static final String ADD_HOST_INTENT = "addHostIntent";
+ private static final String REMOVE_INTENT = "removeIntent";
private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent";
private static final String REQ_RELATED_INTENTS = "requestRelatedIntents";
private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent";
@@ -220,6 +222,7 @@
// TODO: migrate traffic related to separate app
new AddHostIntent(),
new AddMultiSourceIntent(),
+ new RemoveIntent(),
new ReqAllFlowTraffic(),
new ReqAllPortTraffic(),
@@ -426,6 +429,37 @@
}
}
+ private Intent findIntentByPayload(ObjectNode payload) {
+ int appId = Integer.parseInt(string(payload, APP_ID));
+ String appName = string(payload, APP_NAME);
+ ApplicationId applicId = new DefaultApplicationId(appId, appName);
+ long intentKey = Long.decode(string(payload, KEY));
+
+ Key key = Key.of(intentKey, applicId);
+ log.debug("Attempting to select intent by key={}", key);
+
+ Intent intent = intentService.getIntent(key);
+
+ return intent;
+ }
+
+ private final class RemoveIntent extends RequestHandler {
+ private RemoveIntent() {
+ super(REMOVE_INTENT);
+ }
+
+ @Override
+ public void process(long sid, ObjectNode payload) {
+ Intent intent = findIntentByPayload(payload);
+ if (intent == null) {
+ log.warn("Unable to find intent from payload {}", payload);
+ } else {
+ log.debug("Removing intent {}", intent.key());
+ intentService.withdraw(intent);
+ }
+ }
+ }
+
private final class AddMultiSourceIntent extends RequestHandler {
private AddMultiSourceIntent() {
super(ADD_MULTI_SRC_INTENT);
@@ -551,19 +585,11 @@
@Override
public void process(long sid, ObjectNode payload) {
- int appId = Integer.parseInt(string(payload, APP_ID));
- String appName = string(payload, APP_NAME);
- ApplicationId applicId = new DefaultApplicationId(appId, appName);
- long intentKey = Long.decode(string(payload, KEY));
-
- Key key = Key.of(intentKey, applicId);
- log.debug("Attempting to select intent key={}", key);
-
- Intent intent = intentService.getIntent(key);
+ Intent intent = findIntentByPayload(payload);
if (intent == null) {
- log.debug("no such intent found!");
+ log.warn("Unable to find intent from payload {}", payload);
} else {
- log.debug("starting to monitor intent {}", key);
+ log.debug("starting to monitor intent {}", intent.key());
traffic.monitor(intent);
}
}