2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11 import java.util.Dictionary;
12 import java.util.List;
13 import org.apache.felix.dm.Component;
14 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
15 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import org.opendaylight.controller.sal.core.Edge;
20 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
21 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
22 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
24 public class TopologyServices implements ITopologyServiceShimListener,
25 IPluginInTopologyService {
26 protected static final Logger logger = LoggerFactory
27 .getLogger(TopologyServices.class);
28 private IPluginOutTopologyService salTopoService = null;
29 private IRefreshInternalProvider topoRefreshService = null;
30 private String containerName;
33 * Function called by the dependency manager when all the required
34 * dependencies are satisfied
37 @SuppressWarnings("unchecked")
38 void init(Component c) {
39 logger.trace("INIT called!");
40 Dictionary<Object, Object> props = c.getServiceProperties();
41 containerName = (props != null) ? (String) props.get("containerName")
46 * Function called by the dependency manager when at least one dependency
47 * become unsatisfied or when the component is shutting down because for
48 * example bundle is being stopped.
52 logger.trace("DESTROY called!");
56 * Function called by dependency manager after "init ()" is called and after
57 * the services provided by the class are registered in the service registry
61 logger.trace("START called!");
65 * Function called by the dependency manager before the services exported by
66 * the component are unregistered, this will be followed by a "destroy ()"
71 logger.trace("STOP called!");
75 * Retrieve SAL service IPluginOutTopologyService
78 * Called by Dependency Manager as soon as the SAL service is
81 public void setPluginOutTopologyService(IPluginOutTopologyService s) {
82 logger.trace("Setting IPluginOutTopologyService to: {}", s);
83 this.salTopoService = s;
87 * called when SAL service IPluginOutTopologyService is no longer available
90 * Called by Dependency Manager as soon as the SAL service is
93 public void unsetPluginOutTopologyService(IPluginOutTopologyService s) {
94 if (this.salTopoService == s) {
95 logger.trace("UNSetting IPluginOutTopologyService from: {}", s);
96 this.salTopoService = null;
101 * Retrieve OF protocol_plugin service IRefreshInternalProvider
104 * Called by Dependency Manager as soon as the SAL service is
107 public void setRefreshInternalProvider(IRefreshInternalProvider s) {
108 logger.trace("Setting IRefreshInternalProvider to: {}", s);
109 this.topoRefreshService = s;
113 * called when OF protocol_plugin service IRefreshInternalProvider is no
117 * Called by Dependency Manager as soon as the SAL service is
120 public void unsetRefreshInternalProvider(IRefreshInternalProvider s) {
121 if (this.topoRefreshService == s) {
122 logger.trace("UNSetting IRefreshInternalProvider from: {}", s);
123 this.topoRefreshService = null;
128 public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
129 if (this.salTopoService != null) {
130 this.salTopoService.edgeUpdate(topoedgeupdateList);
135 public void sollicitRefresh() {
136 logger.debug("Got a request to refresh topology");
137 topoRefreshService.requestRefresh(containerName);
141 public void edgeOverUtilized(Edge edge) {
142 if (this.salTopoService != null) {
143 this.salTopoService.edgeOverUtilized(edge);
148 public void edgeUtilBackToNormal(Edge edge) {
149 if (this.salTopoService != null) {
150 this.salTopoService.edgeUtilBackToNormal(edge);