Repository: stratos Updated Branches: refs/heads/docker-grouping-merge 757e33236 -> 83ede2f59
Fixing null check in ClusterMonitorFactory.getDockerServiceClusterMonitor() method Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/324fc5c7 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/324fc5c7 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/324fc5c7 Branch: refs/heads/docker-grouping-merge Commit: 324fc5c7d8cbfdaf157f2bf2f20c1afda993269e Parents: 19fdf7a Author: Imesh Gunaratne <[email protected]> Authored: Fri Nov 7 19:36:38 2014 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Fri Nov 7 19:36:38 2014 +0530 ---------------------------------------------------------------------- .../monitor/cluster/ClusterMonitorFactory.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/324fc5c7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index 2e45a89..b9c1576 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -366,18 +366,23 @@ public class ClusterMonitorFactory { throw new PolicyValidationException(msg); } - java.util.Properties props = cluster.getProperties(); - String kubernetesHostClusterID = props.getProperty(StratosConstants.KUBERNETES_CLUSTER_ID); + java.util.Properties properties = cluster.getProperties(); + if(properties == null) { + throw new RuntimeException(String.format("Properties not found in kubernetes cluster: [cluster-id] %s", + cluster.getClusterId())); + } + + String kubernetesHostClusterID = properties.getProperty(StratosConstants.KUBERNETES_CLUSTER_ID); KubernetesClusterContext kubernetesClusterCtxt = new KubernetesClusterContext(kubernetesHostClusterID, cluster.getClusterId()); - String minReplicasProperty = props.getProperty(StratosConstants.KUBERNETES_MIN_REPLICAS); + String minReplicasProperty = properties.getProperty(StratosConstants.KUBERNETES_MIN_REPLICAS); if (minReplicasProperty != null && !minReplicasProperty.isEmpty()) { int minReplicas = Integer.parseInt(minReplicasProperty); kubernetesClusterCtxt.setMinReplicas(minReplicas); } - String maxReplicasProperty = props.getProperty(StratosConstants.KUBERNETES_MAX_REPLICAS); + String maxReplicasProperty = properties.getProperty(StratosConstants.KUBERNETES_MAX_REPLICAS); if (maxReplicasProperty != null && !maxReplicasProperty.isEmpty()) { int maxReplicas = Integer.parseInt(maxReplicasProperty); kubernetesClusterCtxt.setMaxReplicas(maxReplicas); @@ -424,8 +429,8 @@ public class ClusterMonitorFactory { } // find lb reference type - if (props.containsKey(Constants.LOAD_BALANCER_REF)) { - String value = props.getProperty(Constants.LOAD_BALANCER_REF); + if (properties.containsKey(Constants.LOAD_BALANCER_REF)) { + String value = properties.getProperty(Constants.LOAD_BALANCER_REF); dockerClusterMonitor.setLbReferenceType(value); if (log.isDebugEnabled()) { log.debug("Set the lb reference type: " + value);
