b5624af6afc8e916572bad446ab1e1438a166b3a
[controller.git] / opendaylight / containermanager / it.implementation / src / main / java / org / opendaylight / controller / containermanager / internal / ContainerManager.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 /**
11  * @file   ContainerManager.java
12  *
13  * @brief  Manage one or many Containers
14  *
15  *
16  */
17 package org.opendaylight.controller.containermanager.internal;
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.HashSet;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
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;
36
37 public class ContainerManager implements IContainerManager {
38     private static final Logger logger = LoggerFactory
39             .getLogger(ContainerManager.class);
40     private IClusterGlobalServices clusterServices;
41     /*
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
45      */
46     private Set<IContainerAware> iContainerAware = (Set<IContainerAware>) Collections
47             .synchronizedSet(new HashSet<IContainerAware>());
48     private Set<IContainerListener> iContainerListener = Collections
49             .synchronizedSet(new HashSet<IContainerListener>());
50
51     void setIContainerListener(IContainerListener s) {
52         if (this.iContainerListener != null) {
53             this.iContainerListener.add(s);
54         }
55     }
56
57     void unsetIContainerListener(IContainerListener s) {
58         if (this.iContainerListener != null) {
59             this.iContainerListener.remove(s);
60         }
61     }
62
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
67             // far
68             List<String> containerDB = getContainerNames();
69             if (containerDB != null) {
70                 for (int i = 0; i < containerDB.size(); i++) {
71                     iContainerAware.containerCreate(containerDB.get(i));
72                 }
73             }
74         }
75     }
76
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
81         // component itself
82     }
83
84     public void setClusterServices(IClusterGlobalServices i) {
85         this.clusterServices = i;
86         logger.debug("IClusterServices set");
87     }
88
89     public void unsetClusterServices(IClusterGlobalServices i) {
90         if (this.clusterServices == i) {
91             this.clusterServices = null;
92             logger.debug("IClusterServices Unset");
93         }
94     }
95
96     public void init() {
97         logger.info("ContainerManager startup....");
98     }
99
100     public void destroy() {
101         // Clear local states
102         this.iContainerAware.clear();
103         this.iContainerListener.clear();
104
105         logger.info("ContainerManager Shutdown....");
106     }
107
108     @Override
109     public List<String> getContainerNames() {
110         /*
111          * Return container names as they were configured by user (case sensitive)
112          * along with the default container
113          */
114         List<String> containerNameList = new ArrayList<String>();
115         containerNameList.add(GlobalConstants.DEFAULT.toString());
116         return containerNameList;
117     }
118
119     @Override
120     public boolean hasNonDefaultContainer() {
121         return false;
122     }
123
124     @Override
125     public Status addContainer(ContainerConfig configObject) {
126         // TODO Auto-generated method stub
127         return null;
128     }
129
130     @Override
131     public Status removeContainer(ContainerConfig configObject) {
132         // TODO Auto-generated method stub
133         return null;
134     }
135
136     @Override
137     public Status removeContainer(String containerName) {
138         // TODO Auto-generated method stub
139         return null;
140     }
141
142     @Override
143     public Status addContainerEntry(String containerName, List<String> portList) {
144         // TODO Auto-generated method stub
145         return null;
146     }
147
148     @Override
149     public Status removeContainerEntry(String containerName,
150             List<String> portList) {
151         // TODO Auto-generated method stub
152         return null;
153     }
154
155     @Override
156     public Status addContainerFlows(String containerName,
157             List<ContainerFlowConfig> configObject) {
158         // TODO Auto-generated method stub
159         return null;
160     }
161
162     @Override
163     public Status removeContainerFlows(String containerName,
164             List<ContainerFlowConfig> configObject) {
165         // TODO Auto-generated method stub
166         return null;
167     }
168
169     @Override
170     public Status removeContainerFlows(String containerName, Set<String> name) {
171         // TODO Auto-generated method stub
172         return null;
173     }
174
175     @Override
176     public List<ContainerConfig> getContainerConfigList() {
177         // TODO Auto-generated method stub
178         return null;
179     }
180
181     @Override
182     public ContainerConfig getContainerConfig(String containerName) {
183         // TODO Auto-generated method stub
184         return null;
185     }
186
187     @Override
188     public List<String> getContainerNameList() {
189         // TODO Auto-generated method stub
190         return null;
191     }
192
193     @Override
194     public boolean doesContainerExist(String ContainerId) {
195         // TODO Auto-generated method stub
196         return false;
197     }
198
199     @Override
200     public Map<String, List<ContainerFlowConfig>> getContainerFlows() {
201         // TODO Auto-generated method stub
202         return null;
203     }
204
205     @Override
206     public List<ContainerFlowConfig> getContainerFlows(String containerName) {
207         // TODO Auto-generated method stub
208         return null;
209     }
210
211     @Override
212     public List<String> getContainerFlowNameList(String containerName) {
213         // TODO Auto-generated method stub
214         return null;
215     }
216
217 }