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
11 * @file ContainerImpl.java
13 * @brief Class that instantiated per-container implements the
14 * interface IContainer
17 package org.opendaylight.controller.containermanager.internal;
19 import java.util.concurrent.ConcurrentMap;
20 import java.util.ArrayList;
21 import java.util.HashSet;
22 import java.util.Dictionary;
25 import org.apache.felix.dm.Component;
26 import org.opendaylight.controller.sal.core.ContainerFlow;
27 import org.opendaylight.controller.sal.core.IContainer;
28 import org.opendaylight.controller.sal.core.Node;
29 import org.opendaylight.controller.sal.core.NodeConnector;
31 import org.opendaylight.controller.containermanager.ContainerData;
34 import java.util.List;
36 public class ContainerImpl implements IContainer {
37 private String containerName = null;
38 private IContainerInternal iContainerInternal = null;
40 public void setIContainerInternal(IContainerInternal s) {
41 this.iContainerInternal = s;
44 public void unsetIContainerInternal(IContainerInternal s) {
45 if (this.iContainerInternal == s) {
46 this.iContainerInternal = null;
51 * Function called by the dependency manager when all the required
52 * dependencies are satisfied
55 void init(Component c) {
56 Dictionary<?, ?> props = c.getServiceProperties();
58 this.containerName = (String) props.get("containerName");
63 public String getName() {
64 return this.containerName;
68 public List<ContainerFlow> getContainerFlows() {
69 List<ContainerFlow> list = new ArrayList<ContainerFlow>();
71 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
73 list.addAll(d.getContainerFlowSpecs());
79 public short getTag(Node n) {
80 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
82 return d.getStaticVlan();
84 // Return 0 because in containerData that means an unassigned tag
89 public Set<NodeConnector> getNodeConnectors() {
90 Set<NodeConnector> set = new HashSet<NodeConnector>();
92 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
94 ConcurrentMap<Node, Set<NodeConnector>> m = d.getSwPorts();
96 for (Map.Entry<Node, Set<NodeConnector>> entry : m.entrySet()) {
97 set.addAll(entry.getValue());
105 public Set<Node> getNodes() {
106 Set<Node> set = new HashSet<Node>();
108 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
110 ConcurrentMap<Node, Set<NodeConnector>> m = d.getSwPorts();
112 set.addAll(m.keySet());