incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgog...@apache.org
Subject svn commit: r1206932 - in /incubator/ambari/trunk/controller/src/main/java/org/apache/ambari: controller/ datastore/ datastore/impl/
Date Mon, 28 Nov 2011 00:08:51 GMT
Author: vgogate
Date: Mon Nov 28 00:08:50 2011
New Revision: 1206932

URL: http://svn.apache.org/viewvc?rev=1206932&view=rev
Log:
AMBARI-138. Implement stack persistence

Modified:
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Stacks.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/PersistentDataStore.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/impl/ZookeeperDS.java

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java?rev=1206932&r1=1206931&r2=1206932&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
Mon Nov 28 00:08:50 2011
@@ -112,7 +112,7 @@ public class Cluster {
       this.latestRevisionNumber = dataStore.storeClusterDefinition(c);
       this.clusterDefinitionRevisionsList.put(this.latestRevisionNumber, c);
       this.latestDefinition = c;
-      
+
       // find the plugins for the current definition of the cluster
       loadPlugins(c);
     }

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=1206932&r1=1206931&r2=1206932&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
Mon Nov 28 00:08:50 2011
@@ -70,7 +70,7 @@ public class Clusters {
         cluster123.setGoalState(ClusterState.CLUSTER_STATE_ATTIC);
         List<String> activeServices = new ArrayList<String>();
         activeServices.add("hdfs");
-        activeServices.add("mapred");
+        //activeServices.add("mapred");
         cluster123.setActiveServices(activeServices);
         
         String nodes = "jt-nodex,nn-nodex,hostname-1x,hostname-2x,hostname-3x,"+
@@ -108,7 +108,7 @@ public class Clusters {
         cluster124.setGoalState(ClusterState.CLUSTER_STATE_INACTIVE);
         activeServices = new ArrayList<String>();
         activeServices.add("hdfs");
-        activeServices.add("mapred");
+        //activeServices.add("mapred");
         cluster124.setActiveServices(activeServices);
         
         nodes = "jt-node,nn-node,hostname-1,hostname-2,hostname-3,hostname-4,"+

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java?rev=1206932&r1=1206931&r2=1206932&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Controller.java
Mon Nov 28 00:08:50 2011
@@ -112,11 +112,11 @@ public class Controller {
       Nodes nodesCtx = Nodes.getInstance();
       
       /*
-       *  Recover controller state for Clusters, Stacks and Nodes before 
-       *  opening up the server to clients
+       *  Recover controller state before oopening up the server to clients
+       *  Restore stacks before clusters
        */
-      clustersCtx.recoverClustersStateAfterRestart();
       stacksCtx.recoverStacksAfterRestart();
+      clustersCtx.recoverClustersStateAfterRestart();
       
       /*
        * Start the server after controller state is recovered.

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Stacks.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Stacks.java?rev=1206932&r1=1206931&r2=1206932&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Stacks.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Stacks.java
Mon Nov 28 00:08:50 2011
@@ -56,9 +56,15 @@ public class Stacks {
       try {
         JAXBContext jaxbContext = 
             JAXBContext.newInstance("org.apache.ambari.common.rest.entities");
-        loadDummyStack(jaxbContext, "hadoop-security", 0);
-        loadDummyStack(jaxbContext, "cluster123", 0);
-        loadDummyStack(jaxbContext, "cluster124", 0);
+        if (!this.dataStore.stackExists("hadoop-security")) {
+            loadDummyStack(jaxbContext, "hadoop-security", 0);
+        }
+        if (!this.dataStore.stackExists("cluster123")) {
+            loadDummyStack(jaxbContext, "cluster123", 0);
+        }
+        if (!this.dataStore.stackExists("cluster124")) {
+            loadDummyStack(jaxbContext, "cluster124", 0);
+        }
         //loadDummyStack(jaxbContext, "puppet1", 0);
       } catch (JAXBException e) {
         throw new RuntimeException("Can't create jaxb context", e);
@@ -111,8 +117,9 @@ public class Stacks {
      * Check if stack exists. Names and latest version number is always 
      * cached in the memory
      */
-    public boolean stackExists(String stackName) {
-        if (!this.stacks.containsKey(stackName)) {  
+    public boolean stackExists(String stackName) throws IOException {
+        if (!this.stacks.containsKey(stackName) &&
+             !this.dataStore.stackExists(stackName)) {  
             return false;
         } 
         return true;

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/PersistentDataStore.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/PersistentDataStore.java?rev=1206932&r1=1206931&r2=1206932&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/PersistentDataStore.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/PersistentDataStore.java
Mon Nov 28 00:08:50 2011
@@ -88,5 +88,10 @@ public interface PersistentDataStore {
      * Delete stack
      */
     public void deleteStack(String stackName) throws IOException;
+
+    /**
+     * Check if stack exists
+     */
+    boolean stackExists(String stackName) throws IOException;
     
 }

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/impl/ZookeeperDS.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/impl/ZookeeperDS.java?rev=1206932&r1=1206931&r2=1206932&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/impl/ZookeeperDS.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/datastore/impl/ZookeeperDS.java
Mon Nov 28 00:08:50 2011
@@ -338,6 +338,17 @@ public class ZookeeperDS implements Pers
         }
     }
 
+    @Override
+    public boolean stackExists(String stackName) throws IOException {
+        try {
+            if (zk.exists(ZOOKEEPER_STACKS_ROOT_PATH+"/"+stackName, false) == null) {
+                return false;
+            }
+        } catch (Exception e) {
+            throw new IOException(e);
+        }
+        return true;
+    }
 
     @Override
     public void process(WatchedEvent event) {



Mime
View raw message