cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [41/50] [abbrv] git commit: updated refs/heads/internallb to 20beb7a
Date Thu, 11 Apr 2013 00:15:52 GMT
Internal Lb:

1) When network has both kinds of LB rules - Public and Internal - never send them in the
same set to the provider
2) Added extra checks on the provider side to validate if the schema - Public or Internal
- is supported.


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

Branch: refs/heads/internallb
Commit: 76325e61681c7e191308b27514ba69e523cf12bd
Parents: 56c2fe1
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Apr 8 13:58:08 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Wed Apr 10 16:28:26 2013 -0700

----------------------------------------------------------------------
 .../network/lb/LoadBalancingRulesService.java      |    3 +-
 .../element/F5ExternalLoadBalancerElement.java     |    8 ++-
 .../cloud/network/element/NetscalerElement.java    |   22 ++++++++-
 .../ExternalLoadBalancerUsageManagerImpl.java      |   34 +++++++------
 .../src/com/cloud/network/NetworkManagerImpl.java  |   29 +++++++++--
 .../src/com/cloud/network/dao/LoadBalancerDao.java |    5 +-
 .../com/cloud/network/dao/LoadBalancerDaoImpl.java |    7 ++-
 .../network/element/VirtualRouterElement.java      |   39 +++++++++------
 .../com/cloud/network/lb/LBHealthCheckManager.java |    4 +-
 .../cloud/network/lb/LBHealthCheckManagerImpl.java |    9 ++--
 .../network/lb/LoadBalancingRulesManager.java      |    5 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   14 +++---
 .../router/VirtualNetworkApplianceManagerImpl.java |    7 ++-
 13 files changed, 125 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index 7dc513c..5fc41e3 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -32,6 +32,7 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.rules.HealthCheckPolicy;
 import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.network.rules.StickinessPolicy;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
@@ -138,7 +139,7 @@ public interface LoadBalancingRulesService {
 
     LoadBalancer findById(long LoadBalancer);
     
-    public void updateLBHealthChecks() throws ResourceUnavailableException;
+    public void updateLBHealthChecks(Scheme scheme) throws ResourceUnavailableException;
 
     Map<Ip, UserVm> getLbInstances(long lbId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
index e4002a2..e82cb33 100644
--- a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
+++ b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
@@ -17,6 +17,7 @@
 package com.cloud.network.element;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -188,8 +189,11 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
 
     @Override
     public boolean validateLBRule(Network network, LoadBalancingRule rule) {
-        String algo = rule.getAlgorithm();
-        return (algo.equals("roundrobin") || algo.equals("leastconn"));
+        if (canHandle(network, new ArrayList<LoadBalancingRule>(Arrays.asList(rule))))
{
+            String algo = rule.getAlgorithm();
+            return (algo.equals("roundrobin") || algo.equals("leastconn"));
+        }
+        return true;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index 98b8939..c612c12 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@ -233,6 +233,10 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         if (!canHandle(config, Service.Lb)) {
             return false;
         }
+        
+        if (canHandleLbRules(rules)) {
+            return false;
+        }
 
         if (isBasicZoneNetwok(config)) {
             return applyElasticLoadBalancerRules(config, rules);
@@ -837,7 +841,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
 
     public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule>
lbrules) {
 
-        if (canHandle(network, Service.Lb)) {
+        if (canHandle(network, Service.Lb) && canHandleLbRules(lbrules)) {
             try {
                 return getLBHealthChecks(network, lbrules);
             } catch (ResourceUnavailableException e) {
@@ -918,4 +922,20 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         }
         return null;
     }
+    
+    private boolean canHandleLbRules(List<LoadBalancingRule> rules) {
+        Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+        if (!lbCaps.isEmpty()) {
+            String schemeCaps = lbCaps.get(Capability.LbSchemes);
+            if (schemeCaps != null) {
+                for (LoadBalancingRule rule : rules) {
+                    if (!schemeCaps.contains(rule.getScheme().toString())) {
+                        s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported
by the provider " + this.getName());
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/ExternalLoadBalancerUsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalLoadBalancerUsageManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerUsageManagerImpl.java
index d405382..2c8031c 100644
--- a/server/src/com/cloud/network/ExternalLoadBalancerUsageManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalLoadBalancerUsageManagerImpl.java
@@ -16,6 +16,22 @@
 // under the License.
 package com.cloud.network;
 
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.ExternalNetworkResourceUsageAnswer;
 import com.cloud.agent.api.ExternalNetworkResourceUsageCommand;
@@ -48,6 +64,7 @@ import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.network.rules.PortForwardingRuleVO;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -68,20 +85,6 @@ import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 @Component
 @Local(value = { ExternalLoadBalancerUsageManager.class })
@@ -647,9 +650,10 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase
implements
                 // If an external load balancer is added, manage one entry for each load
balancing rule in this network
                 if (externalLoadBalancer != null && lbAnswer != null) {
                     boolean inline = _networkMgr.isNetworkInlineMode(network);
-                    List<LoadBalancerVO> loadBalancers = _loadBalancerDao.listByNetworkId(network.getId());
+                    List<LoadBalancerVO> loadBalancers = _loadBalancerDao.listByNetworkIdAndScheme(network.getId(),
Scheme.Public);
                     for (LoadBalancerVO loadBalancer : loadBalancers) {
                         String publicIp = _networkMgr.getIp(loadBalancer.getSourceIpAddressId()).getAddress().addr();
+                        
                         if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(),
publicIp, externalLoadBalancer.getId(), lbAnswer, inline)) {
                             throw new ExecutionException(networkErrorMsg + ", load balancing
rule public IP = " + publicIp);
                         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/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 a97f2ce..85d0d9e 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -135,6 +135,7 @@ import com.cloud.network.rules.FirewallManager;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.network.rules.PortForwardingRuleVO;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
@@ -2607,9 +2608,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             success = false;
         }
 
-        // apply load balancer rules
-        if (!_lbMgr.applyLoadBalancersForNetwork(networkId)) {
-            s_logger.warn("Failed to reapply load balancer rules as a part of network id="
+ networkId + " restart");
+        // apply public load balancer rules
+        if (!_lbMgr.applyLoadBalancersForNetwork(networkId, Scheme.Public)) {
+            s_logger.warn("Failed to reapply Public load balancer rules as a part of network
id=" + networkId + " restart");
+            success = false;
+        }
+        
+        // apply internal load balancer rules
+        if (!_lbMgr.applyLoadBalancersForNetwork(networkId, Scheme.Internal)) {
+            s_logger.warn("Failed to reapply internal load balancer rules as a part of network
id=" + networkId + " restart");
             success = false;
         }
 
@@ -3178,12 +3185,22 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         }
 
         try {
-            if (!_lbMgr.revokeLoadBalancersForNetwork(networkId)) {
-                s_logger.warn("Failed to cleanup lb rules as a part of shutdownNetworkRules");
+            if (!_lbMgr.revokeLoadBalancersForNetwork(networkId, Scheme.Public)) {
+                s_logger.warn("Failed to cleanup public lb rules as a part of shutdownNetworkRules");
+                success = false;
+            }
+        } catch (ResourceUnavailableException ex) {
+            s_logger.warn("Failed to cleanup public lb rules as a part of shutdownNetworkRules
due to ", ex);
+            success = false;
+        }
+        
+        try {
+            if (!_lbMgr.revokeLoadBalancersForNetwork(networkId, Scheme.Internal)) {
+                s_logger.warn("Failed to cleanup internal lb rules as a part of shutdownNetworkRules");
                 success = false;
             }
         } catch (ResourceUnavailableException ex) {
-            s_logger.warn("Failed to cleanup lb rules as a part of shutdownNetworkRules due
to ", ex);
+            s_logger.warn("Failed to cleanup public lb rules as a part of shutdownNetworkRules
due to ", ex);
             success = false;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/dao/LoadBalancerDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerDao.java b/server/src/com/cloud/network/dao/LoadBalancerDao.java
index 611282e..2a3e92e 100644
--- a/server/src/com/cloud/network/dao/LoadBalancerDao.java
+++ b/server/src/com/cloud/network/dao/LoadBalancerDao.java
@@ -18,6 +18,7 @@ package com.cloud.network.dao;
 
 import java.util.List;
 
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.db.GenericDao;
 
 public interface LoadBalancerDao extends GenericDao<LoadBalancerVO, Long> {
@@ -29,8 +30,8 @@ public interface LoadBalancerDao extends GenericDao<LoadBalancerVO, Long>
{
 
     LoadBalancerVO findByAccountAndName(Long accountId, String name);
 
-    List<LoadBalancerVO> listByNetworkId(long networkId);
+    List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme);
 
-    List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
+    List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId,
Scheme scheme);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
index f211a7f..39a3aac 100644
--- a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.network.rules.FirewallRule.State;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -57,6 +58,7 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO,
Long> im
         ListByIp = createSearchBuilder();
         ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
         ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        ListByIp.and("scheme", ListByIp.entity().getScheme(), SearchCriteria.Op.EQ);
         ListByIp.done();
 
         IpAndPublicPortSearch = createSearchBuilder();
@@ -104,9 +106,10 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO,
Long> im
     }
 
     @Override
-    public List<LoadBalancerVO> listByNetworkId(long networkId) {
+    public List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme)
{
         SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
         sc.setParameters("networkId", networkId);
+        sc.setParameters("scheme", scheme);
         return listBy(sc);
     }
 
@@ -127,7 +130,7 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO,
Long> im
     }
 
     @Override
-    public List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId) {
+    public List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId,
Scheme scheme) {
         SearchCriteria<LoadBalancerVO> sc = TransitionStateSearch.create();
         sc.setParameters("networkId", networkId);
         sc.setParameters("state", State.Add.toString(), State.Revoke.toString());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 2d4e718..ddb35b6 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -90,6 +90,8 @@ import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.google.gson.Gson;
 
+import edu.emory.mathcs.backport.java.util.Arrays;
+
 @Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
 		        DhcpServiceProvider.class, UserDataServiceProvider.class, 
 		        StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
@@ -338,7 +340,9 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 
     @Override
     public boolean validateLBRule(Network network, LoadBalancingRule rule) {
-        if (canHandle(network, Service.Lb)) {
+        List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>();
+        rules.add(rule);
+        if (canHandle(network, Service.Lb) && canHandleLbRules(rules)) {
             List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(),
Role.VIRTUAL_ROUTER);
             if (routers == null || routers.isEmpty()) {
                 return true;
@@ -351,17 +355,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Override
     public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
         if (canHandle(network, Service.Lb)) {
-            Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
-            if (!lbCaps.isEmpty()) {
-                String schemeCaps = lbCaps.get(Capability.LbSchemes);
-                if (schemeCaps != null) {
-                    for (LoadBalancingRule rule : rules) {
-                        if (!schemeCaps.contains(rule.getScheme().toString())) {
-                            s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not
supported by the provider " + this.getName());
-                            return false;
-                        }
-                    }
-                }
+            if (!canHandleLbRules(rules)) {
+                return false;
             }
             
             List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(),
Role.VIRTUAL_ROUTER);
@@ -375,9 +370,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
                 throw new CloudRuntimeException("Failed to apply load balancing rules in
network " + network.getId());
             } else {
                 return true;
-            }
-            
-            
+            }   
         } else {
             return false;
         }
@@ -961,4 +954,20 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 		// TODO Auto-generated method stub
 		return null;
 	}
+	
+	private boolean canHandleLbRules(List<LoadBalancingRule> rules) {
+	    Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+	    if (!lbCaps.isEmpty()) {
+	        String schemeCaps = lbCaps.get(Capability.LbSchemes);
+	        if (schemeCaps != null) {
+	            for (LoadBalancingRule rule : rules) {
+	                if (!schemeCaps.contains(rule.getScheme().toString())) {
+	                    s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported
by the provider " + this.getName());
+	                    return false;
+	                }
+	            }
+	        }
+	    }
+	    return true;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/lb/LBHealthCheckManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LBHealthCheckManager.java b/server/src/com/cloud/network/lb/LBHealthCheckManager.java
index 2e24965..a9969eb 100644
--- a/server/src/com/cloud/network/lb/LBHealthCheckManager.java
+++ b/server/src/com/cloud/network/lb/LBHealthCheckManager.java
@@ -16,9 +16,11 @@
 // under the License.
 package com.cloud.network.lb;
 
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+
 
 public interface LBHealthCheckManager {
 
-    void updateLBHealthCheck();
+    void updateLBHealthCheck(Scheme scheme);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/lb/LBHealthCheckManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LBHealthCheckManagerImpl.java b/server/src/com/cloud/network/lb/LBHealthCheckManagerImpl.java
index 9054732..62b738b 100644
--- a/server/src/com/cloud/network/lb/LBHealthCheckManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LBHealthCheckManagerImpl.java
@@ -19,7 +19,6 @@ package com.cloud.network.lb;
 import static java.lang.String.format;
 
 import java.util.Map;
-
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -34,6 +33,7 @@ import org.springframework.stereotype.Component;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
@@ -90,7 +90,8 @@ public class LBHealthCheckManagerImpl extends ManagerBase implements LBHealthChe
         @Override
         public void run() {
             try {
-                updateLBHealthCheck();
+                updateLBHealthCheck(Scheme.Public);
+                updateLBHealthCheck(Scheme.Internal);
             } catch (Exception e) {
                 s_logger.error("Exception in LB HealthCheck Update Checker", e);
             }
@@ -98,9 +99,9 @@ public class LBHealthCheckManagerImpl extends ManagerBase implements LBHealthChe
     }
 
     @Override
-    public void updateLBHealthCheck() {
+    public void updateLBHealthCheck(Scheme scheme) {
         try {
-            _lbService.updateLBHealthChecks();
+            _lbService.updateLBHealthChecks(scheme);
         } catch (ResourceUnavailableException e) {
             s_logger.debug("Error while updating the LB HealtCheck ", e);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
index 064a129..759a77c 100644
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManager.java
@@ -25,6 +25,7 @@ import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
 import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
 import com.cloud.network.rules.LbStickinessMethod;
 import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.user.Account;
 import com.cloud.user.UserContext;
 
@@ -47,10 +48,10 @@ public interface LoadBalancingRulesManager extends LoadBalancingRulesService
{
      * @return true if removal is successful
      */
     boolean removeVmFromLoadBalancers(long vmId);
-    boolean applyLoadBalancersForNetwork(long networkId) throws ResourceUnavailableException;
+    boolean applyLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException;
     String getLBCapability(long networkid, String capabilityName);
     boolean configureLbAutoScaleVmGroup(long vmGroupid, String currentState) throws ResourceUnavailableException;
-    boolean revokeLoadBalancersForNetwork(long networkId) throws ResourceUnavailableException;
+    boolean revokeLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException;
 
     boolean validateLbRule(LoadBalancingRule lbRule);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index 2050ea6..ba31e6f 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -840,7 +840,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
     // by CloudStack and update them in lbvmmap table
     @DB
     @Override
-    public void updateLBHealthChecks() throws ResourceUnavailableException {
+    public void updateLBHealthChecks(Scheme scheme) throws ResourceUnavailableException {
         List<LoadBalancerVO> rules = _lbDao.listAll();
         List<NetworkVO> networks = _networkDao.listAll();
         List<LoadBalancerTO> stateRules = null;
@@ -855,7 +855,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
                  * "HealthCheck Manager :: LB Provider in the Network has the Healthcheck
policy capability :: "
                  * + provider.get(0).getName());
                  */
-                rules = _lbDao.listByNetworkId(network.getId());
+                rules = _lbDao.listByNetworkIdAndScheme(network.getId(), scheme);
                 if (rules != null && rules.size() > 0) {
                     List<LoadBalancingRule> lbrules = new ArrayList<LoadBalancingRule>();
                     for (LoadBalancerVO lb : rules) {
@@ -1467,14 +1467,14 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
             lbs = Arrays.asList(lb);
         } else {
             // get all rules in transition state
-            lbs = _lbDao.listInTransitionStateByNetworkId(lb.getNetworkId());
+            lbs = _lbDao.listInTransitionStateByNetworkIdAndScheme(lb.getNetworkId(), lb.getScheme());
         }
         return applyLoadBalancerRules(lbs, true);
     }
 
     @Override
-    public boolean revokeLoadBalancersForNetwork(long networkId) throws ResourceUnavailableException
{
-        List<LoadBalancerVO> lbs = _lbDao.listByNetworkId(networkId);
+    public boolean revokeLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException
{
+        List<LoadBalancerVO> lbs = _lbDao.listByNetworkIdAndScheme(networkId, scheme);
         if (lbs != null) {
             for(LoadBalancerVO lb : lbs) { // called during restart, not persisting state
in db
                 lb.setState(FirewallRule.State.Revoke);
@@ -1487,8 +1487,8 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
     }
 
     @Override
-    public boolean applyLoadBalancersForNetwork(long networkId) throws ResourceUnavailableException
{
-        List<LoadBalancerVO> lbs = _lbDao.listByNetworkId(networkId);
+    public boolean applyLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException
{
+        List<LoadBalancerVO> lbs = _lbDao.listByNetworkIdAndScheme(networkId, scheme);
         if (lbs != null) {
             return applyLoadBalancerRules(lbs, true);
         } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76325e61/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 33aba00..46d55a7 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -172,6 +172,7 @@ import com.cloud.network.router.VirtualRouter.RedundantState;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRule.Purpose;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.network.rules.PortForwardingRule;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
@@ -2389,7 +2390,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                 }
             }
    
-            List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(guestNetworkId);
+            List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(guestNetworkId,
Scheme.Public);
             List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
             if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb,
provider)) {
                 // Re-apply load balancing rules
@@ -3295,7 +3296,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             public boolean execute(Network network, VirtualRouter router) throws ResourceUnavailableException
{
                 if (rules.get(0).getPurpose() == Purpose.LoadBalancing) {
                     // for load balancer we have to resend all lb rules for the network
-                    List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(network.getId());
+                    List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(network.getId(),
Scheme.Public);
                     List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
                     for (LoadBalancerVO lb : lbs) {
                         List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
@@ -3331,7 +3332,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             @Override
             public boolean execute(Network network, VirtualRouter router) throws ResourceUnavailableException
{
                 // for load balancer we have to resend all lb rules for the network
-                List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(network.getId());
+                List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(network.getId(),
Scheme.Public);
                 List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
                 for (LoadBalancerVO lb : lbs) {
                     List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());


Mime
View raw message