Moti Asayag has uploaded a new change for review.

Change subject: engine: Inject DAOs to ResourceManager
......................................................................

engine: Inject DAOs to ResourceManager

Change-Id: I1ce6d4b10514997578abf3cce91833d5a531dc10
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
1 file changed, 34 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/40938/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
index 6075a5d..2427da5 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
@@ -45,9 +45,14 @@
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase;
 import org.ovirt.engine.core.compat.Guid;
-import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase;
+import org.ovirt.engine.core.dao.VdsDAO;
+import org.ovirt.engine.core.dao.VdsDynamicDAO;
+import org.ovirt.engine.core.dao.VmDAO;
+import org.ovirt.engine.core.dao.VmDynamicDAO;
+import org.ovirt.engine.core.dao.VmStatisticsDAO;
+import org.ovirt.engine.core.dao.network.VmNetworkStatisticsDao;
 import org.ovirt.engine.core.utils.ReflectionUtils;
 import org.ovirt.engine.core.utils.collections.MultiValueMapUtils;
 import org.ovirt.engine.core.vdsbroker.irsbroker.IrsBrokerCommand;
@@ -60,8 +65,6 @@
 @Singleton
 public class ResourceManager {
 
-    @Inject
-    private BeanManager beanManager;
     //We can't inject event listener due to Jboss 7.1 bug. using programatic 
lookup instead.
     private volatile IVdsEventListener eventListener;
 
@@ -78,7 +81,28 @@
     private int parallelism;
 
     @Inject
+    private BeanManager beanManager;
+
+    @Inject
     private AuditLogDirector auditLogDirector;
+
+    @Inject
+    private VdsDAO hostDao;
+
+    @Inject
+    private VmDAO vmDao;
+
+    @Inject
+    private VdsDynamicDAO hostDynamicDao;
+
+    @Inject
+    private VmDynamicDAO vmDynamicDao;
+
+    @Inject
+    private VmStatisticsDAO vmStatisticsDao;
+
+    @Inject
+    private VmNetworkStatisticsDao vmNetworkStatisticsDao;
 
     private ResourceManager() {
         this.parallelism = Config.<Integer> 
getValue(ConfigValues.EventProcessingPoolSize);
@@ -102,7 +126,7 @@
         // init the singleton. TODO remove once all code is using CDI
         setInstance(this);
         log.info("Start initializing {}", getClass().getSimpleName());
-        List<VDS> allVdsList = DbFacade.getInstance().getVdsDao().getAll();
+        List<VDS> allVdsList = hostDao.getAll();
         HashSet<Guid> nonResponsiveVdss = new HashSet<Guid>();
         for (VDS helper_vds : allVdsList) {
             if (helper_vds.getStatus() == VDSStatus.NonResponsive) {
@@ -114,7 +138,7 @@
         boolean runningVmsInTransition = false;
 
         // Cleanup all vms dynamic data. This is defensive code on power crash
-        List<VM> vms = DbFacade.getInstance().getVmDao().getAll();
+        List<VM> vms = vmDao.getAll();
         for (VM vm : vms) {
             if (!vm.isNotRunning()) {
                 if (vm.getRunOnVds() != null) {
@@ -154,7 +178,7 @@
             }
         }
 
-        
DbFacade.getInstance().getVdsDynamicDao().updateAllInBatch(updatedEntities);
+        hostDynamicDao.updateAllInBatch(updatedEntities);
 
         // Populate the VDS dictionary
         for (VDS curVds : allVdsList) {
@@ -221,7 +245,7 @@
     }
 
     public void reestablishConnection(Guid vdsId) {
-        VDS vds = DbFacade.getInstance().getVdsDao().get(vdsId);
+        VDS vds = hostDao.get(vdsId);
         RemoveVds(vds.getId());
         AddVds(vds, false);
     }
@@ -299,13 +323,13 @@
     }
 
     private void storeVm(VM vm) {
-        DbFacade.getInstance().getVmDynamicDao().update(vm.getDynamicData());
-        
DbFacade.getInstance().getVmStatisticsDao().update(vm.getStatisticsData());
+        vmDynamicDao.update(vm.getDynamicData());
+        vmStatisticsDao.update(vm.getStatisticsData());
         List<VmNetworkInterface> interfaces = vm.getInterfaces();
         if (interfaces != null) {
             for (VmNetworkInterface ifc : interfaces) {
                 VmNetworkStatistics stats = ifc.getStatistics();
-                
DbFacade.getInstance().getVmNetworkStatisticsDao().update(stats);
+                vmNetworkStatisticsDao.update(stats);
             }
         }
     }


-- 
To view, visit https://gerrit.ovirt.org/40938
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ce6d4b10514997578abf3cce91833d5a531dc10
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <masa...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to