Allon Mureinik has posted comments on this change.

Change subject: core: Disk hotplug validation - Patch 1 of 2
......................................................................


Patch Set 5:

(6 comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java
Line 187:             
diskInterfaces.add(DiskInterface.valueOf(diskHotpluggableInterface));
Line 188:         }
Line 189:         if (!diskInterfaces.contains(disk.getDiskInterface())) {
Line 190:             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED);
Line 191:         }
would it be easier to replace this for and if blocks with something like

diskHotpluggableInterfaces.contains(disk.getInterface().toString())

It would certainly be faster
Line 192: 
Line 193:         return true;
Line 194:     }
Line 195: 


....................................................
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommandTest.java
Line 57:     protected Guid vmId = Guid.newGuid();
Line 58:     private final Guid storagePoolId = Guid.newGuid();
Line 59:     private final Guid storageDomainId = Guid.newGuid();
Line 60:     protected static final ArrayList<String> 
DISK_HOTPLUGGABLE_INTERFACES = new ArrayList<String>(
Line 61:             Arrays.asList("VirtIO_SCSI", "VirtIO"));
Why do you need an ArrayList here?
Arrays.asList returns an immutable List, which fits your needs better, IIUC.

Also, why is this not private?
Line 62: 
Line 63:     @ClassRule
Line 64:     public static final MockConfigRule mcr = new MockConfigRule(
Line 65:             mockConfig(ConfigValues.HotPlugUnsupportedOsList, 
"RHEL3x64"),


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepositoryImpl.java
Line 100:     @Override
Line 101:     public Map<Pair<Integer, Version>, ArrayList<String>> 
getDiskHotpluggableInterfacesMap() {
Line 102: 
Line 103:         List<Version> versions =
Line 104:                 new ArrayList<Version>(Config.<HashSet<Version>> 
GetValue(ConfigValues.SupportedClusterLevels));
why do you need to convert this to a List?
Why not just iterate the given Set?
Line 105:         Map<Pair<Integer, Version>, ArrayList<String>> 
diskHotpluggableInterfacesMap =
Line 106:                 new HashMap<Pair<Integer, Version>, 
ArrayList<String>>();
Line 107: 
Line 108:         for (Integer osId : getOsIds()) {


Line 102: 
Line 103:         List<Version> versions =
Line 104:                 new ArrayList<Version>(Config.<HashSet<Version>> 
GetValue(ConfigValues.SupportedClusterLevels));
Line 105:         Map<Pair<Integer, Version>, ArrayList<String>> 
diskHotpluggableInterfacesMap =
Line 106:                 new HashMap<Pair<Integer, Version>, 
ArrayList<String>>();
same here - why isn't this Map<Pair<Integer, Version>, Set<String>> ?
Line 107: 
Line 108:         for (Integer osId : getOsIds()) {
Line 109:             for (Version version : versions) {
Line 110:                 diskHotpluggableInterfacesMap.put(


Line 167:     @Override
Line 168:     public ArrayList<String> getNetworkDevices(int osId, Version 
version) {
Line 169:         String devices =
Line 170:                 getValueByVersion(idToUnameLookup.get(osId), 
"devices.network", version);
Line 171:         return trimElements(devices.split(","));
nice improvement, not sure it's relevant to THIS patch.
Line 172:     }
Line 173: 
Line 174:     @Override
Line 175:     public ArrayList<String> getDiskHotpluggableInterfaces(int osId, 
Version version) {


Line 336:     private ArrayList<String> trimElements(String... elements) {
Line 337:         ArrayList<String> list = new 
ArrayList<String>(elements.length);
Line 338:         for (String e : elements) {
Line 339:             e = e.trim();
Line 340:             if (!StringHelper.isNullOrEmpty(e)) {
e.trim() can NEVER be null, so you just need to check if (e.length() > 0), 
allowing you to drop the StringHelper dependency.
Line 341:                 list.add(e);
Line 342:             }
Line 343:         }
Line 344:         return list;


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic2e4c792b607429daf077c11820b43f171d376b7
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gustavo Frederico Temple Pedrosa <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Frank Kobzik <[email protected]>
Gerrit-Reviewer: Gustavo Frederico Temple Pedrosa 
<[email protected]>
Gerrit-Reviewer: Itamar Heim <[email protected]>
Gerrit-Reviewer: Leonardo Bianconi <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
Gerrit-Reviewer: Sergey Gotliv <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Tomas Jelinek <[email protected]>
Gerrit-Reviewer: Vitor de Lima <[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