cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/master to 502c1db
Date Wed, 21 Aug 2013 09:56:19 GMT
Updated Branches:
  refs/heads/master 7e36dd6be -> 502c1db10


CLOUDSTACK-3441: [Load Test] High delays between VM being allocated to Pod and network implementation
causing delays in VM deployment
The locking code in implement/shutdown network code was not efficient. Even in order to check
the current state of the network lock was getting acquired which is not required. This resulted
in delays in deploy VM as can be seen from attached logs where the code waited on the lock
just to check if network is implemented.
As part of the fix moved out code that is checking if the network is already implemented or
shutdowned outside the lock.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/502c1db1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/502c1db1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/502c1db1

Branch: refs/heads/master
Commit: 502c1db1030cfa01850127ba8a8e5e7b1eaf8ead
Parents: 7e36dd6
Author: Koushik Das <koushik@apache.org>
Authored: Sat Aug 17 13:30:20 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Wed Aug 21 15:25:45 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/NetworkManagerImpl.java   | 54 ++++++++++++++------
 1 file changed, 37 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/502c1db1/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index c099e3d..00103e3 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -918,6 +918,19 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         return to;
     }
 
+    boolean isNetworkImplemented(NetworkVO network) {
+        Network.State state = network.getState();
+        if (state == Network.State.Implemented || state == Network.State.Implementing) {
+            return true;
+        } else if (state == Network.State.Setup) {
+            DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
+            if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || (zone.getNetworkType()
== NetworkType.Basic)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     @DB
     public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination
dest, ReservationContext context)
@@ -926,7 +939,16 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         Transaction.currentTxn();
         Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null,
null);
 
-        NetworkVO network = _networksDao.acquireInLockTable(networkId, _networkLockTimeout);
+        NetworkVO network = _networksDao.findById(networkId);
+        NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName());
+        if (isNetworkImplemented(network)) {
+            s_logger.debug("Network id=" + networkId + " is already implemented");
+            implemented.set(guru, network);
+            return implemented;
+        }
+
+        // Acquire lock only when network needs to be implemented
+        network = _networksDao.acquireInLockTable(networkId, _networkLockTimeout);
         if (network == null) {
             // see NetworkVO.java
             ConcurrentOperationException ex = new ConcurrentOperationException("Unable to
acquire network configuration");
@@ -939,23 +961,12 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         }
 
         try {
-            NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName());
-            Network.State state = network.getState();
-            if (state == Network.State.Implemented || state == Network.State.Implementing)
{
+            if (isNetworkImplemented(network)) {
                 s_logger.debug("Network id=" + networkId + " is already implemented");
                 implemented.set(guru, network);
                 return implemented;
             }
 
-            if (state == Network.State.Setup) {
-                DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
-                if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())
|| (zone.getNetworkType() == NetworkType.Basic)) {
-                    s_logger.debug("Network id=" + networkId + " is already implemented");
-                    implemented.set(guru, network);
-                    return implemented;
-                }
-            }
-
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Asking " + guru.getName() + " to implement " + network);
             }
@@ -1940,7 +1951,17 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
     @DB
     public boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements)
{
         boolean result = false;
-        NetworkVO network = null;
+        NetworkVO network = _networksDao.findById(networkId);
+        if (network.getState() == Network.State.Allocated) {
+            s_logger.debug("Network is already shutdown: " + network);
+            return true;
+        }
+
+        if (network.getState() != Network.State.Implemented && network.getState()
!= Network.State.Shutdown) {
+            s_logger.debug("Network is not implemented: " + network);
+            return false;
+        }
+
         try {
             //do global lock for the network
             network = _networksDao.acquireInLockTable(networkId, getNetworkLockTimeout());
@@ -1951,12 +1972,12 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Lock is acquired for network " + network + " as a part of
network shutdown");
             }
-            
+
             if (network.getState() == Network.State.Allocated) {
                 s_logger.debug("Network is already shutdown: " + network);
                 return true;
             }
-            
+
             if (network.getState() != Network.State.Implemented && network.getState()
!= Network.State.Shutdown) {
                 s_logger.debug("Network is not implemented: " + network);
                 return false;
@@ -1974,7 +1995,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
                 }
             }
 
-            
             boolean success = shutdownNetworkElementsAndResources(context, cleanupElements,
network);
 
             Transaction txn = Transaction.currentTxn();


Mime
View raw message