Updated Branches:
  refs/heads/master fe1b88f95 -> e91610407

Updated logic which add cluster to load balancer context on topology events


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/8120208d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/8120208d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/8120208d

Branch: refs/heads/master
Commit: 8120208d534a2b9e29eab06fe79988586edc3695
Parents: 7930d80
Author: Imesh Gunaratne <[email protected]>
Authored: Mon Dec 23 18:36:26 2013 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Mon Dec 23 18:36:26 2013 +0530

----------------------------------------------------------------------
 .../load/balancer/LoadBalancerTopologyReceiver.java |  4 +---
 .../balancer/context/LoadBalancerContextUtil.java   | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8120208d/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyReceiver.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyReceiver.java
 
b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyReceiver.java
index 983f4bf..7a0d9b5 100644
--- 
a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyReceiver.java
+++ 
b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyReceiver.java
@@ -84,9 +84,7 @@ public class LoadBalancerTopologyReceiver implements Runnable 
{
                     TopologyManager.acquireReadLock();
                     for (Service service : 
TopologyManager.getTopology().getServices()) {
                         for (Cluster cluster : service.getClusters()) {
-                            if (hasActiveMembers(cluster)) {
-                                
LoadBalancerContextUtil.addClusterToLbContext(cluster);
-                            }
+                            
LoadBalancerContextUtil.addClusterToLbContext(cluster);
                         }
                     }
                 } finally {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8120208d/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContextUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContextUtil.java
 
b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContextUtil.java
index a7309c2..037a7c3 100644
--- 
a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContextUtil.java
+++ 
b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContextUtil.java
@@ -35,20 +35,23 @@ public class LoadBalancerContextUtil {
         if (cluster == null)
             return;
 
-        // Add cluster to ClusterIdClusterMap
-        
LoadBalancerContext.getInstance().getClusterIdClusterMap().addCluster(cluster);
-
         Service service = 
TopologyManager.getTopology().getService(cluster.getServiceName());
         if (service == null) {
             throw new RuntimeException(String.format("Service not found: 
[cluster] %s", cluster.getClusterId()));
         }
 
+        // Add cluster to ClusterIdClusterMap
+        
LoadBalancerContext.getInstance().getClusterIdClusterMap().addCluster(cluster);
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Cluster added to cluster-id -> cluster 
map: [cluster] %s ", cluster.getClusterId()));
+        }
+
         // Add cluster to HostNameClusterMap
         for (String hostName : cluster.getHostNames()) {
             if 
(!LoadBalancerContext.getInstance().getHostNameClusterMap().containsCluster((hostName)))
 {
                 
LoadBalancerContext.getInstance().getHostNameClusterMap().addCluster(hostName, 
cluster);
                 if (log.isDebugEnabled()) {
-                    log.debug(String.format("Cluster added to single tenant 
cluster map: [cluster] %s [hostname] %s", cluster.getClusterId(), hostName));
+                    log.debug(String.format("Cluster added to hostname -> 
cluster map: [hostname] %s [cluster] %s ", hostName, cluster.getClusterId()));
                 }
             }
         }
@@ -70,12 +73,15 @@ public class LoadBalancerContextUtil {
             if 
(LoadBalancerContext.getInstance().getHostNameClusterMap().containsCluster(hostName))
 {
                 
LoadBalancerContext.getInstance().getHostNameClusterMap().removeCluster(hostName);
                 if (log.isDebugEnabled()) {
-                    log.debug(String.format("Cluster removed from single 
tenant cluster map: [cluster] %s [hostname] %s", cluster.getClusterId(), 
hostName));
+                    log.debug(String.format("Cluster removed from hostname -> 
cluster map: [hostname] %s [cluster] %s ", hostName, cluster.getClusterId()));
                 }
             }
         }
 
         // Remove cluster from ClusterIdClusterMap
         
LoadBalancerContext.getInstance().getClusterIdClusterMap().removeCluster(clusterId);
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Cluster removed from cluster-id -> 
cluster map: [cluster] %s ", cluster.getClusterId()));
+        }
     }
 }

Reply via email to