Skip to content

Commit d42e5c5

Browse files
DaanHooglanddhslove
authored andcommitted
Merge branch '4.19'
1 parent 7b75e0c commit d42e5c5

File tree

13 files changed

+194
-200
lines changed

13 files changed

+194
-200
lines changed

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 35 additions & 36 deletions
Large diffs are not rendered by default.

framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protected void processQuotaBalanceForAccount(AccountVO accountVo, List<QuotaUsag
155155
.map(quotaUsageVO -> new Pair<>(quotaUsageVO.getStartDate(), quotaUsageVO.getEndDate()))
156156
.collect(Collectors.toCollection(LinkedHashSet::new));
157157

158-
logger.info(String.format("Processing quota balance for account[%s] between [%s] and [%s].", accountToString, startDate, lastQuotaUsageEndDate));
158+
logger.info(String.format("Processing quota balance for account[{}] between [{}] and [{}].", accountToString, startDate, lastQuotaUsageEndDate));
159159

160160
long accountId = accountVo.getAccountId();
161161
long domainId = accountVo.getDomainId();
@@ -215,7 +215,7 @@ protected BigDecimal retrieveBalanceForUsageCalculation(long accountId, long dom
215215
QuotaBalanceVO lastRealBalance = _quotaBalanceDao.findLastBalanceEntry(accountId, domainId, startDate);
216216

217217
if (lastRealBalance == null) {
218-
logger.warn(String.format("Account [%s] has quota usage entries, however it does not have a quota balance.", accountToString));
218+
logger.warn("Account [{}] has quota usage entries, however it does not have a quota balance.", accountToString);
219219
} else {
220220
accountBalance = accountBalance.add(lastRealBalance.getCreditBalance());
221221
}

plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.cloud.storage.VMTemplateVO;
4343
import com.cloud.utils.Pair;
4444
import com.cloud.utils.component.AdapterBase;
45-
import com.cloud.utils.exception.CloudRuntimeException;
4645
import com.cloud.vm.VirtualMachine;
4746
import com.cloud.vm.VirtualMachineProfile;
4847

@@ -87,6 +86,7 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
8786
Long podId = plan.getPodId();
8887
Long clusterId = plan.getClusterId();
8988
ServiceOffering offering = vmProfile.getServiceOffering();
89+
List<? extends Host> hostsCopy = null;
9090
List<Host> suitableHosts = new ArrayList<>();
9191

9292
if (type == Host.Type.Storage) {
@@ -105,7 +105,7 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
105105
}
106106
if (hosts != null) {
107107
// retain all computing hosts, regardless of whether they support routing...it's random after all
108-
hostsCopy = new ArrayList<Host>(hosts);
108+
hostsCopy = new ArrayList<>(hosts);
109109
if (ObjectUtils.anyNotNull(offeringHostTag, templateTag)) {
110110
hostsCopy.retainAll(listHostsByTags(type, dcId, podId, clusterId, offeringHostTag, templateTag));
111111
} else {
@@ -122,12 +122,12 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
122122
hostsCopy = ListUtils.union(hostsCopy, _hostDao.findHostsWithTagRuleThatMatchComputeOferringTags(offeringHostTag));
123123

124124
if (hostsCopy.isEmpty()) {
125-
logger.error(String.format("No suitable host found for vm [%s] with tags [%s].", vmProfile, hostTag));
126-
throw new CloudRuntimeException(String.format("No suitable host found for vm [%s].", vmProfile));
125+
logger.info("No suitable host found for VM [{}] in {}.", vmProfile, hostTag);
126+
return null;
127127
}
128128

129-
logger.debug("Random Allocator found " + hostsCopy.size() + " hosts");
130-
if (hostsCopy.size() == 0) {
129+
logger.debug("Random Allocator found {} hosts", hostsCopy.size());
130+
if (hostsCopy.isEmpty()) {
131131
return suitableHosts;
132132
}
133133

@@ -173,7 +173,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
173173
if (logger.isDebugEnabled()) {
174174
logger.debug("Random Allocator found 0 hosts as given host list is empty");
175175
}
176-
return new ArrayList<Host>();
176+
return new ArrayList<>();
177177
}
178178
return findSuitableHosts(vmProfile, plan, type, avoid, hosts, returnUpTo, considerReservedCapacity);
179179
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ protected void reconfigureProcessorByHandler(EnumMap<VmwareStorageProcessorConfi
782782
*/
783783
protected EnumMap<VmwareStorageProcessorConfigurableFields, Object> examineStorageSubSystemCommandFullCloneFlagForVmware(CopyCommand cmd,
784784
EnumMap<VmwareStorageProcessorConfigurableFields, Object> params) {
785-
EnumMap<VmwareStorageProcessorConfigurableFields, Object> paramsCopy = new EnumMap<VmwareStorageProcessorConfigurableFields, Object>(params);
785+
EnumMap<VmwareStorageProcessorConfigurableFields, Object> paramsCopy = new EnumMap<>(params);
786786
HypervisorType hypervisor = cmd.getDestTO().getHypervisorType();
787787
if (hypervisor != null && hypervisor.equals(HypervisorType.VMware)) {
788788
DataStoreTO destDataStore = cmd.getDestTO().getDataStore();

server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
134134
logger.info(" Guest VM is requested with Custom[TPM] version "+ isVMDeployedWithTpm);
135135
if (type == Host.Type.Storage) {
136136
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of routing or not
137-
return new ArrayList<Host>();
137+
return new ArrayList<>();
138138
}
139139

140140
logger.debug("Looking for hosts in zone [{}], pod [{}], cluster [{}]", dcId, podId, clusterId);
@@ -147,8 +147,8 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
147147
boolean hasSvcOfferingTag = hostTagOnOffering != null ? true : false;
148148
boolean hasTemplateTag = hostTagOnTemplate != null ? true : false;
149149

150-
List<HostVO> clusterHosts = new ArrayList<HostVO>();
151-
List<HostVO> hostsMatchingUefiTag = new ArrayList<HostVO>();
150+
List<HostVO> clusterHosts = new ArrayList<>();
151+
List<HostVO> hostsMatchingUefiTag = new ArrayList<>();
152152
if(isVMDeployedWithUefi){
153153
hostsMatchingUefiTag = _hostDao.listByHostCapability(type, clusterId, podId, dcId, Host.HOST_UEFI_ENABLE);
154154
if (logger.isDebugEnabled()) {
@@ -171,8 +171,8 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
171171
if (hostTagOnOffering == null && hostTagOnTemplate == null) {
172172
clusterHosts = _resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId);
173173
} else {
174-
List<HostVO> hostsMatchingOfferingTag = new ArrayList<HostVO>();
175-
List<HostVO> hostsMatchingTemplateTag = new ArrayList<HostVO>();
174+
List<HostVO> hostsMatchingOfferingTag = new ArrayList<>();
175+
List<HostVO> hostsMatchingTemplateTag = new ArrayList<>();
176176
if (hasSvcOfferingTag) {
177177
if (logger.isDebugEnabled()) {
178178
logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering);
@@ -220,7 +220,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
220220

221221

222222
if (clusterHosts.isEmpty()) {
223-
logger.error(String.format("No suitable host found for vm [%s] with tags [%s].", vmProfile, hostTagOnOffering));
223+
logger.error("No suitable host found for vm [{}] with tags [{}].", vmProfile, hostTagOnOffering);
224224
throw new CloudRuntimeException(String.format("No suitable host found for vm [%s].", vmProfile));
225225
}
226226
// add all hosts that we are not considering to the avoid list
@@ -246,8 +246,8 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
246246
ServiceOffering offering = vmProfile.getServiceOffering();
247247
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
248248
Account account = vmProfile.getOwner();
249-
List<Host> suitableHosts = new ArrayList<Host>();
250-
List<Host> hostsCopy = new ArrayList<Host>(hosts);
249+
List<Host> suitableHosts = new ArrayList<>();
250+
List<Host> hostsCopy = new ArrayList<>(hosts);
251251

252252
if (type == Host.Type.Storage) {
253253
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of
@@ -329,7 +329,7 @@ protected List<Host> allocateTo(DeploymentPlan plan, ServiceOffering offering, V
329329
}
330330

331331
long serviceOfferingId = offering.getId();
332-
List<Host> suitableHosts = new ArrayList<Host>();
332+
List<Host> suitableHosts = new ArrayList<>();
333333
ServiceOfferingDetailsVO offeringDetails = null;
334334

335335
for (Host host : hosts) {
@@ -398,15 +398,15 @@ private List<? extends Host> reorderHostsByCapacity(DeploymentPlan plan, List<?
398398
}
399399

400400
//now filter the given list of Hosts by this ordered list
401-
Map<Long, Host> hostMap = new HashMap<Long, Host>();
401+
Map<Long, Host> hostMap = new HashMap<>();
402402
for (Host host : hosts) {
403403
hostMap.put(host.getId(), host);
404404
}
405-
List<Long> matchingHostIds = new ArrayList<Long>(hostMap.keySet());
405+
List<Long> matchingHostIds = new ArrayList<>(hostMap.keySet());
406406

407407
hostIdsByFreeCapacity.retainAll(matchingHostIds);
408408

409-
List<Host> reorderedHosts = new ArrayList<Host>();
409+
List<Host> reorderedHosts = new ArrayList<>();
410410
for(Long id: hostIdsByFreeCapacity){
411411
reorderedHosts.add(hostMap.get(id));
412412
}
@@ -428,15 +428,15 @@ private List<? extends Host> reorderHostsByNumberOfVms(DeploymentPlan plan, List
428428
}
429429

430430
//now filter the given list of Hosts by this ordered list
431-
Map<Long, Host> hostMap = new HashMap<Long, Host>();
431+
Map<Long, Host> hostMap = new HashMap<>();
432432
for (Host host : hosts) {
433433
hostMap.put(host.getId(), host);
434434
}
435-
List<Long> matchingHostIds = new ArrayList<Long>(hostMap.keySet());
435+
List<Long> matchingHostIds = new ArrayList<>(hostMap.keySet());
436436

437437
hostIdsByVmCount.retainAll(matchingHostIds);
438438

439-
List<Host> reorderedHosts = new ArrayList<Host>();
439+
List<Host> reorderedHosts = new ArrayList<>();
440440
for (Long id : hostIdsByVmCount) {
441441
reorderedHosts.add(hostMap.get(id));
442442
}
@@ -459,11 +459,11 @@ protected List<? extends Host> prioritizeHosts(VMTemplateVO template, ServiceOff
459459
// Determine the guest OS category of the template
460460
String templateGuestOSCategory = getTemplateGuestOSCategory(template);
461461

462-
List<Host> prioritizedHosts = new ArrayList<Host>();
463-
List<Host> noHvmHosts = new ArrayList<Host>();
462+
List<Host> prioritizedHosts = new ArrayList<>();
463+
List<Host> noHvmHosts = new ArrayList<>();
464464

465465
// If a template requires HVM and a host doesn't support HVM, remove it from consideration
466-
List<Host> hostsToCheck = new ArrayList<Host>();
466+
List<Host> hostsToCheck = new ArrayList<>();
467467
if (template.isRequiresHvm()) {
468468
for (Host host : hosts) {
469469
if (hostSupportsHVM(host)) {
@@ -483,8 +483,8 @@ protected List<? extends Host> prioritizeHosts(VMTemplateVO template, ServiceOff
483483
}
484484
// If a host is tagged with the same guest OS category as the template, move it to a high priority list
485485
// If a host is tagged with a different guest OS category than the template, move it to a low priority list
486-
List<Host> highPriorityHosts = new ArrayList<Host>();
487-
List<Host> lowPriorityHosts = new ArrayList<Host>();
486+
List<Host> highPriorityHosts = new ArrayList<>();
487+
List<Host> lowPriorityHosts = new ArrayList<>();
488488
for (Host host : hostsToCheck) {
489489
String hostGuestOSCategory = getHostGuestOSCategory(host);
490490
if (hostGuestOSCategory == null) {
@@ -517,7 +517,7 @@ protected List<? extends Host> prioritizeHosts(VMTemplateVO template, ServiceOff
517517
// if service offering is not GPU enabled then move all the GPU enabled hosts to the end of priority list.
518518
if (_serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString()) == null) {
519519

520-
List<Host> gpuEnabledHosts = new ArrayList<Host>();
520+
List<Host> gpuEnabledHosts = new ArrayList<>();
521521
// Check for GPU enabled hosts.
522522
for (Host host : prioritizedHosts) {
523523
if (_resourceMgr.isHostGpuEnabled(host.getId())) {

0 commit comments

Comments
 (0)