use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method getUsedBytes.
private long getUsedBytes(StoragePool storagePool, long volumeIdToIgnore) {
long usedSpace = 0;
List<VolumeVO> lstVolumes = volumeDao.findByPoolIdAndState(storagePool.getId(), Volume.State.Ready);
if (lstVolumes != null) {
for (VolumeVO volume : lstVolumes) {
if (volume.getId() == volumeIdToIgnore) {
continue;
}
usedSpace += getVolumeSizeIncludingHypervisorSnapshotReserve(volume.getSize(), volume.getHypervisorSnapshotReserve());
}
}
List<SnapshotDataStoreVO> snapshotDataStoreVOList = snapshotDataStoreDao.listByStoreIdAndState(storagePool.getId(), ObjectInDataStoreStateMachine.State.Ready);
if (snapshotDataStoreVOList != null) {
for (SnapshotDataStoreVO snapshot : snapshotDataStoreVOList) {
usedSpace += snapshot.getPhysicalSize();
}
}
List<VMTemplateStoragePoolVO> vmTemplateStoragePoolVOList = vmTemplatePoolDao.listByPoolIdAndState(storagePool.getId(), ObjectInDataStoreStateMachine.State.Ready);
if (vmTemplateStoragePoolVOList != null) {
for (VMTemplateStoragePoolVO template : vmTemplateStoragePoolVOList) {
usedSpace += template.getTemplateSize();
}
}
return usedSpace;
}
use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.
the class StorageCacheReplacementAlgorithmLRU method chooseOneToBeReplaced.
@Override
public DataObject chooseOneToBeReplaced(DataStore store) {
if (unusedTimeInterval == null) {
unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30);
}
Calendar cal = Calendar.getInstance();
cal.setTime(DateUtil.now());
cal.add(Calendar.DAY_OF_MONTH, -unusedTimeInterval.intValue());
Date bef = cal.getTime();
QueryBuilder<TemplateDataStoreVO> sc = QueryBuilder.create(TemplateDataStoreVO.class);
sc.and(sc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
sc.and(sc.entity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
sc.and(sc.entity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
sc.and(sc.entity().getDataStoreRole(), SearchCriteria.Op.EQ, store.getRole());
sc.and(sc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0);
TemplateDataStoreVO template = sc.find();
if (template != null) {
return templateFactory.getTemplate(template.getTemplateId(), store);
}
QueryBuilder<VolumeDataStoreVO> volSc = QueryBuilder.create(VolumeDataStoreVO.class);
volSc.and(volSc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
volSc.and(volSc.entity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
volSc.and(volSc.entity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
volSc.and(volSc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0);
VolumeDataStoreVO volume = volSc.find();
if (volume != null) {
return volumeFactory.getVolume(volume.getVolumeId(), store);
}
QueryBuilder<SnapshotDataStoreVO> snapshotSc = QueryBuilder.create(SnapshotDataStoreVO.class);
snapshotSc.and(snapshotSc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
snapshotSc.and(snapshotSc.entity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
snapshotSc.and(snapshotSc.entity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
snapshotSc.and(snapshotSc.entity().getRole(), SearchCriteria.Op.EQ, store.getRole());
snapshotSc.and(snapshotSc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0);
SnapshotDataStoreVO snapshot = snapshotSc.find();
if (snapshot != null) {
return snapshotFactory.getSnapshot(snapshot.getSnapshotId(), store);
}
return null;
}
use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.
the class SnapshotServiceImpl method cleanupVolumeDuringSnapshotFailure.
@Override
public void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) {
SnapshotVO snaphsot = _snapshotDao.findById(snapshotId);
if (snaphsot != null) {
if (snaphsot.getState() != Snapshot.State.BackedUp) {
List<SnapshotDataStoreVO> snapshotDataStoreVOs = _snapshotStoreDao.findBySnapshotId(snapshotId);
for (SnapshotDataStoreVO snapshotDataStoreVO : snapshotDataStoreVOs) {
s_logger.debug("Remove snapshot " + snapshotId + ", status " + snapshotDataStoreVO.getState() + " on snapshot_store_ref table with id: " + snapshotDataStoreVO.getId());
_snapshotStoreDao.remove(snapshotDataStoreVO.getId());
}
s_logger.debug("Remove snapshot " + snapshotId + " status " + snaphsot.getState() + " from snapshot table");
_snapshotDao.remove(snapshotId);
}
}
}
use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.
the class CephSnapshotStrategy method isSnapshotStoredOnRbdStoragePool.
protected boolean isSnapshotStoredOnRbdStoragePool(Snapshot snapshot) {
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
if (snapshotStore == null) {
return false;
}
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(snapshotStore.getDataStoreId());
return storagePoolVO != null && storagePoolVO.getPoolType() == StoragePoolType.RBD;
}
use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.
the class ScaleIOSnapshotStrategy method isSnapshotStoredOnScaleIOStoragePool.
protected boolean isSnapshotStoredOnScaleIOStoragePool(Snapshot snapshot) {
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);
if (snapshotStore == null) {
return false;
}
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(snapshotStore.getDataStoreId());
return storagePoolVO != null && storagePoolVO.getPoolType() == Storage.StoragePoolType.PowerFlex;
}
Aggregations