mooli tayer has posted comments on this change. Change subject: engine: Add infrastructure code for removal of parameter classes ......................................................................
Patch Set 5: (5 comments) .................................................... Commit Message Line 9: Adds the infrastructure code that is Line 10: needed by subsequent patches to remove Line 11: dependency on parameter classes. Line 12: Line 13: A new map Map<String, Object> we have a Map<Guid, VdcParameterValue> Where VdcParameterValue is a pair of VdcParameter and a Type T. VdcParameter has a name, a class<T> type and Guid. Comparing old parameter classes to try and understand the change I saw for example (in AddVmToPoolParameters) one parameter: Guid _vmId; so we have an object that we identify according to a name and we have a guid for it. in other cases (WatchdogParameters) we simply hold a guid called `id` so it's identified by context and other special types (e.g VmWatchdogAction). Let's say we have a Map<String,Object> Then in each command class we keep strings in an agreed form for example: String SOURCE_VM_GUID = 'source_vm_guid' this gives us context. now we can use same generic methods like those introduced here: parameters.get(MigrationCommand.SOURCE_VM_GUID, Guid.class) (this is generic so it will return Guid) and parameters.put(MigrationCommand.SOURCE_VM_GUID, new Guid("asd342...")) Line 14: has been added to VdcQueryParametersBase. This map contains Line 15: all the parameters required for the execution of the Line 16: query. Eliminating the need for a specific QueryParameter Line 17: class. .................................................... File backend/manager/modules/common/pom.xml Line 49: <dependency> Line 50: <groupId>org.springframework</groupId> Line 51: <artifactId>spring-core</artifactId> Line 52: <version>3.2.4.RELEASE</version> Line 53: <type>jar</type> I believe this is the default, so it can be omitted. Line 54: </dependency> Line 55: </dependencies> Line 56: Line 57: <build> .................................................... File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionParametersBase.java Line 158: } Line 159: Line 160: public void setParentParameters(VdcActionParametersBase parameters) { Line 161: parentParameters = parameters; Line 162: } iiuc the idea is to do this change iteratively so you don't want to remove functions used by commands we haven't changed yet. Line 163: Line 164: public boolean getMultipleAction() { Line 165: return multipleAction; Line 166: } .................................................... File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VdcParameter.java Line 7: Line 8: public class VdcParameter<T> implements Serializable { Line 9: Line 10: private String name; Line 11: private Class<T> javaType; We should always use generic classes so the compiler can understand generic method invocations. This compiles: Class<X> clazz = X.class; X x = X.newInstance(); And this does not : Class clazz = X.class; X x = X.newInstance(); Line 12: private Guid guid; Line 13: private static final List<Guid> guidsList = new ArrayList<Guid>(); Line 14: Line 15: /** Line 9: Line 10: private String name; Line 11: private Class<T> javaType; Line 12: private Guid guid; Line 13: private static final List<Guid> guidsList = new ArrayList<Guid>(); There is a bug here - guids are never removed after command compeletion. If you assume not to meet a guid twice then the list is redundant. HashMap for performance - you don't want to iterate all you objects when you add a new one. Can you say where they are created? I am curious because this duplicate validations is new, maybe we currently have a bug? Line 14: Line 15: /** Line 16: * Needed by Json Serialization/Deserialization Line 17: */ -- To view, visit http://gerrit.ovirt.org/20414 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6a0970e492c0eff561888a46b02e47645ff68fc3 Gerrit-PatchSet: 5 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com> Gerrit-Reviewer: Barak Azulay <bazu...@redhat.com> Gerrit-Reviewer: Liran Zelkha <liran.zel...@gmail.com> Gerrit-Reviewer: Ravi Nori <rn...@redhat.com> Gerrit-Reviewer: Yaniv Bronhaim <ybron...@redhat.com> Gerrit-Reviewer: mooli tayer <mta...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches