incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r1179862 - /incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
Date Thu, 06 Oct 2011 21:31:00 GMT
Author: eyang
Date: Thu Oct  6 21:31:00 2011
New Revision: 1179862

URL: http://svn.apache.org/viewvc?rev=1179862&view=rev
Log:
AMBARI-39. Bridged cluster reference gap between REST API with State machine. (Eric Yang)

Modified:
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java?rev=1179862&r1=1179861&r2=1179862&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
Thu Oct  6 21:31:00 2011
@@ -22,6 +22,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
@@ -35,10 +36,16 @@ import org.apache.ambari.common.rest.ent
 import org.apache.ambari.common.rest.entities.Node;
 import org.apache.ambari.common.rest.entities.RoleToNodesMap;
 import org.apache.ambari.common.rest.entities.RoleToNodesMapEntry;
+import org.apache.ambari.common.util.ExceptionUtil;
+import org.apache.ambari.resource.statemachine.ClusterFSM;
+import org.apache.ambari.resource.statemachine.StateMachineInvoker;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class Clusters {
-
+    private static Log LOG = LogFactory.getLog(Clusters.class);
+    
     /*
      * Operational clusters include both active and inactive clusters
      */
@@ -271,7 +278,14 @@ public class Clusters {
     		// Add the cluster to the list, when definition is persisted
     		this.operational_clusters.put(c.getName(), cls);
     		this.operational_clusters_id_to_name.put(cls.getID(), c.getName());
+        /*
+         * Activate the cluster if the goal state is activate
+         */
+        if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_ACTIVE)) {          
+          org.apache.ambari.resource.statemachine.ClusterFSM cs = StateMachineInvoker.createCluster(cls);
+        }
     	}
+    	
     	return c;
     } 
     
@@ -549,6 +563,20 @@ public class Clusters {
             String msg = "Cluster ["+clusterName+"] does not exits";
             throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.NOT_FOUND)).get());
         }
+        try {
+          /*
+           * Find the state of the latest blue print name and revision
+           */
+          String clusterId = this.operational_clusters.get(clusterName).getID();
+          String blueprintName = this.operational_clusters.get(clusterName).getClusterDefinition().getBlueprintName();
+          String blueprintRev = this.operational_clusters.get(clusterName).getClusterDefinition().getBlueprintRevision();
+          ClusterState clusterState = StateMachineInvoker.getClusterState(clusterId, blueprintName,
blueprintRev);
+          Cluster cluster = this.operational_clusters.get(clusterName);
+          cluster.setClusterState(clusterState);
+          this.operational_clusters.put(clusterName, cluster);
+        } catch (Exception e) {
+          LOG.error(ExceptionUtil.getStackTrace(e));
+        }
         return this.operational_clusters.get(clusterName).getClusterState();
     }
     



Mime
View raw message