@@ -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