You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/03/03 19:24:57 UTC

[1/2] stratos git commit: Refining load balancer domain mapping event receiver and topology event receiver

Repository: stratos
Updated Branches:
  refs/heads/master d0c991f5d -> a970a90ce


http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
index 99fcaa1..80b85d8 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
@@ -121,11 +121,10 @@ public class RequestDelegator {
 	 */
     private synchronized Member findNextMemberInCluster(Cluster cluster) {
         // Find algorithm context of the cluster
-        ClusterContext clusterContext = LoadBalancerContext.getInstance().
-                getClusterIdClusterContextMap().getClusterContext(cluster.getClusterId());
+        ClusterContext clusterContext = LoadBalancerContext.getInstance().getClusterContext(cluster.getClusterId());
         if (clusterContext == null) {
             clusterContext = new ClusterContext(cluster.getServiceName(), cluster.getClusterId());
-            LoadBalancerContext.getInstance().getClusterIdClusterContextMap().addClusterContext(clusterContext);
+            LoadBalancerContext.getInstance().addClusterContext(clusterContext);
         }
 
         AlgorithmContext algorithmContext = clusterContext.getAlgorithmContext();

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
index 8a35b12..9c4a66c 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
@@ -612,12 +612,14 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
                 }
             }
 
+            // Map domain mapping app context
             String hostName = extractTargetHost(synCtx);
-            if (LoadBalancerContext.getInstance().getHostNameContextPathMap().contains(hostName)) {
-                String appContext = LoadBalancerContext.getInstance().getHostNameContextPathMap().getAppContext(hostName);
+            if (LoadBalancerContext.getInstance().containsDomainMappingContextPath(hostName)) {
+                String appContext = LoadBalancerContext.getInstance().getDomainMappingContextPath(hostName);
                 if(StringUtils.isNotBlank(appContext)) {
                     if (log.isDebugEnabled()) {
-                        log.debug(String.format("Domain mapping found with application context: [domain-name] %s [app-context] %s", hostName, appContext));
+                        log.debug(String.format("Domain mapping found with application context: [domain-name] %s " +
+                                "[app-context] %s", hostName, appContext));
                         log.debug(String.format("Incoming request address: %s", address));
                     }
                     address = "/" + cleanURLPath(appContext) + "/" + cleanURLPath(address);

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerDomainMappingEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerDomainMappingEventReceiver.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerDomainMappingEventReceiver.java
new file mode 100644
index 0000000..0031d64
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerDomainMappingEventReceiver.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.load.balancer.event.receivers;
+
+import org.apache.stratos.load.balancer.common.domain.Cluster;
+import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerCommonDomainMappingEventReceiver;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.load.balancer.context.LoadBalancerContext;
+
+/**
+ * Load balancer domain mapping event receiver.
+ */
+public class LoadBalancerDomainMappingEventReceiver extends LoadBalancerCommonDomainMappingEventReceiver {
+
+    public LoadBalancerDomainMappingEventReceiver(TopologyProvider topologyProvider) {
+        super(topologyProvider);
+    }
+
+    @Override
+    protected void addDomainMapping(Cluster cluster, String domainName, String contextPath) {
+        super.addDomainMapping(cluster, domainName, contextPath);
+
+        // Add domain mapping context path
+        LoadBalancerContext.getInstance().addDomainMappingContextPath(domainName, contextPath);
+    }
+
+    @Override
+    protected void removeDomainMapping(Cluster cluster, String domainName) {
+        super.removeDomainMapping(cluster, domainName);
+
+        // Remove domain mapping context path
+        LoadBalancerContext.getInstance().removeDomainMappingContextPath(domainName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerTopologyEventReceiver.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerTopologyEventReceiver.java
new file mode 100644
index 0000000..de5c0bb
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/event/receivers/LoadBalancerTopologyEventReceiver.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.load.balancer.event.receivers;
+
+import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerCommonTopologyEventReceiver;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.load.balancer.context.LoadBalancerContext;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+
+/**
+ * Load balancer topology event receiver.
+ */
+public class LoadBalancerTopologyEventReceiver extends LoadBalancerCommonTopologyEventReceiver {
+
+    public LoadBalancerTopologyEventReceiver(TopologyProvider topologyProvider) {
+        super(topologyProvider);
+    }
+
+    @Override
+    protected void removeCluster(Cluster cluster) {
+        super.removeCluster(cluster);
+
+        // Remove cluster context
+        LoadBalancerContext.getInstance().removeClusterContext(cluster.getClusterId());
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
index 33ce789..839ed8d 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
@@ -26,9 +26,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.clustering.DistributedObjectProvider;
 import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerApplicationSignUpEventReceiver;
-import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerDomainMappingEventReceiver;
-import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerTopologyEventReceiver;
+import org.apache.stratos.load.balancer.common.event.receivers.LoadBalancerCommonApplicationSignUpEventReceiver;
 import org.apache.stratos.load.balancer.common.statistics.notifier.LoadBalancerStatisticsNotifier;
 import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
 import org.apache.stratos.load.balancer.conf.LoadBalancerConfiguration;
@@ -36,6 +34,8 @@ import org.apache.stratos.load.balancer.conf.configurator.CEPConfigurator;
 import org.apache.stratos.load.balancer.conf.configurator.SynapseConfigurator;
 import org.apache.stratos.load.balancer.conf.configurator.TopologyFilterConfigurator;
 import org.apache.stratos.load.balancer.endpoint.EndpointDeployer;
+import org.apache.stratos.load.balancer.event.receivers.LoadBalancerDomainMappingEventReceiver;
+import org.apache.stratos.load.balancer.event.receivers.LoadBalancerTopologyEventReceiver;
 import org.apache.stratos.load.balancer.exception.TenantAwareLoadBalanceEndpointException;
 import org.apache.stratos.load.balancer.statistics.LoadBalancerStatisticsCollector;
 import org.apache.stratos.load.balancer.util.LoadBalancerConstants;
@@ -91,10 +91,10 @@ public class LoadBalancerServiceComponent {
 
     private boolean activated = false;
     private ExecutorService executorService;
-    private LoadBalancerTopologyEventReceiver topologyReceiver;
     private TenantEventReceiver tenantReceiver;
-    private LoadBalancerApplicationSignUpEventReceiver applicationSignUpEventReceiver;
+    private LoadBalancerTopologyEventReceiver topologyReceiver;
     private LoadBalancerDomainMappingEventReceiver domainMappingEventReceiver;
+    private LoadBalancerCommonApplicationSignUpEventReceiver applicationSignUpEventReceiver;
     private LoadBalancerStatisticsNotifier statisticsNotifier;
 
     protected void activate(ComponentContext ctxt) {
@@ -220,7 +220,7 @@ public class LoadBalancerServiceComponent {
     }
 
     private void startApplicationSignUpEventReceiver(ExecutorService executorService, TopologyProvider topologyProvider) {
-        applicationSignUpEventReceiver = new LoadBalancerApplicationSignUpEventReceiver(topologyProvider);
+        applicationSignUpEventReceiver = new LoadBalancerCommonApplicationSignUpEventReceiver(topologyProvider);
         applicationSignUpEventReceiver.setExecutorService(executorService);
         applicationSignUpEventReceiver.execute();
         if (log.isInfoEnabled()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
index c8d0c2c..312ff46 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
@@ -21,7 +21,6 @@ package org.apache.stratos.load.balancer.mediators;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
 import org.apache.stratos.load.balancer.conf.LoadBalancerConfiguration;
-import org.apache.stratos.load.balancer.context.LoadBalancerContext;
 import org.apache.stratos.load.balancer.util.LoadBalancerConstants;
 import org.apache.synapse.MessageContext;
 import org.apache.synapse.core.axis2.Axis2MessageContext;
@@ -65,22 +64,23 @@ public class LocationReWriter extends AbstractMediator {
                     }
 
                     // Check whether the location host is an ip address of a known member
-                    String hostname = LoadBalancerContext.getInstance().getMemberIpHostnameMap().get(inLocationUrl.getHost());
-                    if (StringUtils.isEmpty(hostname)) {
-                        TopologyProvider topologyProvider = LoadBalancerConfiguration.getInstance().getTopologyProvider();
+                    TopologyProvider topologyProvider = LoadBalancerConfiguration.getInstance().getTopologyProvider();
+                    String clusterHostname = topologyProvider.getClusterHostname(inLocationUrl.getHost());
+                    if (StringUtils.isEmpty(clusterHostname)) {
                         if (topologyProvider.getClusterByHostName(inLocationUrl.getHost()) == null) {
                         	if (log.isDebugEnabled()) {
-                                log.debug(String.format("A hostname not found for ip: [ip-address] %s", inLocationUrl.getHost()));
+                                log.debug(String.format("A cluster hostname not found for ip: [ip-address] %s",
+                                        inLocationUrl.getHost()));
                             }
                         	return;
                         } else {
-                        	hostname = inLocationUrl.getHost();
+                        	clusterHostname = inLocationUrl.getHost();
                         }
                     }
 
                     if (log.isDebugEnabled()) {
                         log.debug(String.format("A location header found with member ip: [member-ip] %s " +
-                                "[hostname] %s ", inLocationUrl.getHost(), hostname));
+                                "[cluster-hostname] %s ", inLocationUrl.getHost(), clusterHostname));
                     }
 
                     int targetPort = -1;
@@ -96,7 +96,7 @@ public class LocationReWriter extends AbstractMediator {
 
                     if (targetPort != -1) {
                         // Re-write location header
-                        URL outLocationUrl = new URL(inLocationUrl.getProtocol(), hostname, targetPort, inLocationUrl.getFile());
+                        URL outLocationUrl = new URL(inLocationUrl.getProtocol(), clusterHostname, targetPort, inLocationUrl.getFile());
                         transportHeaders.put(LOCATION, outLocationUrl.toString());
                         if (log.isDebugEnabled()) {
                             log.debug(String.format("Location header re-written: %s", outLocationUrl.toString()));


[2/2] stratos git commit: Refining load balancer domain mapping event receiver and topology event receiver

Posted by im...@apache.org.
Refining load balancer domain mapping event receiver and topology event receiver


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

Branch: refs/heads/master
Commit: a970a90ce3a2e6e8618a1373480c74bed9b10283
Parents: d0c991f
Author: Imesh Gunaratne <im...@apache.org>
Authored: Tue Mar 3 23:54:31 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Tue Mar 3 23:54:50 2015 +0530

----------------------------------------------------------------------
 .../load/balancer/common/domain/Cluster.java    |   2 +-
 ...dBalancerApplicationSignUpEventReceiver.java |  74 ----
 ...cerCommonApplicationSignUpEventReceiver.java |  74 ++++
 ...alancerCommonDomainMappingEventReceiver.java | 105 ++++++
 ...LoadBalancerCommonTopologyEventReceiver.java | 354 +++++++++++++++++++
 .../LoadBalancerDomainMappingEventReceiver.java |  86 -----
 .../LoadBalancerTopologyEventReceiver.java      | 354 -------------------
 .../LoadBalancerStatisticsNotifier.java         |   1 -
 .../common/topology/TopologyProvider.java       |  86 +++++
 .../load/balancer/context/AlgorithmContext.java |  53 ++-
 .../load/balancer/context/ClusterContext.java   |   3 +-
 .../balancer/context/LoadBalancerContext.java   |  70 ++--
 .../load/balancer/context/ServiceContext.java   |  58 ---
 .../context/map/AlgorithmContextMap.java        |  90 -----
 .../context/map/ClusterIdClusterContextMap.java |  61 ----
 .../context/map/HostNameAppContextMap.java      |  55 ---
 .../context/map/MemberIpHostnameMap.java        |  64 ----
 .../balancer/endpoint/RequestDelegator.java     |   5 +-
 .../TenantAwareLoadBalanceEndpoint.java         |   8 +-
 .../LoadBalancerDomainMappingEventReceiver.java |  51 +++
 .../LoadBalancerTopologyEventReceiver.java      |  43 +++
 .../internal/LoadBalancerServiceComponent.java  |  12 +-
 .../balancer/mediators/LocationReWriter.java    |  16 +-
 23 files changed, 824 insertions(+), 901 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Cluster.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Cluster.java
index 7f2fd9c..d2f9c4e 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Cluster.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Cluster.java
@@ -97,7 +97,7 @@ public class Cluster {
         return memberMap.get(memberId);
     }
 
-    public Collection getMembers() {
+    public Collection<Member> getMembers() {
         return memberMap.values();
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerApplicationSignUpEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerApplicationSignUpEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerApplicationSignUpEventReceiver.java
deleted file mode 100644
index 1f4e26b..0000000
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerApplicationSignUpEventReceiver.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.common.event.receivers;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
-import org.apache.stratos.load.balancer.common.domain.Cluster;
-import org.apache.stratos.messaging.domain.application.signup.ApplicationSignUp;
-import org.apache.stratos.messaging.domain.application.signup.DomainMapping;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.application.signup.CompleteApplicationSignUpsEvent;
-import org.apache.stratos.messaging.listener.application.signup.CompleteApplicationSignUpsEventListener;
-import org.apache.stratos.messaging.message.receiver.application.signup.ApplicationSignUpEventReceiver;
-
-/**
- * Load balancer application signup event receiver updates the topology in the given topology provider
- * with the hostnames found in application signup events.
- */
-public class LoadBalancerApplicationSignUpEventReceiver extends ApplicationSignUpEventReceiver {
-
-    private static final Log log = LogFactory.getLog(LoadBalancerApplicationSignUpEventReceiver.class);
-
-    private TopologyProvider topologyProvider;
-
-    public LoadBalancerApplicationSignUpEventReceiver(TopologyProvider topologyProvider) {
-        this.topologyProvider = topologyProvider;
-        addEventListeners();
-    }
-
-    private void addEventListeners() {
-        addEventListener(new CompleteApplicationSignUpsEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Complete application signup event received");
-                }
-
-                CompleteApplicationSignUpsEvent completeApplicationSignUpsEvent = (CompleteApplicationSignUpsEvent)event;
-                for(ApplicationSignUp applicationSignUp : completeApplicationSignUpsEvent.getApplicationSignUps()) {
-                    if(applicationSignUp.getDomainMappings() != null) {
-                        for (DomainMapping domainMapping : applicationSignUp.getDomainMappings()) {
-                            if(domainMapping != null) {
-                                Cluster cluster = topologyProvider.getClusterByClusterId(domainMapping.getClusterId());
-                                if(cluster != null) {
-                                    cluster.addHostName(domainMapping.getDomainName());
-                                    log.info(String.format("Domain mapping added: [cluster] %s [domain] %s",
-                                            cluster.getClusterId(), domainMapping.getDomainName()));
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        });
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonApplicationSignUpEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonApplicationSignUpEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonApplicationSignUpEventReceiver.java
new file mode 100644
index 0000000..c9c319d
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonApplicationSignUpEventReceiver.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.load.balancer.common.event.receivers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.load.balancer.common.domain.Cluster;
+import org.apache.stratos.messaging.domain.application.signup.ApplicationSignUp;
+import org.apache.stratos.messaging.domain.application.signup.DomainMapping;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.application.signup.CompleteApplicationSignUpsEvent;
+import org.apache.stratos.messaging.listener.application.signup.CompleteApplicationSignUpsEventListener;
+import org.apache.stratos.messaging.message.receiver.application.signup.ApplicationSignUpEventReceiver;
+
+/**
+ * Load balancer common application signup event receiver updates the topology in the given topology provider
+ * with the hostnames found in application signup events.
+ */
+public class LoadBalancerCommonApplicationSignUpEventReceiver extends ApplicationSignUpEventReceiver {
+
+    private static final Log log = LogFactory.getLog(LoadBalancerCommonApplicationSignUpEventReceiver.class);
+
+    private TopologyProvider topologyProvider;
+
+    public LoadBalancerCommonApplicationSignUpEventReceiver(TopologyProvider topologyProvider) {
+        this.topologyProvider = topologyProvider;
+        addEventListeners();
+    }
+
+    private void addEventListeners() {
+        addEventListener(new CompleteApplicationSignUpsEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Complete application signup event received");
+                }
+
+                CompleteApplicationSignUpsEvent completeApplicationSignUpsEvent = (CompleteApplicationSignUpsEvent)event;
+                for(ApplicationSignUp applicationSignUp : completeApplicationSignUpsEvent.getApplicationSignUps()) {
+                    if(applicationSignUp.getDomainMappings() != null) {
+                        for (DomainMapping domainMapping : applicationSignUp.getDomainMappings()) {
+                            if(domainMapping != null) {
+                                Cluster cluster = topologyProvider.getClusterByClusterId(domainMapping.getClusterId());
+                                if(cluster != null) {
+                                    cluster.addHostName(domainMapping.getDomainName());
+                                    log.info(String.format("Domain mapping added: [cluster] %s [domain] %s",
+                                            cluster.getClusterId(), domainMapping.getDomainName()));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonDomainMappingEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonDomainMappingEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonDomainMappingEventReceiver.java
new file mode 100644
index 0000000..a75121c
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonDomainMappingEventReceiver.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.load.balancer.common.event.receivers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.load.balancer.common.domain.Cluster;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.domain.mapping.DomainMappingAddedEvent;
+import org.apache.stratos.messaging.event.domain.mapping.DomainMappingRemovedEvent;
+import org.apache.stratos.messaging.listener.domain.mapping.DomainMappingAddedEventListener;
+import org.apache.stratos.messaging.listener.domain.mapping.DomainMappingRemovedEventListener;
+import org.apache.stratos.messaging.message.receiver.domain.mapping.DomainMappingEventReceiver;
+
+/**
+ * Load balancer common domain mapping event receiver updates the topology in the given topology provider
+ * with the domains found in domain mapping events.
+ */
+public class LoadBalancerCommonDomainMappingEventReceiver extends DomainMappingEventReceiver {
+
+    private static final Log log = LogFactory.getLog(LoadBalancerCommonDomainMappingEventReceiver.class);
+
+    private TopologyProvider topologyProvider;
+
+    public LoadBalancerCommonDomainMappingEventReceiver(TopologyProvider topologyProvider) {
+        this.topologyProvider = topologyProvider;
+        addEventListeners();
+    }
+
+    private void addEventListeners() {
+
+        addEventListener(new DomainMappingAddedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                DomainMappingAddedEvent domainMappingAddedEvent = (DomainMappingAddedEvent)event;
+
+                String domainName = domainMappingAddedEvent.getDomainName();
+                String contextPath = domainMappingAddedEvent.getContextPath();
+
+                String clusterId = domainMappingAddedEvent.getClusterId();
+                Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
+                if(cluster == null) {
+                    log.warn(String.format("Could not add domain mapping, cluster not found: [cluster] %s", clusterId));
+                }
+
+                addDomainMapping(cluster, domainName, contextPath);
+            }
+        });
+
+        addEventListener(new DomainMappingRemovedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                DomainMappingRemovedEvent domainMappingRemovedEvent = (DomainMappingRemovedEvent)event;
+
+                String clusterId = domainMappingRemovedEvent.getClusterId();
+                Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
+                if(cluster == null) {
+                    log.warn(String.format("Could not remove domain mapping, cluster not found: [cluster] %s", clusterId));
+                }
+
+                String domainName = domainMappingRemovedEvent.getDomainName();
+                removeDomainMapping(cluster, domainName);
+            }
+        });
+    }
+
+    /**
+     * Add domain mapping.
+     * @param cluster
+     * @param domainName
+     * @param contextPath
+     */
+    protected void addDomainMapping(Cluster cluster, String domainName, String contextPath) {
+        cluster.addHostName(domainName, contextPath);
+        log.info(String.format("Domain mapping added: [cluster] %s [domain] %s [context-path]", cluster.getClusterId(), domainName));
+    }
+
+    /**
+     * Remove domain mapping.
+     * @param cluster
+     * @param domainName
+     */
+    protected void removeDomainMapping(Cluster cluster, String domainName) {
+        cluster.removeHostName(domainName);
+        log.info(String.format("Domain mapping removed: [cluster] %s [domain] %s", cluster.getClusterId(), domainName));
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonTopologyEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonTopologyEventReceiver.java
new file mode 100644
index 0000000..326deee
--- /dev/null
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerCommonTopologyEventReceiver.java
@@ -0,0 +1,354 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.load.balancer.common.event.receivers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.topology.MemberStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.messaging.listener.topology.*;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+
+/**
+ * Load balancer common topology receiver updates the topology in the given topology provider
+ * according to topology events.
+ */
+public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiver {
+
+    private static final Log log = LogFactory.getLog(LoadBalancerCommonTopologyEventReceiver.class);
+
+    private TopologyProvider topologyProvider;
+
+    public LoadBalancerCommonTopologyEventReceiver(TopologyProvider topologyProvider) {
+        this.topologyProvider = topologyProvider;
+        addEventListeners();
+    }
+
+    public void execute() {
+	    super.execute();
+        if (log.isInfoEnabled()) {
+            log.info("Load balancer topology receiver thread started");
+        }
+    }
+
+    private void addEventListeners() {
+
+        addEventListener(new CompleteTopologyEventListener() {
+            private boolean initialized;
+
+            @Override
+            protected void onEvent(Event event) {
+                if (!initialized) {
+                    try {
+                        TopologyManager.acquireReadLock();
+                        for (Service service : TopologyManager.getTopology().getServices()) {
+                            for (Cluster cluster : service.getClusters()) {
+                                for (Member member : cluster.getMembers()) {
+                                    if (member.getStatus() == MemberStatus.Active) {
+                                        addMember(cluster.getServiceName(), member.getClusterId(), member.getMemberId());
+                                    }
+                                }
+                            }
+                        }
+                        initialized = true;
+                    } catch (Exception e) {
+                        log.error("Error processing event", e);
+                    } finally {
+                        TopologyManager.releaseReadLock();
+                    }
+                }
+            }
+        });
+
+        addEventListener(new MemberActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
+
+                String serviceName = memberActivatedEvent.getServiceName();
+                String clusterId = memberActivatedEvent.getClusterId();
+                String memberId = memberActivatedEvent.getMemberId();
+
+                try {
+                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+                    addMember(serviceName, clusterId, memberId);
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+                }
+            }
+        });
+
+        addEventListener(new MemberMaintenanceListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event;
+
+                String serviceName = memberMaintenanceModeEvent.getServiceName();
+                String clusterId = memberMaintenanceModeEvent.getClusterId();
+                String memberId = memberMaintenanceModeEvent.getMemberId();
+
+                try {
+                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+                    removeMember(serviceName, clusterId, memberId);
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForCluster(serviceName,
+                            clusterId);
+                }
+            }
+        });
+
+        addEventListener(new MemberSuspendedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event;
+
+                String serviceName = memberSuspendedEvent.getServiceName();
+                String clusterId = memberSuspendedEvent.getClusterId();
+                String memberId = memberSuspendedEvent.getMemberId();
+
+                try {
+                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+                    removeMember(serviceName, clusterId, memberId);
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(),
+                            memberSuspendedEvent.getClusterId());
+                }
+            }
+        });
+
+        addEventListener(new MemberTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
+
+                String serviceName = memberTerminatedEvent.getServiceName();
+                String clusterId = memberTerminatedEvent.getClusterId();
+                String memberId = memberTerminatedEvent.getMemberId();
+
+                try {
+                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+                    removeMember(serviceName, clusterId, memberId);
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+                }
+            }
+        });
+
+        addEventListener(new ClusterRemovedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
+                String serviceName = clusterRemovedEvent.getServiceName();
+                String clusterId = clusterRemovedEvent.getClusterId();
+
+                try {
+                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+
+                    Service service = TopologyManager.getTopology().getService(serviceName);
+                    if (service == null) {
+                        if (log.isWarnEnabled()) {
+                            log.warn(String.format("Service not found in topology: [service] %s", serviceName));
+                        }
+                        return;
+                    }
+
+                    Cluster cluster = service.getCluster(clusterId);
+                    removeCluster(cluster);
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+                }
+            }
+        });
+
+        addEventListener(new ServiceRemovedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event;
+                String serviceName = serviceRemovedEvent.getServiceName();
+
+                try {
+                    TopologyManager.acquireReadLockForService(serviceName);
+
+                    Service service = TopologyManager.getTopology().getService(serviceName);
+                    if (service == null) {
+                        if (log.isWarnEnabled()) {
+                            log.warn(String.format("Service not found in topology: [service] %s",
+                                    serviceName));
+                        }
+                        return;
+                    }
+                    for(Cluster cluster : service.getClusters()) {
+                        removeCluster(cluster);
+                    }
+                } catch (Exception e) {
+                    log.error("Error processing event", e);
+                } finally {
+                    TopologyManager.releaseReadLockForService(serviceName);
+                }
+            }
+        });
+    }
+
+    /**
+     * Remove cluster from topology provider
+     * @param cluster
+     */
+    protected void removeCluster(Cluster cluster) {
+        for(Member member : cluster.getMembers()) {
+            removeMember(member.getServiceName(), member.getClusterId(), member.getMemberId());
+        }
+    }
+
+    /**
+     * Add member to topology provider
+     * @param serviceName
+     * @param clusterId
+     * @param memberId
+     */
+    protected void addMember(String serviceName, String clusterId, String memberId) {
+        Service service = TopologyManager.getTopology().getService(serviceName);
+        if (service == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Service not found in topology: [service] %s",
+                        serviceName));
+            }
+            return;
+        }
+        Cluster cluster = service.getCluster(clusterId);
+        if (cluster == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Cluster not found in topology: [service] %s [cluster] %s",
+                        serviceName, clusterId));
+            }
+            return;
+        }
+        validateHostNames(cluster);
+
+        // Add cluster if not exists
+        if(!topologyProvider.clusterExistsByClusterId(cluster.getClusterId())) {
+            topologyProvider.addCluster(transformCluster(cluster));
+        }
+
+        Member member = cluster.getMember(memberId);
+        if (member == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Member not found in topology: [service] %s [cluster] %s [member] %s",
+                        serviceName, clusterId,
+                        memberId));
+            }
+            return;
+        }
+        topologyProvider.addMember(transformMember(member));
+    }
+
+    /**
+     * Remove member from topology provider
+     * @param serviceName
+     * @param clusterId
+     * @param memberId
+     */
+    protected void removeMember(String serviceName, String clusterId, String memberId) {
+        Service service = TopologyManager.getTopology().getService(serviceName);
+        if (service == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Service not found in topology: [service] %s",
+                        serviceName));
+            }
+            return;
+        }
+
+        Cluster cluster = service.getCluster(clusterId);
+        if (cluster == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Cluster not found in topology: [service] %s [cluster] %s",
+                        serviceName, clusterId));
+            }
+            return;
+        }
+        validateHostNames(cluster);
+
+        Member member = cluster.getMember(memberId);
+        if (member == null) {
+            if (log.isWarnEnabled()) {
+                log.warn(String.format("Member not found in topology: [service] %s [cluster] %s [member] %s",
+                        serviceName, clusterId,
+                        memberId));
+            }
+            return;
+        }
+
+        if (member != null) {
+            topologyProvider.removeMember(cluster.getClusterId(), member.getMemberId());
+        }
+    }
+
+    private void validateHostNames(Cluster cluster) {
+        if((cluster.getHostNames() == null) || (cluster.getHostNames().size() == 0)) {
+            throw new RuntimeException(String.format("Host names not found in cluster: " +
+                    "[cluster] %s", cluster.getClusterId()));
+        }
+    }
+
+    private org.apache.stratos.load.balancer.common.domain.Cluster transformCluster(Cluster messagingCluster) {
+        org.apache.stratos.load.balancer.common.domain.Cluster cluster =
+                new org.apache.stratos.load.balancer.common.domain.Cluster(messagingCluster.getServiceName(),
+                        messagingCluster.getClusterId());
+        cluster.setTenantRange(messagingCluster.getTenantRange());
+        if(messagingCluster.getHostNames() != null) {
+            for (String hostName : messagingCluster.getHostNames()) {
+                cluster.addHostName(hostName);
+            }
+        }
+        return cluster;
+    }
+
+    private org.apache.stratos.load.balancer.common.domain.Member transformMember(Member messagingMember) {
+        boolean useMemberPublicIP = Boolean.getBoolean("load.balancer.member.public.ip");
+        String hostName = (useMemberPublicIP) ? messagingMember.getDefaultPublicIP() :
+                messagingMember.getDefaultPrivateIP();
+        org.apache.stratos.load.balancer.common.domain.Member member =
+                new org.apache.stratos.load.balancer.common.domain.Member(messagingMember.getServiceName(),
+                        messagingMember.getClusterId(), messagingMember.getMemberId(),
+                        hostName);
+        return member;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerDomainMappingEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerDomainMappingEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerDomainMappingEventReceiver.java
deleted file mode 100644
index 8634abc..0000000
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerDomainMappingEventReceiver.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.common.event.receivers;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
-import org.apache.stratos.load.balancer.common.domain.Cluster;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.domain.mapping.DomainMappingAddedEvent;
-import org.apache.stratos.messaging.event.domain.mapping.DomainMappingRemovedEvent;
-import org.apache.stratos.messaging.listener.domain.mapping.DomainMappingAddedEventListener;
-import org.apache.stratos.messaging.listener.domain.mapping.DomainMappingRemovedEventListener;
-import org.apache.stratos.messaging.message.receiver.domain.mapping.DomainMappingEventReceiver;
-
-/**
- * Load balancer domain mapping event receiver updates the topology in the given topology provider
- * with the domains found in domain mapping events.
- */
-public class LoadBalancerDomainMappingEventReceiver extends DomainMappingEventReceiver {
-
-    private static final Log log = LogFactory.getLog(LoadBalancerDomainMappingEventReceiver.class);
-
-    private TopologyProvider topologyProvider;
-
-    public LoadBalancerDomainMappingEventReceiver(TopologyProvider topologyProvider) {
-        this.topologyProvider = topologyProvider;
-        addEventListeners();
-    }
-
-    private void addEventListeners() {
-
-        addEventListener(new DomainMappingAddedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                DomainMappingAddedEvent domainMappingAddedEvent = (DomainMappingAddedEvent)event;
-
-                String domainName = domainMappingAddedEvent.getDomainName();
-                String contextPath = domainMappingAddedEvent.getContextPath();
-
-                String clusterId = domainMappingAddedEvent.getClusterId();
-                Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
-                if(cluster == null) {
-                    log.warn(String.format("Could not add domain mapping, cluster not found: [cluster] %s", clusterId));
-                }
-
-                cluster.addHostName(domainName, contextPath);
-                log.info(String.format("Domain mapping added: [cluster] %s [domain] %s", clusterId, domainName));
-            }
-        });
-
-        addEventListener(new DomainMappingRemovedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                DomainMappingRemovedEvent domainMappingRemovedEvent = (DomainMappingRemovedEvent)event;
-
-                String clusterId = domainMappingRemovedEvent.getClusterId();
-                Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
-                if(cluster == null) {
-                    log.warn(String.format("Could not remove domain mapping, cluster not found: [cluster] %s", clusterId));
-                }
-
-                String domainName = domainMappingRemovedEvent.getDomainName();
-                cluster.removeHostName(domainName);
-                log.info(String.format("Domain mapping removed: [cluster] %s [domain] %s", clusterId, domainName));
-            }
-        });
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerTopologyEventReceiver.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerTopologyEventReceiver.java
deleted file mode 100644
index ee5b5b3..0000000
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/event/receivers/LoadBalancerTopologyEventReceiver.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.common.event.receivers;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.MemberStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.listener.topology.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-/**
- * Load balancer topology receiver updates the topology in the given topology provider
- * according to topology events.
- */
-public class LoadBalancerTopologyEventReceiver extends TopologyEventReceiver {
-
-    private static final Log log = LogFactory.getLog(LoadBalancerTopologyEventReceiver.class);
-
-    private TopologyProvider topologyProvider;
-
-    public LoadBalancerTopologyEventReceiver(TopologyProvider topologyProvider) {
-        this.topologyProvider = topologyProvider;
-        addEventListeners();
-    }
-
-    public void execute() {
-	    super.execute();
-        if (log.isInfoEnabled()) {
-            log.info("Load balancer topology receiver thread started");
-        }
-    }
-
-    private void addEventListeners() {
-
-        addEventListener(new CompleteTopologyEventListener() {
-            private boolean initialized;
-
-            @Override
-            protected void onEvent(Event event) {
-                if (!initialized) {
-                    try {
-                        TopologyManager.acquireReadLock();
-                        for (Service service : TopologyManager.getTopology().getServices()) {
-                            for (Cluster cluster : service.getClusters()) {
-                                for (Member member : cluster.getMembers()) {
-                                    if (member.getStatus() == MemberStatus.Active) {
-                                        addMember(cluster.getServiceName(), member.getClusterId(), member.getMemberId());
-                                    }
-                                }
-                            }
-                        }
-                        initialized = true;
-                    } catch (Exception e) {
-                        log.error("Error processing event", e);
-                    } finally {
-                        TopologyManager.releaseReadLock();
-                    }
-                }
-            }
-        });
-
-        addEventListener(new MemberActivatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
-
-                String serviceName = memberActivatedEvent.getServiceName();
-                String clusterId = memberActivatedEvent.getClusterId();
-                String memberId = memberActivatedEvent.getMemberId();
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-                    addMember(serviceName, clusterId, memberId);
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-                }
-            }
-        });
-
-        addEventListener(new MemberMaintenanceListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event;
-
-                String serviceName = memberMaintenanceModeEvent.getServiceName();
-                String clusterId = memberMaintenanceModeEvent.getClusterId();
-                String memberId = memberMaintenanceModeEvent.getMemberId();
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-                    removeMember(serviceName, clusterId, memberId);
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(serviceName,
-                            clusterId);
-                }
-            }
-        });
-
-        addEventListener(new MemberSuspendedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event;
-
-                String serviceName = memberSuspendedEvent.getServiceName();
-                String clusterId = memberSuspendedEvent.getClusterId();
-                String memberId = memberSuspendedEvent.getMemberId();
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-                    removeMember(serviceName, clusterId, memberId);
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(),
-                            memberSuspendedEvent.getClusterId());
-                }
-            }
-        });
-
-        addEventListener(new MemberTerminatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
-
-                String serviceName = memberTerminatedEvent.getServiceName();
-                String clusterId = memberTerminatedEvent.getClusterId();
-                String memberId = memberTerminatedEvent.getMemberId();
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-                    removeMember(serviceName, clusterId, memberId);
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-                }
-            }
-        });
-
-        addEventListener(new ClusterRemovedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
-                String serviceName = clusterRemovedEvent.getServiceName();
-                String clusterId = clusterRemovedEvent.getClusterId();
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-
-                    Service service = TopologyManager.getTopology().getService(serviceName);
-                    if (service == null) {
-                        if (log.isWarnEnabled()) {
-                            log.warn(String.format("Service not found in topology: [service] %s", serviceName));
-                        }
-                        return;
-                    }
-
-                    Cluster cluster = service.getCluster(clusterId);
-                    removeCluster(cluster);
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-                }
-            }
-        });
-
-        addEventListener(new ServiceRemovedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-                ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event;
-                String serviceName = serviceRemovedEvent.getServiceName();
-
-                try {
-                    TopologyManager.acquireReadLockForService(serviceName);
-
-                    Service service = TopologyManager.getTopology().getService(serviceName);
-                    if (service == null) {
-                        if (log.isWarnEnabled()) {
-                            log.warn(String.format("Service not found in topology: [service] %s",
-                                    serviceName));
-                        }
-                        return;
-                    }
-                    for(Cluster cluster : service.getClusters()) {
-                        removeCluster(cluster);
-                    }
-                } catch (Exception e) {
-                    log.error("Error processing event", e);
-                } finally {
-                    TopologyManager.releaseReadLockForService(serviceName);
-                }
-            }
-        });
-    }
-
-    /**
-     * Remove cluster from topology provider
-     * @param cluster
-     */
-    private void removeCluster(Cluster cluster) {
-        for(Member member : cluster.getMembers()) {
-            removeMember(member.getServiceName(), member.getClusterId(), member.getMemberId());
-        }
-    }
-
-    /**
-     * Add member to topology provider
-     * @param serviceName
-     * @param clusterId
-     * @param memberId
-     */
-    private void addMember(String serviceName, String clusterId, String memberId) {
-        Service service = TopologyManager.getTopology().getService(serviceName);
-        if (service == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Service not found in topology: [service] %s",
-                        serviceName));
-            }
-            return;
-        }
-        Cluster cluster = service.getCluster(clusterId);
-        if (cluster == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Cluster not found in topology: [service] %s [cluster] %s",
-                        serviceName, clusterId));
-            }
-            return;
-        }
-        validateHostNames(cluster);
-
-        // Add cluster if not exists
-        if(!topologyProvider.clusterExistsByClusterId(cluster.getClusterId())) {
-            topologyProvider.addCluster(transformCluster(cluster));
-        }
-
-        Member member = cluster.getMember(memberId);
-        if (member == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Member not found in topology: [service] %s [cluster] %s [member] %s",
-                        serviceName, clusterId,
-                        memberId));
-            }
-            return;
-        }
-        topologyProvider.addMember(transformMember(member));
-    }
-
-    /**
-     * Remove member from topology provider
-     * @param serviceName
-     * @param clusterId
-     * @param memberId
-     */
-    private void removeMember(String serviceName, String clusterId, String memberId) {
-        Service service = TopologyManager.getTopology().getService(serviceName);
-        if (service == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Service not found in topology: [service] %s",
-                        serviceName));
-            }
-            return;
-        }
-
-        Cluster cluster = service.getCluster(clusterId);
-        if (cluster == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Cluster not found in topology: [service] %s [cluster] %s",
-                        serviceName, clusterId));
-            }
-            return;
-        }
-        validateHostNames(cluster);
-
-        Member member = cluster.getMember(memberId);
-        if (member == null) {
-            if (log.isWarnEnabled()) {
-                log.warn(String.format("Member not found in topology: [service] %s [cluster] %s [member] %s",
-                        serviceName, clusterId,
-                        memberId));
-            }
-            return;
-        }
-
-        if (member != null) {
-            topologyProvider.removeMember(cluster.getClusterId(), member.getMemberId());
-        }
-    }
-
-    private void validateHostNames(Cluster cluster) {
-        if((cluster.getHostNames() == null) || (cluster.getHostNames().size() == 0)) {
-            throw new RuntimeException(String.format("Host names not found in cluster: " +
-                    "[cluster] %s", cluster.getClusterId()));
-        }
-    }
-
-    private org.apache.stratos.load.balancer.common.domain.Cluster transformCluster(Cluster messagingCluster) {
-        org.apache.stratos.load.balancer.common.domain.Cluster cluster =
-                new org.apache.stratos.load.balancer.common.domain.Cluster(messagingCluster.getServiceName(),
-                        messagingCluster.getClusterId());
-        cluster.setTenantRange(messagingCluster.getTenantRange());
-        if(messagingCluster.getHostNames() != null) {
-            for (String hostName : messagingCluster.getHostNames()) {
-                cluster.addHostName(hostName);
-            }
-        }
-        return cluster;
-    }
-
-    private org.apache.stratos.load.balancer.common.domain.Member transformMember(Member messagingMember) {
-        boolean useMemberPublicIP = Boolean.getBoolean("load.balancer.member.public.ip");
-        String hostName = (useMemberPublicIP) ? messagingMember.getDefaultPublicIP() :
-                messagingMember.getDefaultPrivateIP();
-        org.apache.stratos.load.balancer.common.domain.Member member =
-                new org.apache.stratos.load.balancer.common.domain.Member(messagingMember.getServiceName(),
-                        messagingMember.getClusterId(), messagingMember.getMemberId(),
-                        hostName);
-        return member;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java
index cf3b27c..9c4cb88 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java
@@ -101,7 +101,6 @@ public class LoadBalancerStatisticsNotifier implements Runnable {
                                     // Load balancer cluster found in topology; we do not need to publish request counts for them.
                                 }
                             }
-
                         }
                     } finally {
                         TopologyManager.releaseReadLock();

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/topology/TopologyProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/topology/TopologyProvider.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/topology/TopologyProvider.java
index 0eb77f8..ebf2802 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/topology/TopologyProvider.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/topology/TopologyProvider.java
@@ -19,11 +19,13 @@
 
 package org.apache.stratos.load.balancer.common.topology;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.load.balancer.common.domain.Cluster;
 import org.apache.stratos.load.balancer.common.domain.Member;
 
+import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -37,13 +39,19 @@ public class TopologyProvider {
     private Map<String, Cluster> clusterIdToClusterMap;
     private Map<String, Cluster> hostNameToClusterMap;
     private Map<String, Map<Integer, Cluster>> hostNameToTenantIdToClusterMap;
+    private Map<String, String> memberHostNameToClusterHostNameMap;
 
     public TopologyProvider() {
         this.clusterIdToClusterMap = new ConcurrentHashMap<String, Cluster>();
         this.hostNameToClusterMap = new ConcurrentHashMap<String, Cluster>();
         this.hostNameToTenantIdToClusterMap = new ConcurrentHashMap<String, Map<Integer, Cluster>>();
+        this.memberHostNameToClusterHostNameMap = new ConcurrentHashMap<String, String>();
     }
 
+    /**
+     * Add cluster to the topology.
+     * @param cluster
+     */
     public void addCluster(Cluster cluster) {
         if(cluster != null) {
             clusterIdToClusterMap.put(cluster.getClusterId(), cluster);
@@ -56,9 +64,20 @@ public class TopologyProvider {
                 log.info(String.format("Cluster added: [cluster] %s [hostnames] %s", cluster.getClusterId(),
                         cluster.getHostNames()));
             }
+
+            Collection<Member> members = cluster.getMembers();
+            if((members != null) && (members.size() > 0)) {
+                for(Member member : members) {
+                    addMember(member);
+                }
+            }
         }
     }
 
+    /**
+     * Remove cluster.
+     * @param clusterId
+     */
     public void removeCluster(String clusterId) {
         Cluster cluster = getClusterByClusterId(clusterId);
         if(cluster == null) {
@@ -77,18 +96,38 @@ public class TopologyProvider {
         }
     }
 
+    /**
+     * Returns true if cluster exists by cluster id else return false.
+     * @param clusterId
+     * @return
+     */
     public boolean clusterExistsByClusterId(String clusterId) {
         return (getClusterByClusterId(clusterId) != null);
     }
 
+    /**
+     * Returns true if cluster exists by host name else return false.
+     * @param hostName
+     * @return
+     */
     public boolean clusterExistsByHostName(String hostName) {
         return (hostNameToClusterMap.containsKey(hostName) || hostNameToTenantIdToClusterMap.containsKey(hostName));
     }
 
+    /**
+     * Returns cluster by cluster id.
+     * @param clusterId
+     * @return
+     */
     public Cluster getClusterByClusterId(String clusterId) {
         return clusterIdToClusterMap.get(clusterId);
     }
 
+    /**
+     * Add cluster for tenant.
+     * @param cluster
+     * @param tenantId
+     */
     public void addCluster(Cluster cluster, int tenantId) {
         if(cluster != null) {
             boolean subscribed = false;
@@ -108,6 +147,11 @@ public class TopologyProvider {
         }
     }
 
+    /**
+     * Remove cluster added for tenant.
+     * @param clusterId
+     * @param tenantId
+     */
     public void removeCluster(String clusterId, int tenantId) {
         Cluster cluster = getClusterByClusterId(clusterId);
         if(cluster == null) {
@@ -127,10 +171,21 @@ public class TopologyProvider {
         }
     }
 
+    /**
+     * Get cluster by hostname.
+     * @param hostName
+     * @return
+     */
     public Cluster getClusterByHostName(String hostName) {
         return hostNameToClusterMap.get(hostName);
     }
 
+    /**
+     * Get cluster by hostname for tenant.
+     * @param hostName
+     * @param tenantId
+     * @return
+     */
     public Cluster getClusterByHostName(String hostName, int tenantId) {
         Map<Integer, Cluster> tenantIdToClusterMap = hostNameToTenantIdToClusterMap.get(hostName);
         if(tenantIdToClusterMap != null) {
@@ -139,6 +194,10 @@ public class TopologyProvider {
         return null;
     }
 
+    /**
+     * Add a member to its cluster.
+     * @param member
+     */
     public void addMember(Member member) {
         Cluster cluster = getClusterByClusterId(member.getClusterId());
         if(cluster == null) {
@@ -146,12 +205,26 @@ public class TopologyProvider {
                     member.getClusterId()));
             return;
         }
+        if(StringUtils.isBlank(member.getHostName())) {
+            log.warn(String.format("Could not add member, member hostname not found: [cluster] %s [member] %s",
+                    member.getClusterId(), member.getMemberId()));
+            return;
+        }
 
         cluster.addMember(member);
+        if((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
+            memberHostNameToClusterHostNameMap.put(member.getHostName(), cluster.getHostNames().iterator().next());
+        }
+
         log.info(String.format("Member added to cluster: [cluster] %s [member] %s",
                 member.getClusterId(), member.getHostName()));
     }
 
+    /**
+     * Remove a member from its cluster.
+     * @param clusterId
+     * @param memberId
+     */
     public void removeMember(String clusterId, String memberId) {
         Cluster cluster = getClusterByClusterId(clusterId);
         if(cluster == null) {
@@ -162,6 +235,10 @@ public class TopologyProvider {
         Member member = cluster.getMember(memberId);
         if(member != null) {
             cluster.removeMember(memberId);
+            if(memberHostNameToClusterHostNameMap.containsKey(member.getHostName())) {
+                memberHostNameToClusterHostNameMap.remove(member.getHostName());
+            }
+
             log.info(String.format("Member removed from cluster: [cluster] %s [member] %s",
                     clusterId, member.getHostName()));
 
@@ -172,4 +249,13 @@ public class TopologyProvider {
             }
         }
     }
+
+    /**
+     * Get cluster hostname of member by member hostname/ip address.
+     * @param memberHostName
+     * @return
+     */
+    public String getClusterHostname(String memberHostName) {
+        return memberHostNameToClusterHostNameMap.get(memberHostName);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
index 240ebba..365cfc4 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
@@ -19,8 +19,10 @@
 
 package org.apache.stratos.load.balancer.context;
 
-import org.apache.stratos.load.balancer.context.map.AlgorithmContextMap;
+import org.apache.stratos.common.clustering.DistributedObjectProvider;
+import org.apache.stratos.load.balancer.internal.ServiceReferenceHolder;
 
+import java.util.Map;
 import java.util.concurrent.locks.Lock;
 
 /**
@@ -28,19 +30,30 @@ import java.util.concurrent.locks.Lock;
  * Key: service name, cluster id
  */
 public class AlgorithmContext {
+
+    private static final String LOAD_BALANCER_ALGORITHM_CONTEXT_MAP = "load.balancer.algorithm.context.map";
+    private static final String CURRENT_MEMBER_INDEX_MAP_LOCK = "current.member.index.map.lock";
+
     private String serviceName;
     private String clusterId;
+    private final Map<String, Integer> clusterMemberIndexMap;
+    private final DistributedObjectProvider distributedObjectProvider;
 
     public AlgorithmContext(String serviceName, String clusterId) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
+        // Initialize distributed object provider
+        distributedObjectProvider = ServiceReferenceHolder.getInstance().getDistributedObjectProvider();
+        // Initialize cluster->memberIndex map
+        clusterMemberIndexMap = distributedObjectProvider.getMap(LOAD_BALANCER_ALGORITHM_CONTEXT_MAP);
+
         Lock lock = null;
         try {
-            lock = AlgorithmContextMap.getInstance().acquireCurrentMemberIndexLock();
-            AlgorithmContextMap.getInstance().putCurrentMemberIndex(serviceName, clusterId, 0);
+            lock = acquireCurrentMemberIndexLock();
+            putCurrentMemberIndex(serviceName, clusterId, 0);
         } finally {
             if(lock != null) {
-                AlgorithmContextMap.getInstance().releaseCurrentMemberIndexLock(lock);
+                releaseCurrentMemberIndexLock(lock);
             }
         }
     }
@@ -54,18 +67,42 @@ public class AlgorithmContext {
     }
 
     public int getCurrentMemberIndex() {
-        return AlgorithmContextMap.getInstance().getCurrentMemberIndex(getServiceName(), getClusterId());
+        return getCurrentMemberIndex(getServiceName(), getClusterId());
     }
 
     public void setCurrentMemberIndex(int currentMemberIndex) {
         Lock lock = null;
         try {
-            lock = AlgorithmContextMap.getInstance().acquireCurrentMemberIndexLock();
-            AlgorithmContextMap.getInstance().putCurrentMemberIndex(getServiceName(), getClusterId(), currentMemberIndex);
+            lock = acquireCurrentMemberIndexLock();
+            putCurrentMemberIndex(getServiceName(), getClusterId(), currentMemberIndex);
         } finally {
             if(lock != null) {
-                AlgorithmContextMap.getInstance().releaseCurrentMemberIndexLock(lock);
+                releaseCurrentMemberIndexLock(lock);
             }
         }
     }
+
+    private String constructKey(String serviceName, String clusterId) {
+        return String.format("%s-%s", serviceName, clusterId);
+    }
+
+    private Lock acquireCurrentMemberIndexLock() {
+        return distributedObjectProvider.acquireLock(CURRENT_MEMBER_INDEX_MAP_LOCK);
+    }
+
+    private void releaseCurrentMemberIndexLock(Lock lock) {
+        if(lock != null) {
+            distributedObjectProvider.releaseLock(lock);
+        }
+    }
+
+    public void putCurrentMemberIndex(String serviceName, String clusterId, int currentMemberIndex) {
+        String key = constructKey(serviceName, clusterId);
+        clusterMemberIndexMap.put(key, currentMemberIndex);
+    }
+
+    public int getCurrentMemberIndex(String serviceName, String clusterId) {
+        String key = constructKey(serviceName, clusterId);
+        return clusterMemberIndexMap.get(key);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ClusterContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ClusterContext.java
index 367258d..bb79d9a 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ClusterContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ClusterContext.java
@@ -19,14 +19,13 @@
 
 package org.apache.stratos.load.balancer.context;
 
-import org.apache.stratos.load.balancer.context.AlgorithmContext;
-
 import java.util.Properties;
 
 /**
  * Defines cluster context properties.
  */
 public class ClusterContext {
+
     private String serviceName;
     private String clusterId;
     private AlgorithmContext algorithmContext;

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
index 0eec59e..2ba0cfd 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
@@ -21,7 +21,10 @@ package org.apache.stratos.load.balancer.context;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.load.balancer.context.map.*;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Defines load balancer context information.
@@ -33,25 +36,13 @@ public class LoadBalancerContext {
     private static volatile LoadBalancerContext instance;
 
     // Map<ClusterId, ClusterContext>
-    private ClusterIdClusterContextMap clusterIdClusterContextMap;
-
-    // Following maps are updated by load balancer topology & tenant receivers.
-    // Map<ClusterId, Cluster>
-    // Keep track of all clusters
-    // Map<Host/Domain-Name, Cluster>
-    // Keep tack of all clusters
-
-    // Map<Host/Domain-Name, AppContext>
-    private HostNameAppContextMap hostNameAppContextMap;
-    // Map<HostName, Map<TenantId, Cluster>>
-    // Map<MemberIp, Hostname>
-    // Keep track of cluster hostnames of of all members  against their ip addresses
-    private MemberIpHostnameMap memberIpHostnameMap;
+    private Map<String, ClusterContext> clusterIdToClusterContextMap;
+    // Map<Host/Domain-Name, DomainMappingContextPath>
+    private Map<String, String> hostNameToDomainMappingContextPathMap;
 
     private LoadBalancerContext() {
-        clusterIdClusterContextMap = new ClusterIdClusterContextMap();
-        hostNameAppContextMap = new HostNameAppContextMap();
-        memberIpHostnameMap = new MemberIpHostnameMap();
+        clusterIdToClusterContextMap = new ConcurrentHashMap<String, ClusterContext>();
+        hostNameToDomainMappingContextPathMap = new ConcurrentHashMap<String, String>();
     }
 
     public static LoadBalancerContext getInstance() {
@@ -66,20 +57,45 @@ public class LoadBalancerContext {
     }
 
     public void clear() {
-        clusterIdClusterContextMap.clear();
-        hostNameAppContextMap.clear();
-        memberIpHostnameMap.clear();
+        clusterIdToClusterContextMap.clear();
+        hostNameToDomainMappingContextPathMap.clear();
+    }
+
+    public Collection<ClusterContext> getClusterContexts() {
+        return clusterIdToClusterContextMap.values();
+    }
+
+    public ClusterContext getClusterContext(String clusterId) {
+        return clusterIdToClusterContextMap.get(clusterId);
+    }
+
+    public boolean containsClusterContext(String clusterId) {
+        return clusterIdToClusterContextMap.containsKey(clusterId);
+    }
+
+    public void addClusterContext(ClusterContext clusterContext) {
+        clusterIdToClusterContextMap.put(clusterContext.getClusterId(), clusterContext);
+    }
+
+    public void removeClusterContext(String clusterId) {
+        clusterIdToClusterContextMap.remove(clusterId);
+    }
+
+    public void addDomainMappingContextPath(String hostName, String appContext) {
+        hostNameToDomainMappingContextPathMap.put(hostName, appContext);
     }
 
-    public ClusterIdClusterContextMap getClusterIdClusterContextMap() {
-        return clusterIdClusterContextMap;
+    public String getDomainMappingContextPath(String hostName) {
+        return hostNameToDomainMappingContextPathMap.get(hostName);
     }
 
-    public HostNameAppContextMap getHostNameContextPathMap() {
-        return hostNameAppContextMap;
+    public void removeDomainMappingContextPath(String hostName) {
+        if(containsDomainMappingContextPath(hostName)) {
+            hostNameToDomainMappingContextPathMap.remove(hostName);
+        }
     }
 
-    public MemberIpHostnameMap getMemberIpHostnameMap() {
-        return memberIpHostnameMap;
+    public boolean containsDomainMappingContextPath(String hostName) {
+        return hostNameToDomainMappingContextPathMap.containsKey(hostName);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ServiceContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ServiceContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ServiceContext.java
deleted file mode 100644
index f00b3bc..0000000
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/ServiceContext.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.context;
-
-import org.apache.stratos.load.balancer.context.ClusterContext;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Defines service context properties.
- */
-public class ServiceContext {
-    private String serviceName;
-    private Map<String, ClusterContext> clusterContextMap;
-
-    public ServiceContext() {
-        clusterContextMap = new HashMap<String, ClusterContext>();
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    public Collection<ClusterContext> getClusterContexts() {
-        return clusterContextMap.values();
-    }
-
-    public ClusterContext getClusterContext(String clusterId) {
-        return clusterContextMap.get(clusterId);
-    }
-
-    public void addClusterContext(ClusterContext clusterContext) {
-        clusterContextMap.put(clusterContext.getClusterId(), clusterContext);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/AlgorithmContextMap.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/AlgorithmContextMap.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/AlgorithmContextMap.java
deleted file mode 100644
index 35acdb0..0000000
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/AlgorithmContextMap.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.context.map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.clustering.DistributedObjectProvider;
-import org.apache.stratos.load.balancer.internal.ServiceReferenceHolder;
-
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-
-/**
- * Algorithm context map is a singleton class for managing load balancing algorithm context
- * of each service cluster.
- */
-public class AlgorithmContextMap {
-    @SuppressWarnings("unused")
-    private static final Log log = LogFactory.getLog(AlgorithmContextMap.class);
-    private static final String LOAD_BALANCER_ALGORITHM_CONTEXT_MAP = "LOAD_BALANCER_ALGORITHM_CONTEXT_MAP";
-    private static final String CURRENT_MEMBER_INDEX_MAP_LOCK = "CURRENT_MEMBER_INDEX_MAP_LOCK";
-    private static AlgorithmContextMap instance;
-
-    private final Map<String, Integer> clusterMemberIndexMap;
-    private final DistributedObjectProvider distributedObjectProvider;
-
-    private AlgorithmContextMap() {
-        // Initialize distributed object provider
-        distributedObjectProvider = ServiceReferenceHolder.getInstance().getDistributedObjectProvider();
-        // Initialize cluster->memberIndex map
-        clusterMemberIndexMap = distributedObjectProvider.getMap(LOAD_BALANCER_ALGORITHM_CONTEXT_MAP);
-    }
-
-    public static AlgorithmContextMap getInstance() {
-        if (instance == null) {
-            synchronized (AlgorithmContextMap.class) {
-                if (instance == null) {
-                    instance = new AlgorithmContextMap();
-                }
-            }
-        }
-        return instance;
-    }
-
-    private String constructKey(String serviceName, String clusterId) {
-        return String.format("%s-%s", serviceName, clusterId);
-    }
-
-    public Lock acquireCurrentMemberIndexLock() {
-        return distributedObjectProvider.acquireLock(CURRENT_MEMBER_INDEX_MAP_LOCK);
-    }
-
-    public void releaseCurrentMemberIndexLock(Lock lock) {
-        if(lock != null) {
-            distributedObjectProvider.releaseLock(lock);
-        }
-    }
-
-    public void putCurrentMemberIndex(String serviceName, String clusterId, int currentMemberIndex) {
-        String key = constructKey(serviceName, clusterId);
-        clusterMemberIndexMap.put(key, currentMemberIndex);
-    }
-
-    public void removeCluster(String serviceName, String clusterId) {
-        String key = constructKey(serviceName, clusterId);
-        clusterMemberIndexMap.remove(key);
-    }
-
-    public int getCurrentMemberIndex(String serviceName, String clusterId) {
-        String key = constructKey(serviceName, clusterId);
-        return clusterMemberIndexMap.get(key);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/ClusterIdClusterContextMap.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/ClusterIdClusterContextMap.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/ClusterIdClusterContextMap.java
deleted file mode 100644
index c36a56d..0000000
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/ClusterIdClusterContextMap.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.stratos.load.balancer.context.map;
-
-import org.apache.stratos.load.balancer.context.ClusterContext;
-
-import java.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Cluster id, cluster context concurrentHashMap for accessing cluster contexts using cluster id:
- * Map[ClusterId, ClusterContext]
- */
-public class ClusterIdClusterContextMap {
-    private ConcurrentHashMap<String, ClusterContext> concurrentHashMap;
-
-    public ClusterIdClusterContextMap() {
-        concurrentHashMap = new ConcurrentHashMap<String, ClusterContext>();
-    }
-
-    public Collection<ClusterContext> getClusterContexts() {
-        return concurrentHashMap.values();
-    }
-
-    public ClusterContext getClusterContext(String clusterId) {
-        return concurrentHashMap.get(clusterId);
-    }
-
-    public boolean containsClusterContext(String clusterId) {
-        return concurrentHashMap.containsKey(clusterId);
-    }
-
-    public void addClusterContext(ClusterContext clusterContext) {
-        concurrentHashMap.put(clusterContext.getClusterId(), clusterContext);
-    }
-
-    public void removeClusterContext(String clusterId) {
-        concurrentHashMap.remove(clusterId);
-    }
-
-    public void clear() {
-        concurrentHashMap.clear();
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/HostNameAppContextMap.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/HostNameAppContextMap.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/HostNameAppContextMap.java
deleted file mode 100644
index 993c41a..0000000
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/HostNameAppContextMap.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.stratos.load.balancer.context.map;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Host/domain name context path map.
- */
-public class HostNameAppContextMap {
-    private ConcurrentHashMap<String, String> concurrentHashMap;
-
-    public HostNameAppContextMap() {
-        concurrentHashMap = new ConcurrentHashMap<String, String>();
-    }
-
-    public void addContextPath(String hostName, String appContext) {
-        concurrentHashMap.put(hostName, appContext);
-    }
-
-    public String getAppContext(String hostName) {
-        return concurrentHashMap.get(hostName);
-    }
-
-    public void removeContextPath(String hostName) {
-        if(contains(hostName)) {
-            concurrentHashMap.remove(hostName);
-        }
-    }
-
-    public boolean contains(String hostName) {
-        return concurrentHashMap.containsKey(hostName);
-    }
-
-    public void clear() {
-        concurrentHashMap.clear();
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a970a90c/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
deleted file mode 100644
index ef3e519..0000000
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/map/MemberIpHostnameMap.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.load.balancer.context.map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Member-ip -> hostname map for maintaining cluster hostnames of all members against their ip addresses.
- */
-public class MemberIpHostnameMap {
-    @SuppressWarnings("unused")
-	private static final Log log = LogFactory.getLog(MemberIpHostnameMap.class);
-
-    private ConcurrentHashMap<String, String> concurrentHashMap;
-
-    public MemberIpHostnameMap() {
-        concurrentHashMap = new ConcurrentHashMap<String, String>();
-    }
-
-    public void put(String ip, String hostname) {
-        concurrentHashMap.put(ip, hostname);
-    }
-
-    public boolean contains(String ip) {
-        return concurrentHashMap.containsKey(ip);
-    }
-
-    public String get(String ip) {
-        if(contains(ip)) {
-            return concurrentHashMap.get(ip);
-        }
-        return null;
-    }
-
-    public void remove(String ip) {
-        if(contains(ip)) {
-            concurrentHashMap.remove(ip);
-        }
-    }
-
-    public void clear() {
-        concurrentHashMap.clear();
-    }
-}