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.ArrayList;
12 import java.util.HashSet;
13 import java.util.List;
15 import java.util.Collections;
17 import org.opendaylight.controller.sal.core.Edge;
18 import org.opendaylight.controller.sal.core.Property;
19 import org.opendaylight.controller.sal.core.UpdateType;
20 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
21 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
22 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
23 import org.opendaylight.controller.sal.topology.ITopologyService;
24 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class Topology implements IPluginOutTopologyService, ITopologyService {
29 protected static final Logger logger = LoggerFactory
30 .getLogger(Topology.class);
31 private Set<IListenTopoUpdates> updateService = Collections
32 .synchronizedSet(new HashSet<IListenTopoUpdates>());
33 private Set<IPluginInTopologyService> pluginService = Collections
34 .synchronizedSet(new HashSet<IPluginInTopologyService>());
36 void setPluginService(IPluginInTopologyService s) {
37 if (this.pluginService != null) {
38 this.pluginService.add(s);
42 void unsetPluginService(IPluginInTopologyService s) {
43 if (this.pluginService != null) {
44 this.pluginService.remove(s);
48 void setUpdateService(IListenTopoUpdates s) {
49 if (this.updateService != null) {
50 this.updateService.add(s);
54 void unsetUpdateService(IListenTopoUpdates s) {
55 if (this.updateService != null) {
56 this.updateService.remove(s);
61 * Function called by the dependency manager when all the required
62 * dependencies are satisfied
69 * Function called by the dependency manager when at least one dependency
70 * become unsatisfied or when the component is shutting down because for
71 * example bundle is being stopped.
75 // Make sure to clear all the data structure we use to track
77 if (this.updateService != null) {
78 this.updateService.clear();
80 if (this.pluginService != null) {
81 this.pluginService.clear();
86 public void sollicitRefresh() {
87 synchronized (this.pluginService) {
88 for (IPluginInTopologyService s : this.pluginService) {
95 public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
96 synchronized (this.updateService) {
97 for (IListenTopoUpdates s : this.updateService) {
98 s.edgeUpdate(topoedgeupdateList);
104 public void edgeOverUtilized(Edge edge) {
105 synchronized (this.updateService) {
106 for (IListenTopoUpdates s : this.updateService) {
107 s.edgeOverUtilized(edge);
113 public void edgeUtilBackToNormal(Edge edge) {
114 synchronized (this.updateService) {
115 for (IListenTopoUpdates s : this.updateService) {
116 s.edgeUtilBackToNormal(edge);