Repository: stratos Updated Branches: refs/heads/stratos-4.1.x 838c31f0d -> 7288794a2
Handling null conditions in cloud controller service findLoadBalancerIPList() method Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/afbb25a7 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/afbb25a7 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/afbb25a7 Branch: refs/heads/stratos-4.1.x Commit: afbb25a7b72749e8a6452f03686f076c23ba904d Parents: 838c31f Author: Imesh Gunaratne <[email protected]> Authored: Tue Oct 13 15:50:38 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 15:50:38 2015 +0530 ---------------------------------------------------------------------- .../impl/CloudControllerServiceImpl.java | 70 ++++++++++---------- 1 file changed, 36 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/afbb25a7/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java index 0fe5e48..efbd002 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java @@ -1122,45 +1122,47 @@ public class CloudControllerServiceImpl implements CloudControllerService { } String clusterId = applicationClusterContext.getClusterId(); - Property ipListProperty = applicationClusterContext.getProperties(). - getProperty(CloudControllerConstants.LOAD_BALANCER_IPS); - if (ipListProperty != null) { - log.info(String.format("Load balancer IP list found in application: [application] %s [cluster] %s " + - "[load-balancer-ip-list] %s", applicationId, clusterId, - ipListProperty.getValue())); - return transformToList(ipListProperty); - } - - Property npListProperty = applicationClusterContext.getProperties(). - getProperty(CloudControllerConstants.NETWORK_PARTITION_ID_LIST); - if(npListProperty != null) { - String npIdListStr = npListProperty.getValue(); - if(StringUtils.isNotEmpty(npIdListStr)) { - List<String> loadBalancerIps = new ArrayList<>(); - String[] npIdArray = npIdListStr.split(","); - for(String networkPartitionId : npIdArray) { - NetworkPartition networkPartition = CloudControllerContext.getInstance(). - getNetworkPartition(networkPartitionId); - if(networkPartition == null) { - throw new CloudControllerException(String.format("Network partition not found: [application] %s " + - "[network-partition] %s", applicationId, networkPartitionId)); - } + org.apache.stratos.common.Properties appClusterContextProperties = applicationClusterContext.getProperties(); + + if(appClusterContextProperties != null) { + Property ipListProperty = appClusterContextProperties.getProperty(CloudControllerConstants.LOAD_BALANCER_IPS); + if (ipListProperty != null) { + log.info(String.format("Load balancer IP list found in application: [application] %s [cluster] %s " + + "[load-balancer-ip-list] %s", applicationId, clusterId, + ipListProperty.getValue())); + return transformToList(ipListProperty); + } + + Property npListProperty = appClusterContextProperties.getProperty(CloudControllerConstants.NETWORK_PARTITION_ID_LIST); + if (npListProperty != null) { + String npIdListStr = npListProperty.getValue(); + if (StringUtils.isNotEmpty(npIdListStr)) { + List<String> loadBalancerIps = new ArrayList<>(); + String[] npIdArray = npIdListStr.split(","); + for (String networkPartitionId : npIdArray) { + NetworkPartition networkPartition = CloudControllerContext.getInstance(). + getNetworkPartition(networkPartitionId); + if (networkPartition == null) { + throw new CloudControllerException(String.format("Network partition not found: [application] %s " + + "[network-partition] %s", applicationId, networkPartitionId)); + } - org.apache.stratos.common.Properties properties = networkPartition.getProperties(); - if(properties != null) { - ipListProperty = properties.getProperty(CloudControllerConstants.LOAD_BALANCER_IPS); - if (ipListProperty != null) { - log.debug(String.format("Load balancer IP list found in network partition: " + - "[application] %s [cluster] %s [load-balancer-ip-list] %s", applicationId, - clusterId, ipListProperty.getValue())); - String[] ipArray = ipListProperty.getValue().split(","); - for (String ip : ipArray) { - loadBalancerIps.add(ip); + org.apache.stratos.common.Properties npProperties = networkPartition.getProperties(); + if (npProperties != null) { + ipListProperty = npProperties.getProperty(CloudControllerConstants.LOAD_BALANCER_IPS); + if (ipListProperty != null) { + log.debug(String.format("Load balancer IP list found in network partition: " + + "[application] %s [cluster] %s [load-balancer-ip-list] %s", applicationId, + clusterId, ipListProperty.getValue())); + String[] ipArray = ipListProperty.getValue().split(","); + for (String ip : ipArray) { + loadBalancerIps.add(ip); + } } } } + return loadBalancerIps; } - return loadBalancerIps; } } return null;
