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 9dc322d
Date Mon, 21 Jul 2014 11:21:09 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master b8ddbe8ff -> 9dc322d46


CLOUDSTACK-7144: No GSLB provider is available during assigning load
balancing rule

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


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

Branch: refs/heads/master
Commit: 9dc322d46fa5cfb9abd87c408988abad1219d607
Parents: b8ddbe8
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Mon Jul 21 16:48:28 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Mon Jul 21 16:50:21 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    | 21 ++++++++++++--------
 ...GlobalLoadBalancingRulesServiceImplTest.java |  4 +++-
 5 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dc322d4/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 908d8f0..02034d6 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
@@ -234,6 +234,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/9dc322d4/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 e5086d2..1986777 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
@@ -98,5 +98,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/9dc322d4/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 fc1c7e2..1eba0b2 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
@@ -224,7 +224,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/9dc322d4/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 c84fea2..1d2c62b 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -95,10 +95,10 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
     @Inject
     AgentManager _agentMgr;
 
-    protected GslbServiceProvider _gslbProvider = null;
+    protected List<GslbServiceProvider> _gslbProviders;
 
-    public void setGslbServiceProvider(GslbServiceProvider provider) {
-        _gslbProvider = provider;
+    public void setGslbServiceProviders(List<GslbServiceProvider> providers) {
+        _gslbProviders = providers;
     }
 
     @Override
@@ -656,8 +656,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
                 new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType, 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);
@@ -686,7 +686,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);
@@ -711,11 +711,16 @@ 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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dc322d4/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 d152c66..94bc3c7 100644
--- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
+++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
@@ -720,7 +720,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