3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.protocol_plugin.openflow.internal;
12 import java.util.Dictionary;
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
17 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 import org.opendaylight.controller.sal.core.Edge;
22 import org.opendaylight.controller.sal.core.Property;
23 import org.opendaylight.controller.sal.core.UpdateType;
24 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
25 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
27 public class TopologyServices implements ITopologyServiceShimListener,
28 IPluginInTopologyService {
29 protected static final Logger logger = LoggerFactory
30 .getLogger(TopologyServices.class);
31 private IPluginOutTopologyService salTopoService = null;
32 private IRefreshInternalProvider topoRefreshService = null;
33 private String containerName;
36 * Function called by the dependency manager when all the required
37 * dependencies are satisfied
40 @SuppressWarnings("unchecked")
41 void init(Component c) {
42 logger.debug("INIT called!");
43 Dictionary<Object, Object> props = c.getServiceProperties();
44 containerName = (props != null) ? (String) props.get("containerName")
49 * Function called by the dependency manager when at least one
50 * dependency become unsatisfied or when the component is shutting
51 * down because for example bundle is being stopped.
55 logger.debug("DESTROY called!");
59 * Function called by dependency manager after "init ()" is called
60 * and after the services provided by the class are registered in
61 * the service registry
65 logger.debug("START called!");
69 * Function called by the dependency manager before the services
70 * exported by the component are unregistered, this will be
71 * followed by a "destroy ()" calls
75 logger.debug("STOP called!");
79 * Retrieve SAL service IPluginOutTopologyService
81 * @param s Called by Dependency Manager as soon as the SAL
82 * service is available
84 public void setPluginOutTopologyService(IPluginOutTopologyService s) {
85 logger.debug("Setting IPluginOutTopologyService to:" + s);
86 this.salTopoService = s;
90 * called when SAL service IPluginOutTopologyService is no longer available
92 * @param s Called by Dependency Manager as soon as the SAL
93 * service is unavailable
95 public void unsetPluginOutTopologyService(IPluginOutTopologyService s) {
96 if (this.salTopoService == s) {
97 logger.debug("UNSetting IPluginOutTopologyService from:" + s);
98 this.salTopoService = null;
103 * Retrieve OF protocol_plugin service IRefreshInternalProvider
105 * @param s Called by Dependency Manager as soon as the SAL
106 * service is available
108 public void setRefreshInternalProvider(IRefreshInternalProvider s) {
109 logger.debug("Setting IRefreshInternalProvider to:" + s);
110 this.topoRefreshService = s;
114 * called when OF protocol_plugin service IRefreshInternalProvider
115 * is no longer available
117 * @param s Called by Dependency Manager as soon as the SAL
118 * service is unavailable
120 public void unsetRefreshInternalProvider(IRefreshInternalProvider s) {
121 if (this.topoRefreshService == s) {
122 logger.debug("UNSetting IRefreshInternalProvider from:" + s);
123 this.topoRefreshService = null;
128 public void edgeUpdate(Edge edge, UpdateType type, Set<Property> props) {
129 if (this.salTopoService != null) {
130 this.salTopoService.edgeUpdate(edge, type, props);
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);