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.ArrayList;
20 import java.util.Dictionary;
21 import java.util.HashSet;
22 import java.util.List;
25 import java.util.concurrent.ConcurrentMap;
27 import org.apache.felix.dm.Component;
28 import org.opendaylight.controller.containermanager.ContainerData;
29 import org.opendaylight.controller.sal.core.ContainerFlow;
30 import org.opendaylight.controller.sal.core.IContainer;
31 import org.opendaylight.controller.sal.core.Node;
32 import org.opendaylight.controller.sal.core.NodeConnector;
34 public class ContainerImpl implements IContainer {
35 private String containerName = null;
36 private IContainerInternal iContainerInternal = null;
38 public void setIContainerInternal(IContainerInternal s) {
39 this.iContainerInternal = s;
42 public void unsetIContainerInternal(IContainerInternal s) {
43 if (this.iContainerInternal == s) {
44 this.iContainerInternal = null;
49 * Function called by the dependency manager when all the required
50 * dependencies are satisfied
53 void init(Component c) {
54 Dictionary<?, ?> props = c.getServiceProperties();
56 this.containerName = (String) props.get("containerName");
61 public String getName() {
62 return this.containerName;
66 public List<ContainerFlow> getContainerFlows() {
67 List<ContainerFlow> list = new ArrayList<ContainerFlow>();
69 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
71 list.addAll(d.getContainerFlowSpecs());
77 public short getTag(Node n) {
78 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
80 return d.getStaticVlan();
82 // Return 0 because in containerData that means an unassigned tag
87 public Set<NodeConnector> getNodeConnectors() {
88 Set<NodeConnector> set = new HashSet<NodeConnector>();
90 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
92 ConcurrentMap<Node, Set<NodeConnector>> m = d.getSwPorts();
94 for (Map.Entry<Node, Set<NodeConnector>> entry : m.entrySet()) {
95 set.addAll(entry.getValue());
103 public Set<Node> getNodes() {
104 Set<Node> set = new HashSet<Node>();
106 ContainerData d = this.iContainerInternal.getContainerData(this.containerName);
108 ConcurrentMap<Node, Set<NodeConnector>> m = d.getSwPorts();
110 set.addAll(m.keySet());
117 public String getContainerAdminRole() {
118 return iContainerInternal.getContainerData(containerName).getContainerAdminRole();
122 public String getContainerOperatorRole() {
123 return iContainerInternal.getContainerData(containerName).getContainerOperatorRole();