bug 6892: update resourceCount for snapshot after the DB record is created; if snapshot fails to create on the backend - reduce resource count

Also fixed couple of other issues:
* usage event generation - generate event only when snapshot is created on primary and backed up on secondary
* zoneId was always set to 0 for snapshot.delete event, fixed this.
* Fixed resource_count decrement for manual snapshot deletion
This commit is contained in:
alena 2011-03-10 15:17:11 -08:00
parent 09d5bcc59c
commit 346ca43714
4 changed files with 420 additions and 418 deletions

View File

@ -119,7 +119,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
}
@Override
public void create(){
public void create() throws ResourceAllocationException{
Snapshot snapshot = _snapshotService.allocSnapshot(this);
if (snapshot != null) {
this.setEntityId(snapshot.getId());
@ -129,7 +129,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
}
@Override
public void execute() throws ResourceAllocationException{
public void execute() {
Snapshot snapshot = _snapshotService.createSnapshot(this);
if (snapshot != null) {
SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot);

View File

@ -37,7 +37,7 @@ public interface SnapshotService {
* @param cmd the API command wrapping the parameters for creating the snapshot (mainly volumeId)
* @return the Snapshot that was created
*/
Snapshot createSnapshot(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException;
Snapshot createSnapshot(CreateSnapshotCmd cmd) throws InvalidParameterValueException;
/**
* List all snapshots of a disk volume. Optionally lists snapshots created by specified interval
@ -79,6 +79,6 @@ public interface SnapshotService {
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);
Snapshot allocSnapshot(CreateSnapshotCmd cmd);
Snapshot allocSnapshot(CreateSnapshotCmd cmd) throws ResourceAllocationException;
}

View File

@ -44,7 +44,7 @@ public interface SnapshotManager {
* @param cmd the API command wrapping the parameters for creating the snapshot (mainly volumeId)
* @return the Snapshot that was created
*/
SnapshotVO createSnapshotImpl(Long volumeId, Long policyId, Long snapshotId) throws ResourceAllocationException;
SnapshotVO createSnapshotImpl(Long volumeId, Long policyId, Long snapshotId);
/**
* After successfully creating a snapshot of a volume, copy the snapshot to the secondary storage for