Adding ability to wipe-out UI model cache and network config.
Change-Id: I3d4aecb989c1d4fc2589471fa3ddd53f62c49eb5
diff --git a/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java b/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
index cd42752..880621d 100644
--- a/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
@@ -23,6 +23,7 @@
import org.onosproject.net.Device;
import org.onosproject.net.Host;
import org.onosproject.net.Link;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.device.DeviceAdminService;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.group.GroupService;
@@ -34,7 +35,9 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.link.LinkAdminService;
import org.onosproject.net.region.RegionAdminService;
+import org.onosproject.ui.UiExtensionService;
import org.onosproject.ui.UiTopoLayoutService;
+
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -68,9 +71,11 @@
wipeOutGroups();
wipeOutDevices();
wipeOutLinks();
+ wipeOutNetworkConfig();
wipeOutLayouts();
wipeOutRegions();
+ wipeOutUiCache();
}
private void wipeOutIntents() {
@@ -95,14 +100,12 @@
intentService.addListener(listener);
intentsToWithdrawn.forEach(intentService::withdraw);
try {
- // Wait 1.5 seconds for each Intent
- completableFuture.get(intentsToWithdrawn.size() * 1500L, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- print("Got interrupted exception while withdrawn Intents " + e.toString());
- } catch (ExecutionException e) {
- print("Got execution exception while withdrawn Intents " + e.toString());
- } catch (TimeoutException e) {
- print("Got timeout exception while withdrawn Intents " + e.toString());
+ if (!intentsToWithdrawn.isEmpty()) {
+ // Wait 1.5 seconds for each Intent
+ completableFuture.get(intentsToWithdrawn.size() * 1500L, TimeUnit.MILLISECONDS);
+ }
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ print("Encountered exception while withdrawing intents: " + e.toString());
} finally {
intentService.removeListener(listener);
}
@@ -186,4 +189,15 @@
RegionAdminService service = get(RegionAdminService.class);
service.getRegions().forEach(r -> service.removeRegion(r.id()));
}
+
+ private void wipeOutNetworkConfig() {
+ print("Wiping network configs");
+ get(NetworkConfigService.class).removeConfig();
+ }
+
+ private void wipeOutUiCache() {
+ print("Wiping ui model cache");
+ get(UiExtensionService.class).refreshModel();
+ }
+
}
diff --git a/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java b/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java
index 3794af2..4764412 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java
@@ -59,4 +59,9 @@
* @return the navigation localization bundle
*/
LionBundle getNavLionBundle();
+
+ /**
+ * Refreshes the backing model.
+ */
+ void refreshModel();
}
diff --git a/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java b/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java
index 8a246dc..93bcf9f 100644
--- a/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java
@@ -45,4 +45,8 @@
public LionBundle getNavLionBundle() {
return null;
}
+
+ @Override
+ public void refreshModel() {
+ }
}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index a50fd1b..e384677 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -61,6 +61,7 @@
import org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler;
import org.onosproject.ui.impl.topo.Topo2ViewMessageHandler;
import org.onosproject.ui.impl.topo.Traffic2Overlay;
+import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
import org.onosproject.ui.lion.LionBundle;
import org.onosproject.ui.lion.LionUtils;
import org.slf4j.Logger;
@@ -144,6 +145,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ private UiSharedTopologyModel sharedModel;
+
// User preferences
private ConsistentMap<String, ObjectNode> prefsConsistentMap;
private Map<String, ObjectNode> prefs;
@@ -344,6 +348,11 @@
}
@Override
+ public void refreshModel() {
+ sharedModel.reload();
+ }
+
+ @Override
public Set<String> getUserNames() {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
prefs.keySet().forEach(k -> builder.add(userName(k)));
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
index f9f4436..14d29ac 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
@@ -224,6 +224,14 @@
// Methods for topo session (or CLI) to use to get information from us
/**
+ * Reloads the cache's internal state.
+ */
+ public void reload() {
+ cache.clear();
+ cache.load();
+ }
+
+ /**
* Refreshes the cache's internal state.
*/
public void refresh() {