http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java index a349389..f5319ea 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java @@ -52,10 +52,10 @@ import com.cloud.vm.VMInstanceVO; import com.cloud.vm.dao.VMInstanceDao; @Component -@Local (value={SnapshotDao.class}) +@Local(value = { SnapshotDao.class }) public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao { public static final Logger s_logger = Logger.getLogger(SnapshotDaoImpl.class.getName()); - //TODO: we should remove these direct sqls + // TODO: we should remove these direct sqls private static final String GET_LAST_SNAPSHOT = "SELECT snapshots.id FROM snapshot_store_ref, snapshots where snapshots.id = snapshot_store_ref.snapshot_id AND snapshosts.volume_id = ? AND snapshot_store_ref.role = ? ORDER BY created DESC"; private static final String UPDATE_SNAPSHOT_VERSION = "UPDATE snapshots SET version = ? WHERE volume_id = ? AND version = ?"; private static final String GET_SECHOST_ID = "SELECT store_id FROM snapshots, snapshot_store_ref where snapshots.id = snapshot_store_ref.snapshot_id AND volume_id = ? AND backup_snap_id IS NOT NULL AND sechost_id IS NOT NULL LIMIT 1"; @@ -71,9 +71,12 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements private SearchBuilder<SnapshotVO> StatusSearch; private GenericSearchBuilder<SnapshotVO, Long> CountSnapshotsByAccount; private GenericSearchBuilder<SnapshotVO, SumCount> secondaryStorageSearch; - @Inject ResourceTagDao _tagsDao; - @Inject protected VMInstanceDao _instanceDao; - @Inject protected VolumeDao _volumeDao; + @Inject + ResourceTagDao _tagsDao; + @Inject + protected VMInstanceDao _instanceDao; + @Inject + protected VolumeDao _volumeDao; @Override public SnapshotVO findNextSnapshot(long snapshotId) { @@ -83,20 +86,19 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements } @Override - public List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid) { + public List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid) { SearchCriteria<SnapshotVO> sc = backupUuidSearch.create(); sc.setParameters("backupUuid", backupUuid); return listBy(sc, null); } @Override - public List<SnapshotVO> listByVolumeIdType(long volumeId, Type type ) { + public List<SnapshotVO> listByVolumeIdType(long volumeId, Type type) { return listByVolumeIdType(null, volumeId, type); } - @Override - public List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version ) { + public List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version) { return listByVolumeIdVersion(null, volumeId, version); } @@ -106,27 +108,27 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements } @Override - public List<SnapshotVO> listByVolumeId(Filter filter, long volumeId ) { + public List<SnapshotVO> listByVolumeId(Filter filter, long volumeId) { SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); return listBy(sc, filter); } - @Override + @Override public List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId) { SearchCriteria<SnapshotVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); return listIncludingRemovedBy(sc, null); } - public List<SnapshotVO> listByVolumeIdType(Filter filter, long volumeId, Type type ) { + public List<SnapshotVO> listByVolumeIdType(Filter filter, long volumeId, Type type) { SearchCriteria<SnapshotVO> sc = VolumeIdTypeSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("type", type.ordinal()); return listBy(sc, filter); } - public List<SnapshotVO> listByVolumeIdVersion(Filter filter, long volumeId, String version ) { + public List<SnapshotVO> listByVolumeIdVersion(Filter filter, long volumeId, String version) { SearchCriteria<SnapshotVO> sc = VolumeIdVersionSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("version", version); @@ -151,15 +153,17 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements VolumeIdVersionSearch.and("volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.and("version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.done(); -/* - ParentIdSearch = createSearchBuilder(); - ParentIdSearch.and("prevSnapshotId", ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ); - ParentIdSearch.done(); - - backupUuidSearch = createSearchBuilder(); - backupUuidSearch.and("backupUuid", backupUuidSearch.entity().getBackupSnapshotId(), SearchCriteria.Op.EQ); - backupUuidSearch.done(); -*/ + /* + * ParentIdSearch = createSearchBuilder(); + * ParentIdSearch.and("prevSnapshotId", + * ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ); + * ParentIdSearch.done(); + * + * backupUuidSearch = createSearchBuilder(); + * backupUuidSearch.and("backupUuid", + * backupUuidSearch.entity().getBackupSnapshotId(), + * SearchCriteria.Op.EQ); backupUuidSearch.done(); + */ AccountIdSearch = createSearchBuilder(); AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ); AccountIdSearch.done(); @@ -183,9 +187,11 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder(); volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ); - volumeSearch.join("instanceVolumes", instanceSearch, instanceSearch.entity().getId(), volumeSearch.entity().getInstanceId(), JoinType.INNER); + volumeSearch.join("instanceVolumes", instanceSearch, instanceSearch.entity().getId(), volumeSearch.entity() + .getInstanceId(), JoinType.INNER); - InstanceIdSearch.join("instanceSnapshots", volumeSearch, volumeSearch.entity().getId(), InstanceIdSearch.entity().getVolumeId(), JoinType.INNER); + InstanceIdSearch.join("instanceSnapshots", volumeSearch, volumeSearch.entity().getId(), InstanceIdSearch + .entity().getVolumeId(), JoinType.INNER); InstanceIdSearch.done(); secondaryStorageSearch = createSearchBuilder(SumCount.class); @@ -212,6 +218,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements } return null; } + @Override public long getLastSnapshot(long volumeId, DataStoreRole role) { Transaction txn = Transaction.currentTxn(); @@ -268,30 +275,30 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements @Override public Long countSnapshotsForAccount(long accountId) { - SearchCriteria<Long> sc = CountSnapshotsByAccount.create(); + SearchCriteria<Long> sc = CountSnapshotsByAccount.create(); sc.setParameters("account", accountId); return customSearch(sc, null).get(0); } @Override - public List<SnapshotVO> listByInstanceId(long instanceId, Snapshot.State... status) { - SearchCriteria<SnapshotVO> sc = this.InstanceIdSearch.create(); + public List<SnapshotVO> listByInstanceId(long instanceId, Snapshot.State... status) { + SearchCriteria<SnapshotVO> sc = this.InstanceIdSearch.create(); - if (status != null && status.length != 0) { - sc.setParameters("status", (Object[])status); - } + if (status != null && status.length != 0) { + sc.setParameters("status", (Object[]) status); + } - sc.setJoinParameters("instanceSnapshots", "state", Volume.State.Ready); - sc.setJoinParameters("instanceVolumes", "instanceId", instanceId); + sc.setJoinParameters("instanceSnapshots", "state", Volume.State.Ready); + sc.setJoinParameters("instanceVolumes", "instanceId", instanceId); return listBy(sc, null); } @Override public List<SnapshotVO> listByStatus(long volumeId, Snapshot.State... status) { - SearchCriteria<SnapshotVO> sc = this.StatusSearch.create(); - sc.setParameters("volumeId", volumeId); - sc.setParameters("status", (Object[])status); - return listBy(sc, null); + SearchCriteria<SnapshotVO> sc = this.StatusSearch.create(); + sc.setParameters("volumeId", volumeId); + sc.setParameters("status", (Object[]) status); + return listBy(sc, null); } @Override @@ -311,7 +318,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements @Override public List<SnapshotVO> listAllByStatus(Snapshot.State... status) { SearchCriteria<SnapshotVO> sc = this.StatusSearch.create(); - sc.setParameters("status", (Object[])status); + sc.setParameters("status", (Object[]) status); return listBy(sc, null); } @@ -319,7 +326,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements public boolean updateState(State currentState, Event event, State nextState, SnapshotVO snapshot, Object data) { Transaction txn = Transaction.currentTxn(); txn.start(); - SnapshotVO snapshotVO = (SnapshotVO)snapshot; + SnapshotVO snapshotVO = (SnapshotVO) snapshot; snapshotVO.setState(nextState); super.update(snapshotVO.getId(), snapshotVO); txn.commit();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java index 467d491..f65b583 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDao.java @@ -28,11 +28,17 @@ import com.cloud.utils.db.GenericDao; * Data Access Object for snapshot_policy table */ public interface SnapshotPolicyDao extends GenericDao<SnapshotPolicyVO, Long> { - List<SnapshotPolicyVO> listByVolumeId(long volumeId); - List<SnapshotPolicyVO> listByVolumeId(long volumeId, Filter filter); + List<SnapshotPolicyVO> listByVolumeId(long volumeId); + + List<SnapshotPolicyVO> listByVolumeId(long volumeId, Filter filter); + Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId); + Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId, Filter filter); - SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType); + + SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType); + List<SnapshotPolicyVO> listActivePolicies(); + SnapshotPolicyVO findOneByVolume(long volumeId); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java index 3f894a2..662ad43 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java @@ -16,7 +16,6 @@ // under the License. package com.cloud.storage.dao; - import java.util.List; import javax.ejb.Local; @@ -32,33 +31,33 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; @Component -@Local (value={SnapshotPolicyDao.class}) +@Local(value = { SnapshotPolicyDao.class }) public class SnapshotPolicyDaoImpl extends GenericDaoBase<SnapshotPolicyVO, Long> implements SnapshotPolicyDao { - private final SearchBuilder<SnapshotPolicyVO> VolumeIdSearch; - private final SearchBuilder<SnapshotPolicyVO> VolumeIdIntervalSearch; - private final SearchBuilder<SnapshotPolicyVO> ActivePolicySearch; - - @Override - public SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType) { - SearchCriteria<SnapshotPolicyVO> sc = VolumeIdIntervalSearch.create(); + private final SearchBuilder<SnapshotPolicyVO> VolumeIdSearch; + private final SearchBuilder<SnapshotPolicyVO> VolumeIdIntervalSearch; + private final SearchBuilder<SnapshotPolicyVO> ActivePolicySearch; + + @Override + public SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType) { + SearchCriteria<SnapshotPolicyVO> sc = VolumeIdIntervalSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("interval", intvType.ordinal()); - return findOneBy(sc); - } - - @Override + return findOneBy(sc); + } + + @Override public SnapshotPolicyVO findOneByVolume(long volumeId) { SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("active", true); return findOneBy(sc); } - - @Override - public List<SnapshotPolicyVO> listByVolumeId(long volumeId) { - return listByVolumeId(volumeId, null); - } - + + @Override + public List<SnapshotPolicyVO> listByVolumeId(long volumeId) { + return listByVolumeId(volumeId, null); + } + @Override public List<SnapshotPolicyVO> listByVolumeId(long volumeId, Filter filter) { SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create(); @@ -66,7 +65,7 @@ public class SnapshotPolicyDaoImpl extends GenericDaoBase<SnapshotPolicyVO, Long sc.setParameters("active", true); return listBy(sc, filter); } - + @Override public Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long volumeId) { return listAndCountByVolumeId(volumeId, null); @@ -85,12 +84,12 @@ public class SnapshotPolicyDaoImpl extends GenericDaoBase<SnapshotPolicyVO, Long VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdSearch.and("active", VolumeIdSearch.entity().isActive(), SearchCriteria.Op.EQ); VolumeIdSearch.done(); - + VolumeIdIntervalSearch = createSearchBuilder(); VolumeIdIntervalSearch.and("volumeId", VolumeIdIntervalSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdIntervalSearch.and("interval", VolumeIdIntervalSearch.entity().getInterval(), SearchCriteria.Op.EQ); VolumeIdIntervalSearch.done(); - + ActivePolicySearch = createSearchBuilder(); ActivePolicySearch.and("active", ActivePolicySearch.entity().isActive(), SearchCriteria.Op.EQ); ActivePolicySearch.done(); @@ -101,5 +100,5 @@ public class SnapshotPolicyDaoImpl extends GenericDaoBase<SnapshotPolicyVO, Long SearchCriteria<SnapshotPolicyVO> sc = ActivePolicySearch.create(); sc.setParameters("active", true); return listIncludingRemovedBy(sc); - } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java index 0419e28..7ca0a39 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDao.java @@ -16,10 +16,9 @@ // under the License. package com.cloud.storage.dao; - import java.util.Date; import java.util.List; -import com.cloud.storage.SnapshotPolicyVO; + import com.cloud.storage.SnapshotScheduleVO; import com.cloud.utils.db.GenericDao; @@ -28,7 +27,7 @@ import com.cloud.utils.db.GenericDao; */ public interface SnapshotScheduleDao extends GenericDao<SnapshotScheduleVO, Long> { - List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date); + List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date); List<SnapshotScheduleVO> getSchedulesToExecute(Date currentTimestamp); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java index c01644e..72d47fa 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java @@ -30,60 +30,63 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; @Component -@Local (value={SnapshotScheduleDao.class}) +@Local(value = { SnapshotScheduleDao.class }) public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, Long> implements SnapshotScheduleDao { - protected final SearchBuilder<SnapshotScheduleVO> executableSchedulesSearch; - protected final SearchBuilder<SnapshotScheduleVO> coincidingSchedulesSearch; + protected final SearchBuilder<SnapshotScheduleVO> executableSchedulesSearch; + protected final SearchBuilder<SnapshotScheduleVO> coincidingSchedulesSearch; private final SearchBuilder<SnapshotScheduleVO> VolumeIdSearch; private final SearchBuilder<SnapshotScheduleVO> VolumeIdPolicyIdSearch; - - - protected SnapshotScheduleDaoImpl() { - - executableSchedulesSearch = createSearchBuilder(); - executableSchedulesSearch.and("scheduledTimestamp", executableSchedulesSearch.entity().getScheduledTimestamp(), SearchCriteria.Op.LT); - executableSchedulesSearch.and("asyncJobId", executableSchedulesSearch.entity().getAsyncJobId(), SearchCriteria.Op.NULL); + + protected SnapshotScheduleDaoImpl() { + + executableSchedulesSearch = createSearchBuilder(); + executableSchedulesSearch.and("scheduledTimestamp", executableSchedulesSearch.entity().getScheduledTimestamp(), + SearchCriteria.Op.LT); + executableSchedulesSearch.and("asyncJobId", executableSchedulesSearch.entity().getAsyncJobId(), + SearchCriteria.Op.NULL); executableSchedulesSearch.done(); - + coincidingSchedulesSearch = createSearchBuilder(); - coincidingSchedulesSearch.and("volumeId", coincidingSchedulesSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); - coincidingSchedulesSearch.and("scheduledTimestamp", coincidingSchedulesSearch.entity().getScheduledTimestamp(), SearchCriteria.Op.LT); - coincidingSchedulesSearch.and("asyncJobId", coincidingSchedulesSearch.entity().getAsyncJobId(), SearchCriteria.Op.NULL); + coincidingSchedulesSearch.and("volumeId", coincidingSchedulesSearch.entity().getVolumeId(), + SearchCriteria.Op.EQ); + coincidingSchedulesSearch.and("scheduledTimestamp", coincidingSchedulesSearch.entity().getScheduledTimestamp(), + SearchCriteria.Op.LT); + coincidingSchedulesSearch.and("asyncJobId", coincidingSchedulesSearch.entity().getAsyncJobId(), + SearchCriteria.Op.NULL); coincidingSchedulesSearch.done(); - + VolumeIdSearch = createSearchBuilder(); VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdSearch.done(); - + VolumeIdPolicyIdSearch = createSearchBuilder(); VolumeIdPolicyIdSearch.and("volumeId", VolumeIdPolicyIdSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdPolicyIdSearch.and("policyId", VolumeIdPolicyIdSearch.entity().getPolicyId(), SearchCriteria.Op.EQ); VolumeIdPolicyIdSearch.done(); - - } - - /** - * {@inheritDoc} - */ - @Override - public List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date) { - SearchCriteria<SnapshotScheduleVO> sc = coincidingSchedulesSearch.create(); - sc.setParameters("volumeId", volumeId); - sc.setParameters("scheduledTimestamp", date); - // Don't return manual snapshots. They will be executed through another code path. + + } + + /** + * {@inheritDoc} + */ + @Override + public List<SnapshotScheduleVO> getCoincidingSnapshotSchedules(long volumeId, Date date) { + SearchCriteria<SnapshotScheduleVO> sc = coincidingSchedulesSearch.create(); + sc.setParameters("volumeId", volumeId); + sc.setParameters("scheduledTimestamp", date); + // Don't return manual snapshots. They will be executed through another + // code path. sc.addAnd("policyId", SearchCriteria.Op.NEQ, 1L); return listBy(sc); - } + } - @Override public SnapshotScheduleVO findOneByVolume(long volumeId) { SearchCriteria<SnapshotScheduleVO> sc = VolumeIdSearch.create(); sc.setParameters("volumeId", volumeId); return findOneBy(sc); } - - + @Override public SnapshotScheduleVO findOneByVolumePolicy(long volumeId, long policyId) { SearchCriteria<SnapshotScheduleVO> sc = VolumeIdPolicyIdSearch.create(); @@ -91,8 +94,9 @@ public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, sc.setParameters("policyId", policyId); return findOneBy(sc); } - /** - * {@inheritDoc} + + /** + * {@inheritDoc} */ @Override public List<SnapshotScheduleVO> getSchedulesToExecute(Date currentTimestamp) { @@ -100,9 +104,9 @@ public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, sc.setParameters("scheduledTimestamp", currentTimestamp); return listBy(sc); } - + /** - * {@inheritDoc} + * {@inheritDoc} */ @Override public SnapshotScheduleVO getCurrentSchedule(Long volumeId, Long policyId, boolean executing) { @@ -113,7 +117,8 @@ public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, if (policyId != null) { sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId); if (policyId != Snapshot.MANUAL_POLICY_ID) { - // manual policies aren't scheduled by the snapshot poller, so don't look for the jobId here + // manual policies aren't scheduled by the snapshot poller, so + // don't look for the jobId here sc.addAnd("asyncJobId", op); } } else { @@ -121,14 +126,14 @@ public class SnapshotScheduleDaoImpl extends GenericDaoBase<SnapshotScheduleVO, } List<SnapshotScheduleVO> snapshotSchedules = listBy(sc); - // This will return only one schedule because of a DB uniqueness constraint. + // This will return only one schedule because of a DB uniqueness + // constraint. assert (snapshotSchedules.size() <= 1); if (snapshotSchedules.isEmpty()) { return null; - } - else { + } else { return snapshotSchedules.get(0); } } - + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java index 38b5253..8952e6c 100644 --- a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java @@ -32,11 +32,12 @@ import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; @Component -@Local(value=StoragePoolDetailsDao.class) -public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailVO, Long> implements StoragePoolDetailsDao { - +@Local(value = StoragePoolDetailsDao.class) +public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailVO, Long> implements + StoragePoolDetailsDao { + protected final SearchBuilder<StoragePoolDetailVO> PoolSearch; - + protected StoragePoolDetailsDaoImpl() { super(); PoolSearch = createSearchBuilder(); @@ -44,13 +45,13 @@ public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailV PoolSearch.and("name", PoolSearch.entity().getName(), SearchCriteria.Op.EQ); PoolSearch.done(); } - + @Override public void update(long poolId, Map<String, String> details) { Transaction txn = Transaction.currentTxn(); SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); sc.setParameters("pool", poolId); - + txn.start(); expunge(sc); for (Map.Entry<String, String> entry : details.entrySet()) { @@ -59,19 +60,19 @@ public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailV } txn.commit(); } - + @Override public Map<String, String> getDetails(long poolId) { - SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); - sc.setParameters("pool", poolId); - - List<StoragePoolDetailVO> details = listBy(sc); - Map<String, String> detailsMap = new HashMap<String, String>(); - for (StoragePoolDetailVO detail : details) { - detailsMap.put(detail.getName(), detail.getValue()); - } - - return detailsMap; + SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create(); + sc.setParameters("pool", poolId); + + List<StoragePoolDetailVO> details = listBy(sc); + Map<String, String> detailsMap = new HashMap<String, String>(); + for (StoragePoolDetailVO detail : details) { + detailsMap.put(detail.getName(), detail.getValue()); + } + + return detailsMap; } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java index 4f509d1..730216b 100644 --- a/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java @@ -46,13 +46,16 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo protected static final String HOST_FOR_POOL_SEARCH = "SELECT * FROM storage_pool_host_ref ph, host h where ph.host_id = h.id and ph.pool_id=? and h.status=? "; - protected static final String STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph " - + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " GROUP by p.data_center_id"; + protected static final String STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + + " FROM storage_pool p, storage_pool_host_ref ph " + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + + " GROUP by p.data_center_id"; - protected static final String SHARED_STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + " FROM storage_pool p, storage_pool_host_ref ph " - + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + " AND p.pool_type NOT IN ('LVM', 'Filesystem')" + " GROUP by p.data_center_id"; + protected static final String SHARED_STORAGE_POOL_HOST_INFO = "SELECT p.data_center_id, count(ph.host_id) " + + " FROM storage_pool p, storage_pool_host_ref ph " + " WHERE p.id = ph.pool_id AND p.data_center_id = ? " + + " AND p.pool_type NOT IN ('LVM', 'Filesystem')" + " GROUP by p.data_center_id"; - protected static final String DELETE_PRIMARY_RECORDS = "DELETE " + "FROM storage_pool_host_ref " + "WHERE host_id = ?"; + protected static final String DELETE_PRIMARY_RECORDS = "DELETE " + "FROM storage_pool_host_ref " + + "WHERE host_id = ?"; public StoragePoolHostDaoImpl() { PoolSearch = createSearchBuilder(); @@ -83,7 +86,7 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo sc.setParameters("host_id", hostId); return listIncludingRemovedBy(sc); } - + @Override public List<StoragePoolHostVO> listByHostId(long hostId) { SearchCriteria<StoragePoolHostVO> sc = HostSearch.create(); @@ -113,7 +116,8 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo pstmt.setString(2, hostStatus.toString()); rs = pstmt.executeQuery(); while (rs.next()) { - // result.add(toEntityBean(rs, false)); TODO: this is buggy in GenericDaoBase for hand constructed queries + // result.add(toEntityBean(rs, false)); TODO: this is buggy in + // GenericDaoBase for hand constructed queries long id = rs.getLong(1); // ID column result.add(findById(id)); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java index c05abf5..9cd9778 100644 --- a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java +++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDao.java @@ -20,6 +20,7 @@ import java.util.List; import com.cloud.storage.StoragePoolWorkVO; import com.cloud.utils.db.GenericDao; + /** * Data Access Object for storage_pool table */ @@ -34,5 +35,5 @@ public interface StoragePoolWorkDao extends GenericDao<StoragePoolWorkVO, Long> void removePendingJobsOnMsRestart(long msId, long poolId); List<Long> searchForPoolIdsForPendingWorkJobs(long msId); - + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java index 360a814..052bae4 100644 --- a/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolWorkDaoImpl.java @@ -35,43 +35,53 @@ import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; @Component -@Local(value={StoragePoolWorkDao.class}) @DB(txn=false) -public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Long> implements StoragePoolWorkDao { +@Local(value = { StoragePoolWorkDao.class }) +@DB(txn = false) +public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Long> implements StoragePoolWorkDao { protected final SearchBuilder<StoragePoolWorkVO> PendingWorkForPrepareForMaintenanceSearch; protected final SearchBuilder<StoragePoolWorkVO> PendingWorkForCancelMaintenanceSearch; protected final SearchBuilder<StoragePoolWorkVO> PoolAndVmIdSearch; protected final SearchBuilder<StoragePoolWorkVO> PendingJobsForDeadMs; - + private final String FindPoolIds = "SELECT distinct storage_pool_work.pool_id FROM storage_pool_work WHERE mgmt_server_id = ?"; - + protected StoragePoolWorkDaoImpl() { PendingWorkForPrepareForMaintenanceSearch = createSearchBuilder(); - PendingWorkForPrepareForMaintenanceSearch.and("poolId", PendingWorkForPrepareForMaintenanceSearch.entity().getPoolId(), SearchCriteria.Op.EQ); - PendingWorkForPrepareForMaintenanceSearch.and("stoppedForMaintenance", PendingWorkForPrepareForMaintenanceSearch.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ); - PendingWorkForPrepareForMaintenanceSearch.and("startedAfterMaintenance", PendingWorkForPrepareForMaintenanceSearch.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ); + PendingWorkForPrepareForMaintenanceSearch.and("poolId", PendingWorkForPrepareForMaintenanceSearch.entity() + .getPoolId(), SearchCriteria.Op.EQ); + PendingWorkForPrepareForMaintenanceSearch.and("stoppedForMaintenance", + PendingWorkForPrepareForMaintenanceSearch.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ); + PendingWorkForPrepareForMaintenanceSearch.and("startedAfterMaintenance", + PendingWorkForPrepareForMaintenanceSearch.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ); PendingWorkForPrepareForMaintenanceSearch.done(); - + PendingWorkForCancelMaintenanceSearch = createSearchBuilder(); - PendingWorkForCancelMaintenanceSearch.and("poolId", PendingWorkForCancelMaintenanceSearch.entity().getPoolId(), SearchCriteria.Op.EQ); - PendingWorkForCancelMaintenanceSearch.and("stoppedForMaintenance", PendingWorkForCancelMaintenanceSearch.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ); - PendingWorkForCancelMaintenanceSearch.and("startedAfterMaintenance", PendingWorkForCancelMaintenanceSearch.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ); + PendingWorkForCancelMaintenanceSearch.and("poolId", PendingWorkForCancelMaintenanceSearch.entity().getPoolId(), + SearchCriteria.Op.EQ); + PendingWorkForCancelMaintenanceSearch.and("stoppedForMaintenance", PendingWorkForCancelMaintenanceSearch + .entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ); + PendingWorkForCancelMaintenanceSearch.and("startedAfterMaintenance", PendingWorkForCancelMaintenanceSearch + .entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ); PendingWorkForCancelMaintenanceSearch.done(); PoolAndVmIdSearch = createSearchBuilder(); PoolAndVmIdSearch.and("poolId", PoolAndVmIdSearch.entity().getPoolId(), SearchCriteria.Op.EQ); PoolAndVmIdSearch.and("vmId", PoolAndVmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); PoolAndVmIdSearch.done(); - + PendingJobsForDeadMs = createSearchBuilder(); - PendingJobsForDeadMs.and("managementServerId", PendingJobsForDeadMs.entity().getManagementServerId(), SearchCriteria.Op.EQ); + PendingJobsForDeadMs.and("managementServerId", PendingJobsForDeadMs.entity().getManagementServerId(), + SearchCriteria.Op.EQ); PendingJobsForDeadMs.and("poolId", PendingJobsForDeadMs.entity().getPoolId(), SearchCriteria.Op.EQ); - PendingJobsForDeadMs.and("stoppedForMaintenance", PendingJobsForDeadMs.entity().isStoppedForMaintenance(), SearchCriteria.Op.EQ); - PendingJobsForDeadMs.and("startedAfterMaintenance", PendingJobsForDeadMs.entity().isStartedAfterMaintenance(), SearchCriteria.Op.EQ); + PendingJobsForDeadMs.and("stoppedForMaintenance", PendingJobsForDeadMs.entity().isStoppedForMaintenance(), + SearchCriteria.Op.EQ); + PendingJobsForDeadMs.and("startedAfterMaintenance", PendingJobsForDeadMs.entity().isStartedAfterMaintenance(), + SearchCriteria.Op.EQ); PendingJobsForDeadMs.done(); - + } - + @Override public List<StoragePoolWorkVO> listPendingWorkForPrepareForMaintenanceByPoolId(long poolId) { SearchCriteria<StoragePoolWorkVO> sc = PendingWorkForPrepareForMaintenanceSearch.create(); @@ -80,7 +90,7 @@ public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Lo sc.setParameters("startedAfterMaintenance", false); return listBy(sc); } - + @Override public List<StoragePoolWorkVO> listPendingWorkForCancelMaintenanceByPoolId(long poolId) { SearchCriteria<StoragePoolWorkVO> sc = PendingWorkForCancelMaintenanceSearch.create(); @@ -89,7 +99,7 @@ public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Lo sc.setParameters("startedAfterMaintenance", false); return listBy(sc); } - + @Override public StoragePoolWorkVO findByPoolIdAndVmId(long poolId, long vmId) { SearchCriteria<StoragePoolWorkVO> sc = PoolAndVmIdSearch.create(); @@ -97,22 +107,22 @@ public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Lo sc.setParameters("vmId", vmId); return listBy(sc).get(0); } - + @Override public void removePendingJobsOnMsRestart(long msId, long poolId) { - //hung jobs are those which are stopped, but never started + // hung jobs are those which are stopped, but never started SearchCriteria<StoragePoolWorkVO> sc = PendingJobsForDeadMs.create(); sc.setParameters("managementServerId", msId); sc.setParameters("poolId", poolId); sc.setParameters("stoppedForMaintenance", true); - sc.setParameters("startedAfterMaintenance", false); + sc.setParameters("startedAfterMaintenance", false); remove(sc); } - + @Override @DB - public List<Long> searchForPoolIdsForPendingWorkJobs(long msId){ - + public List<Long> searchForPoolIdsForPendingWorkJobs(long msId) { + StringBuilder sql = new StringBuilder(FindPoolIds); Transaction txn = Transaction.currentTxn(); @@ -126,7 +136,7 @@ public class StoragePoolWorkDaoImpl extends GenericDaoBase<StoragePoolWorkVO, Lo while (rs.next()) { poolIds.add(rs.getLong("pool_id")); - } + } return poolIds; } catch (SQLException e) { throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java index 19e5a85..0714690 100644 --- a/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/SwiftDaoImpl.java @@ -33,7 +33,7 @@ import com.cloud.utils.db.GenericDaoBase; * */ @Component -@Local (value={SwiftDao.class}) +@Local(value = { SwiftDao.class }) public class SwiftDaoImpl extends GenericDaoBase<SwiftVO, Long> implements SwiftDao { public static final Logger s_logger = Logger.getLogger(SwiftDaoImpl.class.getName()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/UploadDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/UploadDao.java b/engine/schema/src/com/cloud/storage/dao/UploadDao.java index 06336ae..0defb36 100755 --- a/engine/schema/src/com/cloud/storage/dao/UploadDao.java +++ b/engine/schema/src/com/cloud/storage/dao/UploadDao.java @@ -24,13 +24,12 @@ import com.cloud.storage.Upload.Type; import com.cloud.storage.Upload.Mode; import com.cloud.utils.db.GenericDao; -public interface UploadDao extends GenericDao<UploadVO, Long> { +public interface UploadDao extends GenericDao<UploadVO, Long> { - List<UploadVO> listByTypeUploadStatus(long typeId, Type type, - Status uploadState); + List<UploadVO> listByTypeUploadStatus(long typeId, Type type, Status uploadState); - List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadInProgress); - - List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState); + List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadInProgress); + + List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java index 4c6da39..8e112bf 100755 --- a/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/UploadDaoImpl.java @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. package com.cloud.storage.dao; + import java.util.List; import javax.ejb.Local; @@ -29,64 +30,64 @@ import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; @Component -@Local(value={UploadDao.class}) +@Local(value = { UploadDao.class }) public class UploadDaoImpl extends GenericDaoBase<UploadVO, Long> implements UploadDao { - public static final Logger s_logger = Logger.getLogger(UploadDaoImpl.class.getName()); - protected final SearchBuilder<UploadVO> typeUploadStatusSearch; - protected final SearchBuilder<UploadVO> typeHostAndUploadStatusSearch; - protected final SearchBuilder<UploadVO> typeModeAndStatusSearch; - - protected static final String UPDATE_UPLOAD_INFO = - "UPDATE upload SET upload_state = ?, upload_pct= ?, last_updated = ? " - + ", upload_error_str = ?, upload_job_id = ? " - + "WHERE host_id = ? and type_id = ? and type = ?"; - - protected static final String UPLOADS_STATE_DC= - "SELECT * FROM upload t, host h where t.host_id = h.id and h.data_center_id=? " - + " and t.type_id=? and t.upload_state = ?" ; - - - public UploadDaoImpl() { - typeUploadStatusSearch = createSearchBuilder(); - typeUploadStatusSearch.and("type_id", typeUploadStatusSearch.entity().getTypeId(), SearchCriteria.Op.EQ); - typeUploadStatusSearch.and("upload_state", typeUploadStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ); - typeUploadStatusSearch.and("type", typeUploadStatusSearch.entity().getType(), SearchCriteria.Op.EQ); - typeUploadStatusSearch.done(); - - typeHostAndUploadStatusSearch = createSearchBuilder(); - typeHostAndUploadStatusSearch.and("host_id", typeHostAndUploadStatusSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ); - typeHostAndUploadStatusSearch.and("upload_state", typeHostAndUploadStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ); - typeHostAndUploadStatusSearch.done(); - - typeModeAndStatusSearch = createSearchBuilder(); - typeModeAndStatusSearch.and("mode", typeModeAndStatusSearch.entity().getMode(), SearchCriteria.Op.EQ); - typeModeAndStatusSearch.and("upload_state", typeModeAndStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ); - typeModeAndStatusSearch.done(); - - } - - @Override - public List<UploadVO> listByTypeUploadStatus(long typeId, UploadVO.Type type, UploadVO.Status uploadState) { - SearchCriteria<UploadVO> sc = typeUploadStatusSearch.create(); - sc.setParameters("type_id", typeId); - sc.setParameters("type", type); - sc.setParameters("upload_state", uploadState.toString()); - return listBy(sc); - } - - @Override - public List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadState){ + public static final Logger s_logger = Logger.getLogger(UploadDaoImpl.class.getName()); + protected final SearchBuilder<UploadVO> typeUploadStatusSearch; + protected final SearchBuilder<UploadVO> typeHostAndUploadStatusSearch; + protected final SearchBuilder<UploadVO> typeModeAndStatusSearch; + + protected static final String UPDATE_UPLOAD_INFO = "UPDATE upload SET upload_state = ?, upload_pct= ?, last_updated = ? " + + ", upload_error_str = ?, upload_job_id = ? " + "WHERE host_id = ? and type_id = ? and type = ?"; + + protected static final String UPLOADS_STATE_DC = "SELECT * FROM upload t, host h where t.host_id = h.id and h.data_center_id=? " + + " and t.type_id=? and t.upload_state = ?"; + + public UploadDaoImpl() { + typeUploadStatusSearch = createSearchBuilder(); + typeUploadStatusSearch.and("type_id", typeUploadStatusSearch.entity().getTypeId(), SearchCriteria.Op.EQ); + typeUploadStatusSearch.and("upload_state", typeUploadStatusSearch.entity().getUploadState(), + SearchCriteria.Op.EQ); + typeUploadStatusSearch.and("type", typeUploadStatusSearch.entity().getType(), SearchCriteria.Op.EQ); + typeUploadStatusSearch.done(); + + typeHostAndUploadStatusSearch = createSearchBuilder(); + typeHostAndUploadStatusSearch.and("host_id", typeHostAndUploadStatusSearch.entity().getDataStoreId(), + SearchCriteria.Op.EQ); + typeHostAndUploadStatusSearch.and("upload_state", typeHostAndUploadStatusSearch.entity().getUploadState(), + SearchCriteria.Op.EQ); + typeHostAndUploadStatusSearch.done(); + + typeModeAndStatusSearch = createSearchBuilder(); + typeModeAndStatusSearch.and("mode", typeModeAndStatusSearch.entity().getMode(), SearchCriteria.Op.EQ); + typeModeAndStatusSearch.and("upload_state", typeModeAndStatusSearch.entity().getUploadState(), + SearchCriteria.Op.EQ); + typeModeAndStatusSearch.done(); + + } + + @Override + public List<UploadVO> listByTypeUploadStatus(long typeId, UploadVO.Type type, UploadVO.Status uploadState) { + SearchCriteria<UploadVO> sc = typeUploadStatusSearch.create(); + sc.setParameters("type_id", typeId); + sc.setParameters("type", type); + sc.setParameters("upload_state", uploadState.toString()); + return listBy(sc); + } + + @Override + public List<UploadVO> listByHostAndUploadStatus(long sserverId, Status uploadState) { SearchCriteria<UploadVO> sc = typeHostAndUploadStatusSearch.create(); sc.setParameters("host_id", sserverId); sc.setParameters("upload_state", uploadState.toString()); return listBy(sc); - } - - @Override - public List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState){ - SearchCriteria<UploadVO> sc = typeModeAndStatusSearch.create(); - sc.setParameters("mode", mode.toString()); - sc.setParameters("upload_state", uploadState.toString()); - return listBy(sc); - } + } + + @Override + public List<UploadVO> listByModeAndStatus(Mode mode, Status uploadState) { + SearchCriteria<UploadVO> sc = typeModeAndStatusSearch.create(); + sc.setParameters("mode", mode.toString()); + sc.setParameters("upload_state", uploadState.toString()); + return listBy(sc); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java index b4376fd..b80ad3a 100755 --- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java +++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java @@ -30,36 +30,49 @@ import com.cloud.utils.fsm.StateDao; /* * Data Access Object for vm_templates table */ -public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<TemplateState, TemplateEvent, VMTemplateVO> { +public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, + StateDao<TemplateState, TemplateEvent, VMTemplateVO> { + public List<VMTemplateVO> listByPublic(); - public List<VMTemplateVO> listByPublic(); - public VMTemplateVO findByName(String templateName); - public VMTemplateVO findByTemplateName(String templateName); + public VMTemplateVO findByName(String templateName); - //public void update(VMTemplateVO template); + public VMTemplateVO findByTemplateName(String templateName); + // public void update(VMTemplateVO template); - public List<VMTemplateVO> listAllSystemVMTemplates(); + public List<VMTemplateVO> listAllSystemVMTemplates(); - public List<VMTemplateVO> listDefaultBuiltinTemplates(); - public String getRoutingTemplateUniqueName(); - public List<VMTemplateVO> findIsosByIdAndPath(Long domainId, Long accountId, String path); - public List<VMTemplateVO> listReadyTemplates(); - public List<VMTemplateVO> listByAccountId(long accountId); + public List<VMTemplateVO> listDefaultBuiltinTemplates(); - public long addTemplateToZone(VMTemplateVO tmplt, long zoneId); - public List<VMTemplateVO> listAllInZone(long dataCenterId); - public List<VMTemplateVO> listAllActive(); + public String getRoutingTemplateUniqueName(); + + public List<VMTemplateVO> findIsosByIdAndPath(Long domainId, Long accountId, String path); + + public List<VMTemplateVO> listReadyTemplates(); + + public List<VMTemplateVO> listByAccountId(long accountId); + + public long addTemplateToZone(VMTemplateVO tmplt, long zoneId); + + public List<VMTemplateVO> listAllInZone(long dataCenterId); + + public List<VMTemplateVO> listAllActive(); public List<VMTemplateVO> listByHypervisorType(List<HypervisorType> hyperTypes); - public List<VMTemplateVO> publicIsoSearch(Boolean bootable, boolean listRemoved, Map<String, String> tags); - public List<VMTemplateVO> userIsoSearch(boolean listRemoved); + + public List<VMTemplateVO> publicIsoSearch(Boolean bootable, boolean listRemoved, Map<String, String> tags); + + public List<VMTemplateVO> userIsoSearch(boolean listRemoved); + VMTemplateVO findSystemVMTemplate(long zoneId); + VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType); VMTemplateVO findRoutingTemplate(HypervisorType type, String templateName); + List<Long> listPrivateTemplatesByHost(Long hostId); + public Long countTemplatesForAccount(long accountId); List<VMTemplateVO> findTemplatesToSyncToS3();
