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 ContainerManager.java
13 * @brief Manage one or many Containers
17 package org.opendaylight.controller.containermanager.internal;
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.HashSet;
22 import java.util.List;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
29 import org.opendaylight.controller.containermanager.ContainerConfig;
30 import org.opendaylight.controller.containermanager.ContainerFlowConfig;
31 import org.opendaylight.controller.containermanager.IContainerManager;
32 import org.opendaylight.controller.sal.core.IContainerAware;
33 import org.opendaylight.controller.sal.core.IContainerListener;
34 import org.opendaylight.controller.sal.utils.GlobalConstants;
35 import org.opendaylight.controller.sal.utils.Status;
37 public class ContainerManager implements IContainerManager {
38 private static final Logger logger = LoggerFactory
39 .getLogger(ContainerManager.class);
40 private IClusterGlobalServices clusterServices;
42 * Collection containing the configuration objects.
43 * This is configuration world: container names (also the map key)
44 * are maintained as they were configured by user, same case
46 private Set<IContainerAware> iContainerAware = (Set<IContainerAware>) Collections
47 .synchronizedSet(new HashSet<IContainerAware>());
48 private Set<IContainerListener> iContainerListener = Collections
49 .synchronizedSet(new HashSet<IContainerListener>());
51 void setIContainerListener(IContainerListener s) {
52 if (this.iContainerListener != null) {
53 this.iContainerListener.add(s);
57 void unsetIContainerListener(IContainerListener s) {
58 if (this.iContainerListener != null) {
59 this.iContainerListener.remove(s);
63 public void setIContainerAware(IContainerAware iContainerAware) {
64 if (!this.iContainerAware.contains(iContainerAware)) {
65 this.iContainerAware.add(iContainerAware);
66 // Now call the container creation for all the known containers so
68 List<String> containerDB = getContainerNames();
69 if (containerDB != null) {
70 for (int i = 0; i < containerDB.size(); i++) {
71 iContainerAware.containerCreate(containerDB.get(i));
77 public void unsetIContainerAware(IContainerAware iContainerAware) {
78 this.iContainerAware.remove(iContainerAware);
79 // There is no need to do cleanup of the component when
80 // unregister because it will be taken care by the Containerd
84 public void setClusterServices(IClusterGlobalServices i) {
85 this.clusterServices = i;
86 logger.debug("IClusterServices set");
89 public void unsetClusterServices(IClusterGlobalServices i) {
90 if (this.clusterServices == i) {
91 this.clusterServices = null;
92 logger.debug("IClusterServices Unset");
97 logger.info("ContainerManager startup....");
100 public void destroy() {
101 // Clear local states
102 this.iContainerAware.clear();
103 this.iContainerListener.clear();
105 logger.info("ContainerManager Shutdown....");
109 public List<String> getContainerNames() {
111 * Return container names as they were configured by user (case sensitive)
112 * along with the default container
114 List<String> containerNameList = new ArrayList<String>();
115 containerNameList.add(GlobalConstants.DEFAULT.toString());
116 return containerNameList;
120 public boolean hasNonDefaultContainer() {
125 public Status addContainer(ContainerConfig configObject) {
126 // TODO Auto-generated method stub
131 public Status removeContainer(ContainerConfig configObject) {
132 // TODO Auto-generated method stub
137 public Status removeContainer(String containerName) {
138 // TODO Auto-generated method stub
143 public Status addContainerEntry(String containerName, List<String> portList) {
144 // TODO Auto-generated method stub
149 public Status removeContainerEntry(String containerName,
150 List<String> portList) {
151 // TODO Auto-generated method stub
156 public Status addContainerFlows(String containerName,
157 List<ContainerFlowConfig> configObject) {
158 // TODO Auto-generated method stub
163 public Status removeContainerFlows(String containerName,
164 List<ContainerFlowConfig> configObject) {
165 // TODO Auto-generated method stub
170 public Status removeContainerFlows(String containerName, Set<String> name) {
171 // TODO Auto-generated method stub
176 public List<ContainerConfig> getContainerConfigList() {
177 // TODO Auto-generated method stub
182 public ContainerConfig getContainerConfig(String containerName) {
183 // TODO Auto-generated method stub
188 public List<String> getContainerNameList() {
189 // TODO Auto-generated method stub
194 public boolean doesContainerExist(String ContainerId) {
195 return GlobalConstants.DEFAULT.toString().equalsIgnoreCase(ContainerId);
199 public Map<String, List<ContainerFlowConfig>> getContainerFlows() {
200 // TODO Auto-generated method stub
205 public List<ContainerFlowConfig> getContainerFlows(String containerName) {
206 // TODO Auto-generated method stub
211 public List<String> getContainerFlowNameList(String containerName) {
212 // TODO Auto-generated method stub