import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
import org.opendaylight.controller.clustering.services.IClusterContainerServices;
import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.ConfigurationObject;
import org.opendaylight.controller.configuration.IConfigurationContainerAware;
+import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Host;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
import org.opendaylight.controller.sal.topology.ITopologyService;
import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.IObjectReader;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
-import org.opendaylight.controller.sal.utils.ObjectReader;
-import org.opendaylight.controller.sal.utils.ObjectWriter;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.switchmanager.ISwitchManager;
protected static final String TOPOHOSTSDB = "topologymanager.hostsDB";
protected static final String TOPONODECONNECTORDB = "topologymanager.nodeConnectorDB";
protected static final String TOPOUSERLINKSDB = "topologymanager.userLinksDB";
+ private static final String USER_LINKS_FILE_NAME = "userTopology.conf";
private static final Logger log = LoggerFactory.getLogger(TopologyManagerImpl.class);
private ITopologyService topoService;
private IClusterContainerServices clusterContainerService;
+ private IConfigurationContainerService configurationService;
private ISwitchManager switchManager;
// DB of all the Edges with properties which constitute our topology
private ConcurrentMap<Edge, Set<Property>> edgesDB;
// Topology Manager Aware listeners - for clusterwide updates
private Set<ITopologyManagerClusterWideAware> topologyManagerClusterWideAware =
new CopyOnWriteArraySet<ITopologyManagerClusterWideAware>();
- private static String ROOT = GlobalConstants.STARTUPHOME.toString();
- private String userLinksFileName;
private ConcurrentMap<String, TopologyUserLinkConfig> userLinksDB;
private BlockingQueue<TopoEdgeUpdate> notifyQ = new LinkedBlockingQueue<TopoEdgeUpdate>();
private volatile Boolean shuttingDown = false;
}
}
+ public void setConfigurationContainerService(IConfigurationContainerService service) {
+ log.trace("Got configuration service set request {}", service);
+ this.configurationService = service;
+ }
+
+ public void unsetConfigurationContainerService(IConfigurationContainerService service) {
+ log.trace("Got configuration service UNset request");
+ this.configurationService = null;
+ }
+
void setSwitchManager(ISwitchManager s) {
log.debug("Adding ISwitchManager: {}", s);
this.switchManager = s;
containerName = "UNKNOWN";
}
- userLinksFileName = ROOT + "userTopology_" + containerName + ".conf";
registerWithOSGIConsole();
- if ((clusterContainerService != null) && (clusterContainerService.amICoordinator())) {
- loadConfiguration();
- }
+ loadConfiguration();
+
// Restore the shuttingDown status on init of the component
shuttingDown = false;
notifyThread = new Thread(new TopologyNotify(notifyQ));
notifyThread = null;
}
- @SuppressWarnings("unchecked")
private void loadConfiguration() {
- ObjectReader objReader = new ObjectReader();
- ConcurrentMap<String, TopologyUserLinkConfig> confList =
- (ConcurrentMap<String, TopologyUserLinkConfig>) objReader.read(this, userLinksFileName);
-
- if (confList != null) {
- for (TopologyUserLinkConfig conf : confList.values()) {
- addUserLink(conf);
- }
+ for (ConfigurationObject conf : configurationService.retrieveConfiguration(this, USER_LINKS_FILE_NAME)) {
+ addUserLink((TopologyUserLinkConfig) conf);
}
}
}
public Status saveConfigInternal() {
- ObjectWriter objWriter = new ObjectWriter();
-
- Status saveStatus = objWriter.write(
- new ConcurrentHashMap<String, TopologyUserLinkConfig>(userLinksDB), userLinksFileName);
+ Status saveStatus = configurationService.persistConfiguration(
+ new ArrayList<ConfigurationObject>(userLinksDB.values()), USER_LINKS_FILE_NAME);
- if (! saveStatus.isSuccess()) {
+ if (!saveStatus.isSuccess()) {
return new Status(StatusCode.INTERNALERROR, "Topology save failed: " + saveStatus.getDescription());
}
return saveStatus;