@Override public boolean equals(Object obj) { if (obj instanceof SnapshotDataStoreVO) { SnapshotDataStoreVO other = (SnapshotDataStoreVO)obj; return (snapshotId == other.getSnapshotId() && dataStoreId == other.getDataStoreId()); } return false; }
@Override public List<SnapshotInfo> listSnapshotOnCache(long snapshotId) { List<SnapshotDataStoreVO> cacheSnapshots = snapshotStoreDao.listOnCache(snapshotId); List<SnapshotInfo> snapObjs = new ArrayList<SnapshotInfo>(); for (SnapshotDataStoreVO cacheSnap : cacheSnapshots) { long storeId = cacheSnap.getDataStoreId(); DataStore store = storeMgr.getDataStore(storeId, DataStoreRole.ImageCache); SnapshotInfo tmplObj = getSnapshot(snapshotId, store); snapObjs.add(tmplObj); } return snapObjs; }
@Override public List<SnapshotInfo> getSnapshots(long volumeId, DataStoreRole role) { List<SnapshotDataStoreVO> allSnapshotsFromVolumeAndDataStore = snapshotStoreDao.listAllByVolumeAndDataStore(volumeId, role); if (CollectionUtils.isEmpty(allSnapshotsFromVolumeAndDataStore)) { return new ArrayList<>(); } List<SnapshotInfo> infos = new ArrayList<>(); for (SnapshotDataStoreVO snapshotDataStoreVO : allSnapshotsFromVolumeAndDataStore) { DataStore store = storeMgr.getDataStore(snapshotDataStoreVO.getDataStoreId(), role); SnapshotVO snapshot = snapshotDao.findById(snapshotDataStoreVO.getSnapshotId()); SnapshotObject info = SnapshotObject.getSnapshotObject(snapshot, store); infos.add(info); } return infos; }
@Override public SnapshotInfo getReadySnapshotOnCache(long snapshotId) { SnapshotDataStoreVO snapStore = snapshotStoreDao.findReadyOnCache(snapshotId); if (snapStore != null) { DataStore store = storeMgr.getDataStore(snapStore.getDataStoreId(), DataStoreRole.ImageCache); return getSnapshot(snapshotId, store); } else { return null; } }
public DataStoreRole getDataStoreRole(Snapshot snapshot) { SnapshotDataStoreVO snapshotStore = _snapshotDataStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
private static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) { SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) { SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); if (dataStore == null) { return DataStoreRole.Image; } Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
@Override public String getSecondaryStorageURL(SnapshotVO snapshot) { SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image); if (snapshotStore != null) { DataStore store = dataStoreMgr.getDataStore(snapshotStore.getDataStoreId(), DataStoreRole.Image); if (store != null) { return store.getUri(); } } throw new CloudRuntimeException("Can not find secondary storage hosting the snapshot"); }
@Override public SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role) { SnapshotVO snapshot = snapshotDao.findById(snapshotId); SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshotId, role); if (snapshotStore == null) { snapshotStore = snapshotStoreDao.findByVolume(snapshot.getVolumeId(), role); if (snapshotStore == null) { return null; } } DataStore store = storeMgr.getDataStore(snapshotStore.getDataStoreId(), role); SnapshotObject so = SnapshotObject.getSnapshotObject(snapshot, store); return so; }
private DataStore findSnapshotImageStore(SnapshotInfo snapshot) { Boolean fullSnapshot = true; Boolean snapshotFullBackup = snapshot.getFullBackup(); if (snapshotFullBackup != null) { fullSnapshot = snapshotFullBackup; } if (fullSnapshot) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } else { SnapshotInfo parentSnapshot = snapshot.getParent(); // Note that DataStore information in parentSnapshot is for primary // data store here, we need to // find the image store where the parent snapshot backup is located SnapshotDataStoreVO parentSnapshotOnBackupStore = null; if (parentSnapshot != null) { parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); } if (parentSnapshotOnBackupStore == null) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } return dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole()); } }
long storagePoolId = snapStoreVo.getDataStoreId(); StoragePoolVO storagePoolVO = storagePoolDao.findById(storagePoolId);
@Override public List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long snapshotId, Long volumeId, boolean readyOnly) { Long zoneId = null; if (snapshotId != null) { Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId); VolumeVO volume = findVolumeById(snapshot.getVolumeId()); // it seems that the volume can actually be removed from the DB at some point if it's deleted // if volume comes back null, use another technique to try to discover the zone if (volume == null) { SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore != null) { long storagePoolId = snapshotStore.getDataStoreId(); StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); if (storagePool != null) { zoneId = storagePool.getDataCenterId(); } } } else { zoneId = volume.getDataCenterId(); } } else { VolumeVO volume = findVolumeById(volumeId); zoneId = volume.getDataCenterId(); } if (zoneId == null) { throw new CloudRuntimeException("Unable to determine the zone ID"); } return createTemplateResponses(view, templateId, zoneId, readyOnly); }
@Override public SnapshotInfo getChild() { QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class); sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId()); sc.and(sc.entity().getRole(), Op.EQ, store.getRole()); sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error); sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId()); SnapshotDataStoreVO vo = sc.find(); if (vo == null) { return null; } return snapshotFactory.getSnapshot(vo.getId(), store); }
long snapshotStoragePoolId = snapshotStore.getDataStoreId(); long snapshotStoragePoolId = snapshotStore.getDataStoreId(); long snapshotStoragePoolId = snapshotStore.getDataStoreId();
long snapshotStoragePoolId = snapshotStore.getDataStoreId();
DataStore store = dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole()); VolumeVO volume = volumeDao.findById(snapshot.getVolumeId()); if (oldestSnapshotOnPrimary != null) { if (oldestSnapshotOnPrimary.getDataStoreId() == volume.getPoolId() && oldestSnapshotOnPrimary.getId() != parentSnapshotOnPrimaryStore.getId()) { int _deltaSnapshotMax = NumbersUtil.parseInt(configDao.getValue("snapshot.delta.max"), SnapshotManager.DELTAMAX);
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);
storeSearch.and("store_id", storeSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); storeSearch.and("store_role", storeSearch.entity().getRole(), SearchCriteria.Op.EQ); storeSearch.and("state", storeSearch.entity().getState(), SearchCriteria.Op.NEQ); destroyedSearch.and("store_id", destroyedSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); destroyedSearch.and("store_role", destroyedSearch.entity().getRole(), SearchCriteria.Op.EQ); destroyedSearch.and("state", destroyedSearch.entity().getState(), SearchCriteria.Op.EQ); cacheSearch.and("store_id", cacheSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); cacheSearch.and("store_role", cacheSearch.entity().getRole(), SearchCriteria.Op.EQ); cacheSearch.and("state", cacheSearch.entity().getState(), SearchCriteria.Op.NEQ); storeSnapshotSearch.and("store_id", storeSnapshotSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); storeSnapshotSearch.and("store_role", storeSnapshotSearch.entity().getRole(), SearchCriteria.Op.EQ); storeSnapshotSearch.and("state", storeSnapshotSearch.entity().getState(), SearchCriteria.Op.EQ); parentSnapshotSearch.and("store_id", parentSnapshotSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); parentSnapshotSearch.and("store_role", parentSnapshotSearch.entity().getRole(), SearchCriteria.Op.EQ); parentSnapshotSearch.and("state", parentSnapshotSearch.entity().getState(), SearchCriteria.Op.EQ);