Source:
private void saveDataToDb() { if (_saveVdsDynamic) { _vdsManager.updateDynamicData(_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; } }); } } for (VmDynamic vmDynamic : _vmDynamicToSave.values()) { if (vmDynamic.getStatus() == VMStatus.Up) { vmDynamic.setReason(""); } } 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()); getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); getVdsEventListener().addExternallyManagedVms(_externalVmsToAdd); }

Target:
private void saveDataToDb() { if (_saveVdsDynamic) { _vdsManager.updateDynamicData(_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()); getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); getVdsEventListener().addExternallyManagedVms(_externalVmsToAdd); }