incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgog...@apache.org
Subject svn commit: r1180278 - in /incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client: AmbariClient.java ClusterCreate.java Command.java
Date Fri, 07 Oct 2011 23:27:38 GMT
Author: vgogate
Date: Fri Oct  7 23:27:37 2011
New Revision: 1180278

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

Modified:
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.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/Command.java

Modified: 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=1180278&r1=1180277&r2=1180278&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/AmbariClient.java
Fri Oct  7 23:27:37 2011
@@ -34,13 +34,13 @@ public class AmbariClient {
        
         HashMap<String, String> clusterCommands = new HashMap<String, String>();
         clusterCommands.put("create", "ClusterCreate");
-        clusterCommands.put("update", "ClusterUpdate.class");
-        clusterCommands.put("delete", "ClusterDelete.class");
+        clusterCommands.put("update", "ClusterUpdate");
+        clusterCommands.put("delete", "ClusterDelete");
         
         HashMap<String, String> blueprintCommands = new HashMap<String, String>();
-        blueprintCommands.put("list", "BlueprintList.class");
-        blueprintCommands.put("history", "BlueprintHistory.class");
-        blueprintCommands.put("add", "BlueprintAdd.class");
+        blueprintCommands.put("list", "BlueprintList");
+        blueprintCommands.put("history", "BlueprintHistory");
+        blueprintCommands.put("add", "BlueprintAdd");
         
         HashMap<String, String> nodeCommands = new HashMap<String, String>();
         nodeCommands.put("list", "NodeList.class");
@@ -64,15 +64,21 @@ public class AmbariClient {
         c.InitializeCommandsMap();
         
         /*
-         * 
+         * Validate the arguments
          */
         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());
+           if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
+               System.out.println("Usage: AmbariClient <CommandCateogry> <CommandName>
<CommandOptions>\n");
+               System.out.println("       To get the help on each command use -help  e.g.
\"AmbariClient cluster list -help\"\n");
+               for (String category : c.commands.keySet()) {
+                   System.out.println("CommandCategory : ["+ category+"] : Commands "+c.commands.get(category).keySet());
+               }
+               System.exit(0);
+           }
+           if (args[0].equalsIgnoreCase("version")) {
+               System.out.println("VERSION 0.1.0");
+               System.exit(0);
            }
-           System.exit(-1);
         }
         
         /*
@@ -89,7 +95,7 @@ public class AmbariClient {
         }
         
         /*
-         * Instantiate appropriate class based on command cateogry and command name
+         * Instantiate appropriate class based on command category and command name
          */
         try {
             Class<?>[] classParm = new Class<?>[] {String[].class};

Modified: 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=1180278&r1=1180277&r2=1180278&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
Fri Oct  7 23:27:37 2011
@@ -258,21 +258,6 @@ public class ClusterCreate extends Comma
         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")+">]");

Modified: 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=1180278&r1=1180277&r2=1180278&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/Command.java Fri
Oct  7 23:27:37 2011
@@ -17,12 +17,9 @@
  */
 package org.apache.ambari.client;
 
-public class Command {
+public abstract class Command {
     
     protected String baseURLString = "http://localhost:4080/rest";
     
-    public void run () throws Exception {
-        
-    }
-
+    public abstract void run () throws Exception;
 }



Mime
View raw message