Daniel Erez has posted comments on this change.

Change subject: webadmin: MoveOrCopyDiskModel: postInitStorageDomains 
refactoring.
......................................................................


Patch Set 3:

(6 comments)

http://gerrit.ovirt.org/#/c/36555/3/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/MoveOrCopyDiskModel.java
File 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/MoveOrCopyDiskModel.java:

Line 207:         postCopyOrMoveInit();
Line 208:     }
Line 209: 
Line 210:     private ArrayList<StorageDomain> 
getDestinationDomains(ArrayList<StorageDomain> activeStorageDomains,
Line 211:             ArrayList<StorageDomain> sourceStorageDomainsToExclude, 
DiskModel diskModel, boolean isDiskBasedOnTemplate) {
hmm, 'sourceStorageDomainsToExclude' is a bit confusing naming as we pass here 
the entire set of source domains.. maybe 'sourceActiveStorageDomains'?
Line 212: 
Line 213:         boolean shouldFilterBySourceType = 
isFilterDestinationDomainsBySourceType(diskModel);
Line 214:         DiskImage diskImage = ((DiskImage) diskModel.getDisk());
Line 215: 


Line 210:     private ArrayList<StorageDomain> 
getDestinationDomains(ArrayList<StorageDomain> activeStorageDomains,
Line 211:             ArrayList<StorageDomain> sourceStorageDomainsToExclude, 
DiskModel diskModel, boolean isDiskBasedOnTemplate) {
Line 212: 
Line 213:         boolean shouldFilterBySourceType = 
isFilterDestinationDomainsBySourceType(diskModel);
Line 214:         DiskImage diskImage = ((DiskImage) diskModel.getDisk());
do we ensure the disk is a DiskImage before invoking the method?
Line 215: 
Line 216:         DiskModel templateDisk = null;
Line 217:         if (isDiskBasedOnTemplate) {
Line 218:             templateDisk = getTemplateDiskByVmDisk(diskModel);


Line 218:             templateDisk = getTemplateDiskByVmDisk(diskModel);
Line 219:         }
Line 220: 
Line 221:         ArrayList<StorageDomain> destinationDomains = new 
ArrayList<>();
Line 222:         for (StorageDomain sd : activeStorageDomains ) {
formatter
Line 223:             // Storage domain destination should not be a domain 
which the disk is attached to.
Line 224:             if (!sourceStorageDomainsToExclude.contains(sd)) {
Line 225:                 // Destination should be in the same pool as the disk.
Line 226:                 boolean connectedToSamePool = 
sd.getStoragePoolId().equals(diskImage.getStoragePoolId());


Line 224:             if (!sourceStorageDomainsToExclude.contains(sd)) {
Line 225:                 // Destination should be in the same pool as the disk.
Line 226:                 boolean connectedToSamePool = 
sd.getStoragePoolId().equals(diskImage.getStoragePoolId());
Line 227: 
Line 228:                 if (connectedToSamePool) {
for readability, consider 'continue' here. i.e. if (!connectedToSamePool) { 
continue; }
Line 229:                     boolean hasSameSubType = 
sd.getStorageType().getStorageSubtype() == 
diskImage.getStorageTypes().get(0).getStorageSubtype();
Line 230: 
Line 231:                     if (!shouldFilterBySourceType || 
(shouldFilterBySourceType && hasSameSubType)) {
Line 232:                         boolean isDomainValidForDiskTemplate = true;


Line 228:                 if (connectedToSamePool) {
Line 229:                     boolean hasSameSubType = 
sd.getStorageType().getStorageSubtype() == 
diskImage.getStorageTypes().get(0).getStorageSubtype();
Line 230: 
Line 231:                     if (!shouldFilterBySourceType || 
(shouldFilterBySourceType && hasSameSubType)) {
Line 232:                         boolean isDomainValidForDiskTemplate = true;
try to extract this logic to another method, might be ab clearer to read..
Line 233:                         if ( templateDisk != null ) {
Line 234:                             isDomainValidForDiskTemplate = 
((DiskImage) templateDisk.getDisk()).getStorageIds().contains(sd.getId());
Line 235:                         }
Line 236: 


Line 229:                     boolean hasSameSubType = 
sd.getStorageType().getStorageSubtype() == 
diskImage.getStorageTypes().get(0).getStorageSubtype();
Line 230: 
Line 231:                     if (!shouldFilterBySourceType || 
(shouldFilterBySourceType && hasSameSubType)) {
Line 232:                         boolean isDomainValidForDiskTemplate = true;
Line 233:                         if ( templateDisk != null ) {
formatter
Line 234:                             isDomainValidForDiskTemplate = 
((DiskImage) templateDisk.getDisk()).getStorageIds().contains(sd.getId());
Line 235:                         }
Line 236: 
Line 237:                         if (isDomainValidForDiskTemplate) {


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I7538a341c3a7059b0a6ee369ca1a9b33648df456
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Amit Aviram <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Amit Aviram <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to