rebase to master

This commit is contained in:
Edison Su 2013-02-13 17:08:39 -08:00
parent ff047e75d3
commit 0f532c4b3a
5 changed files with 13 additions and 5 deletions

View File

@ -19,7 +19,6 @@ package com.cloud.storage;
import java.util.Date; import java.util.Date;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject; import com.cloud.utils.fsm.StateObject;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.Identity;
@ -55,6 +54,7 @@ public interface Snapshot extends ControlledEntity, Identity, InternalIdentity,
} }
public enum State { public enum State {
Allocated,
Creating, Creating,
CreatedOnPrimary, CreatedOnPrimary,
BackingUp, BackingUp,

View File

@ -117,7 +117,7 @@ public class SnapshotVO implements Snapshot {
this.snapshotType = snapshotType; this.snapshotType = snapshotType;
this.typeDescription = typeDescription; this.typeDescription = typeDescription;
this.size = size; this.size = size;
this.state = State.Creating; this.state = State.Allocated;
this.prevSnapshotId = 0; this.prevSnapshotId = 0;
this.hypervisorType = hypervisorType; this.hypervisorType = hypervisorType;
this.version = "2.2"; this.version = "2.2";

View File

@ -20,7 +20,7 @@ SnapshotStateMachineManager {
@Inject @Inject
protected SnapshotDao snapshotDao; protected SnapshotDao snapshotDao;
public SnapshotStateMachineManagerImpl() { public SnapshotStateMachineManagerImpl() {
stateMachine.addTransition(null, Event.CreateRequested, Snapshot.State.Creating); stateMachine.addTransition(Snapshot.State.Allocated, Event.CreateRequested, Snapshot.State.Creating);
stateMachine.addTransition(Snapshot.State.Creating, Event.OperationSucceeded, Snapshot.State.CreatedOnPrimary); stateMachine.addTransition(Snapshot.State.Creating, Event.OperationSucceeded, Snapshot.State.CreatedOnPrimary);
stateMachine.addTransition(Snapshot.State.Creating, Event.OperationNotPerformed, Snapshot.State.BackedUp); stateMachine.addTransition(Snapshot.State.Creating, Event.OperationNotPerformed, Snapshot.State.BackedUp);
stateMachine.addTransition(Snapshot.State.Creating, Event.OperationFailed, Snapshot.State.Error); stateMachine.addTransition(Snapshot.State.Creating, Event.OperationFailed, Snapshot.State.Error);

View File

@ -67,6 +67,9 @@ import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.vm.UserVmVO; import com.cloud.vm.UserVmVO;
import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.snapshot.VMSnapshot;
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
@Component @Component
public class AncientSnasphotStrategy implements SnapshotStrategy { public class AncientSnasphotStrategy implements SnapshotStrategy {
@ -103,6 +106,8 @@ public class AncientSnasphotStrategy implements SnapshotStrategy {
DataMotionService motionSrv; DataMotionService motionSrv;
@Inject @Inject
ObjectInDataStoreManager objInStoreMgr; ObjectInDataStoreManager objInStoreMgr;
@Inject
VMSnapshotDao _vmSnapshotDao;
@Override @Override

View File

@ -28,6 +28,8 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd; import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -61,7 +63,7 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.storage.GuestOSVO; import com.cloud.storage.GuestOSVO;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO; import com.cloud.storage.SnapshotVO;
import com.cloud.storage.StoragePoolVO; import com.cloud.storage.StoragePool;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.GuestOSDao; import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.dao.SnapshotDao;
@ -115,6 +117,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
@Inject StoragePoolDao _storagePoolDao; @Inject StoragePoolDao _storagePoolDao;
@Inject SnapshotDao _snapshotDao; @Inject SnapshotDao _snapshotDao;
@Inject VirtualMachineManager _itMgr; @Inject VirtualMachineManager _itMgr;
@Inject DataStoreManager dataStoreMgr;
@Inject ConfigurationDao _configDao; @Inject ConfigurationDao _configDao;
int _vmSnapshotMax; int _vmSnapshotMax;
StateMachine2<VMSnapshot.State, VMSnapshot.Event, VMSnapshot> _vmSnapshottateMachine ; StateMachine2<VMSnapshot.State, VMSnapshot.Event, VMSnapshot> _vmSnapshottateMachine ;
@ -393,7 +396,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
List<VolumeVO> volumeVos = _volumeDao.findByInstance(vmId); List<VolumeVO> volumeVos = _volumeDao.findByInstance(vmId);
for (VolumeVO volume : volumeVos) { for (VolumeVO volume : volumeVos) {
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId()); StoragePool pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
VolumeTO volumeTO = new VolumeTO(volume, pool); VolumeTO volumeTO = new VolumeTO(volume, pool);
volumeTOs.add(volumeTO); volumeTOs.add(volumeTO);
} }