mirror of https://github.com/apache/cloudstack.git
fix perf. issue in deploy vm. also remove dead code in dao
This commit is contained in:
parent
da857591f4
commit
d532bec118
|
|
@ -14,9 +14,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
*/
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -25,47 +25,47 @@ import com.cloud.host.Status;
|
|||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
/**
|
||||
* Data Access Object for storage_pool table
|
||||
*/
|
||||
public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
* @return the list of storage pools in the datacenter
|
||||
*/
|
||||
List<StoragePoolVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
* @param podId the id of the pod
|
||||
* @return the list of storage pools in the datacenter
|
||||
*/
|
||||
List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param capacity capacity in bytes
|
||||
*/
|
||||
void updateCapacity(long id, long capacity);
|
||||
|
||||
/**
|
||||
* Set available bytes of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param available available capacity in bytes
|
||||
*/
|
||||
void updateAvailable(long id, long available);
|
||||
/**
|
||||
* Data Access Object for storage_pool table
|
||||
*/
|
||||
public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
* @return the list of storage pools in the datacenter
|
||||
*/
|
||||
List<StoragePoolVO> listByDataCenterId(long datacenterId);
|
||||
|
||||
/**
|
||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
||||
* @param podId the id of the pod
|
||||
* @return the list of storage pools in the datacenter
|
||||
*/
|
||||
List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||
|
||||
/**
|
||||
* Set capacity of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param capacity capacity in bytes
|
||||
*/
|
||||
void updateCapacity(long id, long capacity);
|
||||
|
||||
/**
|
||||
* Set available bytes of storage pool in bytes
|
||||
* @param id pool id.
|
||||
* @param available available capacity in bytes
|
||||
*/
|
||||
void updateAvailable(long id, long available);
|
||||
|
||||
|
||||
|
||||
StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
|
||||
|
||||
/**
|
||||
* Find pool by name.
|
||||
*
|
||||
* @param name name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
/**
|
||||
* Find pool by name.
|
||||
*
|
||||
* @param name name of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
List<StoragePoolVO> findPoolByName(String name);
|
||||
|
||||
/**
|
||||
|
|
@ -79,18 +79,18 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
|||
|
||||
List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
|
||||
|
||||
/**
|
||||
* Find pool by UUID.
|
||||
*
|
||||
* @param uuid uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
StoragePoolVO findPoolByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
|
||||
|
||||
StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
|
||||
/**
|
||||
* Find pool by UUID.
|
||||
*
|
||||
* @param uuid uuid of pool.
|
||||
* @return the single StoragePoolVO
|
||||
*/
|
||||
StoragePoolVO findPoolByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
|
||||
|
||||
StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
|
||||
|
||||
List<StoragePoolVO> listPoolByHostPath(String host, String path);
|
||||
|
||||
void deleteStoragePoolRecords(ArrayList<Long> ids);
|
||||
|
|
@ -101,9 +101,10 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
|||
|
||||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
long countBy(long podId, Status... statuses);
|
||||
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
List<StoragePoolVO> listByStatus(StoragePoolStatus status);
|
||||
}
|
||||
|
||||
long countPoolsByStatus(StoragePoolStatus... statuses);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
protected final SearchBuilder<StoragePoolVO> DcPodSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
|
||||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> MaintenanceCountSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
|
||||
|
||||
|
||||
|
||||
protected final StoragePoolDetailsDao _detailsDao;
|
||||
|
|
@ -94,11 +95,12 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
DeleteLvmSearch.cp();
|
||||
DeleteLvmSearch.done();
|
||||
|
||||
MaintenanceCountSearch = createSearchBuilder(Long.class);
|
||||
MaintenanceCountSearch.and("pool", MaintenanceCountSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
MaintenanceCountSearch.select(null, Func.COUNT, null);
|
||||
MaintenanceCountSearch.and("status", MaintenanceCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
||||
MaintenanceCountSearch.done();
|
||||
|
||||
|
||||
StatusCountSearch = createSearchBuilder(Long.class);
|
||||
StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
||||
StatusCountSearch.select(null, Func.COUNT, null);
|
||||
StatusCountSearch.done();
|
||||
|
||||
_detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
|
||||
}
|
||||
|
|
@ -349,12 +351,13 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long countBy(long primaryStorageId, Status... statuses) {
|
||||
SearchCriteria<Long> sc = MaintenanceCountSearch.create();
|
||||
public long countPoolsByStatus( StoragePoolStatus... statuses) {
|
||||
SearchCriteria<Long> sc = StatusCountSearch.create();
|
||||
|
||||
sc.setParameters("status", (Object[])statuses);
|
||||
sc.setParameters("pool", primaryStorageId);
|
||||
|
||||
List<Long> rs = customSearchIncludingRemoved(sc, null);
|
||||
if (rs.size() == 0) {
|
||||
|
|
|
|||
|
|
@ -2383,9 +2383,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
// check if we have available pools for vm deployment
|
||||
List<StoragePoolVO> availablePools = _storagePoolDao.listByStatus(StoragePoolStatus.Up);
|
||||
|
||||
if (availablePools == null || availablePools.size() < 1) {
|
||||
long availablePools = _storagePoolDao.countPoolsByStatus(StoragePoolStatus.Up);
|
||||
if (availablePools < 1) {
|
||||
throw new StorageUnavailableException("There are no available pools in the UP state for vm deployment", -1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue