Bug 1029: Remove dead code: samples/clustersession
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / TopologyServices.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
10
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;
18
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;
23
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;
31
32     /**
33      * Function called by the dependency manager when all the required
34      * dependencies are satisfied
35      *
36      */
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")
42                 : null;
43     }
44
45     /**
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.
49      *
50      */
51     void destroy() {
52         logger.trace("DESTROY called!");
53     }
54
55     /**
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
58      *
59      */
60     void start() {
61         logger.trace("START called!");
62     }
63
64     /**
65      * Function called by the dependency manager before the services exported by
66      * the component are unregistered, this will be followed by a "destroy ()"
67      * calls
68      *
69      */
70     void stop() {
71         logger.trace("STOP called!");
72     }
73
74     /**
75      * Retrieve SAL service IPluginOutTopologyService
76      *
77      * @param s
78      *            Called by Dependency Manager as soon as the SAL service is
79      *            available
80      */
81     public void setPluginOutTopologyService(IPluginOutTopologyService s) {
82         logger.trace("Setting IPluginOutTopologyService to: {}", s);
83         this.salTopoService = s;
84     }
85
86     /**
87      * called when SAL service IPluginOutTopologyService is no longer available
88      *
89      * @param s
90      *            Called by Dependency Manager as soon as the SAL service is
91      *            unavailable
92      */
93     public void unsetPluginOutTopologyService(IPluginOutTopologyService s) {
94         if (this.salTopoService == s) {
95             logger.trace("UNSetting IPluginOutTopologyService from: {}", s);
96             this.salTopoService = null;
97         }
98     }
99
100     /**
101      * Retrieve OF protocol_plugin service IRefreshInternalProvider
102      *
103      * @param s
104      *            Called by Dependency Manager as soon as the SAL service is
105      *            available
106      */
107     public void setRefreshInternalProvider(IRefreshInternalProvider s) {
108         logger.trace("Setting IRefreshInternalProvider to: {}", s);
109         this.topoRefreshService = s;
110     }
111
112     /**
113      * called when OF protocol_plugin service IRefreshInternalProvider is no
114      * longer available
115      *
116      * @param s
117      *            Called by Dependency Manager as soon as the SAL service is
118      *            unavailable
119      */
120     public void unsetRefreshInternalProvider(IRefreshInternalProvider s) {
121         if (this.topoRefreshService == s) {
122             logger.trace("UNSetting IRefreshInternalProvider from: {}", s);
123             this.topoRefreshService = null;
124         }
125     }
126
127     @Override
128     public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
129         if (this.salTopoService != null) {
130             this.salTopoService.edgeUpdate(topoedgeupdateList);
131         }
132     }
133
134     @Override
135     public void sollicitRefresh() {
136         logger.debug("Got a request to refresh topology");
137         topoRefreshService.requestRefresh(containerName);
138     }
139
140     @Override
141     public void edgeOverUtilized(Edge edge) {
142         if (this.salTopoService != null) {
143             this.salTopoService.edgeOverUtilized(edge);
144         }
145     }
146
147     @Override
148     public void edgeUtilBackToNormal(Edge edge) {
149         if (this.salTopoService != null) {
150             this.salTopoService.edgeUtilBackToNormal(edge);
151         }
152     }
153 }