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<ArrayList<String>> hierarchies =
- * getHostNetworkHierarchy(host.getNetworkAddress());
- * logHierarchies(hierarchies);
- */
} else {
// No need to reset the tiering if no other hosts are currently
// connected
logger.debug(
"HostTracker Topology linkUpdate handling src:{}[port {}] dst:{}[port {}] added: {}",
new Object[] { srcNid, srcPort, dstNid, dstPort, added });
- clearTiers();
- for (Entry<InetAddress, HostNodeConnector> 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
</Export-Package>
<Import-Package>
org.opendaylight.controller.containermanager,
+ org.opendaylight.controller.configuration,
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.sal.packet.address,
org.opendaylight.controller.sal.action,
<artifactId>containermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
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;
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;
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;
@Controller
@RequestMapping("/")
-public class Topology {
+public class Topology implements IObjectReader, IConfigurationAware {
+ private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+ private String topologyWebFileName = null;
protected Map<String, Map<String, Map<String, Object>>> metaCache = new HashMap<String, Map<String, Map<String, Object>>>();
protected Map<String, Map<String, Object>> stagedNodes;
protected Map<String, Integer> metaNodeSingleHash = new HashMap<String, Integer>();
protected Map<String, Integer> metaNodeConfigurationHash = new HashMap<String, Integer>();
+ public Topology() {
+ ServiceHelper.registerGlobalService(IConfigurationAware.class, this, null);
+ topologyWebFileName = ROOT + "topologyCache.sav";
+ loadConfiguration();
+ }
+
/**
* Topology of nodes and hosts in the network in JSON format.
*
return false;
}
+
+ @SuppressWarnings("unchecked")
+ private void loadConfiguration() {
+ ObjectReader objReader = new ObjectReader();
+ metaCache = (Map<String, Map<String, Map<String, Object>>>) objReader.read(this, topologyWebFileName);
+ if (metaCache == null) metaCache = new HashMap<String, Map<String, Map<String, Object>>>();
+ }
+
+ @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