GUI -- deleting experimental code for topo refactoring.
Change-Id: I3984f2f4a29496259877bf045c4cc8f46d78c033
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/AltTopoViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/AltTopoViewMessageHandler.java
deleted file mode 100644
index 935141d..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/AltTopoViewMessageHandler.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-import org.onlab.osgi.ServiceDirectory;
-import org.onosproject.core.CoreService;
-import org.onosproject.ui.JsonUtils;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiConnection;
-import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.impl.topo.OverlayService;
-import org.onosproject.ui.impl.topo.SummaryData;
-import org.onosproject.ui.impl.topo.TopoUiEvent;
-import org.onosproject.ui.impl.topo.TopoUiListener;
-import org.onosproject.ui.impl.topo.TopoUiModelService;
-import org.onosproject.ui.impl.topo.overlay.AbstractSummaryGenerator;
-import org.onosproject.ui.impl.topo.overlay.SummaryGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.System.currentTimeMillis;
-import static org.onosproject.ui.impl.topo.TopoUiEvent.Type.SUMMARY_UPDATE;
-
-/**
- * Facility for handling inbound messages from the topology view, and
- * generating outbound messages for the same.
- */
-public class AltTopoViewMessageHandler extends UiMessageHandler
- implements OverlayService {
-
- private static final String TOPO_START = "topoStart";
- private static final String TOPO_HEARTBEAT = "topoHeartbeat";
- private static final String TOPO_STOP = "topoStop";
- private static final String REQ_SUMMARY = "requestSummary";
- private static final String CANCEL_SUMMARY = "cancelSummary";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- protected ServiceDirectory directory;
- protected TopoUiModelService modelService;
-
- private ModelListener modelListener;
- private String version;
- private SummaryGenerator defaultSummaryGenerator;
- private SummaryGenerator currentSummaryGenerator;
-
-
- private boolean topoActive = false;
-
- @Override
- public void init(UiConnection connection, ServiceDirectory directory) {
- super.init(connection, directory);
- this.directory = checkNotNull(directory, "Directory cannot be null");
- modelService = directory.get(TopoUiModelService.class);
- defaultSummaryGenerator = new DefSummaryGenerator("node", "ONOS Summary");
-
- bindEventHandlers();
- modelListener = new ModelListener();
- version = getVersion();
- currentSummaryGenerator = defaultSummaryGenerator;
- }
-
- @Override
- public void destroy() {
- cancelAllMonitoring();
- stopListeningToModel();
- super.destroy();
- }
-
-
- @Override
- protected Collection<RequestHandler> createRequestHandlers() {
- return ImmutableSet.of(
- new TopoStart(),
- new TopoHeartbeat(),
- new TopoStop(),
- new ReqSummary(),
- new CancelSummary()
- // TODO: add more handlers here.....
- );
- }
-
- // =====================================================================
-
- private void cancelAllMonitoring() {
- // TODO:
- }
-
- private void startListeningToModel() {
- topoActive = true;
- modelService.addListener(modelListener);
- }
-
- private void stopListeningToModel() {
- topoActive = false;
- modelService.removeListener(modelListener);
- }
-
- private String getVersion() {
- String ver = directory.get(CoreService.class).version().toString();
- return ver.replace(".SNAPSHOT", "*").replaceFirst("~.*$", "");
- }
-
- // =====================================================================
- // Overlay Service
- // TODO: figure out how we are going to switch overlays in and out...
-
- private final Map<String, SummaryGenerator> summGenCache = Maps.newHashMap();
-
- @Override
- public void addSummaryGenerator(String overlayId, SummaryGenerator generator) {
- log.info("Adding custom Summary Generator for overlay [{}]", overlayId);
- summGenCache.put(overlayId, generator);
- }
-
- @Override
- public void removeSummaryGenerator(String overlayId) {
- summGenCache.remove(overlayId);
- log.info("Custom Summary Generator for overlay [{}] removed", overlayId);
- }
-
-
-
- // =====================================================================
- // Request Handlers for (topo view) events from the UI...
-
- private final class TopoStart extends RequestHandler {
- private TopoStart() {
- super(TOPO_START);
- }
-
- @Override
- public void process(long sid, ObjectNode payload) {
- startListeningToModel();
- sendMessages(modelService.getInitialState());
- }
- }
-
- private final class TopoHeartbeat extends RequestHandler {
- private TopoHeartbeat() {
- super(TOPO_HEARTBEAT);
- }
- @Override
- public void process(long sid, ObjectNode payload) {
- modelListener.nudge();
- }
- }
-
- private final class TopoStop extends RequestHandler {
- private TopoStop() {
- super(TOPO_STOP);
- }
-
- @Override
- public void process(long sid, ObjectNode payload) {
- stopListeningToModel();
- }
- }
-
- private final class ReqSummary extends RequestHandler {
- private ReqSummary() {
- super(REQ_SUMMARY);
- }
-
- @Override
- public void process(long sid, ObjectNode payload) {
- modelService.startSummaryMonitoring();
- // NOTE: showSummary messages forwarded through the model listener
- }
- }
-
- private final class CancelSummary extends RequestHandler {
- private CancelSummary() {
- super(CANCEL_SUMMARY);
- }
-
- @Override
- public void process(long sid, ObjectNode payload) {
- modelService.stopSummaryMonitoring();
- }
- }
-
- // =====================================================================
-
- private final class DefSummaryGenerator extends AbstractSummaryGenerator {
- public DefSummaryGenerator(String iconId, String title) {
- super(iconId, title);
- }
-
- @Override
- public ObjectNode generateSummary() {
- SummaryData data = modelService.getSummaryData();
- iconId("node");
- title("ONOS Summary");
- clearProps();
- prop("Devices", format(data.deviceCount()));
- prop("Links", format(data.linkCount()));
- prop("Hosts", format(data.hostCount()));
- prop("Topology SCCs", format(data.clusterCount()));
- separator();
- prop("Intents", format(data.intentCount()));
- prop("Flows", format(data.flowRuleCount()));
- prop("Version", version);
- return buildObjectNode();
- }
- }
-
- // =====================================================================
- // Private Helper Methods...
-
- private void sendMessages(Collection<ObjectNode> messages) {
- if (topoActive) {
- UiConnection connection = connection();
- if (connection != null) {
- messages.forEach(connection::sendMessage);
- }
- }
- }
-
- private void sendMessages(ObjectNode message) {
- if (topoActive) {
- UiConnection connection = connection();
- if (connection != null) {
- connection.sendMessage(message);
- }
- }
- }
-
- // =====================================================================
- // Our listener for model events so we can push changes out to the UI...
-
- private class ModelListener implements TopoUiListener {
- private static final long AWAKE_THRESHOLD_MS = 6000;
-
- private long lastNudged = currentTimeMillis();
-
- @Override
- public void event(TopoUiEvent event) {
- log.debug("Handle Event: {}", event);
- ModelEventHandler handler = eventHandlerBinding.get(event.type());
-
- // any handlers not bound explicitly are assumed to be pass-thru...
- if (handler == null) {
- handler = passThruHandler;
- }
- handler.handleEvent(event);
- }
-
- @Override
- public boolean isAwake() {
- return currentTimeMillis() - lastNudged < AWAKE_THRESHOLD_MS;
- }
-
- public void nudge() {
- lastNudged = currentTimeMillis();
- }
- }
-
-
- // =====================================================================
- // Model Event Handler definitions and bindings...
-
- private interface ModelEventHandler {
- void handleEvent(TopoUiEvent event);
- }
-
- private ModelEventHandler passThruHandler = event -> {
- // simply forward the event message as is
- ObjectNode message = event.subject();
- if (message != null) {
- sendMessages(event.subject());
- }
- };
-
- private ModelEventHandler summaryHandler = event -> {
- // use the currently selected summary generator to create the body..
- ObjectNode payload = currentSummaryGenerator.generateSummary();
- sendMessages(JsonUtils.envelope("showSummary", payload));
- };
-
-
- // TopoUiEvent type binding of handlers
- private final Map<TopoUiEvent.Type, ModelEventHandler>
- eventHandlerBinding = new HashMap<>();
-
- private void bindEventHandlers() {
- eventHandlerBinding.put(SUMMARY_UPDATE, summaryHandler);
- // NOTE: no need to bind pass-thru handlers
- }
-}
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 11839df..ddc61f8 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
@@ -211,10 +211,6 @@
// ==================================================================
- /**
- * @deprecated in Cardinal Release
- */
- @Deprecated
private final class TopoStart extends RequestHandler {
private TopoStart() {
super(TOPO_START);
@@ -230,10 +226,6 @@
}
}
- /**
- * @deprecated in Cardinal Release
- */
- @Deprecated
private final class TopoHeartbeat extends RequestHandler {
private TopoHeartbeat() {
super(TOPO_HEARTBEAT);
@@ -258,10 +250,6 @@
}
}
- /**
- * @deprecated in Cardinal Release
- */
- @Deprecated
private final class TopoStop extends RequestHandler {
private TopoStop() {
super(TOPO_STOP);
@@ -274,10 +262,6 @@
}
}
- /**
- * @deprecated in Cardinal Release
- */
- @Deprecated
private final class ReqSummary extends RequestHandler {
private ReqSummary() {
super(REQ_SUMMARY);
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
index 42dcd9f..2deabc0 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
@@ -110,10 +110,7 @@
/**
* Facility for creating messages bound for the topology viewer.
- *
- * @deprecated in Cardinal Release
*/
-@Deprecated
public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
protected static final Logger log =
@@ -943,6 +940,7 @@
}
// Auxiliary key/value carrier.
+ @Deprecated
static class Prop {
public final String key;
public final String value;
@@ -954,12 +952,14 @@
}
// Auxiliary properties separator
+ @Deprecated
static class Separator extends Prop {
protected Separator() {
super("-", "");
}
}
+ // TODO: move this to traffic overlay component
// Auxiliary carrier of data for requesting traffic message.
static class TrafficClass {
public final boolean showTraffic;
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 c3c9538..84e9995 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
@@ -33,8 +33,6 @@
import org.onosproject.ui.UiTopoOverlayFactory;
import org.onosproject.ui.UiView;
import org.onosproject.ui.UiViewHidden;
-import org.onosproject.ui.impl.topo.OverlayService;
-import org.onosproject.ui.impl.topo.overlay.SummaryGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,8 +50,7 @@
*/
@Component(immediate = true)
@Service
-public class UiExtensionManager
- implements UiExtensionService, SpriteService, OverlayService {
+public class UiExtensionManager implements UiExtensionService, SpriteService {
private static final ClassLoader CL =
UiExtensionManager.class.getClassLoader();
@@ -70,9 +67,6 @@
// Core views & core extension
private final UiExtension core = createCoreExtension();
- // Topology Message Handler
- private final AltTopoViewMessageHandler topoHandler =
- new AltTopoViewMessageHandler();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
@@ -96,7 +90,6 @@
UiMessageHandlerFactory messageHandlerFactory =
() -> ImmutableList.of(
new TopologyViewMessageHandler(),
-// topoHandler,
new DeviceViewMessageHandler(),
new LinkViewMessageHandler(),
new HostViewMessageHandler(),
@@ -182,18 +175,4 @@
return sprites.get(name);
}
-
- // =====================================================================
- // Topology Overlay API -- pass through to topology message handler
-
- // NOTE: while WIP, comment out calls to topoHandler (for checked in code)
- @Override
- public void addSummaryGenerator(String overlayId, SummaryGenerator generator) {
- topoHandler.addSummaryGenerator(overlayId, generator);
- }
-
- @Override
- public void removeSummaryGenerator(String overlayId) {
- topoHandler.removeSummaryGenerator(overlayId);
- }
}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/MetaDb.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/MetaDb.java
deleted file mode 100644
index f890137..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/MetaDb.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * A database of meta information stored for topology objects.
- */
-// package private
-class MetaDb {
-
- private static Map<String, ObjectNode> metaCache = new ConcurrentHashMap<>();
-
- /**
- * Adds meta UI information about the specified object to the given payload.
- *
- * @param id object identifier
- * @param payload payload to which the info should be added
- */
- public void addMetaUi(String id, ObjectNode payload) {
- ObjectNode meta = metaCache.get(id);
- if (meta != null) {
- payload.set("metaUi", meta);
- }
- }
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/ModelListenerRegistry.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/ModelListenerRegistry.java
deleted file mode 100644
index ae29da4..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/ModelListenerRegistry.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import org.onosproject.event.ListenerRegistry;
-import org.slf4j.Logger;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * A listener registry that automatically prunes listeners that have not
- * been sending heartbeat messages to assure us they are really listening.
- */
-// package private
-class ModelListenerRegistry
- extends ListenerRegistry<TopoUiEvent, TopoUiListener> {
-
- private final Logger log = getLogger(getClass());
-
- private final Set<TopoUiListener> zombies = new HashSet<>();
-
- @Override
- public void process(TopoUiEvent event) {
- zombies.clear();
- for (TopoUiListener listener : listeners) {
- try {
- if (listener.isAwake()) {
- listener.event(event);
- } else {
- zombies.add(listener);
- }
- } catch (Exception error) {
- reportProblem(event, error);
- }
- }
-
- // clean up zombie listeners
- for (TopoUiListener z : zombies) {
- log.debug("Removing zombie model listener: {}", z);
- removeListener(z);
- }
- }
-
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/OverlayService.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/OverlayService.java
deleted file mode 100644
index a046a12..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/OverlayService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import org.onosproject.ui.impl.topo.overlay.SummaryGenerator;
-
-/**
- * Provides the API for external agents to inject topology overlay behavior.
- */
-// TODO: move to core-api module
-public interface OverlayService {
-
- /**
- * Registers a custom summary generator for the specified overlay.
- *
- * @param overlayId overlay identifier
- * @param generator generator to register
- */
- void addSummaryGenerator(String overlayId, SummaryGenerator generator);
-
- /**
- * Unregisters the generator associated with the specified overlay.
- *
- * @param overlayId overlay identifier
- */
- void removeSummaryGenerator(String overlayId);
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/SummaryData.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/SummaryData.java
deleted file mode 100644
index c53d82d..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/SummaryData.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-/**
- * Provides basic summary data for the topology.
- */
-// TODO: review -- move to core-api module?
-public interface SummaryData {
-
- /**
- * Returns the number of devices.
- *
- * @return number of devices
- */
- int deviceCount();
-
- /**
- * Returns the number of links.
- *
- * @return number of links
- */
- int linkCount();
-
- /**
- * Returns the number of hosts.
- *
- * @return number of hosts
- */
- int hostCount();
-
- /**
- * Returns the number of clusters (topology SCCs).
- *
- * @return number of clusters
- */
- int clusterCount();
-
- /**
- * Returns the number of intents in the system.
- *
- * @return number of intents
- */
- long intentCount();
-
- /**
- * Returns the number of flow rules in the system.
- *
- * @return number of flow rules
- */
- int flowRuleCount();
-
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoMessageFactory.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoMessageFactory.java
deleted file mode 100644
index 59af263..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoMessageFactory.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cluster.ClusterEvent;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.Annotated;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultEdgeLink;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.EdgeLink;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.HostLocation;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.ui.JsonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.cluster.ControllerNode.State.ACTIVE;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Facility for generating messages in {@link ObjectNode} form from
- * ONOS model events.
- */
-// package private
-class TopoMessageFactory {
-
- private static final ProviderId PROVIDER_ID =
- new ProviderId("core", "org.onosproject.core", true);
- private static final String COMPACT = "%s/%s-%s/%s";
- private static final PortNumber PORT_ZERO = portNumber(0);
-
- private static final Map<Enum<?>, String> LOOKUP = new HashMap<>();
-
- static {
- LOOKUP.put(ClusterEvent.Type.INSTANCE_ADDED, "addInstance");
- LOOKUP.put(ClusterEvent.Type.INSTANCE_REMOVED, "removeInstance");
- LOOKUP.put(DeviceEvent.Type.DEVICE_ADDED, "addDevice");
- LOOKUP.put(DeviceEvent.Type.DEVICE_UPDATED, "updateDevice");
- LOOKUP.put(DeviceEvent.Type.DEVICE_REMOVED, "removeDevice");
- LOOKUP.put(LinkEvent.Type.LINK_ADDED, "addLink");
- LOOKUP.put(LinkEvent.Type.LINK_UPDATED, "updateLink");
- LOOKUP.put(LinkEvent.Type.LINK_REMOVED, "removeLink");
- LOOKUP.put(HostEvent.Type.HOST_ADDED, "addHost");
- LOOKUP.put(HostEvent.Type.HOST_UPDATED, "updateHost");
- LOOKUP.put(HostEvent.Type.HOST_REMOVED, "removeHost");
- }
-
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private MetaDb metaDb;
-
- private ClusterService clusterService;
- private DeviceService deviceService;
- private LinkService linkService;
- private HostService hostService;
- private MastershipService mastershipService;
-
-
- // ===================================================================
- // Private helper methods
-
- private ObjectNode objectNode() {
- return MAPPER.createObjectNode();
- }
-
- private ArrayNode arrayNode() {
- return MAPPER.createArrayNode();
- }
-
- private String toLc(Object o) {
- return o.toString().toLowerCase();
- }
-
- // Event type to message type lookup (with fallback).
- private String messageTypeLookup(Enum<?> type, String fallback) {
- String msgType = LOOKUP.get(type);
- return msgType == null ? fallback : msgType;
- }
-
- // Returns the name of the master node for the specified device ID.
- private String master(DeviceId deviceId) {
- NodeId master = mastershipService.getMasterFor(deviceId);
- return master != null ? master.toString() : "";
- }
-
- // Produces JSON structure from annotations.
- private ObjectNode props(Annotations annotations) {
- ObjectNode props = objectNode();
- if (annotations != null) {
- for (String key : annotations.keys()) {
- props.put(key, annotations.value(key));
- }
- }
- return props;
- }
-
- // Adds a geo location JSON to the specified payload object.
- private void addGeoLocation(Annotated annotated, ObjectNode payload) {
- Annotations annot = annotated.annotations();
- if (annot == null) {
- return;
- }
-
- String slat = annot.value(AnnotationKeys.LATITUDE);
- String slng = annot.value(AnnotationKeys.LONGITUDE);
- try {
- if (!isNullOrEmpty(slat) && !isNullOrEmpty(slng)) {
- double lat = Double.parseDouble(slat);
- double lng = Double.parseDouble(slng);
- ObjectNode loc = objectNode()
- .put("type", "latlng")
- .put("lat", lat)
- .put("lng", lng);
- payload.set("location", loc);
- }
- } catch (NumberFormatException e) {
- log.warn("Invalid geo data latitude={}; longitude={}", slat, slng);
- }
- }
-
- // Produces compact string representation of a link.
- private String compactLinkString(Link link) {
- return String.format(COMPACT, link.src().elementId(), link.src().port(),
- link.dst().elementId(), link.dst().port());
- }
-
- // Generates an edge link from the specified host location.
- private EdgeLink edgeLink(Host host, boolean isIngress) {
- ConnectPoint cp = new ConnectPoint(host.id(), PORT_ZERO);
- return new DefaultEdgeLink(PROVIDER_ID, cp, host.location(), isIngress);
- }
-
- // Encodes the specified host location into a JSON object.
- private ObjectNode hostConnect(HostLocation loc) {
- return objectNode()
- .put("device", loc.deviceId().toString())
- .put("port", loc.port().toLong());
- }
-
- // Returns the first IP address from the specified set.
- private String firstIp(Set<IpAddress> addresses) {
- Iterator<IpAddress> it = addresses.iterator();
- return it.hasNext() ? it.next().toString() : "unknown";
- }
-
- // Returns a JSON array of the specified strings.
- private ArrayNode labels(String... labels) {
- ArrayNode array = arrayNode();
- for (String label : labels) {
- array.add(label);
- }
- return array;
- }
-
- // ===================================================================
- // API for generating messages
-
- /**
- * Injects service references so that the message compilation methods
- * can do required lookups when needed.
- *
- * @param meta meta DB
- * @param cs cluster service
- * @param ds device service
- * @param ls link service
- * @param hs host service
- * @param ms mastership service
- */
- public void injectServices(MetaDb meta, ClusterService cs, DeviceService ds,
- LinkService ls, HostService hs,
- MastershipService ms) {
- metaDb = meta;
- clusterService = cs;
- deviceService = ds;
- linkService = ls;
- hostService = hs;
- mastershipService = ms;
- }
-
- /**
- * Transforms a cluster event into an object-node-based message.
- *
- * @param ev cluster event
- * @return marshaled event message
- */
- public ObjectNode instanceMessage(ClusterEvent ev) {
- ControllerNode node = ev.subject();
- NodeId nid = node.id();
- String id = nid.toString();
- String ip = node.ip().toString();
- int switchCount = mastershipService.getDevicesOf(nid).size();
-
- ObjectNode payload = objectNode()
- .put("id", id)
- .put("ip", ip)
- .put("online", clusterService.getState(nid) == ACTIVE)
- .put("uiAttached", node.equals(clusterService.getLocalNode()))
- .put("switches", switchCount);
-
- ArrayNode labels = arrayNode().add(id).add(ip);
-
- payload.set("labels", labels);
- metaDb.addMetaUi(id, payload);
-
- String msgType = messageTypeLookup(ev.type(), "addInstance");
- return JsonUtils.envelope(msgType, payload);
- }
-
- /**
- * Transforms a device event into an object-node-based message.
- *
- * @param ev device event
- * @return marshaled event message
- */
- public ObjectNode deviceMessage(DeviceEvent ev) {
- Device device = ev.subject();
- DeviceId did = device.id();
- String id = did.toString();
-
- ObjectNode payload = objectNode()
- .put("id", id)
- .put("type", toLc(device.type()))
- .put("online", deviceService.isAvailable(did))
- .put("master", master(did));
-
- Annotations annot = device.annotations();
- String name = annot.value(AnnotationKeys.NAME);
- String friendly = isNullOrEmpty(name) ? id : name;
- payload.set("labels", labels("", friendly, id));
- payload.set("props", props(annot));
-
- addGeoLocation(device, payload);
- metaDb.addMetaUi(id, payload);
-
- String msgType = messageTypeLookup(ev.type(), "updateDevice");
- return JsonUtils.envelope(msgType, payload);
- }
-
- /**
- * Transforms a link event into an object-node-based message.
- *
- * @param ev link event
- * @return marshaled event message
- */
- public ObjectNode linkMessage(LinkEvent ev) {
- Link link = ev.subject();
- ObjectNode payload = objectNode()
- .put("id", compactLinkString(link))
- .put("type", toLc(link.type()))
- .put("online", link.state() == Link.State.ACTIVE)
- .put("linkWidth", 1.2)
- .put("src", link.src().deviceId().toString())
- .put("srcPort", link.src().port().toString())
- .put("dst", link.dst().deviceId().toString())
- .put("dstPort", link.dst().port().toString());
-
- String msgType = messageTypeLookup(ev.type(), "updateLink");
- return JsonUtils.envelope(msgType, payload);
- }
-
- /**
- * Transforms a host event into an object-node-based message.
- *
- * @param ev host event
- * @return marshaled event message
- */
- public ObjectNode hostMessage(HostEvent ev) {
- Host host = ev.subject();
- HostId hid = host.id();
- String id = hid.toString();
- Annotations annot = host.annotations();
-
- String hostType = annot.value(AnnotationKeys.TYPE);
-
- ObjectNode payload = objectNode()
- .put("id", id)
- .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType)
- .put("ingress", compactLinkString(edgeLink(host, true)))
- .put("egress", compactLinkString(edgeLink(host, false)));
-
- // TODO: make cp an array of connect point objects (multi-homed)
- payload.set("cp", hostConnect(host.location()));
- String ipStr = firstIp(host.ipAddresses());
- String macStr = host.mac().toString();
- payload.set("labels", labels(ipStr, macStr));
- payload.set("props", props(annot));
- addGeoLocation(host, payload);
- metaDb.addMetaUi(id, payload);
-
- String mstType = messageTypeLookup(ev.type(), "updateHost");
- return JsonUtils.envelope(mstType, payload);
- }
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiEvent.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiEvent.java
deleted file mode 100644
index 957476c..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiEvent.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.event.AbstractEvent;
-
-/**
- * Describes Topology UI Model events.
- */
-public class TopoUiEvent extends AbstractEvent<TopoUiEvent.Type, ObjectNode> {
-
- /**
- * Type of Topology UI Model events.
- */
- public enum Type {
- // notification events
- SUMMARY_UPDATE,
-
- // unsolicited topology events
- INSTANCE_ADDED,
- INSTANCE_REMOVED,
- DEVICE_ADDED,
- DEVICE_UPDATED,
- DEVICE_REMOVED,
- LINK_ADDED,
- LINK_UPDATED,
- LINK_REMOVED,
- HOST_ADDED,
- HOST_UPDATED,
- HOST_REMOVED
- }
-
-
- protected TopoUiEvent(Type type, ObjectNode subject) {
- super(type, subject);
- }
-
- protected TopoUiEvent(Type type, ObjectNode subject, long time) {
- super(type, subject, time);
- }
-
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiListener.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiListener.java
deleted file mode 100644
index 8e8f2ed..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Defines a listener of Topology UI Model events.
- */
-public interface TopoUiListener extends EventListener<TopoUiEvent> {
-
- /**
- * Returns true if the listener really is listening.
- *
- * @return true if awake
- */
- boolean isAwake();
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelManager.java
deleted file mode 100644
index 3c355ab..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelManager.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.cluster.ClusterEvent;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.event.EventDeliveryService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-import org.onosproject.net.Link;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED;
-import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED;
-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.impl.topo.TopoUiEvent.Type.SUMMARY_UPDATE;
-
-
-/**
- * Maintains a UI-centric model of the topology, as inferred from interactions
- * with the different (device, host, link, ...) services. Will serve up this
- * model to anyone who cares to {@link TopoUiListener listen}.
- */
-@Component(immediate = true)
-@Service
-public class TopoUiModelManager implements TopoUiModelService {
-
- // TODO: put back to 30,000 ms for production
- private static final long SUMMARY_PERIOD = 15_000;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LinkService linkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected IntentService intentService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TopologyService topologyService;
-
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected EventDeliveryService eventDispatcher;
-
-
- private final ModelListenerRegistry listenerRegistry =
- new ModelListenerRegistry();
-
- private final TopoMessageFactory messageFactory = new TopoMessageFactory();
- private final MetaDb metaDb = new MetaDb();
-
- private final Timer timer = new Timer("topology-view");
-
- private TimerTask summaryTask = null;
- private boolean summaryRunning = false;
-
-
- @Activate
- public void activate() {
- eventDispatcher.addSink(TopoUiEvent.class, listenerRegistry);
- messageFactory.injectServices(
- metaDb,
- clusterService,
- deviceService,
- linkService,
- hostService,
- mastershipService
- // TODO: others??
- );
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- eventDispatcher.removeSink(TopoUiEvent.class);
- log.info("Stopped");
- }
-
-
- @Override
- public void addListener(TopoUiListener listener) {
- listenerRegistry.addListener(listener);
- }
-
- @Override
- public void removeListener(TopoUiListener listener) {
- listenerRegistry.removeListener(listener);
- }
-
- @Override
- public List<ObjectNode> getInitialState() {
- List<ObjectNode> results = new ArrayList<>();
- addInstances(results);
- addDevices(results);
- addLinks(results);
- addHosts(results);
- return results;
- }
-
- @Override
- public synchronized void startSummaryMonitoring() {
- // first, cancel previous task if not canceled already
- stopSummaryMonitoring();
-
- // create and start a summary task, to execute with no delay, and
- // every SUMMARY_PERIOD milliseconds thereafter.
- summaryTask = new TimerTask() {
- @Override
- public void run() {
- if (summaryRunning) {
- post(new TopoUiEvent(SUMMARY_UPDATE, null));
- }
- }
- };
-
- timer.schedule(summaryTask, 0, SUMMARY_PERIOD);
- summaryRunning = true;
- }
-
- @Override
- public synchronized void stopSummaryMonitoring() {
- if (summaryTask != null) {
- summaryTask.cancel();
- summaryTask = null;
- }
- summaryRunning = false;
- }
-
- @Override
- public SummaryData getSummaryData() {
- return new SummaryDataImpl();
- }
-
- // =====================================================================
-
- private final class SummaryDataImpl implements SummaryData {
- private final Topology topology = topologyService.currentTopology();
-
- @Override
- public int deviceCount() {
- return topology.deviceCount();
- }
-
- @Override
- public int linkCount() {
- return topology.linkCount();
- }
-
- @Override
- public int hostCount() {
- return hostService.getHostCount();
- }
-
- @Override
- public int clusterCount() {
- return topology.clusterCount();
- }
-
- @Override
- public long intentCount() {
- return intentService.getIntentCount();
- }
-
- @Override
- public int flowRuleCount() {
- return flowRuleService.getFlowRuleCount();
- }
- }
-
- // =====================================================================
-
- private static final Comparator<? super ControllerNode> NODE_COMPARATOR =
- (o1, o2) -> o1.id().toString().compareTo(o2.id().toString());
-
- // =====================================================================
-
- private void addInstances(List<ObjectNode> results) {
- List<ControllerNode> nodes = new ArrayList<>(clusterService.getNodes());
- Collections.sort(nodes, NODE_COMPARATOR);
- for (ControllerNode node : nodes) {
- ClusterEvent ev = new ClusterEvent(INSTANCE_ADDED, node);
- results.add(messageFactory.instanceMessage(ev));
- }
- }
-
- private void addDevices(List<ObjectNode> results) {
- // Send optical first, others later -- for layered rendering
- List<DeviceEvent> deferred = new ArrayList<>();
-
- for (Device device : deviceService.getDevices()) {
- DeviceEvent ev = new DeviceEvent(DEVICE_ADDED, device);
- if (device.type() == Device.Type.ROADM) {
- results.add(messageFactory.deviceMessage(ev));
- } else {
- deferred.add(ev);
- }
- }
-
- for (DeviceEvent ev : deferred) {
- results.add(messageFactory.deviceMessage(ev));
- }
- }
-
- private void addLinks(List<ObjectNode> results) {
- // Send optical first, others later -- for layered rendering
- List<LinkEvent> deferred = new ArrayList<>();
-
- for (Link link : linkService.getLinks()) {
- LinkEvent ev = new LinkEvent(LINK_ADDED, link);
- if (link.type() == Link.Type.OPTICAL) {
- results.add(messageFactory.linkMessage(ev));
- } else {
- deferred.add(ev);
- }
- }
-
- for (LinkEvent ev : deferred) {
- results.add(messageFactory.linkMessage(ev));
- }
- }
-
- private void addHosts(List<ObjectNode> results) {
- for (Host host : hostService.getHosts()) {
- HostEvent ev = new HostEvent(HOST_ADDED, host);
- results.add(messageFactory.hostMessage(ev));
- }
- }
-
- // =====================================================================
-
- private void post(TopoUiEvent event) {
- if (event != null) {
- eventDispatcher.post(event);
- }
- }
-
- // NOTE: session-independent state only
- // private inner classes to listen to device/host/link events
- // TODO..
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelService.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelService.java
deleted file mode 100644
index 83d0dbf..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoUiModelService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.util.List;
-
-/**t
- * Defines the API for the Topology UI Model.
- */
-public interface TopoUiModelService {
-
- /**
- * Registers the specified listener for Topology UI Model events.
- *
- * @param listener the listener
- */
- void addListener(TopoUiListener listener);
-
- /**
- * Unregister the specified listener.
- *
- * @param listener the listener
- */
- void removeListener(TopoUiListener listener);
-
-
- /**
- * Returns events describing the current state of the model.
- * <p>
- * These will be in the form of "addInstance", "addDevice", "addLink",
- * and "addHost" events, as appropriate.
- *
- * @return initial state messages
- */
- List<ObjectNode> getInitialState();
-
- /**
- * Starts the summary monitoring process.
- * <p>
- * Sends a "showSummary" message now, and schedules a task to send
- * updates whenever the data changes.
- */
- void startSummaryMonitoring();
-
- /**
- * Cancels the task that sends summary updates.
- */
- void stopSummaryMonitoring();
-
- /**
- * Returns base data about the topology.
- *
- * @return summary data
- */
- SummaryData getSummaryData();
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/AbstractSummaryGenerator.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/AbstractSummaryGenerator.java
deleted file mode 100644
index ce840bd..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/AbstractSummaryGenerator.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo.overlay;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Base implementation of a {@link SummaryGenerator}. Provides convenience
- * methods for compiling a list of properties to be displayed in the summary
- * panel on the UI.
- */
-public abstract class AbstractSummaryGenerator implements SummaryGenerator {
- private static final String NUMBER_FORMAT = "#,###";
- private static final DecimalFormat DF = new DecimalFormat(NUMBER_FORMAT);
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- private final List<Prop> props = new ArrayList<>();
- private String iconId;
- private String title;
-
- /**
- * Constructs a summary generator without specifying the icon ID or title.
- * It is expected that the title (and optionally the icon ID) will be set
- * later via {@link #title(String)} (and {@link #iconId(String)}), before
- * {@link #buildObjectNode()} is invoked to generate the message payload.
- */
- public AbstractSummaryGenerator() {
- }
-
- /**
- * Constructs a summary generator that uses the specified iconId ID and
- * title in its generated output.
- *
- * @param iconId iconId ID
- * @param title title
- */
- public AbstractSummaryGenerator(String iconId, String title) {
- this.iconId = iconId;
- this.title = title;
- }
-
- /**
- * Subclasses need to provide an implementation.
- *
- * @return the summary payload
- */
- @Override
- public abstract ObjectNode generateSummary();
-
- /**
- * Formats the given number into a string, using comma separator.
- *
- * @param number the number
- * @return formatted as a string
- */
- protected String format(Number number) {
- return DF.format(number);
- }
-
- /**
- * Sets the iconId ID to use.
- *
- * @param iconId iconId ID
- */
- protected void iconId(String iconId) {
- this.iconId = iconId;
- }
-
- /**
- * Sets the summary panel title.
- *
- * @param title the title
- */
- protected void title(String title) {
- this.title = title;
- }
-
- /**
- * Clears out the cache of properties.
- */
- protected void clearProps() {
- props.clear();
- }
-
- /**
- * Adds a property to the summary. Note that the value is converted to
- * a string by invoking the <code>toString()</code> method on it.
- *
- * @param label the label
- * @param value the value
- */
- protected void prop(String label, Object value) {
- props.add(new Prop(label, value));
- }
-
- /**
- * Adds a separator to the summary; when rendered on the client, a visible
- * break between properties.
- */
- protected void separator() {
- props.add(new Prop("-", ""));
- }
-
- /**
- * Builds an object node from the current state of the summary generator.
- *
- * @return summary payload as JSON object node
- */
- protected ObjectNode buildObjectNode() {
- ObjectNode result = MAPPER.createObjectNode();
- // NOTE: "id" and "type" are currently used for title and iconID
- // so that this structure can be "re-used" with detail panel payloads
- result.put("id", title).put("type", iconId);
-
- ObjectNode pnode = MAPPER.createObjectNode();
- ArrayNode porder = MAPPER.createArrayNode();
-
- for (Prop p : props) {
- porder.add(p.label);
- pnode.put(p.label, p.value);
- }
- result.set("propOrder", porder);
- result.set("props", pnode);
-
- return result;
- }
-
- // ===================================================================
-
- /**
- * Abstraction of a property, that is, a label-value pair.
- */
- private static class Prop {
- private final String label;
- private final String value;
-
- public Prop(String label, Object value) {
- this.label = label;
- this.value = value.toString();
- }
- }
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/SummaryGenerator.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/SummaryGenerator.java
deleted file mode 100644
index aa1be9c..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/SummaryGenerator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo.overlay;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * May be called upon to generate the summary messages for the topology view
- * in the GUI.
- * <p>
- * It is assumed that if a custom summary generator is installed on the server
- * (as part of a topology overlay), a peer custom summary message handler will
- * be installed on the client side to handle the messages thus generated.
- */
-public interface SummaryGenerator {
- /**
- * Generates the payload for the "showSummary" message.
- *
- * @return the message payload
- */
- ObjectNode generateSummary();
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/package-info.java
deleted file mode 100644
index c5eda13..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/overlay/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Base abstractions and utilities for creating topology view overlays; experimental.
- */
-package org.onosproject.ui.impl.topo.overlay;
\ No newline at end of file
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
deleted file mode 100644
index 77d97b9..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Topology view server-side model service with ability for apps to overlay
- * their own functionality and information; experimental.
- */
-package org.onosproject.ui.impl.topo;
\ No newline at end of file