Allon Mureinik has posted comments on this change. Change subject: exporting OvfDataUpdater logic to commands ......................................................................
Patch Set 2: (12 comments) http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OvfDataUpdater.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OvfDataUpdater.java: Line 73: log.infoFormat("Attempting to update ovfs in domain in Data Center {0}", Line 74: pool.getName()); Line 75: Line 76: Set<Guid> domainsToUpdate = (Set<Guid>) returnValueBase.getActionReturnValue(); Line 77: if (domainsToUpdate != null) { when can this be null? Line 78: for (Guid id : domainsToUpdate) { Line 79: performOvfUpdateForDomain(pool.getId(), id); Line 80: } Line 81: } http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OvfUpdateProcessHelper.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OvfUpdateProcessHelper.java: Line 36: * Adds the given vm metadata to the given map Line 37: */ Line 38: protected String buildMetadataDictionaryForVm(VM vm, Line 39: Map<Guid, KeyValuePairCompat<String, List<Guid>>> metaDictionary, Line 40: ArrayList<DiskImage> allVmImages) { 1. This doesn't look like engine's code-style wrt indentation 2. Why pass an ArrayList and not a List (or Collection, for that matter) Line 41: String vmMeta = generateVmMetadata(vm, allVmImages); Line 42: metaDictionary.put( Line 43: vm.getId(), Line 44: new KeyValuePairCompat<String, List<Guid>>(vmMeta, LinqUtils.transformToList(vm.getDiskMap().values(), Line 67: @Override Line 68: public Guid eval(DiskImage diskImage) { Line 69: return diskImage.getId(); Line 70: } Line 71: }))); This is the second time you repeat the same function - please extract it to a static inner class. Line 72: return templateMeta; Line 73: } Line 74: Line 75: /** Line 94: return ImagesHandler.getAllImageSnapshots(diskImage.getImageId()); Line 95: } Line 96: Line 97: Line 98: protected ArrayList<DiskImage> getVmImagesFromDb(VM vm) { Why return an ArrayList and not a List (or Collection, for that matter)? Line 99: ArrayList<DiskImage> allVmImages = new ArrayList<>(); Line 100: List<DiskImage> filteredDisks = ImagesHandler.filterImageDisks(vm.getDiskList(), false, true, true); Line 101: Line 102: for (DiskImage diskImage : filteredDisks) { Line 148: * Update the information contained in the given meta dictionary table in the given storage pool/storage domain. Line 149: */ Line 150: protected boolean executeUpdateVmInSpmCommand(Guid storagePoolId, Line 151: Map<Guid, KeyValuePairCompat<String, List<Guid>>> metaDictionary, Line 152: Guid storageDomainId) { formatting? Line 153: UpdateVMVDSCommandParameters tempVar = new UpdateVMVDSCommandParameters(storagePoolId, metaDictionary); Line 154: tempVar.setStorageDomainId(storageDomainId); Line 155: return Backend.getInstance().getResourceManager().RunVdsCommand(VDSCommandType.UpdateVM, tempVar) Line 156: .getSucceeded(); http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessDownVmCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessDownVmCommand.java: Line 107 Line 108 Line 109 Line 110 Line 111 What does this have to do with the patch? http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStoragePoolCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStoragePoolCommand.java: Line 62: return ovfUpdateProcessHelper; Line 63: } Line 64: Line 65: protected int loadConfigValue() { Line 66: return Config.<Integer> getValue(ConfigValues.OvfItemsCountPerUpdate); Why is this needed? And if it is, can we have a better name than loadXYZ Line 67: } Line 68: Line 69: @Override Line 70: protected void executeCommand() { http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStoragePoolCommandTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ProcessOvfUpdateForStoragePoolCommandTest.java: Line 68: import org.ovirt.engine.core.utils.MockConfigRule; Line 69: Line 70: @RunWith(MockitoJUnitRunner.class) Line 71: public class ProcessOvfUpdateForStoragePoolCommandTest { Line 72: private final int ITEMS_COUNT_PER_UPDATE = 100; should be static. Line 73: private ProcessOvfUpdateForStoragePoolCommand<StoragePoolParametersBase> command; Line 74: Line 75: @Mock Line 76: private StoragePoolDAO storagePoolDAO; Line 116: @Before Line 117: public void setUp() { Line 118: command = Mockito.spy(new ProcessOvfUpdateForStoragePoolCommand<>(new StoragePoolParametersBase())); Line 119: ovfUpdateProcessHelper = Mockito.spy(new OvfUpdateProcessHelper()); Line 120: doReturn(ITEMS_COUNT_PER_UPDATE).when(command).loadConfigValue(); This should be done with MockConfigRule too Line 121: doReturn(new ArrayList<DiskImage>()).when(ovfUpdateProcessHelper).getAllImageSnapshots(any(DiskImage.class)); Line 122: doReturn(false).when(command).ovfOnAnyDomainSupported(any(StoragePool.class)); Line 123: doCallRealMethod().when(command).executeCommand(); Line 124: // init members Line 118: command = Mockito.spy(new ProcessOvfUpdateForStoragePoolCommand<>(new StoragePoolParametersBase())); Line 119: ovfUpdateProcessHelper = Mockito.spy(new OvfUpdateProcessHelper()); Line 120: doReturn(ITEMS_COUNT_PER_UPDATE).when(command).loadConfigValue(); Line 121: doReturn(new ArrayList<DiskImage>()).when(ovfUpdateProcessHelper).getAllImageSnapshots(any(DiskImage.class)); Line 122: doReturn(false).when(command).ovfOnAnyDomainSupported(any(StoragePool.class)); Consider using a more fine-grained matcher than any Line 123: doCallRealMethod().when(command).executeCommand(); Line 124: // init members Line 125: initMembers(); Line 126: Line 169: executedUpdatedMetadataForStoragePool = new HashMap<>(); Line 170: executedRemovedIds = new HashSet<>(); Line 171: executedUpdatedOvfGenerationIdsInDb = new HashMap<>(); Line 172: Line 173: for (int i=0; i<2; i++) { formatting Line 174: Guid domainId = Guid.newGuid(); Line 175: StorageDomainOvfInfo ovfInfo = new StorageDomainOvfInfo(domainId, null, null, StorageDomainOvfInfoStatus.UPDATED, null); Line 176: StorageDomain domain = new StorageDomain(); Line 177: domain.setId(domainId); http://gerrit.ovirt.org/#/c/33157/2/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java File backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java: Line 650: } Line 651: Line 652: public SnapshotDao getVmNetwork() { Line 653: return getDbFacade().getSnapshotDao(); Line 654: } How is this related to the patch? Line 655: Line 656: public VmDynamicDAO getVmDynamicDAO() { Line 657: return getDbFacade().getVmDynamicDao(); Line 658: } -- To view, visit http://gerrit.ovirt.org/33157 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6780aedf2d215d08c4bed0ff4f7520c45f753f66 Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Aravot <lara...@redhat.com> Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com> Gerrit-Reviewer: Daniel Erez <de...@redhat.com> Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org 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