From: Madhu Venugopal Date: Tue, 7 May 2013 10:04:14 +0000 (-0700) Subject: Primitive support to save the topology coordinates and cleanup of some unused tiering... X-Git-Tag: releasepom-0.1.0~478^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=84a261775633d132d632c9792353bc2f39c12862 Primitive support to save the topology coordinates and cleanup of some unused tiering code Change-Id: Ibe9ae8ab560533cc7215f3d35b1875265fbe54a6 Signed-off-by: Madhu Venugopal --- diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index 7c312e1577..f416f29a25 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -576,25 +576,6 @@ public class HostTracker implements IfIptoHost, IfHostListener, Tier tier = new Tier(1); switchManager.setNodeProp(node, tier); topologyManager.updateHostLink(p, h, UpdateType.ADDED, null); - /* - * This is a temporary fix for Cisco Live's Hadoop - * Demonstration. The concept of Tiering must be revisited based - * on other application requirements and the design might - * warrant a separate module (as it involves tracking the - * topology/ host changes & updating the Tiering numbers in an - * effective manner). - */ - updateSwitchTiers(node, 1); - - /* - * The following 2 lines are added for testing purposes. We can - * remove it once the North-Bound APIs are available for - * testing. - * - * ArrayList> hierarchies = - * getHostNetworkHierarchy(host.getNetworkAddress()); - * logHierarchies(hierarchies); - */ } else { // No need to reset the tiering if no other hosts are currently // connected @@ -899,16 +880,6 @@ public class HostTracker implements IfIptoHost, IfHostListener, logger.debug( "HostTracker Topology linkUpdate handling src:{}[port {}] dst:{}[port {}] added: {}", new Object[] { srcNid, srcPort, dstNid, dstPort, added }); - clearTiers(); - for (Entry entry : hostsDB.entrySet()) { - HostNodeConnector host = entry.getValue(); - Node node = host.getnodeconnectorNode(); - if (node != null) { - Tier t = new Tier(1); - switchManager.setNodeProp(node, t); - updateSwitchTiers(node, 1); - } - } } @Override diff --git a/opendaylight/web/topology/pom.xml b/opendaylight/web/topology/pom.xml index 0dd10512eb..b260e2d1f8 100644 --- a/opendaylight/web/topology/pom.xml +++ b/opendaylight/web/topology/pom.xml @@ -25,6 +25,7 @@ org.opendaylight.controller.containermanager, + org.opendaylight.controller.configuration, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.sal.packet.address, org.opendaylight.controller.sal.action, @@ -96,6 +97,11 @@ containermanager 0.4.0-SNAPSHOT + + org.opendaylight.controller + configuration + 0.4.0-SNAPSHOT + org.opendaylight.controller switchmanager diff --git a/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java b/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java index 3e25110e58..0f4569fc19 100644 --- a/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java +++ b/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java @@ -10,6 +10,9 @@ package org.opendaylight.controller.topology.web; import java.awt.Dimension; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -21,6 +24,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; +import org.opendaylight.controller.configuration.IConfigurationAware; import org.opendaylight.controller.containermanager.IContainerAuthorization; import org.opendaylight.controller.sal.authorization.Resource; import org.opendaylight.controller.sal.authorization.UserLevel; @@ -33,13 +37,19 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.packet.address.EthernetAddress; import org.opendaylight.controller.sal.utils.GlobalConstants; +import org.opendaylight.controller.sal.utils.IObjectReader; +import org.opendaylight.controller.sal.utils.ObjectReader; +import org.opendaylight.controller.sal.utils.ObjectWriter; import org.opendaylight.controller.sal.utils.ServiceHelper; +import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.switchmanager.Switch; import org.opendaylight.controller.switchmanager.SwitchConfig; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.usermanager.IUserManager; import org.opendaylight.controller.web.DaylightWebUtil; +import org.opendaylight.controller.web.IDaylightWeb; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -53,7 +63,9 @@ import edu.uci.ics.jung.graph.SparseMultigraph; @Controller @RequestMapping("/") -public class Topology { +public class Topology implements IObjectReader, IConfigurationAware { + private static String ROOT = GlobalConstants.STARTUPHOME.toString(); + private String topologyWebFileName = null; protected Map>> metaCache = new HashMap>>(); protected Map> stagedNodes; @@ -64,6 +76,12 @@ public class Topology { protected Map metaNodeSingleHash = new HashMap(); protected Map metaNodeConfigurationHash = new HashMap(); + public Topology() { + ServiceHelper.registerGlobalService(IConfigurationAware.class, this, null); + topologyWebFileName = ROOT + "topologyCache.sav"; + loadConfiguration(); + } + /** * Topology of nodes and hosts in the network in JSON format. * @@ -558,4 +576,25 @@ public class Topology { return false; } + + @SuppressWarnings("unchecked") + private void loadConfiguration() { + ObjectReader objReader = new ObjectReader(); + metaCache = (Map>>) objReader.read(this, topologyWebFileName); + if (metaCache == null) metaCache = new HashMap>>(); + } + + @Override + public Status saveConfiguration() { + ObjectWriter objWriter = new ObjectWriter(); + objWriter.write(metaCache, topologyWebFileName); + return new Status(StatusCode.SUCCESS, null); + } + + @Override + public Object readObject(ObjectInputStream ois) + throws FileNotFoundException, IOException, ClassNotFoundException { + // Perform the class deserialization locally, from inside the package where the class is defined + return ois.readObject(); + } } \ No newline at end of file