cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [1/2] git commit: updated refs/heads/4.2-forward to 5528ba4
Date Thu, 22 Aug 2013 05:47:18 GMT
Updated Branches:
  refs/heads/4.2-forward 1c31ee22d -> 5528ba4b2


CLOUDSTACK-2131: [Performance][Enhancement] Avoid checking for providers that are not enabled
while creating network.
For some scenarios like prepare nic, all network service providers are checked which is not
efficient and also introduces unnecessary dependencies.
The check to use only the required providers is already there for implement, shutdown operation
on network. Put the same check for all missing cases.


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

Branch: refs/heads/4.2-forward
Commit: c86e8fcae54a6af566ec87cf81b3ae228dfacbf8
Parents: 1c31ee2
Author: Koushik Das <koushik@apache.org>
Authored: Wed Aug 21 12:48:51 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Thu Aug 22 11:06:16 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/NetworkManagerImpl.java   | 88 ++++++++++++++------
 1 file changed, 62 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c86e8fca/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 68b1b4f..bcb0e99 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -2148,12 +2148,18 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             updateNic(nic, network.getId(), 1);
         }
 
+        List<Provider> providersToImplement = getNetworkProviders(network.getId());
         for (NetworkElement element : _networkElements) {
-            if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Asking " + element.getName() + " to prepare for " + nic);
-            }
-            if(!prepareElement(element, network, profile, vmProfile, dest, context)) {
-                throw new InsufficientAddressCapacityException("unable to configure the dhcp
service, due to insufficiant address capacity",Network.class, network.getId());
+            if (providersToImplement.contains(element.getProvider())) {
+                if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                    throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                }
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Asking " + element.getName() + " to prepare for " + nic);
+                }
+                if(!prepareElement(element, network, profile, vmProfile, dest, context))
{
+                    throw new InsufficientAddressCapacityException("unable to configure the
dhcp service, due to insufficiant address capacity",Network.class, network.getId());
+                }
             }
         }
 
@@ -2215,10 +2221,16 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
                     s_logger.error("NetworkGuru "+guru+" prepareForMigration failed."); //
XXX: Transaction error
                 }
             }
+            List<Provider> providersToImplement = getNetworkProviders(network.getId());
             for (NetworkElement element : _networkElements) {
-                if(element instanceof NetworkMigrationResponder){
-                    if(!((NetworkMigrationResponder) element).prepareMigration(profile, network,
vm, dest, context)){
-                        s_logger.error("NetworkElement "+element+" prepareForMigration failed.");
// XXX: Transaction error
+                if (providersToImplement.contains(element.getProvider())) {
+                    if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                        throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                    }
+                    if(element instanceof NetworkMigrationResponder){
+                        if(!((NetworkMigrationResponder) element).prepareMigration(profile,
network, vm, dest, context)){
+                            s_logger.error("NetworkElement "+element+" prepareForMigration
failed."); // XXX: Transaction error
+                        }
                     }
                 }
             }
@@ -2287,9 +2299,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             if(guru instanceof NetworkMigrationResponder){
                 ((NetworkMigrationResponder) guru).commitMigration(nicSrc, network, src,
src_context, dst_context);
             }
+            List<Provider> providersToImplement = getNetworkProviders(network.getId());
             for (NetworkElement element : _networkElements) {
-                if(element instanceof NetworkMigrationResponder){
-                    ((NetworkMigrationResponder) element).commitMigration(nicSrc, network,
src, src_context, dst_context);
+                if (providersToImplement.contains(element.getProvider())) {
+                    if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                        throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                    }
+                    if(element instanceof NetworkMigrationResponder){
+                        ((NetworkMigrationResponder) element).commitMigration(nicSrc, network,
src, src_context, dst_context);
+                    }
                 }
             }
             // update the reservation id
@@ -2313,9 +2331,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             if(guru instanceof NetworkMigrationResponder){
                 ((NetworkMigrationResponder) guru).rollbackMigration(nicDst, network, dst,
src_context, dst_context);
             }
+            List<Provider> providersToImplement = getNetworkProviders(network.getId());
             for (NetworkElement element : _networkElements) {
-                if(element instanceof NetworkMigrationResponder){
-                    ((NetworkMigrationResponder) element).rollbackMigration(nicDst, network,
dst, src_context, dst_context);
+                if (providersToImplement.contains(element.getProvider())) {
+                    if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                        throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                    }
+                    if(element instanceof NetworkMigrationResponder){
+                        ((NetworkMigrationResponder) element).rollbackMigration(nicDst, network,
dst, src_context, dst_context);
+                    }
                 }
             }
         }
@@ -2374,13 +2398,19 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
                 txn.commit();
 
                 // Perform release on network elements
+                List<Provider> providersToImplement = getNetworkProviders(network.getId());
                 for (NetworkElement element : _networkElements) {
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Asking " + element.getName() + " to release " + nic);
+                    if (providersToImplement.contains(element.getProvider())) {
+                        if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                            throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                        }
+                        if (s_logger.isDebugEnabled()) {
+                            s_logger.debug("Asking " + element.getName() + " to release "
+ nic);
+                        }
+                        //NOTE: Context appear to never be used in release method
+                        //implementations. Consider removing it from interface Element
+                        element.release(network, profile, vmProfile, null);
                     }
-                    //NOTE: Context appear to never be used in release method
-                    //implementations. Consider removing it from interface Element
-                    element.release(network, profile, vmProfile, null);
                 }
 
             } else {
@@ -2422,16 +2452,22 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
          * because the nic is now being removed.
          */
         if (nic.getReservationStrategy() == Nic.ReservationStrategy.Create) {
+            List<Provider> providersToImplement = getNetworkProviders(network.getId());
             for (NetworkElement element : _networkElements) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Asking " + element.getName() + " to release " + nic);
-                }
-                try {
-                    element.release(network, profile, vm, null);
-                } catch (ConcurrentOperationException ex) {
-                    s_logger.warn("release failed during the nic " +  nic.toString() + "
removeNic due to ", ex);
-                } catch (ResourceUnavailableException ex) {
-                    s_logger.warn("release failed during the nic " +  nic.toString() + "
removeNic due to ", ex);
+                if (providersToImplement.contains(element.getProvider())) {
+                    if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network),
element.getProvider().getName())) {
+                        throw new CloudRuntimeException("Service provider " + element.getProvider().getName()
+ " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
+                    }
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Asking " + element.getName() + " to release " + nic);
+                    }
+                    try {
+                        element.release(network, profile, vm, null);
+                    } catch (ConcurrentOperationException ex) {
+                        s_logger.warn("release failed during the nic " +  nic.toString()
+ " removeNic due to ", ex);
+                    } catch (ResourceUnavailableException ex) {
+                        s_logger.warn("release failed during the nic " +  nic.toString()
+ " removeNic due to ", ex);
+                    }
                 }
             }
         }


Mime
View raw message