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.sal.implementation.internal;
12 import java.util.HashSet;
14 import java.util.Collections;
16 import org.opendaylight.controller.sal.core.Edge;
17 import org.opendaylight.controller.sal.core.Property;
18 import org.opendaylight.controller.sal.core.UpdateType;
19 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
20 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
21 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
22 import org.opendaylight.controller.sal.topology.ITopologyService;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class Topology implements IPluginOutTopologyService, ITopologyService {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(Topology.class);
29 private Set<IListenTopoUpdates> updateService = Collections
30 .synchronizedSet(new HashSet<IListenTopoUpdates>());
31 private Set<IPluginInTopologyService> pluginService = Collections
32 .synchronizedSet(new HashSet<IPluginInTopologyService>());
34 void setPluginService(IPluginInTopologyService s) {
35 if (this.pluginService != null) {
36 this.pluginService.add(s);
40 void unsetPluginService(IPluginInTopologyService s) {
41 if (this.pluginService != null) {
42 this.pluginService.remove(s);
46 void setUpdateService(IListenTopoUpdates s) {
47 if (this.updateService != null) {
48 this.updateService.add(s);
52 void unsetUpdateService(IListenTopoUpdates s) {
53 if (this.updateService != null) {
54 this.updateService.remove(s);
59 * Function called by the dependency manager when all the required
60 * dependencies are satisfied
67 * Function called by the dependency manager when at least one
68 * dependency become unsatisfied or when the component is shutting
69 * down because for example bundle is being stopped.
73 // Make sure to clear all the data structure we use to track
75 if (this.updateService != null) {
76 this.updateService.clear();
78 if (this.pluginService != null) {
79 this.pluginService.clear();
84 public void sollicitRefresh() {
85 synchronized (this.pluginService) {
86 for (IPluginInTopologyService s : this.pluginService) {
93 public void edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
94 synchronized (this.updateService) {
95 for (IListenTopoUpdates s : this.updateService) {
96 s.edgeUpdate(e, type, props);
102 public void edgeOverUtilized(Edge edge) {
103 synchronized (this.updateService) {
104 for (IListenTopoUpdates s : this.updateService) {
105 s.edgeOverUtilized(edge);
111 public void edgeUtilBackToNormal(Edge edge) {
112 synchronized (this.updateService) {
113 for (IListenTopoUpdates s : this.updateService) {
114 s.edgeUtilBackToNormal(edge);