3636import com .cloud .user .Account ;
3737import com .cloud .utils .NumbersUtil ;
3838import com .cloud .utils .Pair ;
39+ import com .cloud .utils .StringUtils ;
3940import com .cloud .utils .component .AdapterBase ;
4041import com .cloud .vm .DiskProfile ;
4142import com .cloud .vm .VirtualMachineProfile ;
43+
4244import org .apache .cloudstack .engine .orchestration .service .VolumeOrchestrationService ;
4345import org .apache .cloudstack .engine .subsystem .api .storage .DataStoreManager ;
4446import org .apache .cloudstack .engine .subsystem .api .storage .StoragePoolAllocator ;
4850import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailsDao ;
4951import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
5052import org .apache .cloudstack .utils .reflectiontostringbuilderutils .ReflectionToStringBuilderUtils ;
53+
5154import org .apache .commons .collections .CollectionUtils ;
52- import org .apache .commons .lang3 .StringUtils ;
5355
5456import javax .inject .Inject ;
5557import javax .naming .ConfigurationException ;
6567public abstract class AbstractStoragePoolAllocator extends AdapterBase implements StoragePoolAllocator {
6668
6769 protected BigDecimal storageOverprovisioningFactor = new BigDecimal (1 );
68- protected String allocationAlgorithm = "random" ;
70+ protected String volumeAllocationAlgorithm = "random" ;
6971 protected long extraBytesPerVolume = 0 ;
7072 @ Inject protected DataStoreManager dataStoreMgr ;
7173 @ Inject protected PrimaryDataStoreDao storagePoolDao ;
@@ -93,9 +95,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
9395 String globalStorageOverprovisioningFactor = configs .get ("storage.overprovisioning.factor" );
9496 storageOverprovisioningFactor = new BigDecimal (NumbersUtil .parseFloat (globalStorageOverprovisioningFactor , 2.0f ));
9597 extraBytesPerVolume = 0 ;
96- String allocationAlgorithm = VolumeOrchestrationService .VolumeAllocationAlgorithm .value ();
97- if (allocationAlgorithm != null ) {
98- this .allocationAlgorithm = allocationAlgorithm ;
98+ String volAllocationAlgorithm = VolumeOrchestrationService .VolumeAllocationAlgorithm .value ();
99+ if (volAllocationAlgorithm != null ) {
100+ this .volumeAllocationAlgorithm = volAllocationAlgorithm ;
99101 }
100102 return true ;
101103 }
@@ -225,15 +227,15 @@ public List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachinePro
225227 }
226228
227229 List <StoragePool > reorderStoragePoolsBasedOnAlgorithm (List <StoragePool > pools , DeploymentPlan plan , Account account ) {
228- logger .debug ("Using volume allocation algorithm {} to reorder pools." , allocationAlgorithm );
229- if (allocationAlgorithm .equals ("random" ) || allocationAlgorithm .equals ("userconcentratedpod_random" ) || (account == null )) {
230+ logger .debug ("Using volume allocation algorithm {} to reorder pools." , volumeAllocationAlgorithm );
231+ if (volumeAllocationAlgorithm .equals ("random" ) || volumeAllocationAlgorithm .equals ("userconcentratedpod_random" ) || (account == null )) {
230232 reorderRandomPools (pools );
231- } else if (StringUtils .equalsAny (allocationAlgorithm , "userdispersing" , "firstfitleastconsumed" )) {
233+ } else if (StringUtils .equalsAny (volumeAllocationAlgorithm , "userdispersing" , "firstfitleastconsumed" )) {
232234 if (logger .isTraceEnabled ()) {
233- logger .trace ("Using reordering algorithm {}" , allocationAlgorithm );
235+ logger .trace ("Using reordering algorithm {}" , volumeAllocationAlgorithm );
234236 }
235237
236- if (allocationAlgorithm .equals ("userdispersing" )) {
238+ if (volumeAllocationAlgorithm .equals ("userdispersing" )) {
237239 pools = reorderPoolsByNumberOfVolumes (plan , pools , account );
238240 } else {
239241 pools = reorderPoolsByCapacity (plan , pools );
@@ -245,7 +247,7 @@ List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> pools, D
245247 void reorderRandomPools (List <StoragePool > pools ) {
246248 StorageUtil .traceLogStoragePools (pools , logger , "pools to choose from: " );
247249 if (logger .isTraceEnabled ()) {
248- logger .trace ("Shuffle this so that we don't check the pools in the same order. Algorithm == {} (or no account?)" , allocationAlgorithm );
250+ logger .trace ("Shuffle this so that we don't check the pools in the same order. Algorithm == {} (or no account?)" , volumeAllocationAlgorithm );
249251 }
250252 StorageUtil .traceLogStoragePools (pools , logger , "pools to shuffle: " );
251253 Collections .shuffle (pools , secureRandom );
0 commit comments