stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [28/32] stratos git commit: Fixed few bugs detected by FindBugs.
Date Fri, 09 Oct 2015 14:35:41 GMT
Fixed few bugs detected by FindBugs.


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

Branch: refs/heads/gsoc-projects-2015
Commit: 8414eaa9a2ca3520f4e1bac1e7e1582aedcc20f8
Parents: 3479746
Author: swapnilpatilRajaram <swapnil.patil@students.iiit.ac.in>
Authored: Sat Aug 15 18:30:21 2015 +0000
Committer: swapnilpatilRajaram <swapnil.patil@students.iiit.ac.in>
Committed: Sat Aug 15 18:30:21 2015 +0000

----------------------------------------------------------------------
 .../apache/stratos/aws/extension/AWSHelper.java |  6 ++---
 .../stratos/aws/extension/AWSLoadBalancer.java  | 23 ++++++++++++--------
 2 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8414eaa9/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSHelper.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSHelper.java
b/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSHelper.java
index 7929099..5a3393f 100644
--- a/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSHelper.java
+++ b/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSHelper.java
@@ -308,8 +308,7 @@ public class AWSHelper {
 			elbClient.setEndpoint(String.format(
 					Constants.ELB_ENDPOINT_URL_FORMAT, region));
 
-			RegisterInstancesWithLoadBalancerResult result = elbClient
-					.registerInstancesWithLoadBalancer(registerInstancesWithLoadBalancerRequest);
+			elbClient.registerInstancesWithLoadBalancer(registerInstancesWithLoadBalancerRequest);
 
 		} catch (AmazonClientException e) {
 			log.error("Could not register instances to load balancer "
@@ -339,8 +338,7 @@ public class AWSHelper {
 			elbClient.setEndpoint(String.format(
 					Constants.ELB_ENDPOINT_URL_FORMAT, region));
 
-			DeregisterInstancesFromLoadBalancerResult result = elbClient
-					.deregisterInstancesFromLoadBalancer(deregisterInstancesFromLoadBalancerRequest);
+			elbClient.deregisterInstancesFromLoadBalancer(deregisterInstancesFromLoadBalancerRequest);
 
 		} catch (AmazonClientException e) {
 			log.error("Could not de-register instances from load balancer "

http://git-wip-us.apache.org/repos/asf/stratos/blob/8414eaa9/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSLoadBalancer.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSLoadBalancer.java
b/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSLoadBalancer.java
index ba04e5c..6b5c3fc 100644
--- a/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSLoadBalancer.java
+++ b/extensions/load-balancer/aws-extension/src/main/java/org/apache/stratos/aws/extension/AWSLoadBalancer.java
@@ -42,12 +42,11 @@ public class AWSLoadBalancer implements LoadBalancer {
 	private static final Log log = LogFactory.getLog(AWSLoadBalancer.class);
 
 	// A map <clusterId, load balancer id>
-	private static ConcurrentHashMap<String, LoadBalancerInfo> clusterIdToLoadBalancerMap;
+	private static ConcurrentHashMap<String, LoadBalancerInfo> clusterIdToLoadBalancerMap
= new ConcurrentHashMap<String, LoadBalancerInfo>();
 
 	private AWSHelper awsHelper;
 
 	public AWSLoadBalancer() throws LoadBalancerExtensionException {
-		clusterIdToLoadBalancerMap = new ConcurrentHashMap<String, LoadBalancerInfo>();
 		awsHelper = new AWSHelper();
 	}
 
@@ -219,19 +218,25 @@ public class AWSLoadBalancer implements LoadBalancer {
 			}
 
 			// Find out clusters which were present earlier but are not now.
-			// Delete load balancers associated with those clusters.
+			List<String> clustersToRemoveFromMap = new ArrayList<String>();
 
 			for (String clusterId : clusterIdToLoadBalancerMap.keySet()) {
 				if (!activeClusters.contains(clusterId)) {
-					// Remove load balancer for that cluster.
-					awsHelper.deleteLoadBalancer(clusterIdToLoadBalancerMap
-							.get(clusterId).getName(),
-							clusterIdToLoadBalancerMap.get(clusterId)
-									.getRegion());
-					clusterIdToLoadBalancerMap.remove(clusterId);
+					clustersToRemoveFromMap.add(clusterId);
 				}
 			}
 
+			// Delete load balancers associated with these clusters.
+			for(String clusterId : clustersToRemoveFromMap)
+			{
+				// Remove load balancer for this cluster.
+				awsHelper.deleteLoadBalancer(clusterIdToLoadBalancerMap
+						.get(clusterId).getName(),
+						clusterIdToLoadBalancerMap.get(clusterId)
+								.getRegion());
+				clusterIdToLoadBalancerMap.remove(clusterId);
+			}
+
 			activeClusters.clear();
 		} catch (LoadBalancerExtensionException e) {
 			throw new LoadBalancerExtensionException(e);


Mime
View raw message