You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/04/13 05:22:19 UTC

[06/16] stratos git commit: Formatting Load balancer common module

Formatting Load balancer common module


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

Branch: refs/heads/master
Commit: e02f3e121a74b46c1b954bf64f8320a0b8a4b2ea
Parents: bf56f15
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Sun Apr 12 20:46:39 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Sun Apr 12 20:46:39 2015 +0530

----------------------------------------------------------------------
 .../pom.xml                                     |  7 ++-
 .../load/balancer/common/domain/Cluster.java    |  4 +-
 .../load/balancer/common/domain/Member.java     |  4 +-
 .../load/balancer/common/domain/Service.java    |  8 +--
 ...alancerCommonDomainMappingEventReceiver.java | 10 ++--
 ...LoadBalancerCommonTopologyEventReceiver.java | 27 +++++----
 .../LoadBalancerCommonServiceComponent.java     | 32 +++++-----
 .../LoadBalancerStatisticsReader.java           |  2 +
 .../common/topology/TopologyProvider.java       | 61 ++++++++++++--------
 9 files changed, 88 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/components/org.apache.stratos.load.balancer.common/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/pom.xml b/components/org.apache.stratos.load.balancer.common/pom.xml
index db81289..b19e0a0 100644
--- a/components/org.apache.stratos.load.balancer.common/pom.xml
+++ b/components/org.apache.stratos.load.balancer.common/pom.xml
@@ -17,7 +17,8 @@
        specific language governing permissions and limitations
        under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <parent>
         <groupId>org.apache.stratos</groupId>
@@ -31,9 +32,9 @@
     <packaging>bundle</packaging>
     <name>Apache Stratos - Load Balancer - Common</name>
     <url>http://apache.org</url>
-    
+
     <dependencies>
-    	<dependency>
+        <dependency>
             <groupId>org.wso2.carbon</groupId>
             <artifactId>org.wso2.carbon.core</artifactId>
             <version>${wso2carbon.version}</version>

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/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 1f4bee9..ccb0195 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
@@ -76,8 +76,8 @@ public class Cluster {
 
     public void removeMember(String memberId) {
         Member member = memberMap.get(memberId);
-        if(member == null) {
-            if(log.isWarnEnabled()) {
+        if (member == null) {
+            if (log.isWarnEnabled()) {
                 log.warn(String.format("Could not remove member, member not found: [member] %s", memberId));
             }
             return;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Member.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Member.java
index dae7e8c..d03dd1f 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Member.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Member.java
@@ -53,7 +53,7 @@ public class Member {
     }
 
     public Port getPort(int proxy) {
-        if(portMap.containsKey(proxy)) {
+        if (portMap.containsKey(proxy)) {
             return portMap.get(proxy);
         }
         return null;
@@ -64,7 +64,7 @@ public class Member {
     }
 
     public void addPorts(Collection<Port> ports) {
-        for(Port port : ports) {
+        for (Port port : ports) {
             addPort(port);
         }
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Service.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Service.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Service.java
index f94e7f8..8b62c3a 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Service.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/domain/Service.java
@@ -77,7 +77,7 @@ public class Service {
     }
 
     public Port getPort(int proxy) {
-        if(portMap.containsKey(proxy)) {
+        if (portMap.containsKey(proxy)) {
             return portMap.get(proxy);
         }
         return null;
@@ -88,15 +88,15 @@ public class Service {
     }
 
     public void addPorts(Collection<Port> ports) {
-        for(Port port : ports) {
-            if(!portExists(port)) {
+        for (Port port : ports) {
+            if (!portExists(port)) {
                 addPort(port);
             }
         }
     }
 
     public void removePort(Port port) {
-        if(portExists(port)) {
+        if (portExists(port)) {
             this.portMap.remove(port.getProxy());
         }
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/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
index a75121c..e78d9e2 100644
--- 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
@@ -50,14 +50,14 @@ public class LoadBalancerCommonDomainMappingEventReceiver extends DomainMappingE
         addEventListener(new DomainMappingAddedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                DomainMappingAddedEvent domainMappingAddedEvent = (DomainMappingAddedEvent)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) {
+                if (cluster == null) {
                     log.warn(String.format("Could not add domain mapping, cluster not found: [cluster] %s", clusterId));
                 }
 
@@ -68,11 +68,11 @@ public class LoadBalancerCommonDomainMappingEventReceiver extends DomainMappingE
         addEventListener(new DomainMappingRemovedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                DomainMappingRemovedEvent domainMappingRemovedEvent = (DomainMappingRemovedEvent)event;
+                DomainMappingRemovedEvent domainMappingRemovedEvent = (DomainMappingRemovedEvent) event;
 
                 String clusterId = domainMappingRemovedEvent.getClusterId();
                 Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
-                if(cluster == null) {
+                if (cluster == null) {
                     log.warn(String.format("Could not remove domain mapping, cluster not found: [cluster] %s", clusterId));
                 }
 
@@ -84,6 +84,7 @@ public class LoadBalancerCommonDomainMappingEventReceiver extends DomainMappingE
 
     /**
      * Add domain mapping.
+     *
      * @param cluster
      * @param domainName
      * @param contextPath
@@ -95,6 +96,7 @@ public class LoadBalancerCommonDomainMappingEventReceiver extends DomainMappingE
 
     /**
      * Remove domain mapping.
+     *
      * @param cluster
      * @param domainName
      */

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/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
index 5a5c014..4412d5c 100644
--- 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
@@ -48,7 +48,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
     }
 
     public void execute() {
-	    super.execute();
+        super.execute();
         if (log.isInfoEnabled()) {
             log.info("Load balancer topology receiver thread started");
         }
@@ -72,7 +72,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
                     }
                 }
             }
-            if(membersFound) {
+            if (membersFound) {
                 initialized = true;
             }
         } catch (Exception e) {
@@ -91,7 +91,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
         addEventListener(new CompleteTopologyEventListener() {
             @Override
             protected void onEvent(Event event) {
-                if(!initialized) {
+                if (!initialized) {
                     initializeTopology();
                 }
             }
@@ -230,7 +230,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
                         }
                         return;
                     }
-                    for(Cluster cluster : service.getClusters()) {
+                    for (Cluster cluster : service.getClusters()) {
                         removeCluster(cluster);
                     }
                 } catch (Exception e) {
@@ -244,16 +244,18 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
 
     /**
      * Remove cluster from topology provider
+     *
      * @param cluster
      */
     protected void removeCluster(Cluster cluster) {
-        for(Member member : cluster.getMembers()) {
+        for (Member member : cluster.getMembers()) {
             removeMember(member.getServiceName(), member.getClusterId(), member.getMemberId());
         }
     }
 
     /**
      * Add member to topology provider
+     *
      * @param serviceName
      * @param clusterId
      * @param memberId
@@ -279,12 +281,12 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
         validateHostNames(cluster);
 
         // Add service if not exists
-        if(!topologyProvider.serviceExists(serviceName)) {
+        if (!topologyProvider.serviceExists(serviceName)) {
             topologyProvider.addService(transformService(service));
         }
 
         // Add cluster if not exists
-        if(!topologyProvider.clusterExistsByClusterId(cluster.getClusterId())) {
+        if (!topologyProvider.clusterExistsByClusterId(cluster.getClusterId())) {
             topologyProvider.addCluster(transformCluster(cluster));
         }
 
@@ -301,7 +303,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
         org.apache.stratos.load.balancer.common.domain.Member lbMember = transformMember(member);
         org.apache.stratos.load.balancer.common.domain.Service lbService = topologyProvider.getTopology().
                 getService(serviceName);
-        if(lbService == null) {
+        if (lbService == null) {
             log.warn(String.format("Service not found: %s", serviceName));
             return;
         }
@@ -311,6 +313,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
 
     /**
      * Remove member from topology provider
+     *
      * @param serviceName
      * @param clusterId
      * @param memberId
@@ -351,7 +354,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
     }
 
     private void validateHostNames(Cluster cluster) {
-        if((cluster.getHostNames() == null) || (cluster.getHostNames().size() == 0)) {
+        if ((cluster.getHostNames() == null) || (cluster.getHostNames().size() == 0)) {
             throw new RuntimeException(String.format("Host names not found in cluster: " +
                     "[cluster] %s", cluster.getClusterId()));
         }
@@ -375,7 +378,7 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
                 new org.apache.stratos.load.balancer.common.domain.Cluster(messagingCluster.getServiceName(),
                         messagingCluster.getClusterId());
         cluster.setTenantRange(messagingCluster.getTenantRange());
-        if(messagingCluster.getHostNames() != null) {
+        if (messagingCluster.getHostNames() != null) {
             for (String hostName : messagingCluster.getHostNames()) {
                 cluster.addHostName(hostName);
             }
@@ -386,13 +389,13 @@ public class LoadBalancerCommonTopologyEventReceiver extends TopologyEventReceiv
     private org.apache.stratos.load.balancer.common.domain.Member transformMember(Member messagingMember) {
 
         String hostName;
-        if(messagingMember.getLoadBalancingIPType() == LoadBalancingIPType.Private) {
+        if (messagingMember.getLoadBalancingIPType() == LoadBalancingIPType.Private) {
             if (StringUtils.isEmpty(messagingMember.getDefaultPrivateIP())) {
                 throw new RuntimeException(String.format("Default private IP not found: [member] %s",
                         messagingMember.getMemberId()));
             }
             hostName = messagingMember.getDefaultPrivateIP();
-        } else if(messagingMember.getLoadBalancingIPType() == LoadBalancingIPType.Public) {
+        } else if (messagingMember.getLoadBalancingIPType() == LoadBalancingIPType.Public) {
             if (StringUtils.isEmpty(messagingMember.getDefaultPublicIP())) {
                 throw new RuntimeException(String.format("Default public IP not found: [member] %s",
                         messagingMember.getMemberId()));

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/internal/LoadBalancerCommonServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/internal/LoadBalancerCommonServiceComponent.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/internal/LoadBalancerCommonServiceComponent.java
index 3b9e7f0..e61e0e6 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/internal/LoadBalancerCommonServiceComponent.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/internal/LoadBalancerCommonServiceComponent.java
@@ -1,20 +1,20 @@
 /**
- *  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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.internal;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java
index c9d2556..c92345b 100644
--- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java
+++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java
@@ -28,6 +28,7 @@ public interface LoadBalancerStatisticsReader {
 
     /**
      * Returns in-flight request count of sliding window configured.
+     *
      * @param clusterId
      */
     int getInFlightRequestCount(String clusterId);
@@ -37,6 +38,7 @@ public interface LoadBalancerStatisticsReader {
 
     /**
      * Returns the number of requests served since the last time this method was called.
+     *
      * @param clusterId
      * @return
      */

http://git-wip-us.apache.org/repos/asf/stratos/blob/e02f3e12/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 2db648d..867c41d 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
@@ -58,10 +58,11 @@ public class TopologyProvider {
 
     /**
      * Add service to the topology.
+     *
      * @param service
      */
     public void addService(Service service) {
-        if(service != null) {
+        if (service != null) {
             topology.addService(service);
             log.info(String.format("Service added: [service] %s", service.getServiceName()));
 
@@ -76,30 +77,31 @@ public class TopologyProvider {
 
     /**
      * Add cluster to the topology.
+     *
      * @param cluster
      */
     public void addCluster(Cluster cluster) {
-        if(cluster != null) {
+        if (cluster != null) {
             Service service = topology.getService(cluster.getServiceName());
-            if(service == null) {
+            if (service == null) {
                 throw new RuntimeException(String.format("Could not add cluster, service not found: [service] %s",
                         cluster.getServiceName()));
             }
             service.addCluster(cluster);
             clusterIdToClusterMap.put(cluster.getClusterId(), cluster);
 
-            for(String hostName : cluster.getHostNames()) {
+            for (String hostName : cluster.getHostNames()) {
                 hostNameToClusterMap.put(hostName, cluster);
             }
 
-            if((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
+            if ((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
                 log.info(String.format("Cluster added to service: [service] %s [cluster] %s [hostnames] %s",
                         cluster.getServiceName(), cluster.getClusterId(), cluster.getHostNames()));
             }
 
             Collection<Member> members = cluster.getMembers();
-            if((members != null) && (members.size() > 0)) {
-                for(Member member : members) {
+            if ((members != null) && (members.size() > 0)) {
+                for (Member member : members) {
                     addMember(member);
                 }
             }
@@ -108,23 +110,24 @@ public class TopologyProvider {
 
     /**
      * Add a member to its cluster.
+     *
      * @param member
      */
     public void addMember(Member member) {
         Cluster cluster = getClusterByClusterId(member.getClusterId());
-        if(cluster == null) {
+        if (cluster == null) {
             log.warn(String.format("Could not add member, cluster not found: [cluster] %s",
                     member.getClusterId()));
             return;
         }
-        if(StringUtils.isBlank(member.getHostName())) {
+        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)) {
+        if ((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
             memberHostNameToClusterHostNameMap.put(member.getHostName(), cluster.getHostNames().iterator().next());
         }
 
@@ -134,21 +137,22 @@ public class TopologyProvider {
 
     /**
      * Remove cluster from the topology.
+     *
      * @param clusterId
      */
     public void removeCluster(String clusterId) {
         Cluster cluster = getClusterByClusterId(clusterId);
-        if(cluster == null) {
+        if (cluster == null) {
             log.warn(String.format("Could not remove cluster, cluster not found: [cluster] %s", clusterId));
             return;
         }
 
-        for(String hostName : cluster.getHostNames()) {
+        for (String hostName : cluster.getHostNames()) {
             hostNameToClusterMap.remove(hostName);
         }
         clusterIdToClusterMap.remove(cluster.getClusterId());
 
-        if((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
+        if ((cluster.getHostNames() != null) && (cluster.getHostNames().size() > 0)) {
             log.info(String.format("Cluster removed: [cluster] %s [hostnames] %s", cluster.getClusterId(),
                     cluster.getHostNames()));
         }
@@ -156,6 +160,7 @@ public class TopologyProvider {
 
     /**
      * Returns true if cluster exists by cluster id else return false.
+     *
      * @param clusterId
      * @return
      */
@@ -165,6 +170,7 @@ public class TopologyProvider {
 
     /**
      * Returns true if cluster exists by host name else return false.
+     *
      * @param hostName
      * @return
      */
@@ -174,6 +180,7 @@ public class TopologyProvider {
 
     /**
      * Get cluster by cluster id.
+     *
      * @param clusterId
      * @return
      */
@@ -183,23 +190,24 @@ public class TopologyProvider {
 
     /**
      * Add tenant signup for cluster.
+     *
      * @param clusterId
      * @param tenantId
      */
     public void addTenantSignUp(String clusterId, int tenantId) {
         Cluster cluster = getClusterByClusterId(clusterId);
-        if(cluster != null) {
+        if (cluster != null) {
             boolean subscribed = false;
-            for(String hostName : cluster.getHostNames()) {
+            for (String hostName : cluster.getHostNames()) {
                 Map<Integer, Cluster> tenantIdToClusterMap = hostNameToTenantIdToClusterMap.get(hostName);
-                if(tenantIdToClusterMap == null) {
+                if (tenantIdToClusterMap == null) {
                     tenantIdToClusterMap = new ConcurrentHashMap<Integer, Cluster>();
                     hostNameToTenantIdToClusterMap.put(hostName, tenantIdToClusterMap);
                 }
                 tenantIdToClusterMap.put(tenantId, cluster);
                 subscribed = true;
             }
-            if(subscribed) {
+            if (subscribed) {
                 log.info(String.format("Tenant signed up to cluster: [tenant] %d [cluster] %s [hostnames] %s",
                         tenantId, cluster.getClusterId(), cluster.getHostNames()));
             }
@@ -208,16 +216,17 @@ public class TopologyProvider {
 
     /**
      * Remove tenant signup for cluster.
+     *
      * @param clusterId
      * @param tenantId
      */
     public void removeTenantSignUp(String clusterId, int tenantId) {
         Cluster cluster = getClusterByClusterId(clusterId);
-        if(cluster == null) {
+        if (cluster == null) {
             log.warn(String.format("Could not remove tenant signup from cluster, cluster not found: [cluster] %s", clusterId));
         }
 
-        for(String hostName : cluster.getHostNames()) {
+        for (String hostName : cluster.getHostNames()) {
             Map<Integer, Cluster> tenantIdToClusterMap = hostNameToTenantIdToClusterMap.get(hostName);
             if (tenantIdToClusterMap != null) {
                 Cluster cluster_ = tenantIdToClusterMap.get(tenantId);
@@ -232,6 +241,7 @@ public class TopologyProvider {
 
     /**
      * Get cluster by hostname.
+     *
      * @param hostName
      * @return
      */
@@ -241,13 +251,14 @@ public class TopologyProvider {
 
     /**
      * 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) {
+        if (tenantIdToClusterMap != null) {
             return tenantIdToClusterMap.get(tenantId);
         }
         return null;
@@ -255,27 +266,28 @@ public class TopologyProvider {
 
     /**
      * Remove a member from its cluster.
+     *
      * @param clusterId
      * @param memberId
      */
     public void removeMember(String clusterId, String memberId) {
         Cluster cluster = getClusterByClusterId(clusterId);
-        if(cluster == null) {
+        if (cluster == null) {
             log.warn(String.format("Could not remove member, cluster not found: [cluster] %s", clusterId));
             return;
         }
 
         Member member = cluster.getMember(memberId);
-        if(member != null) {
+        if (member != null) {
             cluster.removeMember(memberId);
-            if(memberHostNameToClusterHostNameMap.containsKey(member.getHostName())) {
+            if (memberHostNameToClusterHostNameMap.containsKey(member.getHostName())) {
                 memberHostNameToClusterHostNameMap.remove(member.getHostName());
             }
 
             log.info(String.format("Member removed from cluster: [cluster] %s [member] %s",
                     clusterId, member.getHostName()));
 
-            if(cluster.getMembers().size() == 0) {
+            if (cluster.getMembers().size() == 0) {
                 log.info(String.format("No members found in cluster, removing cluster: " +
                         "[cluster] %s", cluster.getClusterId()));
                 removeCluster(cluster.getClusterId());
@@ -285,6 +297,7 @@ public class TopologyProvider {
 
     /**
      * Get cluster hostname of member by member hostname/ip address.
+     *
      * @param memberHostName
      * @return
      */