Skip to content

Commit d0f35d9

Browse files
Julien Hervot de Mattos Vazerikbocks
authored andcommitted
Adição de logs na reordenação de storage pools
Substitui por nova sintaxe do Log4j
1 parent 7324ef4 commit d0f35d9

File tree

1 file changed

+30
-40
lines changed

1 file changed

+30
-40
lines changed

engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ protected List<StoragePool> reorderPoolsByCapacity(DeploymentPlan plan, List<Sto
145145
storageType = "shared";
146146
}
147147

148-
logger.debug(String.format(
149-
"Filtering storage pools by capacity type [%s] as the first storage pool of the list, with name [%s] and ID [%s], is a [%s] storage.",
148+
logger.debug(
149+
"Filtering storage pools by capacity type [{}] as the first storage pool of the list, with name [{}] and ID [{}], is a [{}] storage.",
150150
capacityType, storagePool.getName(), storagePool.getUuid(), storageType
151-
));
151+
);
152152

153153
Pair<List<Long>, Map<Long, Double>> result = capacityDao.orderHostsByFreeCapacity(zoneId, clusterId, capacityType);
154154
List<Long> poolIdsByCapacity = result.first();
@@ -185,7 +185,7 @@ protected List<StoragePool> reorderPoolsByNumberOfVolumes(DeploymentPlan plan, L
185185
Long clusterId = plan.getClusterId();
186186

187187
List<Long> poolIdsByVolCount = volumeDao.listPoolIdsByVolumeCount(dcId, podId, clusterId, account.getAccountId());
188-
logger.debug(String.format("List of pools in ascending order of number of volumes for account [%s] is [%s].", account, poolIdsByVolCount));
188+
logger.debug("List of pools in ascending order of number of volumes for account [{}] is [{}].", account, poolIdsByVolCount);
189189

190190
// now filter the given list of Pools by this ordered list
191191
Map<Long, StoragePool> poolMap = new HashMap<>();
@@ -206,16 +206,11 @@ protected List<StoragePool> reorderPoolsByNumberOfVolumes(DeploymentPlan plan, L
206206

207207
@Override
208208
public List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachineProfile vmProfile, DeploymentPlan plan, DiskProfile dskCh) {
209-
if (logger.isTraceEnabled()) {
210-
logger.trace("reordering pools");
211-
}
212209
if (pools == null) {
213-
logger.trace("There are no pools to reorder; returning null.");
210+
logger.debug("There are no pools to reorder; returning null.");
214211
return null;
215212
}
216-
if (logger.isTraceEnabled()) {
217-
logger.trace(String.format("reordering %d pools", pools.size()));
218-
}
213+
logger.debug("Reordering [{}] pools", pools.size());
219214
Account account = null;
220215
if (vmProfile.getVirtualMachine() != null) {
221216
account = vmProfile.getOwner();
@@ -224,9 +219,7 @@ public List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachinePro
224219
pools = reorderStoragePoolsBasedOnAlgorithm(pools, plan, account);
225220

226221
if (vmProfile.getVirtualMachine() == null) {
227-
if (logger.isTraceEnabled()) {
228-
logger.trace("The VM is null, skipping pools reordering by disk provisioning type.");
229-
}
222+
logger.debug("The VM is null, skipping pool reordering by disk provisioning type.");
230223
return pools;
231224
}
232225

@@ -244,10 +237,6 @@ List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> pools, D
244237
if (volumeAllocationAlgorithm.equals("random") || volumeAllocationAlgorithm.equals("userconcentratedpod_random") || (account == null)) {
245238
reorderRandomPools(pools);
246239
} else if (StringUtils.equalsAny(volumeAllocationAlgorithm, "userdispersing", "firstfitleastconsumed")) {
247-
if (logger.isTraceEnabled()) {
248-
logger.trace("Using reordering algorithm {}", volumeAllocationAlgorithm);
249-
}
250-
251240
if (volumeAllocationAlgorithm.equals("userdispersing")) {
252241
pools = reorderPoolsByNumberOfVolumes(plan, pools, account);
253242
} else {
@@ -259,16 +248,15 @@ List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> pools, D
259248

260249
void reorderRandomPools(List<StoragePool> pools) {
261250
StorageUtil.traceLogStoragePools(pools, logger, "pools to choose from: ");
262-
if (logger.isTraceEnabled()) {
263-
logger.trace("Shuffle this so that we don't check the pools in the same order. Algorithm == 'random' (or no account?)");
264-
}
265-
StorageUtil.traceLogStoragePools(pools, logger, "pools to shuffle: ");
251+
logger.trace("Shuffle this so that we don't check the pools in the same order. Algorithm == 'random' (or no account?)");
252+
logger.debug("Pools to shuffle: [{}]", pools);
266253
Collections.shuffle(pools, secureRandom);
267-
StorageUtil.traceLogStoragePools(pools, logger, "shuffled list of pools to choose from: ");
254+
logger.debug("Shuffled list of pools to choose from: [{}]", pools);
268255
}
269256

270257
private List<StoragePool> reorderPoolsByDiskProvisioningType(List<StoragePool> pools, DiskProfile diskProfile) {
271258
if (diskProfile != null && diskProfile.getProvisioningType() != null && !diskProfile.getProvisioningType().equals(Storage.ProvisioningType.THIN)) {
259+
logger.debug("Reordering [{}] pools by disk provisioning type [{}].", pools.size(), diskProfile.getProvisioningType());
272260
List<StoragePool> reorderedPools = new ArrayList<>();
273261
int preferredIndex = 0;
274262
for (StoragePool pool : pools) {
@@ -282,22 +270,24 @@ private List<StoragePool> reorderPoolsByDiskProvisioningType(List<StoragePool> p
282270
reorderedPools.add(preferredIndex++, pool);
283271
}
284272
}
273+
logger.debug("Reordered list of pools by disk provisioning type [{}]: [{}]", diskProfile.getProvisioningType(), pools);
285274
return reorderedPools;
286275
} else {
276+
logger.debug("Reordering pools by disk provisioning type wasn't necessary.");
287277
return pools;
288278
}
289279
}
290280

291281
protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh, DeploymentPlan plan) {
292-
logger.debug(String.format("Checking if storage pool [%s] is suitable to disk [%s].", pool, dskCh));
282+
logger.debug("Checking if storage pool [{}] is suitable to disk [{}].", pool, dskCh);
293283
if (avoid.shouldAvoid(pool)) {
294-
logger.debug(String.format("StoragePool [%s] is in avoid set, skipping this pool to allocation of disk [%s].", pool, dskCh));
284+
logger.debug("StoragePool [{}] is in avoid set, skipping this pool to allocation of disk [{}].", pool, dskCh);
295285
return false;
296286
}
297287

298288
if (dskCh.requiresEncryption() && !pool.getPoolType().supportsEncryption()) {
299289
if (logger.isDebugEnabled()) {
300-
logger.debug(String.format("Storage pool type '%s' doesn't support encryption required for volume, skipping this pool", pool.getPoolType()));
290+
logger.debug("Storage pool type '[{}]' doesn't support encryption required for volume, skipping this pool", pool.getPoolType());
301291
}
302292
return false;
303293
}
@@ -319,8 +309,8 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
319309
}
320310

321311
if (!checkDiskProvisioningSupport(dskCh, pool)) {
322-
logger.debug(String.format("Storage pool [%s] does not have support to disk provisioning of disk [%s].", pool, ReflectionToStringBuilderUtils.reflectOnlySelectedFields(dskCh,
323-
"type", "name", "diskOfferingId", "templateId", "volumeId", "provisioningType", "hyperType")));
312+
logger.debug("Storage pool [{}] does not have support to disk provisioning of disk [{}].", pool, ReflectionToStringBuilderUtils.reflectOnlySelectedFields(dskCh,
313+
"type", "name", "diskOfferingId", "templateId", "volumeId", "provisioningType", "hyperType"));
324314
return false;
325315
}
326316

@@ -332,7 +322,7 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
332322
HostVO plannedHost = hostDao.findById(plan.getHostId());
333323
if (!storageMgr.checkIfHostAndStoragePoolHasCommonStorageAccessGroups(plannedHost, pool)) {
334324
if (logger.isDebugEnabled()) {
335-
logger.debug(String.format("StoragePool %s and host %s does not have matching storage access groups", pool, plannedHost));
325+
logger.debug("StoragePool [{}] and host [{}] does not have matching storage access groups", pool, plannedHost);
336326
}
337327
return false;
338328
}
@@ -343,13 +333,13 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
343333
if (!isTempVolume) {
344334
volume = volumeDao.findById(dskCh.getVolumeId());
345335
if (!storageMgr.storagePoolCompatibleWithVolumePool(pool, volume)) {
346-
logger.debug(String.format("Pool [%s] is not compatible with volume [%s], skipping it.", pool, volume));
336+
logger.debug("Pool [{}] is not compatible with volume [{}], skipping it.", pool, volume);
347337
return false;
348338
}
349339
}
350340

351341
if (pool.isManaged() && !storageUtil.managedStoragePoolCanScale(pool, plan.getClusterId(), plan.getHostId())) {
352-
logger.debug(String.format("Cannot allocate pool [%s] to volume [%s] because the max number of managed clustered filesystems has been exceeded.", pool, volume));
342+
logger.debug("Cannot allocate pool [{}] to volume [{}] because the max number of managed clustered filesystems has been exceeded.", pool, volume);
353343
return false;
354344
}
355345

@@ -358,13 +348,13 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
358348
requestVolumeDiskProfilePairs.add(new Pair<>(volume, dskCh));
359349
if (dskCh.getHypervisorType() == HypervisorType.VMware) {
360350
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster && storageMgr.isStoragePoolDatastoreClusterParent(pool)) {
361-
logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is a parent datastore cluster.", pool, volume));
351+
logger.debug("Skipping allocation of pool [{}] to volume [{}] because this pool is a parent datastore cluster.", pool, volume);
362352
return false;
363353
}
364354
if (pool.getParent() != 0L) {
365355
StoragePoolVO datastoreCluster = storagePoolDao.findById(pool.getParent());
366356
if (datastoreCluster == null || (datastoreCluster != null && datastoreCluster.getStatus() != StoragePoolStatus.Up)) {
367-
logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is not in [%s] state.", datastoreCluster, volume, StoragePoolStatus.Up));
357+
logger.debug("Skipping allocation of pool [{}] to volume [{}] because this pool is not in [{}] state.", datastoreCluster, volume, StoragePoolStatus.Up);
368358
return false;
369359
}
370360
}
@@ -374,11 +364,11 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
374364
storageMgr.isStoragePoolCompliantWithStoragePolicy(dskCh.getDiskOfferingId(), pool) :
375365
storageMgr.isStoragePoolCompliantWithStoragePolicy(requestVolumeDiskProfilePairs, pool);
376366
if (!isStoragePoolStoragePolicyCompliance) {
377-
logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is not compliant with the storage policy required by the volume.", pool, volume));
367+
logger.debug("Skipping allocation of pool [{}] to volume [{}] because this pool is not compliant with the storage policy required by the volume.", pool, volume);
378368
return false;
379369
}
380370
} catch (StorageUnavailableException e) {
381-
logger.warn(String.format("Could not verify storage policy compliance against storage pool %s due to exception %s", pool.getUuid(), e.getMessage()));
371+
logger.warn("Could not verify storage policy compliance against storage pool [{}] due to exception [{}]", pool.getUuid(), e.getMessage());
382372
return false;
383373
}
384374
}
@@ -427,19 +417,19 @@ private boolean checkHypervisorCompatibility(HypervisorType hyperType, Volume.Ty
427417
protected void logDisabledStoragePools(long dcId, Long podId, Long clusterId, ScopeType scope) {
428418
List<StoragePoolVO> disabledPools = storagePoolDao.findDisabledPoolsByScope(dcId, podId, clusterId, scope);
429419
if (disabledPools != null && !disabledPools.isEmpty()) {
430-
logger.trace(String.format("Ignoring pools [%s] as they are in disabled state.", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(disabledPools)));
420+
logger.trace("Ignoring pools [{}] as they are in disabled state.", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(disabledPools));
431421
}
432422
}
433423

434424
protected void logStartOfSearch(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, int returnUpTo,
435425
boolean bypassStorageTypeCheck){
436-
logger.trace(String.format("%s is looking for storage pools that match the VM's disk profile [%s], virtual machine profile [%s] and "
437-
+ "deployment plan [%s]. Returning up to [%d] and bypassStorageTypeCheck [%s].", this.getClass().getSimpleName(), dskCh, vmProfile, plan, returnUpTo, bypassStorageTypeCheck));
426+
logger.trace("[{}] is looking for storage pools that match the VM's disk profile [{}], virtual machine profile [{}] and "
427+
+ "deployment plan [{}]. Returning up to [{}] and bypassStorageTypeCheck [{}].", this.getClass().getSimpleName(), dskCh, vmProfile, plan, returnUpTo, bypassStorageTypeCheck);
438428
}
439429

440430
protected void logEndOfSearch(List<StoragePool> storagePoolList) {
441-
logger.debug(String.format("%s is returning [%s] suitable storage pools [%s].", this.getClass().getSimpleName(), storagePoolList.size(),
442-
Arrays.toString(storagePoolList.toArray())));
431+
logger.debug("[{}] is returning [{}] suitable storage pools [{}].", this.getClass().getSimpleName(), storagePoolList.size(),
432+
Arrays.toString(storagePoolList.toArray()));
443433
}
444434

445435
}

0 commit comments

Comments
 (0)