forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncJobExecutorContextImpl.java
More file actions
248 lines (206 loc) · 7.27 KB
/
AsyncJobExecutorContextImpl.java
File metadata and controls
248 lines (206 loc) · 7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.async;
import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.agent.AgentManager;
import com.cloud.async.dao.AsyncJobDao;
import com.cloud.event.dao.EventDao;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.server.ManagementServer;
import com.cloud.storage.StorageManager;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.AccountManager;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.UserVmDao;
@Local(value={AsyncJobExecutorContext.class})
public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
private String _name;
private AgentManager _agentMgr;
private NetworkManager _networkMgr;
private UserVmManager _vmMgr;
private SnapshotManager _snapMgr;
private AccountManager _accountMgr;
private StorageManager _storageMgr;
private EventDao _eventDao;
private UserVmDao _vmDao;
private AccountDao _accountDao;
private VolumeDao _volumeDao;
private DomainRouterDao _routerDao;
private IPAddressDao _ipAddressDao;
private AsyncJobDao _jobDao;
private UserDao _userDao;
private VirtualMachineManager _itMgr;
private ManagementServer _managementServer;
@Override
public ManagementServer getManagementServer() {
return _managementServer;
}
@Override
public AgentManager getAgentMgr() {
return _agentMgr;
}
@Override
public NetworkManager getNetworkMgr() {
return _networkMgr;
}
@Override
public UserVmManager getVmMgr() {
return _vmMgr;
}
@Override
public StorageManager getStorageMgr() {
return _storageMgr;
}
/**server/src/com/cloud/async/AsyncJobExecutorContext.java
* @return the _snapMgr
*/
@Override
public SnapshotManager getSnapshotMgr() {
return _snapMgr;
}
@Override
public AccountManager getAccountMgr() {
return _accountMgr;
}
@Override
public EventDao getEventDao() {
return _eventDao;
}
@Override
public UserVmDao getVmDao() {
return _vmDao;
}
@Override
public AccountDao getAccountDao() {
return _accountDao;
}
@Override
public VolumeDao getVolumeDao() {
return _volumeDao;
}
@Override
public DomainRouterDao getRouterDao() {
return _routerDao;
}
@Override
public IPAddressDao getIpAddressDao() {
return _ipAddressDao;
}
@Override
public AsyncJobDao getJobDao() {
return _jobDao;
}
@Override
public UserDao getUserDao() {
return _userDao;
}
@Override
public VirtualMachineManager getItMgr() {
return _itMgr;
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
ComponentLocator locator = ComponentLocator.getCurrentLocator();
_managementServer = (ManagementServer)ComponentLocator.getComponent("management-server");
if (_managementServer == null) {
throw new ConfigurationException("unable to get " + ManagementServer.class.getName());
}
_agentMgr = locator.getManager(AgentManager.class);
if (_agentMgr == null) {
throw new ConfigurationException("unable to get " + AgentManager.class.getName());
}
_networkMgr = locator.getManager(NetworkManager.class);
if (_networkMgr == null) {
throw new ConfigurationException("unable to get " + NetworkManager.class.getName());
}
_vmMgr = locator.getManager(UserVmManager.class);
if (_vmMgr == null) {
throw new ConfigurationException("unable to get " + UserVmManager.class.getName());
}
_snapMgr = locator.getManager(SnapshotManager.class);
if (_snapMgr == null) {
throw new ConfigurationException("unable to get " + SnapshotManager.class.getName());
}
_accountMgr = locator.getManager(AccountManager.class);
if (_accountMgr == null) {
throw new ConfigurationException("unable to get " + AccountManager.class.getName());
}
_storageMgr = locator.getManager(StorageManager.class);
if (_storageMgr == null) {
throw new ConfigurationException("unable to get " + StorageManager.class.getName());
}
_eventDao = locator.getDao(EventDao.class);
if (_eventDao == null) {
throw new ConfigurationException("unable to get " + EventDao.class.getName());
}
_vmDao = locator.getDao(UserVmDao.class);
if (_vmDao == null) {
throw new ConfigurationException("unable to get " + UserVmDao.class.getName());
}
_accountDao = locator.getDao(AccountDao.class);
if (_accountDao == null) {
throw new ConfigurationException("unable to get " + AccountDao.class.getName());
}
_volumeDao = locator.getDao(VolumeDao.class);
if (_volumeDao == null) {
throw new ConfigurationException("unable to get " + VolumeDao.class.getName());
}
_routerDao = locator.getDao(DomainRouterDao.class);
if (_routerDao == null) {
throw new ConfigurationException("unable to get " + DomainRouterDao.class.getName());
}
_ipAddressDao = locator.getDao(IPAddressDao.class);
if (_ipAddressDao == null) {
throw new ConfigurationException("unable to get " + IPAddressDao.class.getName());
}
_jobDao = locator.getDao(AsyncJobDao.class);
if(_jobDao == null) {
throw new ConfigurationException("unable to get " + AsyncJobDao.class.getName());
}
_userDao = locator.getDao(UserDao.class);
if(_userDao == null) {
throw new ConfigurationException("unable to get " + UserDao.class.getName());
}
_itMgr = locator.getManager(VirtualMachineManager.class);
if (_itMgr == null) {
throw new ConfigurationException("unable to get " + VirtualMachineManager.class.getName());
}
return true;
}
@Override
public boolean start() {
return true;
}
@Override
public boolean stop() {
return true;
}
@Override
public String getName() {
return _name;
}
}