incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgog...@apache.org
Subject svn commit: r1180271 - in /incubator/ambari/trunk: ./ client/src/main/java/org/apache/ambari/client/ controller/src/main/java/org/apache/ambari/controller/ controller/src/main/java/org/apache/ambari/controller/rest/resources/
Date Fri, 07 Oct 2011 22:53:26 GMT
Author: vgogate
Date: Fri Oct  7 22:53:25 2011
New Revision: 1180271

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

Added:
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintHistory.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintList.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterDelete.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterUpdate.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeGet.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/ExceptionResponse.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClustersResource.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1180271&r1=1180270&r2=1180271&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Oct  7 22:53:25 2011
@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
+  AMBARI-45. Implement CLI command Cluster create (vgogate)
+
   AMBARI-46. Implemented preservation of cluster id, blueprint name and
   blueprint revision on agent. (Eric Yang)
 

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+import java.lang.reflect.Constructor;
+import java.net.ConnectException;
+import java.util.HashMap;
+
+import org.apache.commons.cli.Options;
+
+public class AmbariClient {
+
+    HashMap<String, HashMap<String, String>> commands = new HashMap<String, HashMap<String, String>>();
+    
+    /*
+     * Initialize commands HashMap
+     */
+    public void InitializeCommandsMap() {
+       
+        HashMap<String, String> clusterCommands = new HashMap<String, String>();
+        clusterCommands.put("create", "ClusterCreate");
+        clusterCommands.put("update", "ClusterUpdate.class");
+        clusterCommands.put("delete", "ClusterDelete.class");
+        
+        HashMap<String, String> blueprintCommands = new HashMap<String, String>();
+        blueprintCommands.put("list", "BlueprintList.class");
+        blueprintCommands.put("history", "BlueprintHistory.class");
+        blueprintCommands.put("add", "BlueprintAdd.class");
+        
+        HashMap<String, String> nodeCommands = new HashMap<String, String>();
+        nodeCommands.put("list", "NodeList.class");
+        nodeCommands.put("get", "NodeGet.class");
+        
+        commands.put("cluster", clusterCommands);
+        commands.put("blueprint", blueprintCommands);
+        commands.put("node", nodeCommands);
+        
+    }
+    
+    /**
+     * @param args
+     */
+    public static void main(String[] args) {
+        
+        /*
+         * Initialize the commands hash map
+         */
+        AmbariClient c = new AmbariClient();
+        c.InitializeCommandsMap();
+        
+        /*
+         * 
+         */
+        if (args.length < 2) {
+           System.out.println("Usage: AmbariClient <CommandCateogry> <CommandName> <CommandOptions>");
+           System.out.println("");
+           for (String category : c.commands.keySet()) {
+               System.out.println("CommandCategory : ["+ category+"] : Commands "+c.commands.get(category).keySet());
+           }
+           System.exit(-1);
+        }
+        
+        /*
+         * Check if args[0] belongs to command cateogory and args[1] in respective commands
+         */
+        if (!c.commands.containsKey(args[0])) {
+            System.out.println("Invalid command category ["+args[0]+"]");
+            System.exit(-1);
+        }
+        
+        if (!c.commands.get(args[0]).containsKey(args[1])){
+            System.out.println("Invalid command ["+args[1]+"] for category ["+args[0]+"]");
+            System.exit(-1);
+        }
+        
+        /*
+         * Instantiate appropriate class based on command cateogry and command name
+         */
+        try {
+            Class<?>[] classParm = new Class<?>[] {String[].class};
+            Object[] objectParm =  new Object[] {args};
+            
+            Class<?> commandClass  = Class.forName("org.apache.ambari.client."+c.commands.get(args[0]).get(args[1]));
+            Constructor<?> co = commandClass.getConstructor(classParm);
+            Command cmd = (Command)co.newInstance(objectParm);
+            cmd.run();
+        } catch (Exception e) {
+            System.err.println( "Command failed. Reason: <" + e.getMessage() +">\n" );
+            // if (verbose) { e.printStackTrace(); }
+            System.exit(-1);
+        }
+    }
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class BlueprintAdd {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintHistory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintHistory.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintHistory.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintHistory.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class BlueprintHistory {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintList.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintList.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintList.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintList.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class BlueprintList {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.ambari.common.rest.entities.ClusterDefinition;
+import org.apache.ambari.common.rest.entities.RoleToNodesMap;
+import org.apache.ambari.common.rest.entities.RoleToNodesMapEntry;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+public class ClusterCreate extends Command {
+
+    String[] args = null;
+    Options options = null;
+    
+    String urlPath = "/clusters";
+    URL resourceURL = null;
+    
+    String clusterName = null;
+    String description = null;
+    String blueprint = null;
+    String blueprint_revision = "-1";
+    String goalState = null;
+    String activeServices = null;
+    String nodeRangeExpressions = null;
+    
+    Properties roleToNodeExpressions = null;
+    RoleToNodesMap roleToNodeMap = null;
+    Boolean wait = false;
+    Boolean dry_run = false;
+    
+    public ClusterCreate (String [] args) throws Exception {  
+        /*
+         * Build options for cluster create
+         */
+        this.args = args;
+        addOptions();
+        this.resourceURL = new URL (""+this.baseURLString+this.urlPath);
+    }
+    
+    public void printUsage () {
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp( "ambari cluster create", this.options);
+    }
+    
+    public void addOptions () {
+             
+        Option wait = new Option( "wait", "Optionally wait for cluster to reach desired state" );
+        Option dry_run = new Option( "dry_run", "Dry run" );
+        Option help = new Option( "help", "Help" );
+        
+        OptionBuilder.withArgName("cluster_name");
+        OptionBuilder.isRequired();
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription( "Name of the cluster to be created");
+        Option name = OptionBuilder.create( "name" );
+        
+        OptionBuilder.withArgName("blueprint_name");
+        OptionBuilder.isRequired();
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription( "Name of the cluster blueprint");
+        Option blueprint = OptionBuilder.create( "blueprint" );
+        
+        OptionBuilder.withArgName( "\"node_exp1; node_exp2; ...\"" );
+        OptionBuilder.isRequired();
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(  "List of node range expressions separated by semicolon (;) and contained in double quotes (\"\")" );
+        Option nodes = OptionBuilder.create( "nodes" );
+        
+        OptionBuilder.withArgName( "blueprint_revision" );
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(  "Blueprint revision, if not specified latest revision is used" );
+        Option blueprint_revision = OptionBuilder.create( "revision" );
+        
+        OptionBuilder.withArgName( "description" );
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(  "Description to be associated with cluster" );
+        Option desc = OptionBuilder.create( "desc" );
+        
+        OptionBuilder.withArgName( "goalstate" );
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(  "Desired goal state of the cluster" );
+        Option goalstate = OptionBuilder.create( "goalstate" );
+        
+        OptionBuilder.withArgName( "\"component-1; component-2; ...\"" );
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(  "List of components to be active in the cluster. Components are seperated by semicolon \";\"" );
+        Option services = OptionBuilder.create( "services" );
+        
+        OptionBuilder.withArgName( "rolename=\"node_exp1; node_exp2; ... \"" );
+        OptionBuilder.hasArgs(2);
+        OptionBuilder.withValueSeparator();
+        OptionBuilder.withDescription( "Provide node range expressions for a given rolename separated by semicolon (;) and contained in double quotes (\"\")" );
+        Option role = OptionBuilder.create( "role" );
+
+        this.options = new Options();
+        options.addOption( wait );   
+        options.addOption(dry_run);
+        options.addOption( name );
+        options.addOption( blueprint );   
+        options.addOption(blueprint_revision);
+        options.addOption( desc );
+        options.addOption( role );
+        options.addOption( goalstate );
+        options.addOption( nodes );
+        options.addOption( services );
+        options.addOption(help);
+    }
+    
+    public void parseCommandLine() {
+     
+        // create the parser
+        CommandLineParser parser = new GnuParser();
+        try {
+            // parse the command line arguments
+            CommandLine line = parser.parse(this.options, this.args );
+            
+            if (line.hasOption("help")) {
+                printUsage();
+                System.exit(0);
+            }
+            
+            this.clusterName=line.getOptionValue("name");
+            this.blueprint=line.getOptionValue("blueprint");
+            this.nodeRangeExpressions=line.getOptionValue("nodes");
+            
+            if (line.hasOption("revision")){
+                this.blueprint_revision=line.getOptionValue("revision");
+                System.out.println("Blueprint Revision = "+this.blueprint_revision);
+            }
+            if (line.hasOption("desc")){
+                this.description=line.getOptionValue("desc");
+                System.out.println("DESCRIPTION = "+this.description);
+            }
+            if (line.hasOption("role")){
+                this.roleToNodeExpressions = line.getOptionProperties("role");
+                /* 
+                System.out.println ("RoleToNodesMap");
+                for (String roleName : this.roleToNodeExpressions.stringPropertyNames()) {
+                    System.out.println ("    <"+roleName+">:<"+ this.roleToNodeExpressions.getProperty(roleName)+">");
+                }
+                */
+            }
+            if (line.hasOption("goalstate")){
+                this.goalState=line.getOptionValue("goalstate");
+                System.out.println("Goalstate = "+this.goalState);
+            }
+            if (line.hasOption("services")){
+                this.activeServices=line.getOptionValue("services");
+                System.out.println("Active Services = "+this.activeServices);
+            }
+            if (line.hasOption("wait")) {
+                this.wait = true;
+            }
+            if (line.hasOption("dry_run")) {
+                this.dry_run = true;
+            } 
+        }
+        catch( ParseException exp ) {
+            // oops, something went wrong
+            System.err.println( "Command parsing failed. Reason: <" + exp.getMessage()+">\n" );
+            printUsage();
+            System.exit(-1);
+        } 
+    }
+    
+    private static URI getBaseURI() {
+        return UriBuilder.fromUri(
+                "http://localhost:4080/rest/").build();
+    }
+    
+    public static List<String> parseExpressionString(String exp) {
+        if (exp == null) { return null; }
+        List<String> list = new ArrayList<String>();
+        String[] result = exp.split(";");
+        for (String x: result) {
+            list.add(x.trim());
+        }
+        return list;
+    }
+    
+    public static RoleToNodesMap getRoleToNodesMap (Properties roleToNodeExpressions) {
+        if (roleToNodeExpressions == null) { return null; };
+        
+        RoleToNodesMap roleToNodesMap = new RoleToNodesMap();
+        for (String roleName : roleToNodeExpressions.stringPropertyNames()) {
+            RoleToNodesMapEntry e = new RoleToNodesMapEntry();
+            e.setRoleName(roleName);
+            e.setNodeRangeExpressions(parseExpressionString(roleToNodeExpressions.getProperty(roleName)));
+            roleToNodesMap.getRoleToNodesMapEntry().add(e);
+        }
+        return roleToNodesMap;
+    }
+    
+    public static void main (String[] args) {
+        String exp = " abc ; pqr ; xyz";
+        List<String> result = parseExpressionString(exp);
+        for (String x : result) {
+            System.out.println("token :<"+x+">");
+        }
+    }
+    
+    public void run() throws Exception {
+        /* 
+         * Parse the command line to get the command line arguments
+         */
+        parseCommandLine();
+        
+        ClientConfig config = new DefaultClientConfig();
+        Client client = Client.create(config);
+        WebResource service = client.resource(getBaseURI());
+        
+        // Create Cluster Definition
+        ClusterDefinition clsDef = new ClusterDefinition();
+        clsDef.setName(this.clusterName);
+        clsDef.setBlueprintName(this.blueprint);
+        clsDef.setNodeRangeExpressions(parseExpressionString(this.nodeRangeExpressions));
+        
+        clsDef.setGoalState(this.goalState);
+        clsDef.setBlueprintRevision(this.blueprint_revision);
+        clsDef.setActiveServices(parseExpressionString(this.activeServices));
+        clsDef.setDescription(this.description);
+        clsDef.setRoleToNodesMap(getRoleToNodesMap(this.roleToNodeExpressions));
+        
+        /*
+        List<String> services = new ArrayList<String>();
+        services.add("hdfs");
+        services.add("mapred");
+        clsDef.setActiveServices(services);
+        clsDef.setBlueprintName("MyClusterBlueprint");
+        clsDef.setGoalState(ClusterDefinition.GOAL_STATE_ACTIVE);
+        
+        List<String> nodeRangeExpressions = new ArrayList();
+        nodeRangeExpressions.add("mhost1 mhost2 mhost3");
+        clsDef.setNodeRangeExpressions(nodeRangeExpressions);
+        clsDef.setBlueprintRevision("0");
+        clsDef.setDescription("This Test Cluster");
+        */
+        
+        ClientResponse response = service.path("clusters").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, clsDef);
+        if (response.getStatus() != 200) { 
+            System.err.println("Cluster create command failed. Reason [Code: <"+response.getStatus()+">, Message: <"+response.getHeaders().getFirst("ErrorMessage")+">]");
+            System.exit(-1);
+        }
+        
+        ClusterDefinition def = response.getEntity(ClusterDefinition.class);
+        System.out.println("CLUSTER NAME ["+def.getName()+"]");
+        System.out.println("CLUSTER NAME ["+def.getDescription()+"]");
+    }
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterDelete.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterDelete.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterDelete.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterDelete.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class ClusterDelete {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterUpdate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterUpdate.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterUpdate.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterUpdate.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class ClusterUpdate {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class Command {
+    
+    protected String baseURLString = "http://localhost:4080/rest";
+    
+    public void run () throws Exception {
+        
+    }
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeGet.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeGet.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeGet.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeGet.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class NodeGet {
+
+}

Added: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java?rev=1180271&view=auto
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java (added)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java Fri Oct  7 22:53:25 2011
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.client;
+
+public class NodeList {
+
+}

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=1180271&r1=1180270&r2=1180271&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 Fri Oct  7 22:53:25 2011
@@ -214,79 +214,79 @@ public class Clusters {
      */   
     public ClusterDefinition addCluster(ClusterDefinition c) throws Exception {
 
-    	/*
-    	 * TODO: Validate the cluster definition
-    	 */
-    	if (c.getName() == null ||  c.getName().equals("")) {
-    		String msg = "Cluster Name must be specified and must be non-empty string";
-    		throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.BAD_REQUEST)).get());
-    	}
-    	
-    	synchronized (operational_clusters) {
-    		/* 
-    		 * Check if cluster already exists
-    		 */
-    		if (operational_clusters.containsKey(c.getName())) {
-    			String msg = "Cluster ["+c.getName()+"] already exists";
-    			throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.CONFLICT)).get());
-    		}
-    		
-    		/*
-    		 * Add new cluster to cluster list
-    		 */
-    		Date requestTime = new Date();
-    		Cluster cls = new Cluster();
-    		ClusterState clsState = new ClusterState();
-    		clsState.setCreationTime(requestTime);
-    		clsState.setLastUpdateTime(requestTime);
-    		clsState.setDeployTime((Date)null);
-    		clsState.setState(ClusterState.CLUSTER_STATE_INACTIVE);
-    		
-    		cls.setID(UUID.randomUUID().toString());
-    		cls.setClusterDefinition(c);
-    		cls.setClusterState(clsState);
-    		
-			/*
-			 * Update cluster nodes reservation.
-			 * TODO: REST API should allow roleToNodesMap separately based on the node attributes 
-			 */
-			if (c.getNodeRangeExpressions() != null) {
-				updateClusterNodesReservation (cls, c.getNodeRangeExpressions());
-			}
-			
-			/*
-			 * Update the Node to Roles association if specified
-			 * Create map of <Cluster - nodeToRolesMap>
-			 * If role is not explicitly associated w/ any node then assign it w/ default role
-			 * If RoleToNodes map is not specified then derive it based on the node attributes 
-			 *  
-			 */
-			if (c.getRoleToNodesMap() != null) {
-				updateNodeToRolesAssociation(c, c.getRoleToNodesMap());
-			} else {
-				/*
-				 * TODO: Derive the role to nodes map based on nodes attributes
-				 * then populate the node to roles association.
-				 */
-			}
-			
-    		/*
-    		 * TODO: Persist the cluster definition to data store as a initial version r0. 
-    		 * 		 Persist reserved nodes against the cluster & service/role
-    		 */
-    			
-    		// 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
+         * TODO: Validate the cluster definition
          */
-        if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_ACTIVE)) {          
-          org.apache.ambari.resource.statemachine.ClusterFSM cs = StateMachineInvoker.createCluster(cls);
+        if (c.getName() == null ||  c.getName().equals("")) {
+            String msg = "Cluster Name must be specified and must be non-empty string";
+            throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.BAD_REQUEST)).get());
         }
-    	}
-    	
-    	return c;
+        
+        synchronized (operational_clusters) {
+            /* 
+             * Check if cluster already exists
+             */
+            if (operational_clusters.containsKey(c.getName())) {
+                String msg = "Cluster ["+c.getName()+"] already exists";
+                throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.CONFLICT)).get());
+            }
+            
+            /*
+             * Add new cluster to cluster list
+             */
+            Date requestTime = new Date();
+            Cluster cls = new Cluster();
+            ClusterState clsState = new ClusterState();
+            clsState.setCreationTime(requestTime);
+            clsState.setLastUpdateTime(requestTime);
+            clsState.setDeployTime((Date)null);
+            clsState.setState(ClusterState.CLUSTER_STATE_INACTIVE);
+            
+            cls.setID(UUID.randomUUID().toString());
+            cls.setClusterDefinition(c);
+            cls.setClusterState(clsState);
+            
+            /*
+             * Update cluster nodes reservation.
+             * TODO: REST API should allow roleToNodesMap separately based on the node attributes 
+             */
+            if (c.getNodeRangeExpressions() != null) {
+                updateClusterNodesReservation (cls, c.getNodeRangeExpressions());
+            }
+            
+            /*
+             * Update the Node to Roles association if specified
+             * Create map of <Cluster - nodeToRolesMap>
+             * If role is not explicitly associated w/ any node then assign it w/ default role
+             * If RoleToNodes map is not specified then derive it based on the node attributes 
+             *  
+             */
+            if (c.getRoleToNodesMap() != null) {
+                updateNodeToRolesAssociation(c, c.getRoleToNodesMap());
+            } else {
+                /*
+                 * TODO: Derive the role to nodes map based on nodes attributes
+                 * then populate the node to roles association.
+                 */
+            }
+            
+            /*
+             * TODO: Persist the cluster definition to data store as a initial version r0. 
+             *          Persist reserved nodes against the cluster & service/role
+             */
+                
+            // 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;
     } 
     
     
@@ -294,147 +294,149 @@ public class Clusters {
      * Update the nodes associated with cluster
      */
     private synchronized void updateClusterNodesReservation (Cluster cls, List<String> nodeRangeExpressions) throws Exception {
-    	
-    	String clusterID = getClusterIDByName(cls.getClusterDefinition().getName());
-    	
-    	/*
-    	 * Check if all the nodes explicitly specified in the RoleToNodesMap belong the cluster node range specified 
-    	 */
-    	ConcurrentHashMap<String, Node> all_nodes = Nodes.getInstance().getNodes();
+        
+        String clusterID = cls.getID();
+        
+        ConcurrentHashMap<String, Node> all_nodes = Nodes.getInstance().getNodes();
         List<String> cluster_node_range = new ArrayList<String>();
         cluster_node_range.addAll(getHostnamesFromRangeExpressions(nodeRangeExpressions));
         
-        List<String> nodes_specified_using_role_association = new ArrayList<String>();
-        for (RoleToNodesMapEntry e : cls.getClusterDefinition().getRoleToNodesMap().getRoleToNodesMapEntry()) {
-            List<String> hosts = getHostnamesFromRangeExpressions(e.getNodeRangeExpressions());
-            nodes_specified_using_role_association.addAll(hosts);
-            // TODO: Remove any duplicate nodes from nodes_specified_using_role_association
+        /*
+         * Check if all the nodes explicitly specified in the RoleToNodesMap belong the cluster node range specified 
+         */
+        if (cls.getClusterDefinition().getRoleToNodesMap() != null) {
+            List<String> nodes_specified_using_role_association = new ArrayList<String>();
+            for (RoleToNodesMapEntry e : cls.getClusterDefinition().getRoleToNodesMap().getRoleToNodesMapEntry()) {
+                List<String> hosts = getHostnamesFromRangeExpressions(e.getNodeRangeExpressions());
+                nodes_specified_using_role_association.addAll(hosts);
+                // TODO: Remove any duplicate nodes from nodes_specified_using_role_association
+            }
+            
+            nodes_specified_using_role_association.removeAll(cluster_node_range);
+            if (!nodes_specified_using_role_association.isEmpty()) {
+                String msg = "Some nodes explicityly associated with roles using RoleToNodesMap do not belong in the " +
+                             "golbal node range specified for the cluster : ["+nodes_specified_using_role_association+"]";
+                throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.BAD_REQUEST)).get());
+            }
         }
         
-        nodes_specified_using_role_association.removeAll(cluster_node_range);
-        if (!nodes_specified_using_role_association.isEmpty()) {
-            String msg = "Some nodes explicityly associated with roles using RoleToNodesMap do not belong in the " +
-            		     "golbal node range specified for the cluster : ["+nodes_specified_using_role_association+"]";
-            throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.BAD_REQUEST)).get());
+        /*
+         * Reserve the nodes as specified in the node range expressions
+         * -- throw exception if any nodes are pre-associated with other cluster
+         */    
+        List<String> nodes_currently_allocated_to_cluster = new ArrayList<String>();
+        for (Node n : Nodes.getInstance().getNodes().values()) {
+            if (n.getNodeState().getClusterID().equals(cls.getID())) {
+                nodes_currently_allocated_to_cluster.add(n.getName());
+            }
+        }
+        
+        List<String> nodes_to_allocate = new ArrayList<String>(cluster_node_range);
+        nodes_to_allocate.removeAll(nodes_currently_allocated_to_cluster);
+        List<String> nodes_to_deallocate = new ArrayList<String>(nodes_currently_allocated_to_cluster);
+        nodes_to_deallocate.removeAll(cluster_node_range);
+        
+        /*
+         * Check for any nodes that are allocated to other cluster
+         */
+        List<String> preallocatedhosts = new ArrayList<String>();
+        for (String n : nodes_to_allocate) {
+            if (all_nodes.containsKey(n) && 
+                    (all_nodes.get(n).getNodeState().getClusterID() != null || 
+                     all_nodes.get(n).getNodeState().getAllocatedToCluster()
+                    )
+                ) {
+                preallocatedhosts.add(n);
+            }
+        }
+        
+        /* 
+         * Throw exception, if some of the hosts are already allocated to other cluster
+         */
+        if (!preallocatedhosts.isEmpty()) {
+            /*
+             * TODO: Return invalid request code and return list of preallocated nodes as a part of
+             *       response element
+             */
+            String msg = "Some of the nodes specified for the cluster roles are allocated to other cluster: ["+preallocatedhosts+"]";
+            throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.CONFLICT)).get());
+        }
+        
+        /*
+         * Allocate nodes to given cluster
+         */    
+        for (String node_name : nodes_to_allocate) {
+            if (all_nodes.containsKey(node_name)) { 
+                // Set the cluster name in the node 
+                synchronized (all_nodes.get(node_name)) {
+                    all_nodes.get(node_name).reserveNodeForCluster(clusterID, true);
+                }    
+            } else {
+                Node node = new Node(node_name);
+                /*
+                 * Set the heartbeat time to very old epoch value
+                 */
+                Date epoch = new Date(0);
+                node.getNodeState().setLastHeartbeatTime(epoch);
+                /*
+                 * TODO: Set agentInstalled = true, unless controller uses SSH to setup the agent
+                 */
+                node.reserveNodeForCluster(clusterID, true);
+                Nodes.getInstance().getNodes().put(node_name, node);
+            }
         }
         
-    	/*
-		 * Reserve the nodes as specified in the node range expressions
-		 * -- throw exception if any nodes are pre-associated with other cluster
-		 */	
-    	List<String> nodes_currently_allocated_to_cluster = new ArrayList<String>();
-    	for (Node n : Nodes.getInstance().getNodes().values()) {
-    		if (n.getNodeState().getClusterID().equals(cls.getClusterDefinition().getName())) {
-    			nodes_currently_allocated_to_cluster.add(n.getName());
-    		}
-    	}
-    	
-    	List<String> nodes_to_allocate = new ArrayList<String>(cluster_node_range);
-    	nodes_to_allocate.removeAll(nodes_currently_allocated_to_cluster);
-    	List<String> nodes_to_deallocate = new ArrayList<String>(nodes_currently_allocated_to_cluster);
-    	nodes_to_deallocate.removeAll(cluster_node_range);
-    	
-		/*
-		 * Check for any nodes that are allocated to other cluster
-		 */
-    	List<String> preallocatedhosts = new ArrayList<String>();
-    	for (String n : nodes_to_allocate) {
-    		if (all_nodes.containsKey(n) && 
-    				(all_nodes.get(n).getNodeState().getClusterID() != null || 
-    				 all_nodes.get(n).getNodeState().getAllocatedToCluster()
-    				)
-    			) {
-    			preallocatedhosts.add(n);
-    		}
-    	}
-    	
-    	/* 
-		 * Throw exception, if some of the hosts are already allocated to other cluster
-		 */
-		if (!preallocatedhosts.isEmpty()) {
-			/*
-			 * TODO: Return invalid request code and return list of preallocated nodes as a part of
-			 *       response element
-			 */
-			String msg = "Some of the nodes specified for the cluster roles are allocated to other cluster: ["+preallocatedhosts+"]";
-    		throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.CONFLICT)).get());
-		}
-		
-		/*
-		 * Allocate nodes to given cluster
-		 */	
-		for (String node_name : nodes_to_allocate) {
-			if (all_nodes.containsKey(node_name)) { 
-				// Set the cluster name in the node 
-				synchronized (all_nodes.get(node_name)) {
-					all_nodes.get(node_name).reserveNodeForCluster(clusterID, true);
-				}	
-			} else {
-				Node node = new Node(node_name);
-				/*
-				 * Set the heartbeat time to very old epoch value
-				 */
-				Date epoch = new Date(0);
-		        node.getNodeState().setLastHeartbeatTime(epoch);
-				/*
-				 * TODO: Set agentInstalled = true, unless controller uses SSH to setup the agent
-				 */
-				node.reserveNodeForCluster(clusterID, true);
-				Nodes.getInstance().getNodes().put(node_name, node);
-			}
-		}
-		
-		/*
-		 * deallocate nodes from a given cluster
-		 * TODO: Node agent would asynchronously clean up the node and notify it through heartbeat which 
-		 * would set the allocatedtoCluster flag false
-		 */
-		for (String node_name : nodes_to_deallocate) {
-			if (all_nodes.containsKey(node_name)) {
-				synchronized (all_nodes.get(node_name)) {
-					all_nodes.get(node_name).releaseNodeFromCluster();
-				}
-			}
-		}
+        /*
+         * deallocate nodes from a given cluster
+         * TODO: Node agent would asynchronously clean up the node and notify it through heartbeat which 
+         * would set the allocatedtoCluster flag false
+         */
+        for (String node_name : nodes_to_deallocate) {
+            if (all_nodes.containsKey(node_name)) {
+                synchronized (all_nodes.get(node_name)) {
+                    all_nodes.get(node_name).releaseNodeFromCluster();
+                }
+            }
+        }
     }
 
-	private synchronized void updateNodeToRolesAssociation (ClusterDefinition c, RoleToNodesMap roleToNodesMap) throws Exception {
-		/*
-		 * Associate roles list with node
-		 */
-		if (roleToNodesMap == null) {
-			return;
-		}
-		
-		/*
-		 * Add list of roles to Node
-		 * If node is not explicitly associated with any role then assign it w/ default role
-		 */
-		for (RoleToNodesMapEntry e : roleToNodesMap.getRoleToNodesMapEntry()) {
-			List<String> hosts = getHostnamesFromRangeExpressions(e.getNodeRangeExpressions());
-			for (String host : hosts) {
-			  if (Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames() == null) {
-			    Nodes.getInstance().getNodes().get(host).getNodeState().setNodeRoleNames((new ArrayList<String>()));
-			  } 
-			  Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames().add(e.getRoleName());
-			}
-		}
-		
-		
-		/*
-		 * Get the list of specified global node list for the cluster and any nodes NOT explicitly specified in the
-		 * role to nodes map, assign them with default role 
-		 */
-		List<String> specified_node_range = new ArrayList<String>();
-    	specified_node_range.addAll(getHostnamesFromRangeExpressions(c.getNodeRangeExpressions()));
-    	for (String host : specified_node_range) {
-    	    if (Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames() == null) {
-    	        Nodes.getInstance().getNodes().get(host).getNodeState().setNodeRoleNames((new ArrayList<String>()));
-    	        String cid = Nodes.getInstance().getNodes().get(host).getNodeState().getClusterID();
-    	        Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames().add(getDefaultRoleName(cid));
-    	    } 
-    	}
-	}
+    private synchronized void updateNodeToRolesAssociation (ClusterDefinition c, RoleToNodesMap roleToNodesMap) throws Exception {
+        /*
+         * Associate roles list with node
+         */
+        if (roleToNodesMap == null) {
+            return;
+        }
+        
+        /*
+         * Add list of roles to Node
+         * If node is not explicitly associated with any role then assign it w/ default role
+         */
+        for (RoleToNodesMapEntry e : roleToNodesMap.getRoleToNodesMapEntry()) {
+            List<String> hosts = getHostnamesFromRangeExpressions(e.getNodeRangeExpressions());
+            for (String host : hosts) {
+              if (Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames() == null) {
+                Nodes.getInstance().getNodes().get(host).getNodeState().setNodeRoleNames((new ArrayList<String>()));
+              } 
+              Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames().add(e.getRoleName());
+            }
+        }
+        
+        
+        /*
+         * Get the list of specified global node list for the cluster and any nodes NOT explicitly specified in the
+         * role to nodes map, assign them with default role 
+         */
+        List<String> specified_node_range = new ArrayList<String>();
+        specified_node_range.addAll(getHostnamesFromRangeExpressions(c.getNodeRangeExpressions()));
+        for (String host : specified_node_range) {
+            if (Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames() == null) {
+                Nodes.getInstance().getNodes().get(host).getNodeState().setNodeRoleNames((new ArrayList<String>()));
+                String cid = Nodes.getInstance().getNodes().get(host).getNodeState().getClusterID();
+                Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames().add(getDefaultRoleName(cid));
+            } 
+        }
+    }
 
     /* 
      * Update cluster definition
@@ -620,36 +622,36 @@ public class Clusters {
      * UTIL methods on entities
      */
     
-	/*
-	 * Get the list of role names associated with node
-	 */
-	public List<String> getAssociatedRoleNames(String hostname) {
-	  return Nodes.getInstance().getNodes().get(hostname).getNodeState().getNodeRoleNames();
-	}
-	
-	/*
-	 *  Return the default role name to be associated with specified cluster node that 
-	 *  has no specific role to nodes association specified in the cluster definition
-	 *  Throw exception if node is not associated to with any cluster
-	 */
-	public String getDefaultRoleName(String clusterID) throws Exception {
-	    Cluster c = Clusters.getInstance().getClusterByID(clusterID);
-	    // TODO: find the default role from the clsuter blueprint 
-		return "slaves-role";
-	}
-	
-	/*
+    /*
+     * Get the list of role names associated with node
+     */
+    public List<String> getAssociatedRoleNames(String hostname) {
+      return Nodes.getInstance().getNodes().get(hostname).getNodeState().getNodeRoleNames();
+    }
+    
+    /*
+     *  Return the default role name to be associated with specified cluster node that 
+     *  has no specific role to nodes association specified in the cluster definition
+     *  Throw exception if node is not associated to with any cluster
+     */
+    public String getDefaultRoleName(String clusterID) throws Exception {
+        Cluster c = Clusters.getInstance().getClusterByID(clusterID);
+        // TODO: find the default role from the clsuter blueprint 
+        return "slaves-role";
+    }
+    
+  /*
    * TODO: Implement proper range expression
    * TODO: Remove any duplicate nodes from the derived list
    */
   public List<String> getHostnamesFromRangeExpressions (List<String> nodeRangeExpressions) throws Exception {
-  	List<String> list = new ArrayList<String>();
-  	for (String nodeRangeExpression : nodeRangeExpressions) {
-    	StringTokenizer st = new StringTokenizer(nodeRangeExpression);
-    	while (st.hasMoreTokens()) {
-    		list.add(st.nextToken());
-    	}
-  	}
-  	return list;
+      List<String> list = new ArrayList<String>();
+      for (String nodeRangeExpression : nodeRangeExpressions) {
+        StringTokenizer st = new StringTokenizer(nodeRangeExpression);
+        while (st.hasMoreTokens()) {
+            list.add(st.nextToken());
+        }
+      }
+      return list;
   }
 }

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/ExceptionResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/ExceptionResponse.java?rev=1180271&r1=1180270&r2=1180271&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/ExceptionResponse.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/ExceptionResponse.java Fri Oct  7 22:53:25 2011
@@ -29,6 +29,7 @@ public class ExceptionResponse  {
         builder.header("ErrorMessage", e.getMessage());
         builder.header("ErrorCode", Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
         r = builder.build();
+        e.printStackTrace();
     }
     
     public ExceptionResponse (String exceptionMessage, Response.Status rs) {

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClustersResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClustersResource.java?rev=1180271&r1=1180270&r2=1180271&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClustersResource.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClustersResource.java Fri Oct  7 22:53:25 2011
@@ -28,6 +28,7 @@ import javax.ws.rs.GET;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;



Mime
View raw message