|
27 | 27 | import com.cloud.storage.StorageManager; |
28 | 28 | import com.cloud.storage.dao.StoragePoolHostDao; |
29 | 29 | import com.cloud.utils.exception.CloudRuntimeException; |
| 30 | +import com.cloud.utils.Profiler; |
30 | 31 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; |
31 | 32 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; |
32 | 33 | import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener; |
@@ -200,51 +201,66 @@ public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) |
200 | 201 | } |
201 | 202 |
|
202 | 203 | @Override |
203 | | - public synchronized boolean processDisconnect(long agentId, Status state) { |
| 204 | + public boolean processDisconnect(long agentId, Status state) { |
204 | 205 | return processDisconnect(agentId, null, null, state); |
205 | 206 | } |
206 | 207 |
|
207 | 208 | @Override |
208 | | - public synchronized boolean processDisconnect(long agentId, String uuid, String name, Status state) { |
| 209 | + public boolean processDisconnect(long agentId, String uuid, String name, Status state) { |
| 210 | + logger.debug("Starting disconnect for Agent [id: {}, uuid: {}, name: {}]", agentId, uuid, name); |
209 | 211 | Host host = _storageManager.getHost(agentId); |
210 | 212 | if (host == null) { |
211 | 213 | logger.warn("Agent [id: {}, uuid: {}, name: {}] not found, not disconnecting pools", agentId, uuid, name); |
212 | 214 | return false; |
213 | 215 | } |
214 | 216 |
|
215 | 217 | if (host.getType() != Host.Type.Routing) { |
| 218 | + logger.debug("Host [id: {}, uuid: {}, name: {}] is not of type {}, skip", agentId, uuid, name, Host.Type.Routing); |
216 | 219 | return false; |
217 | 220 | } |
218 | 221 |
|
| 222 | + logger.debug("Looking for connected Storage Pools for Host [id: {}, uuid: {}, name: {}]", agentId, uuid, name); |
219 | 223 | List<StoragePoolHostVO> storagePoolHosts = _storageManager.findStoragePoolsConnectedToHost(host.getId()); |
220 | 224 | if (storagePoolHosts == null) { |
221 | | - if (logger.isTraceEnabled()) { |
222 | | - logger.trace("No pools to disconnect for host: {}", host); |
223 | | - } |
| 225 | + logger.debug("No pools to disconnect for host: {}", host); |
224 | 226 | return true; |
225 | 227 | } |
226 | 228 |
|
| 229 | + logger.debug("Found {} pools to disconnect for host: {}", storagePoolHosts.size(), host); |
227 | 230 | boolean disconnectResult = true; |
228 | | - for (StoragePoolHostVO storagePoolHost : storagePoolHosts) { |
| 231 | + int storagePoolHostsSize = storagePoolHosts.size(); |
| 232 | + for (int i = 0; i < storagePoolHostsSize; i++) { |
| 233 | + StoragePoolHostVO storagePoolHost = storagePoolHosts.get(i); |
| 234 | + logger.debug("Processing disconnect from Storage Pool {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host); |
229 | 235 | StoragePoolVO pool = _poolDao.findById(storagePoolHost.getPoolId()); |
230 | 236 | if (pool == null) { |
| 237 | + logger.debug("No Storage Pool found with id {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host); |
231 | 238 | continue; |
232 | 239 | } |
233 | 240 |
|
234 | 241 | if (!pool.isShared()) { |
| 242 | + logger.debug("Storage Pool {} ({}) ({} of {}) is not shared for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host); |
235 | 243 | continue; |
236 | 244 | } |
237 | 245 |
|
238 | 246 | // Handle only PowerFlex pool for now, not to impact other pools behavior |
239 | 247 | if (pool.getPoolType() != StoragePoolType.PowerFlex) { |
| 248 | + logger.debug("Storage Pool {} ({}) ({} of {}) is not of type {} for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, pool.getPoolType(), host); |
240 | 249 | continue; |
241 | 250 | } |
242 | 251 |
|
| 252 | + logger.debug("Sending disconnect to Storage Pool {} ({}) ({} of {}) for host: {}", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host); |
| 253 | + Profiler disconnectProfiler = new Profiler(); |
243 | 254 | try { |
| 255 | + disconnectProfiler.start(); |
244 | 256 | _storageManager.disconnectHostFromSharedPool(host, pool); |
245 | 257 | } catch (Exception e) { |
246 | 258 | logger.error("Unable to disconnect host {} from storage pool {} due to {}", host, pool, e.toString()); |
247 | 259 | disconnectResult = false; |
| 260 | + } finally { |
| 261 | + disconnectProfiler.stop(); |
| 262 | + long disconnectDuration = disconnectProfiler.getDurationInMillis() / 1000; |
| 263 | + logger.debug("Finished disconnect with result {} from Storage Pool {} ({}) ({} of {}) for host: {}, duration: {} secs", disconnectResult, pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host, disconnectDuration); |
248 | 264 | } |
249 | 265 | } |
250 | 266 |
|
|
0 commit comments