Allon Mureinik has posted comments on this change.

Change subject: core: [WIP] extract general code from HibernateVmCommand
......................................................................


Patch Set 6: I would prefer that you didn't submit this

(3 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
Line 517:     }
Line 518: 
Line 519:     public static StorageDomain findStorageDomainForMemory(Guid 
storagePoolId, long sizeRequested) {
Line 520:         List<StorageDomain> domainsInPool = 
DbFacade.getInstance().getStorageDomainDao().getAllForStoragePool(storagePoolId);
Line 521:         if (domainsInPool.size() > 0) {
The if is redundant - if the list is empty, the for will just do nothing. No 
need to protect against it
Line 522:             for (StorageDomain currDomain : domainsInPool) {
Line 523:                 if 
((currDomain.getStorageDomainType().equals(StorageDomainType.Master)
Line 524:                         || 
currDomain.getStorageDomainType().equals(StorageDomainType.Data))
Line 525:                         && currDomain.getStatus() == 
StorageDomainStatus.Active


Line 520:         List<StorageDomain> domainsInPool = 
DbFacade.getInstance().getStorageDomainDao().getAllForStoragePool(storagePoolId);
Line 521:         if (domainsInPool.size() > 0) {
Line 522:             for (StorageDomain currDomain : domainsInPool) {
Line 523:                 if 
((currDomain.getStorageDomainType().equals(StorageDomainType.Master)
Line 524:                         || 
currDomain.getStorageDomainType().equals(StorageDomainType.Data))
Use currDomain.getStorageDoaminType().isData() - it covers both Data and Master 
domains
Line 525:                         && currDomain.getStatus() == 
StorageDomainStatus.Active
Line 526:                         && 
doesStorageDomainhaveSpaceForRequest(currDomain, sizeRequested)) {
Line 527:                     return currDomain;
Line 528:                 }


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
Line 1458:      * @return - Memory size for allocation in bytes.
Line 1459:      */
Line 1460:     @JsonIgnore
Line 1461:     public long getTotalMemorySizeInBytes() {
Line 1462:         return (long) (getVmMemSizeMb() + 200 + (64 * 
getNumOfMonitors())) * 1024 * 1024;
Might be a good idea to explain this calculation.

Also, note that you have an overflow issue here.
int+int and int*int return int - so if it overflows, you'll lose data, and the 
fact that you promote it to long afterwards cannot help you.
Just define all your literals as Long literals and you should be OK.
Line 1463:     }
Line 1464: 
Line 1465:     ///////////////////////////////////////////////
Line 1466:     /// Utility methods that check the VM state ///


--
To view, visit http://gerrit.ovirt.org/14290
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I15c4f3302d26eb5d161824f8bb19ecc5dd114a20
Gerrit-PatchSet: 6
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <aha...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Arik Hadas <aha...@redhat.com>
Gerrit-Reviewer: Liron Ar <lara...@redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofren...@redhat.com>
Gerrit-Reviewer: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to