cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [18/18] git commit: updated refs/heads/4.3 to b8a28df
Date Tue, 25 Nov 2014 14:51:54 GMT
CLOUDSTACK-7144: No GSLB provider is available during assigning load
balancing rule

this fix ensures any bean implementing GslbProvider interface are injected
into GlobalLoadBalancingRulesServiceImpl.

(cherry picked from commit 9dc322d46fa5cfb9abd87c408988abad1219d607)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
	server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java


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

Branch: refs/heads/4.3
Commit: b8a28dfae391a4642e06569fbe1c3dbbafa66a69
Parents: 816eb63
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Mon Jul 21 16:48:28 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Nov 25 19:50:37 2014 +0530

----------------------------------------------------------------------
 .../core/spring-core-registry-core-context.xml  |  5 ++++
 ...re-lifecycle-network-context-inheritable.xml |  8 +++++--
 .../spring-server-core-managers-context.xml     |  5 ++--
 .../GlobalLoadBalancingRulesServiceImpl.java    | 24 ++++++++++++--------
 ...GlobalLoadBalancingRulesServiceImplTest.java |  4 +++-
 5 files changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8a28dfa/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
index 5e799c0..a10bbb3 100644
--- a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
+++ b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
@@ -229,6 +229,11 @@
         </property>
     </bean>
 
+    <bean id="gslbServiceProvidersRegistry"
+        class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
+        <property name="excludeKey" value="gslb.service.provider.exclude" />
+    </bean>
+
     <bean id="affinityProcessorsRegistry"
         class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
         <property name="orderConfigKey" value="affinity.processors.order" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8a28dfa/core/resources/META-INF/cloudstack/network/spring-core-lifecycle-network-context-inheritable.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/network/spring-core-lifecycle-network-context-inheritable.xml
b/core/resources/META-INF/cloudstack/network/spring-core-lifecycle-network-context-inheritable.xml
index a54d588..76cdfe3 100644
--- a/core/resources/META-INF/cloudstack/network/spring-core-lifecycle-network-context-inheritable.xml
+++ b/core/resources/META-INF/cloudstack/network/spring-core-lifecycle-network-context-inheritable.xml
@@ -96,5 +96,9 @@
         <property name="typeClass"
             value="com.cloud.network.element.RemoteAccessVPNServiceProvider" />
     </bean>
-
-</beans>
\ No newline at end of file
+    <bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
+        <property name="registry" ref="gslbServiceProvidersRegistry" />
+        <property name="typeClass"
+            value="org.apache.cloudstack.region.gslb.GslbServiceProvider" />
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8a28dfa/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index 31f31cd..a5f9a0b 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -231,7 +231,8 @@
     <bean id="PlannerHostReservationDaoImpl" class="com.cloud.deploy.dao.PlannerHostReservationDaoImpl"
/>
 
     <bean id="GlobalLoadBalancingRulesServiceImpl"
-        class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
-
+        class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" >
+        <property name="gslbServiceProviders" value="#{gslbServiceProvidersRegistry.registered}"
/>
+    </bean>
     <bean id="certServiceImpl" class="org.apache.cloudstack.network.lb.CertServiceImpl"
/>
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8a28dfa/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 62b9748..d4275d4 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -85,9 +85,10 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
     @Inject
     AgentManager _agentMgr;
 
-    protected GslbServiceProvider _gslbProvider=null;
-    public void setGslbServiceProvider(GslbServiceProvider provider) {
-        this._gslbProvider = provider;
+    protected List<GslbServiceProvider> _gslbProviders;
+
+    public void setGslbServiceProviders(List<GslbServiceProvider> providers) {
+        _gslbProviders = providers;
     }
 
     @Override
@@ -663,8 +664,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
                     ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()),
                     dataCenterId);
 
-            siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId,
physicalNetworkId));
-            siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId,
physicalNetworkId));
+            siteLb.setGslbProviderPublicIp(lookupGslbServiceProvider().getZoneGslbProviderPublicIp(dataCenterId,
physicalNetworkId));
+            siteLb.setGslbProviderPrivateIp(lookupGslbServiceProvider().getZoneGslbProviderPrivateIp(dataCenterId,
physicalNetworkId));
             siteLb.setWeight(gslbLbMapVo.getWeight());
 
             zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
@@ -693,7 +694,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             }
 
             try {
-                _gslbProvider.applyGlobalLoadBalancerRule(zoneId.first(), zoneId.second(),
gslbConfigCmd);
+                lookupGslbServiceProvider().applyGlobalLoadBalancerRule(zoneId.first(), zoneId.second(),
gslbConfigCmd);
             } catch (ResourceUnavailableException e) {
                 String msg =  "Failed to configure GSLB rule in the zone " + zoneId.first()
+ " due to " + e.getMessage();
                 s_logger.warn(msg);
@@ -719,15 +720,20 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
 
     private boolean checkGslbServiceEnabledInZone(long zoneId, long physicalNetworkId) {
 
-        if (_gslbProvider == null) {
+        GslbServiceProvider gslbProvider = lookupGslbServiceProvider();
+        if (gslbProvider == null) {
             throw new CloudRuntimeException("No GSLB provider is available");
         }
 
-        return _gslbProvider.isServiceEnabledInZone(zoneId, physicalNetworkId);
+        return gslbProvider.isServiceEnabledInZone(zoneId, physicalNetworkId);
+    }
+
+    protected GslbServiceProvider lookupGslbServiceProvider() {
+        return _gslbProviders.size() == 0 ? null : _gslbProviders.get(0);
     }
 
     @Override
     public GlobalLoadBalancerRule findById(long gslbRuleId) {
         return _gslbRuleDao.findById(gslbRuleId);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8a28dfa/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
index 504ab9c..5b5dd08 100644
--- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
+++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
@@ -726,7 +726,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
         gslbServiceImpl._globalConfigDao = Mockito.mock(ConfigurationDao.class);
         gslbServiceImpl._ipAddressDao = Mockito.mock(IPAddressDao.class);
         gslbServiceImpl._agentMgr = Mockito.mock(AgentManager.class);
-        gslbServiceImpl._gslbProvider = Mockito.mock(GslbServiceProvider.class);
+        List<GslbServiceProvider> mockGslbProviders = new ArrayList<GslbServiceProvider>();
+        mockGslbProviders.add(Mockito.mock(GslbServiceProvider.class));
+        gslbServiceImpl._gslbProviders = mockGslbProviders;
 
         RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd = new RemoveFromGlobalLoadBalancerRuleCmdExtn();
         Class<?> _class = removeFromGslbCmd.getClass().getSuperclass();


Mime
View raw message