cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [4/5] git commit: updated refs/heads/master to 465c9ec
Date Sat, 26 Oct 2013 01:24:58 GMT
rebase to spring changes


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/70b2c015
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/70b2c015
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/70b2c015

Branch: refs/heads/master
Commit: 70b2c0150dad5ca3b42e34d20831a256661bc8f0
Parents: 51a8086
Author: Edison Su <sudison@gmail.com>
Authored: Fri Oct 25 18:15:36 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Fri Oct 25 18:15:36 2013 -0700

----------------------------------------------------------------------
 .../core/spring-core-registry-core-context.xml  |  7 ++-
 ...ng-lifecycle-storage-context-inheritable.xml |  6 ++
 .../api/storage/StorageStrategyFactory.java     |  5 +-
 .../api/storage/VMSnapshotStrategy.java         |  2 +-
 .../spring-engine-schema-core-daos-context.xml  |  1 +
 .../core/spring-engine-storage-core-context.xml |  1 +
 ...-engine-storage-snapshot-storage-context.xml |  7 ++-
 .../vmsnapshot/DefaultVMSnapshotStrategy.java   |  5 +-
 .../helper/StorageStrategyFactoryImpl.java      | 22 +++++++
 .../vm/snapshot/VMSnapshotManagerImpl.java      | 62 ++------------------
 10 files changed, 56 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
index 26d70c9..a8b2e29 100644
--- a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
+++ b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
@@ -260,9 +260,14 @@
         <property name="excludeKey" value="snapshot.strategies.exclude" />
     </bean>
 
+    <bean id="vmSnapshotStrategiesRegistry"
+        class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
+        <property name="excludeKey" value="vmSnapshot.strategies.exclude" />
+    </bean>
+
     <bean id="dataMotionStrategiesRegistry"
         class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
         <property name="excludeKey" value="data.motion.strategies.exclude" />
     </bean>
     
-</beans>
\ No newline at end of file
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/core/resources/META-INF/cloudstack/storage/spring-lifecycle-storage-context-inheritable.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/storage/spring-lifecycle-storage-context-inheritable.xml
b/core/resources/META-INF/cloudstack/storage/spring-lifecycle-storage-context-inheritable.xml
index b6eed7d..ad78cad 100644
--- a/core/resources/META-INF/cloudstack/storage/spring-lifecycle-storage-context-inheritable.xml
+++ b/core/resources/META-INF/cloudstack/storage/spring-lifecycle-storage-context-inheritable.xml
@@ -64,6 +64,12 @@
     </bean>
 
     <bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
+        <property name="registry" ref="vmSnapshotStrategiesRegistry" />
+        <property name="typeClass"
+            value="org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy"
/>
+    </bean>
+
+    <bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
         <property name="registry" ref="dataMotionStrategiesRegistry" />
         <property name="typeClass"
             value="org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy"
/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageStrategyFactory.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageStrategyFactory.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageStrategyFactory.java
index ac1e311..91bcc1f 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageStrategyFactory.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageStrategyFactory.java
@@ -24,6 +24,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.Snaps
 
 import com.cloud.host.Host;
 import com.cloud.storage.Snapshot;
+import com.cloud.vm.snapshot.VMSnapshot;
 
 public interface StorageStrategyFactory {
 
@@ -31,6 +32,8 @@ public interface StorageStrategyFactory {
 
     DataMotionStrategy getDataMotionStrategy(Map<VolumeInfo, DataStore> volumeMap,
Host srcHost, Host destHost);
 
-    SnapshotStrategy getSnapshotStrategy(Snapshot snapshot, SnapshotOperation op); 
+    SnapshotStrategy getSnapshotStrategy(Snapshot snapshot, SnapshotOperation op);
+
+    VMSnapshotStrategy getVmSnapshotStrategy(VMSnapshot vmSnapshot);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java
index 8dd6eca..c2a0ded 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotStrategy.java
@@ -24,5 +24,5 @@ public interface VMSnapshotStrategy {
     VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot);
     boolean deleteVMSnapshot(VMSnapshot vmSnapshot);
     boolean revertVMSnapshot(VMSnapshot vmSnapshot);
-    boolean canHandle(VMSnapshot vmSnapshot);
+    StrategyPriority canHandle(VMSnapshot vmSnapshot);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
----------------------------------------------------------------------
diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
index a70cd00..3fce439 100644
--- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
+++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
@@ -291,6 +291,7 @@
   <bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDaoImpl"
/>
   <bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMRootDiskTagDaoImpl"
/>
   <bean id="vMSnapshotDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl" />
+  <bean id="vMSnapshotDetailsDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDetailsDaoImpl"
/>
   <bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl"
/>
   <bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl"
/>
   <bean id="vMTemplatePoolDaoImpl" class="com.cloud.storage.dao.VMTemplatePoolDaoImpl"
/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/storage/resources/META-INF/cloudstack/core/spring-engine-storage-core-context.xml
----------------------------------------------------------------------
diff --git a/engine/storage/resources/META-INF/cloudstack/core/spring-engine-storage-core-context.xml
b/engine/storage/resources/META-INF/cloudstack/core/spring-engine-storage-core-context.xml
index 8a78fdd..a6a0c22 100644
--- a/engine/storage/resources/META-INF/cloudstack/core/spring-engine-storage-core-context.xml
+++ b/engine/storage/resources/META-INF/cloudstack/core/spring-engine-storage-core-context.xml
@@ -63,6 +63,7 @@
     <bean id="storageStrategyFactoryImpl" class="org.apache.cloudstack.storage.helper.StorageStrategyFactoryImpl"
>
         <property name="dataMotionStrategies" value="#{dataMotionStrategiesRegistry.registered}"
/>
         <property name="snapshotStrategies" value="#{snapshotStrategiesRegistry.registered}"
/>
+        <property name="vmSnapshotStrategies" value="#{vmSnapshotStrategiesRegistry.registered}"
/>
     </bean>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
b/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
index 3faa894..d25aeea 100644
--- a/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
+++ b/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
@@ -30,4 +30,9 @@
     <bean id="xenserverSnapshotStrategy"
         class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
 
-</beans>
\ No newline at end of file
+    <bean id="DefaultVMSnapshotStrategy"
+        class="org.apache.cloudstack.storage.vmsnapshot.DefaultVMSnapshotStrategy" />
+
+    <bean id="VMSnapshotHelperImpl"
+        class="org.apache.cloudstack.storage.vmsnapshot.VMSnapshotHelperImpl" />
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java
index 0ef8ebb..be3cce9 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
 import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
@@ -364,7 +365,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements
VMSnapshot
     }
 
     @Override
-    public boolean canHandle(VMSnapshot vmSnapshot) {
-        return true;
+    public StrategyPriority canHandle(VMSnapshot vmSnapshot) {
+        return StrategyPriority.DEFAULT;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/engine/storage/src/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java
index 30812bf..a1d128b 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java
@@ -31,15 +31,18 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation;
 import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
+import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 
 import com.cloud.host.Host;
 import com.cloud.storage.Snapshot;
+import com.cloud.vm.snapshot.VMSnapshot;
 
 public class StorageStrategyFactoryImpl implements StorageStrategyFactory {
 
     List<SnapshotStrategy> snapshotStrategies;
     List<DataMotionStrategy> dataMotionStrategies;
+    List<VMSnapshotStrategy> vmSnapshotStrategies;
 
     @Override
     public DataMotionStrategy getDataMotionStrategy(final DataObject srcData, final DataObject
destData) {
@@ -71,6 +74,16 @@ public class StorageStrategyFactoryImpl implements StorageStrategyFactory
{
         });
     }
 
+    @Override
+    public VMSnapshotStrategy getVmSnapshotStrategy(final VMSnapshot vmSnapshot) {
+       return bestMatch(vmSnapshotStrategies, new CanHandle<VMSnapshotStrategy>() {
+           @Override
+           public StrategyPriority canHandle(VMSnapshotStrategy strategy) {
+                return strategy.canHandle(vmSnapshot);
+           }
+       });
+    }
+
     private static <T> T bestMatch(Collection<T> collection, final CanHandle<T>
canHandle) {
         if (collection.size() == 0)
             return null;
@@ -111,4 +124,13 @@ public class StorageStrategyFactoryImpl implements StorageStrategyFactory
{
         this.dataMotionStrategies = dataMotionStrategies;
     }
 
+    @Inject
+    public void setVmSnapshotStrategies(List<VMSnapshotStrategy> vmSnapshotStrategies)
{
+        this.vmSnapshotStrategies = vmSnapshotStrategies;
+    }
+
+    public List<VMSnapshotStrategy> getVmSnapshotStrategies() {
+        return vmSnapshotStrategies;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70b2c015/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index 3f473bd..ee81c82 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -27,26 +27,13 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.CreateVMSnapshotAnswer;
-import com.cloud.agent.api.CreateVMSnapshotCommand;
-import com.cloud.agent.api.DeleteVMSnapshotAnswer;
-import com.cloud.agent.api.DeleteVMSnapshotCommand;
-import com.cloud.agent.api.RevertToVMSnapshotAnswer;
-import com.cloud.agent.api.RevertToVMSnapshotCommand;
-import com.cloud.agent.api.VMSnapshotTO;
-import com.cloud.agent.api.to.VolumeTO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
@@ -75,14 +62,6 @@ import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
-
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.TransactionCallback;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
-import com.cloud.utils.db.TransactionCallbackWithException;
-import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
-import com.cloud.utils.db.TransactionStatus;
-
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VMInstanceVO;
@@ -92,21 +71,6 @@ import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
-import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
-import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 @Component
 @Local(value = { VMSnapshotManager.class, VMSnapshotService.class })
@@ -123,16 +87,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
     @Inject VirtualMachineManager _itMgr;
     @Inject ConfigurationDao _configDao;
     @Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
-    @Inject List<VMSnapshotStrategy> vmSnapshotStrategies;
-
-    public List<VMSnapshotStrategy> getVmSnapshotStrategies() {
-        return vmSnapshotStrategies;
-    }
-
     @Inject
-    public void setVmSnapshotStrategies(List<VMSnapshotStrategy> vmSnapshotStrategies)
{
-        this.vmSnapshotStrategies = vmSnapshotStrategies;
-    }
+    StorageStrategyFactory storageStrategyFactory;
 
     int _vmSnapshotMax;
     int _wait;
@@ -343,13 +299,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
     }
 
     private VMSnapshotStrategy findVMSnapshotStrategy(VMSnapshot vmSnapshot) {
-        VMSnapshotStrategy snapshotStrategy = null;
-        for(VMSnapshotStrategy strategy : vmSnapshotStrategies) {
-            if (strategy.canHandle(vmSnapshot)) {
-                snapshotStrategy = strategy;
-                break;
-            }
-        }
+        VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(vmSnapshot);
 
         if (snapshotStrategy == null) {
             throw new CloudRuntimeException("can't find vm snapshot strategy for vmsnapshot:
" + vmSnapshot.getId());


Mime
View raw message