Simon Hunt

GUI -- deleting experimental code for topo refactoring.

Change-Id: I3984f2f4a29496259877bf045c4cc8f46d78c033
......@@ -211,10 +211,6 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
// ==================================================================
/**
* @deprecated in Cardinal Release
*/
@Deprecated
private final class TopoStart extends RequestHandler {
private TopoStart() {
super(TOPO_START);
......@@ -230,10 +226,6 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
}
}
/**
* @deprecated in Cardinal Release
*/
@Deprecated
private final class TopoHeartbeat extends RequestHandler {
private TopoHeartbeat() {
super(TOPO_HEARTBEAT);
......@@ -258,10 +250,6 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
}
}
/**
* @deprecated in Cardinal Release
*/
@Deprecated
private final class TopoStop extends RequestHandler {
private TopoStop() {
super(TOPO_STOP);
......@@ -274,10 +262,6 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
}
}
/**
* @deprecated in Cardinal Release
*/
@Deprecated
private final class ReqSummary extends RequestHandler {
private ReqSummary() {
super(REQ_SUMMARY);
......
......@@ -110,10 +110,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.StatsType.P
/**
* 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 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// Auxiliary key/value carrier.
@Deprecated
static class Prop {
public final String key;
public final String value;
......@@ -954,12 +952,14 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
}
// 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;
......
......@@ -33,8 +33,6 @@ import org.onosproject.ui.UiMessageHandlerFactory;
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 @@ import static org.onosproject.ui.UiView.Category.PLATFORM;
*/
@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 @@ public class UiExtensionManager
// 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 @@ public class UiExtensionManager
UiMessageHandlerFactory messageHandlerFactory =
() -> ImmutableList.of(
new TopologyViewMessageHandler(),
// topoHandler,
new DeviceViewMessageHandler(),
new LinkViewMessageHandler(),
new HostViewMessageHandler(),
......@@ -182,18 +175,4 @@ public class UiExtensionManager
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);
}
}
......
/*
* 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);
}
}
}
/*
* 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);
}
}
}
/*
* 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);
}
/*
* 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();
}
/*
* 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);
}
}
/*
* 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();
}
/*
* 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..
}
/*
* 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();
}
/*
* 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();
}
}
}
/*
* 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();
}
/*
* 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
/*
* 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