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;
14 import java.util.ArrayList;
16 import org.apache.felix.dm.Component;
17 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
18 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 import org.opendaylight.controller.sal.core.Edge;
23 import org.opendaylight.controller.sal.core.Property;
24 import org.opendaylight.controller.sal.core.UpdateType;
25 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
26 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
27 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
29 public class TopologyServices implements ITopologyServiceShimListener,
30 IPluginInTopologyService {
31 protected static final Logger logger = LoggerFactory
32 .getLogger(TopologyServices.class);
33 private IPluginOutTopologyService salTopoService = null;
34 private IRefreshInternalProvider topoRefreshService = null;
35 private String containerName;
38 * Function called by the dependency manager when all the required
39 * dependencies are satisfied
42 @SuppressWarnings("unchecked")
43 void init(Component c) {
44 logger.trace("INIT called!");
45 Dictionary<Object, Object> props = c.getServiceProperties();
46 containerName = (props != null) ? (String) props.get("containerName")
51 * Function called by the dependency manager when at least one dependency
52 * become unsatisfied or when the component is shutting down because for
53 * example bundle is being stopped.
57 logger.trace("DESTROY called!");
61 * Function called by dependency manager after "init ()" is called and after
62 * the services provided by the class are registered in the service registry
66 logger.trace("START called!");
70 * Function called by the dependency manager before the services exported by
71 * the component are unregistered, this will be followed by a "destroy ()"
76 logger.trace("STOP called!");
80 * Retrieve SAL service IPluginOutTopologyService
83 * Called by Dependency Manager as soon as the SAL service is
86 public void setPluginOutTopologyService(IPluginOutTopologyService s) {
87 logger.trace("Setting IPluginOutTopologyService to: {}", s);
88 this.salTopoService = s;
92 * called when SAL service IPluginOutTopologyService is no longer available
95 * Called by Dependency Manager as soon as the SAL service is
98 public void unsetPluginOutTopologyService(IPluginOutTopologyService s) {
99 if (this.salTopoService == s) {
100 logger.trace("UNSetting IPluginOutTopologyService from: {}", s);
101 this.salTopoService = null;
106 * Retrieve OF protocol_plugin service IRefreshInternalProvider
109 * Called by Dependency Manager as soon as the SAL service is
112 public void setRefreshInternalProvider(IRefreshInternalProvider s) {
113 logger.trace("Setting IRefreshInternalProvider to: {}", s);
114 this.topoRefreshService = s;
118 * called when OF protocol_plugin service IRefreshInternalProvider is no
122 * Called by Dependency Manager as soon as the SAL service is
125 public void unsetRefreshInternalProvider(IRefreshInternalProvider s) {
126 if (this.topoRefreshService == s) {
127 logger.trace("UNSetting IRefreshInternalProvider from: {}", s);
128 this.topoRefreshService = null;
133 public void edgeUpdate(Edge edge, UpdateType type, Set<Property> props) {
134 if (this.salTopoService != null) {
135 List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
136 TopoEdgeUpdate teu = new TopoEdgeUpdate(edge, props, type);
137 topoedgeupdateList.add(teu);
138 this.salTopoService.edgeUpdate(topoedgeupdateList);
143 public void sollicitRefresh() {
144 logger.debug("Got a request to refresh topology");
145 topoRefreshService.requestRefresh(containerName);
149 public void edgeOverUtilized(Edge edge) {
150 if (this.salTopoService != null) {
151 this.salTopoService.edgeOverUtilized(edge);
156 public void edgeUtilBackToNormal(Edge edge) {
157 if (this.salTopoService != null) {
158 this.salTopoService.edgeUtilBackToNormal(edge);