mirror of https://github.com/apache/cloudstack.git
don't break old code
This commit is contained in:
parent
525cb3dd5d
commit
3bd089acb5
|
|
@ -357,8 +357,12 @@ public class AlertManagerImpl implements AlertManager {
|
|||
try {
|
||||
txn.start();
|
||||
// delete the old records
|
||||
_capacityDao.clearNonStorageCapacities();
|
||||
|
||||
if (_useNewNetworking) {
|
||||
_capacityDao.clearNonStorageCapacities2();
|
||||
} else {
|
||||
_capacityDao.clearNonStorageCapacities();
|
||||
}
|
||||
|
||||
for (CapacityVO newCapacity : newCapacities) {
|
||||
s_logger.trace("Executing capacity update");
|
||||
_capacityDao.persist(newCapacity);
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@ public interface CapacityDao extends GenericDao<CapacityVO, Long> {
|
|||
void clearNonStorageCapacities();
|
||||
void clearStorageCapacities();
|
||||
CapacityVO findByHostIdType(Long hostId, short capacityType);
|
||||
void clearNonStorageCapacities2();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
private static final String ADD_ALLOCATED_SQL = "UPDATE `cloud`.`op_host_capacity` SET used_capacity = used_capacity + ? WHERE host_id = ? AND capacity_type = ?";
|
||||
private static final String SUBTRACT_ALLOCATED_SQL = "UPDATE `cloud`.`op_host_capacity` SET used_capacity = used_capacity - ? WHERE host_id = ? AND capacity_type = ?";
|
||||
private static final String CLEAR_STORAGE_CAPACITIES = "DELETE FROM `cloud`.`op_host_capacity` WHERE capacity_type=2 OR capacity_type=3 OR capacity_type=6"; //clear storage and secondary_storage capacities
|
||||
private static final String CLEAR_NON_STORAGE_CAPACITIES = "DELETE FROM `cloud`.`op_host_capacity` WHERE capacity_type<>2 AND capacity_type<>3 AND capacity_type<>6 AND capacity_type<>0 AND capacity_type<>1"; //clear non-storage and non-secondary_storage capacities
|
||||
private static final String CLEAR_NON_STORAGE_CAPACITIES = "DELETE FROM `cloud`.`op_host_capacity` WHERE capacity_type<>2 AND capacity_type<>3 AND capacity_type<>6"; //clear non-storage and non-secondary_storage capacities
|
||||
private static final String CLEAR_NON_STORAGE_CAPACITIES2 = "DELETE FROM `cloud`.`op_host_capacity` WHERE capacity_type<>2 AND capacity_type<>3 AND capacity_type<>6 AND capacity_type<>0 AND capacity_type<>1"; //clear non-storage and non-secondary_storage capacities
|
||||
private SearchBuilder<CapacityVO> _hostIdTypeSearch;
|
||||
|
||||
public CapacityDaoImpl() {
|
||||
|
|
@ -88,6 +89,22 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
txn.rollback();
|
||||
s_logger.warn("Exception clearing non storage capacities", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearNonStorageCapacities2() {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
txn.start();
|
||||
String sql = CLEAR_NON_STORAGE_CAPACITIES2;
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Exception clearing non storage capacities", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue