Skip to content

Commit f1134da

Browse files
author
Prasanna Santhanam
committed
Group storage subsystem components for spring
Breaking down storage components among oss, nonoss and simulator contexts. The default components are loaded by OSS - applicationContext + componentContext NonOSS - applicationContext + nonossComponentContext Simulator - applicationContext + simulatorComponentContext provider beans are are selectively overridden for simpler configuration. Where possible beans are loaded by local reference. <list merge=true> does not unfortunately work perfectly for bean merging the providers causing a bit of bloat. Explore for later. Signed-off-by: Prasanna Santhanam <tsp@apache.org>
1 parent fd867d5 commit f1134da

10 files changed

Lines changed: 255 additions & 130 deletions

File tree

client/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,12 @@
273273
<groupId>org.apache.cloudstack</groupId>
274274
<artifactId>cloud-plugin-storage-image-swift</artifactId>
275275
<version>${project.version}</version>
276-
</dependency>
276+
</dependency>
277+
<dependency>
278+
<groupId>org.apache.cloudstack</groupId>
279+
<artifactId>cloud-plugin-storage-image-simulator</artifactId>
280+
<version>${project.version}</version>
281+
</dependency>
277282
<dependency>
278283
<groupId>org.apache.cloudstack</groupId>
279284
<artifactId>cloud-plugin-syslog-alerts</artifactId>

client/tomcatconf/applicationContext.xml.in

Lines changed: 119 additions & 60 deletions
Large diffs are not rendered by default.

client/tomcatconf/componentContext.xml.in

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
under the License.
1919
-->
2020
<beans xmlns="http://www.springframework.org/schema/beans"
21-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2222
xmlns:context="http://www.springframework.org/schema/context"
23-
xmlns:tx="http://www.springframework.org/schema/tx"
23+
xmlns:tx="http://www.springframework.org/schema/tx"
2424
xmlns:aop="http://www.springframework.org/schema/aop"
2525
xsi:schemaLocation="http://www.springframework.org/schema/beans
2626
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
@@ -31,6 +31,8 @@
3131
http://www.springframework.org/schema/context
3232
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
3333

34+
<context:annotation-config />
35+
3436

3537
<!--
3638

@@ -95,7 +97,26 @@
9597

9698
It determines whether or not a adapter is activated or how it is loaded in order in its managing provider,
9799

98-
-->
100+
-->
101+
<bean id="CloudStackImageStoreProviderImpl"
102+
class="org.apache.cloudstack.storage.datastore.provider.CloudStackImageStoreProviderImpl"/>
103+
<bean id="S3ImageStoreProviderImpl"
104+
class="org.apache.cloudstack.storage.datastore.provider.S3ImageStoreProviderImpl"/>
105+
<bean id="SwiftImageStoreProviderImpl"
106+
class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl"/>
107+
108+
<!--Storage Providers-->
109+
<bean id="dataStoreProviderManager"
110+
class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
111+
<property name="providers">
112+
<list merge="true">
113+
<ref bean="CloudStackPrimaryDataStoreProviderImpl"/>
114+
<ref local="CloudStackImageStoreProviderImpl"/>
115+
<ref local="S3ImageStoreProviderImpl"/>
116+
<ref local="SwiftImageStoreProviderImpl"/>
117+
</list>
118+
</property>
119+
</bean>
99120

100121
<!-- Security adapters -->
101122
<bean id="userAuthenticators" class="com.cloud.utils.component.AdapterList">

client/tomcatconf/nonossComponentContext.xml.in

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<bean id="VmwareDatacenterDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterDaoImpl" />
8181
<bean id="VmwareDatacenterZoneMapDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDaoImpl" />
8282
<bean id="LegacyZoneDaoImpl" class="com.cloud.hypervisor.vmware.dao.LegacyZoneDaoImpl" />
83-
<bean id="vmwareStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.VmwareStorageMotionStrategy"/>
8483

8584
<!--
8685
Nicira support components
@@ -182,7 +181,35 @@
182181

183182
It determines whether or not a adapter is activated or how it is loaded in order in its managing provider,
184183

185-
-->
184+
-->
185+
186+
187+
<!--Motion Strategies-->
188+
<bean id="vmwareStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.VmwareStorageMotionStrategy" />
189+
<bean id="dataMotionServiceImpl" class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">
190+
<property name="strategies">
191+
<list>
192+
<ref bean="ancientDataMotionStrategy"/>
193+
<ref bean="xenserverStorageMotionStrategy"/>
194+
<ref local="vmwareStorageMotionStrategy"/>
195+
</list>
196+
</property>
197+
</bean>
198+
199+
<!--<bean id="SolidfirePrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.SolidfirePrimaryDataStoreProvider"/>-->
200+
<!--Storage Providers-->
201+
<bean id="dataStoreProviderManager"
202+
class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
203+
<property name="providers">
204+
<list merge="true">
205+
<ref bean="CloudStackPrimaryDataStoreProviderImpl"/>
206+
<ref bean="CloudStackImageStoreProviderImpl"/>
207+
<ref bean="S3ImageStoreProviderImpl"/>
208+
<ref bean="SwiftImageStoreProviderImpl"/>
209+
<!--<ref local="SolidfirePrimaryDataStoreProvider"/>-->
210+
</list>
211+
</property>
212+
</bean>
186213

187214
<!-- Security adapters -->
188215
<bean id="userAuthenticators" class="com.cloud.utils.component.AdapterList">

client/tomcatconf/simulatorComponentContext.xml.in

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,39 @@
1818
-->
1919
<beans xmlns="http://www.springframework.org/schema/beans"
2020
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xmlns:context="http://www.springframework.org/schema/context"
22-
xmlns:tx="http://www.springframework.org/schema/tx"
23-
xmlns:aop="http://www.springframework.org/schema/aop"
2421
xsi:schemaLocation="http://www.springframework.org/schema/beans
25-
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
26-
http://www.springframework.org/schema/tx
27-
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
28-
http://www.springframework.org/schema/aop
29-
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
30-
http://www.springframework.org/schema/context
31-
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
22+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
3223

3324
<!--
3425
OSS deployment component configuration
3526
-->
3627
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker"/>
3728
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl"/>
3829

39-
<!-- simulator components -->
40-
<!--<bean id="SimulatorSecondaryDiscoverer" class="com.cloud.resource.SimulatorSecondaryDiscoverer">-->
41-
<!--<property name="name" value="SecondaryStorage"/>-->
42-
<!--</bean>-->
4330
<bean id="SimulatorDiscoverer" class="com.cloud.resource.SimulatorDiscoverer">
4431
<property name="name" value="Simulator Agent"/>
4532
</bean>
4633
<bean id="SimulatorGuru" class="com.cloud.simulator.SimulatorGuru">
4734
<property name="name" value="Simulator Guru"/>
4835
</bean>
4936

37+
<bean id="SimulatorImageStoreProviderImpl"
38+
class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl"/>
39+
40+
<!--Storage Providers-->
41+
<!--<bean id="dataStoreProviderManagerChild" parent="dataStoreProviderManager">-->
42+
<bean id="dataStoreProviderManager"
43+
class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
44+
<property name="providers">
45+
<!--Override the cloudstack default image store provider to use simulator defined provider-->
46+
<list>
47+
<!--Data Store Providers-->
48+
<ref bean="CloudStackPrimaryDataStoreProviderImpl"/>
49+
<ref bean="SimulatorImageStoreProviderImpl"/>
50+
</list>
51+
</property>
52+
</bean>
53+
5054
<!--
5155
Managers & pluggable adapters configuration under OSS deployment
5256
-->
@@ -85,7 +89,6 @@
8589
<property name="Adapters">
8690
<list>
8791
<ref bean="SimulatorDiscoverer"/>
88-
<ref bean="SimulatorSecondaryDiscoverer"/>
8992
<ref bean="XcpServerDiscoverer"/>
9093
<ref bean="SecondaryStorageDiscoverer"/>
9194
<ref bean="KvmServerDiscoverer"/>
@@ -124,10 +127,6 @@
124127
<ref bean="FirstFitPlanner"/>
125128
<ref bean="UserDispersingPlanner"/>
126129
<ref bean="UserConcentratedPodPlanner"/>
127-
128-
<!--
129-
<ref bean="BareMetalPlanner" />
130-
-->
131130
</list>
132131
</property>
133132
</bean>
@@ -175,9 +174,6 @@
175174
<list>
176175
<ref bean="VirtualRouter"/>
177176
<ref bean="VpcVirtualRouter"/>
178-
<!--
179-
<ref bean="BareMetalDhcp"/>
180-
-->
181177
</list>
182178
</property>
183179
</bean>
@@ -206,19 +202,15 @@
206202
<ref bean="SecurityGroupProvider"/>
207203
<ref bean="VpcVirtualRouter"/>
208204
<ref bean="InternalLbVm"/>
209-
<!--
210-
<ref bean="BareMetalDhcp"/>
211-
<ref bean="BareMetalPxe"/>
212-
<ref bean="BareMetalUserdata"/>
213-
-->
214205
</list>
215206
</property>
216207
</bean>
217208

218209
<!--
219210
Image Store
220211
-->
221-
<!--<bean id="simulatorImageStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl" />-->
212+
213+
222214

223215
<bean id="GlobalLoadBalancingRulesServiceImpl"
224216
class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl"/>
@@ -244,5 +236,4 @@
244236
<property name="name" value="ExplicitDedicationProcessor"/>
245237
<property name="type" value="ExplicitDedication"/>
246238
</bean>
247-
248239
</beans>

developer/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
<version>${project.version}</version>
5959
<scope>compile</scope>
6060
</dependency>
61+
<dependency>
62+
<groupId>org.apache.cloudstack</groupId>
63+
<artifactId>cloud-plugin-storage-image-simulator</artifactId>
64+
<version>${project.version}</version>
65+
<scope>compile</scope>
66+
</dependency>
6167
</dependencies>
6268
<build>
6369
<defaultGoal>install</defaultGoal>

engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
package org.apache.cloudstack.storage.motion;
2020

21-
import java.util.List;
22-
import java.util.Map;
23-
24-
import javax.inject.Inject;
25-
21+
import com.cloud.agent.api.to.VirtualMachineTO;
22+
import com.cloud.host.Host;
23+
import com.cloud.utils.exception.CloudRuntimeException;
2624
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
2725
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
2826
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
@@ -32,9 +30,9 @@
3230
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
3331
import org.springframework.stereotype.Component;
3432

35-
import com.cloud.agent.api.to.VirtualMachineTO;
36-
import com.cloud.host.Host;
37-
import com.cloud.utils.exception.CloudRuntimeException;
33+
import javax.inject.Inject;
34+
import java.util.List;
35+
import java.util.Map;
3836

3937
@Component
4038
public class DataMotionServiceImpl implements DataMotionService {
@@ -72,4 +70,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmT
7270
}
7371
throw new CloudRuntimeException("can't find strategy to move data");
7472
}
73+
74+
public void setStrategies(List<DataMotionStrategy> strategies) {
75+
this.strategies = strategies;
76+
}
7577
}

engine/storage/integration-test/test/resource/storageContext.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
<bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl" />
8282
<bean id="cloudStackImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.CloudStackImageStoreProviderImpl" />
8383
<bean id="s3ImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.S3ImageStoreProviderImpl" />
84-
<bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />
84+
<bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />
85+
<bean id="simulatorImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl" />
8586
<bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
8687
<bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
8788
<bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />

engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,30 @@
1818
*/
1919
package org.apache.cloudstack.storage.datastore;
2020

21-
import java.util.List;
22-
import java.util.Map;
23-
24-
import javax.inject.Inject;
25-
21+
import com.cloud.storage.DataStoreRole;
22+
import com.cloud.utils.exception.CloudRuntimeException;
23+
import edu.emory.mathcs.backport.java.util.Collections;
2624
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2725
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
2826
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
2927
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
3028
import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
3129
import org.springframework.stereotype.Component;
3230

33-
import com.cloud.storage.DataStoreRole;
34-
import com.cloud.utils.exception.CloudRuntimeException;
35-
36-
import edu.emory.mathcs.backport.java.util.Collections;
31+
import javax.inject.Inject;
32+
import java.util.List;
3733

3834
@Component
3935
public class DataStoreManagerImpl implements DataStoreManager {
4036
@Inject
41-
PrimaryDataStoreProviderManager primaryStorMgr;
37+
PrimaryDataStoreProviderManager primaryStoreMgr;
4238
@Inject
4339
ImageStoreProviderManager imageDataStoreMgr;
4440

4541
@Override
4642
public DataStore getDataStore(long storeId, DataStoreRole role) {
4743
if (role == DataStoreRole.Primary) {
48-
return primaryStorMgr.getPrimaryDataStore(storeId);
44+
return primaryStoreMgr.getPrimaryDataStore(storeId);
4945
} else if (role == DataStoreRole.Image) {
5046
return imageDataStoreMgr.getImageStore(storeId);
5147
} else if (role == DataStoreRole.ImageCache) {
@@ -57,7 +53,7 @@ public DataStore getDataStore(long storeId, DataStoreRole role) {
5753
@Override
5854
public DataStore getDataStore(String uuid, DataStoreRole role) {
5955
if (role == DataStoreRole.Primary) {
60-
return primaryStorMgr.getPrimaryDataStore(uuid);
56+
return primaryStoreMgr.getPrimaryDataStore(uuid);
6157
} else if (role == DataStoreRole.Image) {
6258
return imageDataStoreMgr.getImageStore(uuid);
6359
}
@@ -81,7 +77,7 @@ public DataStore getImageStore(long zoneId) {
8177

8278
@Override
8379
public DataStore getPrimaryDataStore(long storeId) {
84-
return primaryStorMgr.getPrimaryDataStore(storeId);
80+
return primaryStoreMgr.getPrimaryDataStore(storeId);
8581
}
8682

8783
@Override
@@ -94,4 +90,11 @@ public List<DataStore> listImageStores() {
9490
return imageDataStoreMgr.listImageStores();
9591
}
9692

93+
public void setPrimaryStoreMgr(PrimaryDataStoreProviderManager primaryStoreMgr) {
94+
this.primaryStoreMgr = primaryStoreMgr;
95+
}
96+
97+
public void setImageDataStoreMgr(ImageStoreProviderManager imageDataStoreMgr) {
98+
this.imageDataStoreMgr = imageDataStoreMgr;
99+
}
97100
}

0 commit comments

Comments
 (0)