|
21 | 21 | import javax.inject.Inject; |
22 | 22 |
|
23 | 23 | import com.cloud.storage.StorageManager; |
| 24 | +import com.cloud.utils.Profiler; |
24 | 25 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; |
25 | 26 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; |
26 | 27 | import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener; |
@@ -144,51 +145,66 @@ public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) |
144 | 145 | } |
145 | 146 |
|
146 | 147 | @Override |
147 | | - public synchronized boolean processDisconnect(long agentId, Status state) { |
| 148 | + public boolean processDisconnect(long agentId, Status state) { |
148 | 149 | return processDisconnect(agentId, null, null, state); |
149 | 150 | } |
150 | 151 |
|
151 | 152 | @Override |
152 | | - public synchronized boolean processDisconnect(long agentId, String uuid, String name, Status state) { |
| 153 | + public boolean processDisconnect(long agentId, String uuid, String name, Status state) { |
| 154 | + logger.debug("Starting disconnect for Agent [id: {}, uuid: {}, name: {}]", agentId, uuid, name); |
153 | 155 | Host host = _storageManager.getHost(agentId); |
154 | 156 | if (host == null) { |
155 | 157 | logger.warn("Agent [id: {}, uuid: {}, name: {}] not found, not disconnecting pools", agentId, uuid, name); |
156 | 158 | return false; |
157 | 159 | } |
158 | 160 |
|
159 | 161 | if (host.getType() != Host.Type.Routing) { |
| 162 | + logger.debug("Host [id: {}, uuid: {}, name: {}] is not of type {}, skip", agentId, uuid, name, Host.Type.Routing); |
160 | 163 | return false; |
161 | 164 | } |
162 | 165 |
|
| 166 | + logger.debug("Looking for connected Storage Pools for Host [id: {}, uuid: {}, name: {}]", agentId, uuid, name); |
163 | 167 | List<StoragePoolHostVO> storagePoolHosts = _storageManager.findStoragePoolsConnectedToHost(host.getId()); |
164 | 168 | if (storagePoolHosts == null) { |
165 | | - if (logger.isTraceEnabled()) { |
166 | | - logger.trace("No pools to disconnect for host: {}", host); |
167 | | - } |
| 169 | + logger.debug("No pools to disconnect for host: {}", host); |
168 | 170 | return true; |
169 | 171 | } |
170 | 172 |
|
| 173 | + logger.debug("Found {} pools to disconnect for host: {}", storagePoolHosts.size(), host); |
171 | 174 | boolean disconnectResult = true; |
172 | | - for (StoragePoolHostVO storagePoolHost : storagePoolHosts) { |
| 175 | + int storagePoolHostsSize = storagePoolHosts.size(); |
| 176 | + for (int i = 0; i < storagePoolHostsSize; i++) { |
| 177 | + StoragePoolHostVO storagePoolHost = storagePoolHosts.get(i); |
| 178 | + logger.debug("Processing disconnect from Storage Pool {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host); |
173 | 179 | StoragePoolVO pool = _poolDao.findById(storagePoolHost.getPoolId()); |
174 | 180 | if (pool == null) { |
| 181 | + logger.debug("No Storage Pool found with id {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host); |
175 | 182 | continue; |
176 | 183 | } |
177 | 184 |
|
178 | 185 | if (!pool.isShared()) { |
| 186 | + logger.debug("Storage Pool {} ({}) ({} of {}) is not shared for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host); |
179 | 187 | continue; |
180 | 188 | } |
181 | 189 |
|
182 | 190 | // Handle only PowerFlex pool for now, not to impact other pools behavior |
183 | 191 | if (pool.getPoolType() != StoragePoolType.PowerFlex) { |
| 192 | + logger.debug("Storage Pool {} ({}) ({} of {}) is not of type {} for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, pool.getPoolType(), host); |
184 | 193 | continue; |
185 | 194 | } |
186 | 195 |
|
| 196 | + logger.debug("Sending disconnect to Storage Pool {} ({}) ({} of {}) for host: {}", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host); |
| 197 | + Profiler disconnectProfiler = new Profiler(); |
187 | 198 | try { |
| 199 | + disconnectProfiler.start(); |
188 | 200 | _storageManager.disconnectHostFromSharedPool(host, pool); |
189 | 201 | } catch (Exception e) { |
190 | 202 | logger.error("Unable to disconnect host {} from storage pool {} due to {}", host, pool, e.toString()); |
191 | 203 | disconnectResult = false; |
| 204 | + } finally { |
| 205 | + disconnectProfiler.stop(); |
| 206 | + long disconnectDuration = disconnectProfiler.getDurationInMillis() / 1000; |
| 207 | + logger.debug("Finished disconnect with result {} from Storage Pool {} ({}) ({} of {}) for host: {}, duration: {} secs", disconnectResult, pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host, disconnectDuration); |
192 | 208 | } |
193 | 209 | } |
194 | 210 |
|
|
0 commit comments