Mike Kolesnik has posted comments on this change.

Change subject: core: add NetworkLinking to UpdateVmInterfaceCommand
......................................................................


Patch Set 14: (13 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmInterfaceCommand.java
Line 42:     private VmDevice oldVmDevice;
Line 43:     private boolean macAddressChanged;
Line 44:     private VdsAction requiredVdsAction = null;
Line 45: 
Line 46:     private enum VdsAction {
By convention, Inner types go at end of class
Line 47:         plug,
Line 48:         unplug,
Line 49:         unplugPlug,
Line 50:         update


Line 43:     private boolean macAddressChanged;
Line 44:     private VdsAction requiredVdsAction = null;
Line 45: 
Line 46:     private enum VdsAction {
Line 47:         plug,
Enum members should be all CAPS
Line 48:         unplug,
Line 49:         unplugPlug,
Line 50:         update
Line 51:     }


Line 51:     }
Line 52: 
Line 53:     public UpdateVmInterfaceCommand(T parameters) {
Line 54:         super(parameters);
Line 55:         setVmId(parameters.getVmId());
If you set it here. please replace references to the vmId from the parameters 
with getVmId()
Line 56:         if (getVm().getStatus() == VMStatus.Up) {
Line 57:             setVdsId(getVm().getRunOnVds().getValue());
Line 58:         }
Line 59:     }


Line 52: 
Line 53:     public UpdateVmInterfaceCommand(T parameters) {
Line 54:         super(parameters);
Line 55:         setVmId(parameters.getVmId());
Line 56:         if (getVm().getStatus() == VMStatus.Up) {
Why is this logic in ctor? There will always be a db call even if the vdsId 
field is not used
Line 57:             setVdsId(getVm().getRunOnVds().getValue());
Line 58:         }
Line 59:     }
Line 60: 


Line 57:             setVdsId(getVm().getRunOnVds().getValue());
Line 58:         }
Line 59:     }
Line 60: 
Line 61:     private VmNetworkInterface getInterface() {
Please replace all calls of getParameters().getInterface() to call this method
Line 62:         return getParameters().getInterface();
Line 63:     }
Line 64: 
Line 65:     public String getInterfaceName() {


Line 113:                                 getVm(),
Line 114:                                 
getVmNetworkInterfaceDao().get(getInterface().getId()),
Line 115:                                 oldVmDevice));
Line 116:             }
Line 117:             }
Why is there no handling for unplugPlug (or alternatively default) case?
Line 118:         }
Line 119:         return true;
Line 120:     }
Line 121: 


Line 120:     }
Line 121: 
Line 122:     private boolean isProperiesRequireVmUpdateDeviceWereUpdated() {
Line 123:         return (!StringUtils.equals(oldIface.getNetworkName(),
Line 124:                 getInterface().getNetworkName()) || 
oldIface.isLinked() != getInterface().isLinked());
Why not use getNetworkName() method?
Line 125:     }
Line 126: 
Line 127:     private boolean isPropertiesRequireUnplugPlugWereUpdated() {
Line 128:         // Type was updated


Line 123:         return (!StringUtils.equals(oldIface.getNetworkName(),
Line 124:                 getInterface().getNetworkName()) || 
oldIface.isLinked() != getInterface().isLinked());
Line 125:     }
Line 126: 
Line 127:     private boolean isPropertiesRequireUnplugPlugWereUpdated() {
This method can be represented as a single return statement..

The comments aren't really helpful, they just say what is already visible from 
the code.
Line 128:         // Type was updated
Line 129:         if (!oldIface.getType().equals(getInterface().getType())) {
Line 130:             return true;
Line 131:         }


Line 139:         }
Line 140:         return false;
Line 141:     }
Line 142: 
Line 143:     private VdsAction getRequiredVdsAction() {
The comments aren't really helpful as they just say what is already visible in 
the code
Line 144: 
Line 145:         if (requiredVdsAction == null) {
Line 146:             if (getVm().getStatus() == VMStatus.Up) {
Line 147:                 // plug


Line 142: 
Line 143:     private VdsAction getRequiredVdsAction() {
Line 144: 
Line 145:         if (requiredVdsAction == null) {
Line 146:             if (getVm().getStatus() == VMStatus.Up) {
This if can be joined with the one above using &&
Line 147:                 // plug
Line 148:                 if (!oldIface.isActive() && 
getInterface().isActive()) {
Line 149:                     requiredVdsAction = VdsAction.plug;
Line 150:                 }


Line 243: 
Line 244:         boolean linkingSupported =
Line 245:                 Config.<Boolean> 
GetValue(ConfigValues.NetworkLinkingSupported,
Line 246:                         getVm().getVdsGroupCompatibilityVersion().
Line 247:                                 getValue());
Why is this in new line always?
Line 248: 
Line 249:         if (!linkingSupported) {
Line 250:             if (!getInterface().isLinked()) {
Line 251:                 
addCanDoActionMessage(VdcBllMessages.UNLINKING_IS_NOT_SUPPORTED);


Line 270:                                 getValue()));
Line 271:                 return false;
Line 272:             }
Line 273:         } else {
Line 274:             if (getRequiredVdsAction() == VdsAction.update) {
You don't have to nest the if, and could instead have an 'else if'
Line 275:                 if (getInterface().isPortMirroring()) {
Line 276:                     
addCanDoActionMessage(VdcBllMessages.CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING);
Line 277:                     return false;
Line 278:                 }


Line 271:                 return false;
Line 272:             }
Line 273:         } else {
Line 274:             if (getRequiredVdsAction() == VdsAction.update) {
Line 275:                 if (getInterface().isPortMirroring()) {
You don't have to nest the internal if, and could instead use &&
Line 276:                     
addCanDoActionMessage(VdcBllMessages.CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING);
Line 277:                     return false;
Line 278:                 }
Line 279:             }


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0ea914badc716f2908f45c020b53ced423ed23ec
Gerrit-PatchSet: 14
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alona Kaplan <alkap...@redhat.com>
Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com>
Gerrit-Reviewer: Mike Kolesnik <mkole...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to