Make SnapshotStrategy and DataMotionStrategy discovered and registered

This commit is contained in:
Darren Shepherd 2013-10-03 17:03:28 -07:00
parent 12146ce40c
commit c9a9a3b7b3
9 changed files with 112 additions and 18 deletions

View File

@ -184,4 +184,14 @@
</property>
</bean>
<bean id="snapshotStrategiesRegistry"
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
<property name="excludeKey" value="snapshot.strategies.exclude" />
</bean>
<bean id="dataMotionStrategiesRegistry"
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
<property name="excludeKey" value="data.motion.strategies.exclude" />
</bean>
</beans>

View File

@ -49,6 +49,7 @@
<property name="registry" ref="templateAdapterRegistry" />
<property name="typeClass" value="com.cloud.template.TemplateAdapter" />
</bean>
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
<property name="registry" ref="podAllocatorsRegistry" />
@ -56,5 +57,18 @@
value="com.cloud.agent.manager.allocator.PodAllocator" />
</bean>
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
<property name="registry" ref="snapshotStrategiesRegistry" />
<property name="typeClass"
value="org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy" />
</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" />
</bean>
</beans>

View File

@ -26,20 +26,10 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean id="ancientDataMotionStrategy"
class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
<bean id="xenserverStorageMotionStrategy"
class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
<bean id="dataMotionServiceImpl"
class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">
<property name="strategies">
<list>
<ref local="ancientDataMotionStrategy" />
<ref local="xenserverStorageMotionStrategy" />
</list>
</property>
<property name="strategies" value="#{dataMotionStrategiesRegistry.registered}" />
</bean>
</beans>

View File

@ -0,0 +1,34 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean id="ancientDataMotionStrategy"
class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
<bean id="xenserverStorageMotionStrategy"
class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
</beans>

View File

@ -36,7 +36,7 @@ import java.util.Map;
@Component
public class DataMotionServiceImpl implements DataMotionService {
@Inject
List<DataMotionStrategy> strategies;
@Override
@ -74,7 +74,12 @@ public class DataMotionServiceImpl implements DataMotionService {
throw new CloudRuntimeException("can't find strategy to move data");
}
@Inject
public void setStrategies(List<DataMotionStrategy> strategies) {
this.strategies = strategies;
}
public List<DataMotionStrategy> getStrategies() {
return strategies;
}
}

View File

@ -31,9 +31,6 @@
class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl"
depends-on="snapshotStateMachineManagerImpl, snapshotDataFactoryImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl" />
<bean id="xenserverSnapshotStrategy"
class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
<bean id="snapshotDataFactoryImpl"
class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl"
depends-on="dataStoreManagerImpl, snapshotDataStoreDaoImpl, volumeDataFactoryImpl" />

View File

@ -0,0 +1,33 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean id="xenserverSnapshotStrategy"
class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
</beans>

View File

@ -142,7 +142,9 @@
<bean id="site2SiteVpnManagerImpl" class="com.cloud.network.vpn.Site2SiteVpnManagerImpl" />
<bean id="snapshotManagerImpl" class="com.cloud.storage.snapshot.SnapshotManagerImpl" />
<bean id="snapshotManagerImpl" class="com.cloud.storage.snapshot.SnapshotManagerImpl" >
<property name="snapshotStrategies" value="#{snapshotStrategiesRegistry.registered}" />
</bean>
<bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" />
<bean id="storageNetworkManagerImpl" class="com.cloud.network.StorageNetworkManagerImpl" />

View File

@ -195,7 +195,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
@Inject EndPointSelector _epSelector;
@Inject
private ResourceManager _resourceMgr;
@Inject
protected List<SnapshotStrategy> snapshotStrategies;
@ -1193,4 +1193,13 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
}
return snapshot;
}
public List<SnapshotStrategy> getSnapshotStrategies() {
return snapshotStrategies;
}
@Inject
public void setSnapshotStrategies(List<SnapshotStrategy> snapshotStrategies) {
this.snapshotStrategies = snapshotStrategies;
}
}