Arik Hadas has uploaded a new change for review.

Change subject: core: remove pending VMs counting
......................................................................

core: remove pending VMs counting

The number of pending VMs is not in use anywhere, but it is still
computed. In order to compute the pending VMs we increment and decrement
the counter while running VMs in synchronized blocks and it is not good
in terms of performance. So since this code is redundant, it is better
to remove it.

Change-Id: I3bd7a757be2979b86227ce56064e6165080035eb
Signed-off-by: Arik Hadas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
2 files changed, 0 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/84/21884/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index dd9ea68..5fa3558 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -201,7 +201,6 @@
         setVdsId(new Guid(getVm().getRunOnVds().toString()));
         if (getVds() != null) {
             try {
-                incrementVdsPendingVmsCount();
                 VDSReturnValue result = getBackend()
                         .getResourceManager()
                         .RunAsyncVdsCommand(VDSCommandType.Resume,
@@ -211,7 +210,6 @@
                 ExecutionHandler.setAsyncJob(getExecutionContext(), true);
             } finally {
                 freeLock();
-                decrementVdsPendingVmsCount();
             }
         } else {
             setActionReturnValue(getVm().getStatus());
@@ -224,7 +222,6 @@
             VMStatus status = null;
             try {
                 VmHandler.updateVmGuestAgentVersion(getVm());
-                incrementVdsPendingVmsCount();
                 if (connectLunDisks(getVdsId())) {
                     status = createVm();
                     ExecutionHandler.setAsyncJob(getExecutionContext(), true);
@@ -246,7 +243,6 @@
 
             } finally {
                 freeLock();
-                decrementVdsPendingVmsCount();
             }
             setActionReturnValue(status);
 
@@ -423,24 +419,6 @@
         // setting lock to null in order not to release lock twice
         setLock(null);
         setSucceeded(true);
-    }
-
-    private void decrementVdsPendingVmsCount() {
-        synchronized (_vds_pending_vm_count) {
-            int i = _vds_pending_vm_count.get(getVdsId());
-            _vds_pending_vm_count.put(getVdsId(), i - 1);
-        }
-    }
-
-    private void incrementVdsPendingVmsCount() {
-        synchronized (_vds_pending_vm_count) {
-            if (!_vds_pending_vm_count.containsKey(getVdsId())) {
-                _vds_pending_vm_count.put(getVdsId(), 1);
-            } else {
-                int i = _vds_pending_vm_count.get(getVdsId());
-                _vds_pending_vm_count.put(getVdsId(), i + 1);
-            }
-        }
     }
 
     protected VMStatus createVm() {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index 6ee75e5..e300cf8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -4,7 +4,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.BlockingQueue;
@@ -56,7 +55,6 @@
         IVdsAsyncCommand, RunVmDelayer {
 
     private static Log log = LogFactory.getLog(RunVmCommandBase.class);
-    protected static final HashMap<Guid, Integer> _vds_pending_vm_count = new 
HashMap<Guid, Integer>();
     protected boolean _isRerun = false;
     protected VDS _destinationVds;
     private SnapshotsValidator snapshotsValidator=new SnapshotsValidator();


-- 
To view, visit http://gerrit.ovirt.org/21884
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bd7a757be2979b86227ce56064e6165080035eb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to