findbugs: retrieve the objects to remove from the collection(s)

This commit is contained in:
Daan Hoogland 2014-01-28 15:36:40 +01:00
parent d7ee7a7431
commit fe262caa75

View File

@ -165,7 +165,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} }
public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) { public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) {
this._storagePoolAllocators = storagePoolAllocators; _storagePoolAllocators = storagePoolAllocators;
} }
protected List<HostAllocator> _hostAllocators; protected List<HostAllocator> _hostAllocators;
@ -175,7 +175,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} }
public void setHostAllocators(List<HostAllocator> hostAllocators) { public void setHostAllocators(List<HostAllocator> hostAllocators) {
this._hostAllocators = hostAllocators; _hostAllocators = hostAllocators;
} }
@Inject @Inject
@ -221,7 +221,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} }
public void setPlanners(List<DeploymentPlanner> planners) { public void setPlanners(List<DeploymentPlanner> planners) {
this._planners = planners; _planners = planners;
} }
protected List<AffinityGroupProcessor> _affinityProcessors; protected List<AffinityGroupProcessor> _affinityProcessors;
@ -231,7 +231,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} }
public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) { public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) {
this._affinityProcessors = affinityProcessors; _affinityProcessors = affinityProcessors;
} }
@Override @Override
@ -1142,9 +1142,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
List<StoragePool> suitablePools = new ArrayList<StoragePool>(); List<StoragePool> suitablePools = new ArrayList<StoragePool>();
StoragePool pool = null; StoragePool pool = null;
if (toBeCreated.getPoolId() != null) { if (toBeCreated.getPoolId() != null) {
pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(toBeCreated.getPoolId()); pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(toBeCreated.getPoolId());
} else { } else {
pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(plan.getPoolId()); pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(plan.getPoolId());
} }
if (!pool.isInMaintenance()) { if (!pool.isInMaintenance()) {
@ -1156,7 +1156,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) { if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) {
canReusePool = true; canReusePool = true;
} else if (plan.getDataCenterId() == exstPoolDcId) { } else if (plan.getDataCenterId() == exstPoolDcId) {
DataStore dataStore = this.dataStoreMgr.getPrimaryDataStore(pool.getId()); DataStore dataStore = dataStoreMgr.getPrimaryDataStore(pool.getId());
if (dataStore != null && dataStore.getScope() != null && dataStore.getScope().getScopeType() == ScopeType.ZONE) { if (dataStore != null && dataStore.getScope() != null && dataStore.getScope().getScopeType() == ScopeType.ZONE) {
canReusePool = true; canReusePool = true;
} }
@ -1259,9 +1259,14 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} }
} }
if (suitableVolumeStoragePools.values() != null) { HashSet<Long> toRemove = new HashSet<Long>();
poolsToAvoidOutput.removeAll(suitableVolumeStoragePools.values()); for (List<StoragePool> lsp : suitableVolumeStoragePools.values()) {
for (StoragePool sp : lsp) {
toRemove.add(sp.getId());
}
} }
poolsToAvoidOutput.removeAll(toRemove);
if (avoid.getPoolsToAvoid() != null) { if (avoid.getPoolsToAvoid() != null) {
avoid.getPoolsToAvoid().addAll(poolsToAvoidOutput); avoid.getPoolsToAvoid().addAll(poolsToAvoidOutput);
} }