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.sal.implementation.internal;
11 import java.util.Collections;
12 import java.util.HashSet;
13 import java.util.List;
16 import org.opendaylight.controller.sal.core.Edge;
17 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
18 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
19 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
20 import org.opendaylight.controller.sal.topology.ITopologyService;
21 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class Topology implements IPluginOutTopologyService, ITopologyService {
26 protected static final Logger logger = LoggerFactory
27 .getLogger(Topology.class);
28 private Set<IListenTopoUpdates> updateService = Collections
29 .synchronizedSet(new HashSet<IListenTopoUpdates>());
30 private Set<IPluginInTopologyService> pluginService = Collections
31 .synchronizedSet(new HashSet<IPluginInTopologyService>());
33 void setPluginService(IPluginInTopologyService s) {
34 if (this.pluginService != null) {
35 this.pluginService.add(s);
39 void unsetPluginService(IPluginInTopologyService s) {
40 if (this.pluginService != null) {
41 this.pluginService.remove(s);
45 void setUpdateService(IListenTopoUpdates s) {
46 if (this.updateService != null) {
47 this.updateService.add(s);
51 void unsetUpdateService(IListenTopoUpdates s) {
52 if (this.updateService != null) {
53 this.updateService.remove(s);
58 * Function called by the dependency manager when all the required
59 * dependencies are satisfied
66 * Function called by the dependency manager when at least one dependency
67 * become unsatisfied or when the component is shutting down because for
68 * example bundle is being stopped.
72 // Make sure to clear all the data structure we use to track
74 if (this.updateService != null) {
75 this.updateService.clear();
77 if (this.pluginService != null) {
78 this.pluginService.clear();
83 public void sollicitRefresh() {
84 synchronized (this.pluginService) {
85 for (IPluginInTopologyService s : this.pluginService) {
92 public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
93 synchronized (this.updateService) {
94 for (IListenTopoUpdates s : this.updateService) {
95 s.edgeUpdate(topoedgeupdateList);
101 public void edgeOverUtilized(Edge edge) {
102 synchronized (this.updateService) {
103 for (IListenTopoUpdates s : this.updateService) {
104 s.edgeOverUtilized(edge);
110 public void edgeUtilBackToNormal(Edge edge) {
111 synchronized (this.updateService) {
112 for (IListenTopoUpdates s : this.updateService) {
113 s.edgeUtilBackToNormal(edge);