Return-Path: X-Original-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 57C2B94BE for ; Tue, 29 Nov 2011 02:05:02 +0000 (UTC) Received: (qmail 17754 invoked by uid 500); 29 Nov 2011 02:05:02 -0000 Delivered-To: apmail-incubator-ambari-commits-archive@incubator.apache.org Received: (qmail 17738 invoked by uid 500); 29 Nov 2011 02:05:02 -0000 Mailing-List: contact ambari-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@incubator.apache.org Delivered-To: mailing list ambari-commits@incubator.apache.org Received: (qmail 17731 invoked by uid 99); 29 Nov 2011 02:05:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 02:05:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 02:04:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DB16F238890A; Tue, 29 Nov 2011 02:04:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1207732 - in /incubator/ambari/trunk: CHANGES.txt controller/src/main/java/org/apache/ambari/controller/Cluster.java controller/src/main/java/org/apache/ambari/controller/Clusters.java Date: Tue, 29 Nov 2011 02:04:36 -0000 To: ambari-commits@incubator.apache.org From: vgogate@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111129020436.DB16F238890A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: vgogate Date: Tue Nov 29 02:04:35 2011 New Revision: 1207732 URL: http://svn.apache.org/viewvc?rev=1207732&view=rev Log: AMBARI-144. Implement getInstallAndConfigureScript for a given revision of cluster definition. Modified: incubator/ambari/trunk/CHANGES.txt 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 Modified: incubator/ambari/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1207732&r1=1207731&r2=1207732&view=diff ============================================================================== --- incubator/ambari/trunk/CHANGES.txt (original) +++ incubator/ambari/trunk/CHANGES.txt Tue Nov 29 02:04:35 2011 @@ -2,6 +2,8 @@ Ambari Change log Release 0.1.0 - unreleased + AMBARI-144. Implement getInstallAndConfigureScript for a given revision of cluster definition. (vgogate) + AMBARI-143. Fixes an annotation issue in HeartBeat class (ddas) AMBZRI-142. Add cluster must validate if requested nodes are pre-allocated to any other existing cluster (vgogate) 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=1207732&r1=1207731&r2=1207732&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 Tue Nov 29 02:04:35 2011 @@ -117,16 +117,6 @@ public class Cluster { loadPlugins(c); } - /** - * @return Add puppet configuration - */ - public synchronized void updatePuppetConfiguration(String puppetConfig) throws Exception { - //this.latestRevisionNumber = dataStore.storeClusterDefinition(c); - //this.clusterDefinitionRevisionsList.put(this.latestRevisionNumber, c); - //this.latestDefinition = c; - } - - /* * Load plugins for the current definition of the cluster */ 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=1207732&r1=1207731&r2=1207732&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 Tue Nov 29 02:04:35 2011 @@ -295,11 +295,10 @@ public class Clusters { /* * Create Puppet config - if (configChanged || updateNodeToRolesAssociation || updateNodesReservation) { String puppetConfig = this.getPuppetConfigString (newcd); - //cls.updatePuppetConfiguration(puppetConfig); - }*/ + cls.updatePuppetConfiguration(puppetConfig); + } */ /* * Update the nodes reservation and node to roles association @@ -312,6 +311,11 @@ public class Clusters { } /* + * Print puppet config + */ + System.out.println(getInstallAndConfigureScript(clusterName, -1)); + + /* * Invoke state machine event */ if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_ACTIVE)) { @@ -374,15 +378,6 @@ public class Clusters { } /* - * TODO: Create and update the puppet configuration - */ - String puppetConfig = this.getPuppetConfigString (cdef); - System.out.println("=============================="); - System.out.println(puppetConfig); - System.out.println("=============================="); - - - /* * Persist the new cluster and add entry to cache */ Cluster cls = this.addClusterEntry(cdef, clsState); @@ -403,6 +398,11 @@ public class Clusters { } /* + * Print puppet config + */ + System.out.println(getInstallAndConfigureScript(clusterName, -1)); + + /* * Create the cluster object with state machine & * activate it if the goal state is ACTIVE * TODO: Make sure createCluster is idempotent (i.e. if object already exists @@ -719,16 +719,7 @@ public class Clusters { } return bp; } - - - /* - * Get the deployment script for this clustername/revision combo - */ - public String getInstallAndConfigureScript(String clusterName, - int revision) { - return ""; //TODO: fill - } - + /* * Get the latest cluster definition */ @@ -874,7 +865,12 @@ public class Clusters { } } - private String getPuppetConfigString (ClusterDefinition c) throws Exception { + + /* + * Get the deployment script for this clustername/revision combo + */ + public String getInstallAndConfigureScript(String clusterName, int revision) throws Exception { + ClusterDefinition c = getClusterByName (clusterName).getClusterDefinition(revision); // TODO: ignore if comps or roles are not present in stack. Stacks stacksCtx = Stacks.getInstance(); Stack stack = stacksCtx.getStack(c.getStackName(), Integer.parseInt(c.getStackRevision())); @@ -882,21 +878,36 @@ public class Clusters { if (stack.getComponents() != null) { for (Component comp : stack.getComponents()) { if (comp.getRoles() != null) { - for (Role role : comp.getRoles()) { + for (int k=0; k { "; config = config+role.getName()+" => { "; if (role.getConfiguration() != null && role.getConfiguration().getCategory() != null) { - for (ConfigurationCategory cat : role.getConfiguration().getCategory()) { - config = config+"\""+cat.getName()+"\" => { "; - if (cat.getProperty() != null) { - for (Property p : cat.getProperty()) { - config = config+p.getName()+" => "+p.getValue()+", "; + for (int j=0; j { "; + if (cat.getProperty() != null) { + for (int i=0; i "+p.getValue()+" "; + } else { + config = config+p.getName()+" => "+p.getValue()+", "; + } } } - config = config +" }, \n"; + if (j == role.getConfiguration().getCategory().size()-1) { + config = config +" } \n"; + } else { + config = config +" }, \n"; + } } } - config = config + "}, \n"; + if (k == comp.getRoles().size()-1) { + config = config + "} \n"; + } else { + config = config + "}, \n"; + } } } } @@ -904,15 +915,25 @@ public class Clusters { config = config + "} \n"; config = config + "$role_to_nodes = { "; - for (RoleToNodes roleToNodesEntry : c.getRoleToNodesMap()) { + for (int i=0; i ["; - for (String host : this.getHostnamesFromRangeExpressions(roleToNodesEntry.getNodes())) { - config = config + "\'"+host+"\',"; + List host_list = this.getHostnamesFromRangeExpressions(roleToNodesEntry.getNodes()); + for (int j=0; j