Allon Mureinik has posted comments on this change.

Change subject: core: WIP : RemoveImageDisk - race when updating snapshots ovf 
(#828192)
......................................................................


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

(5 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveImageCommand.java
Line 112:                 VM vm = getVmForNonShareableDiskImage(diskImage);
Line 113:                 lockVmSnapshotsWithWait(vm);
Line 114:                 updatedSnapshots = 
prepareSnapshotConfigWithoutImage(diskImage.getId());
Line 115:             } else {
Line 116:                 updatedSnapshots = null;
optional: I'd use Collections.emptyList()
Line 117:             }
Line 118: 
Line 119:             
TransactionSupport.executeInScope(TransactionScopeOption.Required,
Line 120:                     new TransactionMethod<Object>() {


Line 143:                             }
Line 144: 
Line 145:                             
getBaseDiskDao().remove(diskImage.getId());
Line 146:                             getVmDeviceDAO().remove(new 
VmDeviceId(diskImage.getId(), null));
Line 147:                             if (updatedSnapshots != null) {
here, if the list was empty, you could have saved the if.
Line 148:                                 for (Snapshot s : updatedSnapshots) {
Line 149:                                     getSnapshotDao().update(s);
Line 150:                                 }
Line 151:                             }


Line 160:             }
Line 161:         }
Line 162:     }
Line 163: 
Line 164:     EngineLock snapshotsEngineLock = new EngineLock();
This should be private.
Line 165: 
Line 166:     private void lockVmSnapshotsWithWait(VM vm) {
Line 167:         Map<String, String> snapshotsExlusiveLockMap = new 
HashMap<String, String>();
Line 168:         snapshotsExlusiveLockMap.put(vm.getId().toString(), 
LockingGroup.VM_SNAPSHOTS.name());


Line 164:     EngineLock snapshotsEngineLock = new EngineLock();
Line 165: 
Line 166:     private void lockVmSnapshotsWithWait(VM vm) {
Line 167:         Map<String, String> snapshotsExlusiveLockMap = new 
HashMap<String, String>();
Line 168:         snapshotsExlusiveLockMap.put(vm.getId().toString(), 
LockingGroup.VM_SNAPSHOTS.name());
instead of new and put, use Collections.singletonMap - it's cleaner on the eyes
Line 169:         
snapshotsEngineLock.setExclusiveLocks(snapshotsExlusiveLockMap);
Line 170:         getLockManager().acquireLockWait(snapshotsEngineLock);
Line 171:     }
Line 172: 


Line 182:      */
Line 183:     private VM getVmForNonShareableDiskImage(DiskImage disk) {
Line 184:         if (!disk.isShareable()) {
Line 185:             List<VM> vms = getVmDAO().getVmsListForDisk(disk.getId());
Line 186:             if (vms != null && !vms.isEmpty()) {
"vms != null is redundent - the DAO ensures it will return an empty list if no 
vms are available
Line 187:                 return vms.get(0);
Line 188:             }
Line 189:         }
Line 190:         return null;


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iccb44f1aa9d204477955343167133849a4146753
Gerrit-PatchSet: 13
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Ayal Baron <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Liron Aravot <[email protected]>
Gerrit-Reviewer: Maor Lipchuk <[email protected]>
Gerrit-Reviewer: Michael Kublin <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to