You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2014/12/12 11:11:42 UTC

[40/50] stratos git commit: fixing to create VMClusterContext only once

fixing to create VMClusterContext only once


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

Branch: refs/heads/master
Commit: 00612912923bb5ff9bce754c35a414f0a4bcd96c
Parents: 0183827
Author: reka <rt...@gmail.com>
Authored: Fri Dec 12 10:20:38 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Dec 12 10:20:47 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/monitor/cluster/VMClusterMonitor.java     | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/00612912/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
index ccd5e03..361148e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
@@ -1132,10 +1132,13 @@ public class VMClusterMonitor extends AbstractClusterMonitor {
             ClusterInstance clusterInstance = cluster.getInstanceContexts(parentInstanceId);
             if (clusterInstance != null) {
                 // Cluster instance is already there. No need to create one.
-                VMClusterContext clusterContext;
-                clusterContext =
-                        ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(), cluster);
-                this.setClusterContext(clusterContext);
+                VMClusterContext clusterContext = (VMClusterContext) this.getClusterContext();
+                if(clusterContext == null) {
+                    clusterContext =
+                            ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(), cluster);
+                    this.setClusterContext(clusterContext);
+                }
+
                 // create VMClusterContext and then add all the instanceContexts
                 clusterContext.addInstanceContext(parentInstanceId, cluster);
                 if (this.getInstance(clusterInstance.getInstanceId()) == null) {