Alissa Bonas has posted comments on this change.

Change subject: core: add the image block alignment scan
......................................................................


Patch Set 5: (10 inline comments)

....................................................
File backend/manager/dbscripts/upgrade/03_02_0480_base_disks_alignment.sql
Line 1: select fn_db_add_column('base_disks', 'alignment', 'smallint default 
0');
Line 2: select fn_db_add_column('base_disks', 'last_alignment_scan', 'timestamp 
with time zone');
Line 3: insert into action_version_map values (231, '3.3', '*');
pls pay attention that script name is 3.2 , while here you insert values 3.3


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ScanDiskAlignmentCommand.java
Line 82:             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DISK_NOT_EXIST);
Line 83:         }
Line 84: 
Line 85:         if (getDiskType() == DiskStorageType.IMAGE) {
Line 86:             if (((DiskImage) getDisk()).getImageStatus() != 
ImageStatus.OK) {
why the second nested "if" is not just part of the upper "if" (the one that 
checks type) with a && condition between them?
And is it safe to cast it here to DiskImage? What if the casting fails?
Line 87:                 return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DISKS_LOCKED);
Line 88:             }
Line 89:         }
Line 90: 


Line 99:         if (getVdsIdInPool() == null) {
Line 100:             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL);
Line 101:         }
Line 102: 
Line 103:         if (!validate(new 
StoragePoolValidator(getStoragePoolDao().get(getStoragePoolId())).isUp())) {
isn't  an error message missing here? what will be displayed to user in this 
case?
Line 104:             return false;
Line 105:         }
Line 106: 
Line 107:         return true;


Line 134:             lunParameters.setLunGuid(lunDisk.getLun().getLUN_id());
Line 135: 
Line 136:             parameters = lunParameters;
Line 137:         } else {
Line 138:             throw new RuntimeException("Unknown DiskStorageType " + 
getDiskType().toString());
why isn't the disk type check taken care of in canDoAction? so executeCommand 
should not be concerned about this check?
and while at it - is this exception logged somewhere? Also, perhaps consider 
adding to the exception the disk id? otherwise it's too generic and not 
explaining where is the problem.
Line 139:         }
Line 140: 
Line 141:         Boolean isDiskAligned = (Boolean) runVdsCommand(
Line 142:                 VDSCommandType.ScanDiskAlignment, 
parameters).getReturnValue();


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskAlignment.java
Line 12: 
Line 13:     private int intValue;
Line 14:     final private static Map<Integer, DiskAlignment> mappings;
Line 15: 
Line 16:     static {
not very recommended to have static init blocks. Here the logic is not very 
complicated, but in general keep in mind that having a potential exception in 
such block is very hard to detect, and can harm the classloading process.
Line 17:         mappings = new HashMap<Integer, DiskAlignment>();
Line 18: 
Line 19:         for (DiskAlignment enumValue : values()) {
Line 20:             mappings.put(enumValue.getValue(), enumValue);


Line 28:     public int getValue() {
Line 29:         return intValue;
Line 30:     }
Line 31: 
Line 32:     public static DiskAlignment forValue(int value) {
not a very standard name, and not clear what this method does. (what is 
forValue?)
it better be getXYZ
Line 33:         return mappings.get(value);
Line 34:     }


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AbstractBaseDiskRowMapper.java
Line 31:         if (!StringUtils.isEmpty(propagateErrors)) {
Line 32:             
disk.setPropagateErrors(PropagateErrors.valueOf(propagateErrors));
Line 33:         }
Line 34: 
Line 35:         disk.setShareable(rs.getBoolean("shareable"));
Isn't there somewhere constants for the properties names such as disk_id, 
disk_alias, etc? (I don't know )
If yes - it's better to move using them
Line 36:         disk.setBoot(rs.getBoolean("boot"));
Line 37:         
disk.setAlignment(DiskAlignment.forValue(rs.getInt("alignment")));
Line 38:         
disk.setLastAlignmentScan(DbFacadeUtils.fromDate(rs.getTimestamp("last_alignment_scan")));
Line 39: 


....................................................
File 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/AlignmentScanReturnForXmlRpc.java
Line 4: 
Line 5: import org.ovirt.engine.core.vdsbroker.irsbroker.StatusReturnForXmlRpc;
Line 6: 
Line 7: public final class AlignmentScanReturnForXmlRpc extends 
StatusReturnForXmlRpc {
Line 8:     private static final String ALIGNMENT = "alignment";
the name itself of the constant should reflect what it does - is it a key? a 
category?
otherwise it looks a bit strange "alignment=alignment"
Line 9: 
Line 10:     private Map<String, Object> mAlignment;
Line 11: 
Line 12:     public AlignmentScanReturnForXmlRpc(Map<String, Object> innerMap) {


Line 6: 
Line 7: public final class AlignmentScanReturnForXmlRpc extends 
StatusReturnForXmlRpc {
Line 8:     private static final String ALIGNMENT = "alignment";
Line 9: 
Line 10:     private Map<String, Object> mAlignment;
the first "m" - if it represents "member" , it's not standard in java.
The member's name is not very clear , it should reflect what it contains.
Line 11: 
Line 12:     public AlignmentScanReturnForXmlRpc(Map<String, Object> innerMap) {
Line 13:         super(innerMap);
Line 14:         mAlignment = (Map<String, Object>) innerMap.get(ALIGNMENT);


....................................................
File 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ScanDiskAlignmentVDSCommand.java
Line 2: 
Line 3: import 
org.ovirt.engine.core.common.vdscommands.ScanDiskAlignmentVDSCommandParameters;
Line 4: 
Line 5: public class ScanDiskAlignmentVDSCommand<P extends 
ScanDiskAlignmentVDSCommandParameters> extends VdsBrokerCommand<P> {
Line 6:     private AlignmentScanReturnForXmlRpc mDiskAlignment;
The name of the member is not very clear.
Also, if the first letter "m" stands for "member" - this is not per java 
standard, so it's redundant.
Line 7: 
Line 8:     public ScanDiskAlignmentVDSCommand(P parameters) {
Line 9:         super(parameters);
Line 10:     }


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I4858b7bbfa453230fcafecfbc5358c715d5d825b
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimo...@redhat.com>
Gerrit-Reviewer: Alissa Bonas <abo...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimo...@redhat.com>
Gerrit-Reviewer: Liron Ar <lara...@redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to