Source:
private void saveDataToDb() { if (_saveVdsDynamic) { _vdsManager.UpdateDynamicDataVerify(_vds.getDynamicData()); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.updateStatisticsData(stat); checkVdsMemoryThreshold(stat); checkVdsCpuThreshold(stat); checkVdsNetworkThreshold(stat); checkVdsSwapThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { getDbFacade().getInterfaceDao().massUpdateStatisticsForVds(statistics); return null; } }); } } getDbFacade().getVmDynamicDao().updateAllInBatch(_vmDynamicToSave.values()); getDbFacade().getVmStatisticsDao().updateAllInBatch(_vmStatisticsToSave.values()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics); getDbFacade().getDiskImageDynamicDao().updateAllInBatch(_vmDiskImageDynamicToSave.values()); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); ResourceManager.getInstance().getEventListener().addExternallyManagedVms(_externalVmsToAdd); }

Target:
private void saveDataToDb() { if (_saveVdsDynamic && !originDynamicData.equals(_vds.getDynamicData())) { _vdsManager.UpdateDynamicData(_vds.getDynamicData()); log.info("Updating vdsDynamic for host " + _vds.getName() + ". Original was " + originDynamicData.getStatus() + " and new is " + _vds.getDynamicData().getStatus()); } else { log.debug("Unneeded update of vdsDynamic for VDS: " + _vds.getName() + " was ignored."); } if (_saveVdsStatistics) { VdsStatistics stat = _vds.getStatisticsData(); _vdsManager.updateStatisticsData(stat); checkVdsMemoryThreshold(stat); checkVdsCpuThreshold(stat); checkVdsNetworkThreshold(stat); checkVdsSwapThreshold(stat); final List<VdsNetworkStatistics> statistics = new LinkedList<VdsNetworkStatistics>(); for (VdsNetworkInterface iface : _vds.getInterfaces()) { statistics.add(iface.getStatistics()); } if (!statistics.isEmpty()) { TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Void>() { @Override public Void runInTransaction() { getDbFacade().getInterfaceDao().massUpdateStatisticsForVds(statistics); return null; } }); } } getDbFacade().getVmDynamicDao().updateAllInBatch(_vmDynamicToSave.values()); getDbFacade().getVmStatisticsDao().updateAllInBatch(_vmStatisticsToSave.values()); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : _vmInterfaceStatisticsToSave.values()) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics); getDbFacade().getDiskImageDynamicDao().updateAllInBatch(_vmDiskImageDynamicToSave.values()); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); ResourceManager.getInstance().getEventListener().addExternallyManagedVms(_externalVmsToAdd); }