incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgog...@apache.org
Subject svn commit: r1197296 - in /incubator/ambari/trunk/controller/src/main/java/org/apache/ambari: controller/Clusters.java controller/Controller.java datastore/impl/ZookeeperDS.java
Date Thu, 03 Nov 2011 20:19:25 GMT
Author: vgogate
Date: Thu Nov  3 20:19:25 2011
New Revision: 1197296

URL: http://svn.apache.org/viewvc?rev=1197296&view=rev
Log:
AMBARI-125

Modified:
    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/datastore/impl/ZookeeperDS.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=1197296&r1=1197295&r2=1197296&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 Nov  3 20:19:25 2011
@@ -553,7 +553,7 @@ public class Clusters {
     /*
      * Update the nodes associated with cluster
      */
-    public synchronized void updateClusterNodesReservation (String clusterName, ClusterDefinition
clsDef) throws Exception {
+    private synchronized void updateClusterNodesReservation (String clusterName, ClusterDefinition
clsDef) throws Exception {
                 
         ConcurrentHashMap<String, Node> all_nodes = Nodes.getInstance().getNodes();
         List<String> cluster_node_range = new ArrayList<String>();
@@ -654,7 +654,7 @@ public class Clusters {
      * @param roleToNodesList
      * @throws Exception
      */
-    public synchronized void updateNodeToRolesAssociation (String clusterNodes, List<RoleToNodes>
roleToNodesList) throws Exception {
+    private synchronized void updateNodeToRolesAssociation (String clusterNodes, List<RoleToNodes>
roleToNodesList) throws Exception {
         /*
          * Associate roles list with node
          */
@@ -865,4 +865,29 @@ public class Clusters {
       }
       return list;
   }
+  
+  /*
+   * Restart recovery for clusters
+   */
+  public void recoverClustersStateAfterRestart () throws Exception {
+      for (Cluster cls : this.getClustersList("ALL")) {
+          ClusterDefinition cdef = cls.getClusterDefinition(-1);
+          this.validateClusterDefinition (cdef);
+          /*
+           * Update cluster nodes reservation. 
+           */
+          if (cdef.getNodes() != null 
+              && !cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ATTIC))
{
+              this.updateClusterNodesReservation (cls.getName(), cdef);
+          }
+          
+          /*
+           * Update the Node to Roles association
+           *
+           */
+          if (!cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ATTIC)) {
+              this.updateNodeToRolesAssociation(cdef.getNodes(), cdef.getRoleToNodes());
+          }
+      }
+  }
 }

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=1197296&r1=1197295&r2=1197296&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
Thu Nov  3 20:19:25 2011
@@ -113,30 +113,17 @@ public class Controller {
       server.setStopAtShutdown(true);
       
       /*
-       *  Recover controller state before opening up the server to clients
+       * Initialize the resources 
        */
-      Clusters clusterCtx = Clusters.getInstance();
+      Clusters clustersCtx = Clusters.getInstance();
       Stacks stacksCtx = Stacks.getInstance();
       Nodes nodesCtx = Nodes.getInstance();
       
-      for (Cluster cls : clusterCtx.getClustersList("ALL")) {
-          ClusterDefinition cdef = cls.getClusterDefinition(-1);
-          /*
-           * Update cluster nodes reservation. 
-           */
-          if (cdef.getNodes() != null 
-              && !cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ATTIC))
{
-              clusterCtx.updateClusterNodesReservation (cls.getName(), cdef);
-          }
-          
-          /*
-           * Update the Node to Roles association
-           *
-           */
-          if (!cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ATTIC)) {
-              clusterCtx.updateNodeToRolesAssociation(cdef.getNodes(), cdef.getRoleToNodes());
-          }
-      }
+      /*
+       *  Recover controller state for Clusters, Stacks and Nodes before 
+       *  opening up the server to clients
+       */
+      clustersCtx.recoverClustersStateAfterRestart();
       
       /*
        * Start the server after controller state is recovered.

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=1197296&r1=1197295&r2=1197296&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
Thu Nov  3 20:19:25 2011
@@ -45,8 +45,8 @@ public class ZookeeperDS implements Pers
             }
             
             while (!this.zkCoonected) {
-                Thread.sleep(5000);
-                System.out.println("Waiting for ZK connection");
+                System.out.println("Waiting for ZK connection!");
+                Thread.sleep(2000);
             }
             
             /*
@@ -130,7 +130,7 @@ public class ZookeeperDS implements Pers
 
     @Override
     public synchronized void storeClusterState(String clusterName, ClusterState clsState)
-            throws IOException {
+           throws IOException {
         /*
          * Update the cluster state
          */



Mime
View raw message