cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: updated refs/heads/master to cb595ca
Date Tue, 04 Jun 2013 13:23:45 GMT
Updated Branches:
  refs/heads/master ee3043b88 -> cb595cafc


CLOUDSTACK-2390:[GSLB] After removeFromGSLBRule, still CloudStack things
that lb rule is active

removing the GSLB rule to Lb rule mapping once rules are applied on the
GSLB service provider


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

Branch: refs/heads/master
Commit: cb595cafc7b4fad56e7da6b4f3a1e71402648d44
Parents: ee3043b
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Tue Jun 4 15:51:31 2013 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Tue Jun 4 18:53:17 2013 +0530

----------------------------------------------------------------------
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |   47 +++++++++++---
 1 files changed, 37 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb595caf/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
index 02c7720..7c46d4a 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -260,7 +260,13 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             s_logger.debug("Configuring gslb rule configuration on the gslb service providers
in the participating zones");
 
             // apply the gslb rule on to the back end gslb service providers on zones participating
in gslb
-            applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+            if (!applyGlobalLoadBalancerRuleConfig(gslbRuleId, false)) {
+                s_logger.warn("Failed to add load balancer rules " + newLbRuleIds + " to
global load balancer rule id "
+                        + gslbRuleId);
+                CloudRuntimeException ex = new CloudRuntimeException(
+                        "Failed to add load balancer rules to GSLB rule ");
+                throw ex;
+            }
 
             // on success set state to Active
             gslbRule.setState(GlobalLoadBalancerRule.State.Active);
@@ -269,7 +275,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             success = true;
 
         } catch (ResourceUnavailableException e) {
-            throw new CloudRuntimeException("Failed to apply gslb config");
+            throw new CloudRuntimeException("Failed to apply new GSLB configuration while
assigning new LB rules to GSLB rule.");
         }
 
         return  success;
@@ -359,11 +365,28 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             s_logger.debug("Attempting to configure global load balancer rule configuration
on the gslb service providers ");
 
             // apply the gslb rule on to the back end gslb service providers
-            applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+            if (!applyGlobalLoadBalancerRuleConfig(gslbRuleId, false)) {
+                s_logger.warn("Failed to remove load balancer rules " + lbRuleIdsToremove
+ " from global load balancer rule id "
+                        + gslbRuleId);
+                CloudRuntimeException ex = new CloudRuntimeException(
+                        "Failed to remove load balancer rule ids from GSLB rule ");
+                throw ex;
+            }
 
-            // on success set state to Active
+            txn.start();
+
+            // remove the mappings of gslb rule to Lb rule that are in revoked state
+            for (Long lbRuleId : lbRuleIdsToremove) {
+                GlobalLoadBalancerLbRuleMapVO removeGslbLbMap = _gslbLbMapDao.findByGslbRuleIdAndLbRuleId(gslbRuleId,
lbRuleId);
+                _gslbLbMapDao.remove(removeGslbLbMap.getId());
+            }
+
+            // on success set state back to Active
             gslbRule.setState(GlobalLoadBalancerRule.State.Active);
             _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+
+            txn.commit();
+
             success = true;
         } catch (ResourceUnavailableException e) {
             throw new CloudRuntimeException("Failed to update removed load balancer details
from gloabal load balancer");
@@ -402,8 +425,16 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
 
         _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
 
-        if (gslbRule.getState() == GlobalLoadBalancerRule.State.Revoke) {
-            throw new InvalidParameterValueException("global load balancer rule id: " + gslbRuleId
+ " is already in revoked state");
+        if (gslbRule.getState() == com.cloud.region.ha.GlobalLoadBalancerRule.State.Staged)
{
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Rule Id: " + gslbRuleId + " is still in Staged state so just
removing it.");
+            }
+            _gslbRuleDao.remove(gslbRuleId);
+            return;
+        } else  if (gslbRule.getState() == GlobalLoadBalancerRule.State.Add || gslbRule.getState()
== GlobalLoadBalancerRule.State.Active) {
+            //mark the GSlb rule to be in revoke state
+            gslbRule.setState(GlobalLoadBalancerRule.State.Revoke);
+            _gslbRuleDao.update(gslbRuleId, gslbRule);
         }
 
         Transaction txn = Transaction.currentTxn();
@@ -418,10 +449,6 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             }
         }
 
-        //mark the GSlb rule to be in revoke state
-        gslbRule.setState(GlobalLoadBalancerRule.State.Revoke);
-        _gslbRuleDao.update(gslbRuleId, gslbRule);
-
         txn.commit();
 
         boolean success = false;


Mime
View raw message