You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2014/01/08 15:39:51 UTC
git commit: updated refs/heads/master to cbe2560
Updated Branches:
refs/heads/master e58c3c809 -> cbe2560a7
CLOUDSTACK-5303: fix incorrect resource count (snapshot, secondary_storage)
(cherry picked from commit 4bb85cd7f921d66eabe72d00dcde817affd48732)
Conflicts:
server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cbe2560a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cbe2560a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cbe2560a
Branch: refs/heads/master
Commit: cbe2560a78b8f0b1f71188bb46f2a3ea3067960c
Parents: e58c3c8
Author: Wei Zhou <w....@leaseweb.com>
Authored: Wed Jan 8 15:38:06 2014 +0100
Committer: Wei Zhou <w....@leaseweb.com>
Committed: Wed Jan 8 15:38:06 2014 +0100
----------------------------------------------------------------------
.../schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java | 2 ++
.../src/com/cloud/storage/snapshot/SnapshotManagerImpl.java | 9 ++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbe2560a/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 d401065..204447c 100644
--- a/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/SnapshotDaoImpl.java
@@ -175,6 +175,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
CountSnapshotsByAccount = createSearchBuilder(Long.class);
CountSnapshotsByAccount.select(null, Func.COUNT, null);
CountSnapshotsByAccount.and("account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
+ CountSnapshotsByAccount.and("status", CountSnapshotsByAccount.entity().getState(), SearchCriteria.Op.NIN);
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
CountSnapshotsByAccount.done();
@@ -268,6 +269,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
public Long countSnapshotsForAccount(long accountId) {
SearchCriteria<Long> sc = CountSnapshotsByAccount.create();
sc.setParameters("account", accountId);
+ sc.setParameters("status", State.Error, State.Destroyed);
return customSearch(sc, null).get(0);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbe2560a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 998a941..a9eae7d 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -430,8 +430,10 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_DELETE, snapshotCheck.getAccountId(), snapshotCheck.getDataCenterId(), snapshotId,
snapshotCheck.getName(), null, null, 0L, snapshotCheck.getClass().getName(), snapshotCheck.getUuid());
}
- _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.snapshot);
- _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
+ if (snapshotCheck.getState() != Snapshot.State.Error && snapshotCheck.getState() != Snapshot.State.Destroyed)
+ _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.snapshot);
+ if (snapshotCheck.getState() == Snapshot.State.BackedUp)
+ _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
}
return result;
} catch (Exception e) {
@@ -949,7 +951,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), snapshot.getDataCenterId(), snapshotId, snapshot.getName(),
null, null, volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid());
- _resourceLimitMgr.incrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Image);
// Correct the resource count of snapshot in case of delta snapshots.
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize() - snapshotStoreRef.getSize()));
@@ -958,6 +959,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
}
} catch (Exception e) {
s_logger.debug("Failed to create snapshot", e);
+ _resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));
throw new CloudRuntimeException("Failed to create snapshot", e);
}
@@ -1102,6 +1104,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
if (snapshot == null) {
throw new CloudRuntimeException("Failed to create snapshot for volume: " + volume.getId());
}
+ _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.snapshot);
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, new Long(volume.getSize()));
return snapshot;
}