incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r1180754 [1/3] - in /incubator/ambari/branches/branch-0.0: ./ bin/ common/src/main/java/org/apache/hms/common/conf/ common/src/main/java/org/apache/hms/common/entity/manifest/ common/src/main/java/org/apache/hms/common/util/ controller/ con...
Date Mon, 10 Oct 2011 00:57:21 GMT
Author: eyang
Date: Mon Oct 10 00:57:19 2011
New Revision: 1180754

URL: http://svn.apache.org/viewvc?rev=1180754&view=rev
Log:
AMBARI-49. Added functional UI for HMS. (Eric Yang)

Added:
    incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/WadlResource.java
    incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/config/ExtendedWadlGeneratorConfig.java
    incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-doc.xml
    incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-grammars.xml
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-blueprint.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-software.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.js
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/javascript/
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/javascript/index.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/javascript/javascript.js
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/xml/
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/xml/index.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/mode/xml/xml.js
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/overlay.js
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/runmode.js
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/cobalt.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/default.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/eclipse.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/elegant.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/neat.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/theme/night.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/list-blueprint.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/list-software.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/manage-blueprint.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/manage-software.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/wadl.xsl
Modified:
    incubator/ambari/branches/branch-0.0/bin/hms-config.sh
    incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/conf/CommonConfigurationKeys.java
    incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/entity/manifest/NodesManifest.java
    incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/util/ZookeeperUtil.java
    incubator/ambari/branches/branch-0.0/controller/pom.xml
    incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/Controller.java
    incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/ConfigManager.java
    incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/SoftwareManager.java
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-cluster.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-nodes.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/css/default.css
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/list-nodes.html
    incubator/ambari/branches/branch-0.0/controller/src/main/webapps/nav.html
    incubator/ambari/branches/branch-0.0/pom.xml

Modified: incubator/ambari/branches/branch-0.0/bin/hms-config.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/bin/hms-config.sh?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/bin/hms-config.sh (original)
+++ incubator/ambari/branches/branch-0.0/bin/hms-config.sh Mon Oct 10 00:57:19 2011
@@ -73,8 +73,8 @@ if [ -f "${HMS_CONF_DIR}/hms-env.sh" ]; 
   . "${HMS_CONF_DIR}/hms-env.sh"
 fi
 
-COMMON=`ls ${HMS_HOME}/lib/*.jar`
-export COMMON=`echo ${COMMON} | sed 'y/ /:/'`
+COMMON="${HMS_HOME}/lib/*"
+#export COMMON=`echo ${COMMON} | sed 'y/ /:/'`
 
 export HMS_CORE=${HMS_HOME}/hms-core-${HMS_VERSION}.jar
 export HMS_AGENT=${HMS_HOME}/hms-agent-${HMS_VERSION}.jar

Modified: incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/conf/CommonConfigurationKeys.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/conf/CommonConfigurationKeys.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/conf/CommonConfigurationKeys.java (original)
+++ incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/conf/CommonConfigurationKeys.java Mon Oct 10 00:57:19 2011
@@ -61,4 +61,13 @@ public class CommonConfigurationKeys {
   public static final String ZOOKEEPER_STATUS_QUEUE_PATH_KEY = "hms.zookeeper.status.queue.path";
   /** Default location of zookeeper status queue */
   public static final String ZOOKEEPER_STATUS_QUEUE_PATH_DEFAULT = "/status";
+  
+  /** Path to zookeeper software manifest */
+  public static final String ZOOKEEPER_SOFTWARE_MANIFEST_KEY = "hms.software.manifest.path";
+  
+  /** Default location of software manifest */
+  public static final String ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT = "/software-manifest";
+  
+  /** Path to zookeeper config blueprint */
+  public static final String ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT = "/config-blueprint";
 }

Modified: incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/entity/manifest/NodesManifest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/entity/manifest/NodesManifest.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/entity/manifest/NodesManifest.java (original)
+++ incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/entity/manifest/NodesManifest.java Mon Oct 10 00:57:19 2011
@@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
-import org.apache.hms.common.entity.manifest.Node;
-
 @XmlAccessorType(XmlAccessType.FIELD) 
 @XmlType(propOrder = { "roles" })
 @XmlRootElement

Modified: incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/util/ZookeeperUtil.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/util/ZookeeperUtil.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/util/ZookeeperUtil.java (original)
+++ incubator/ambari/branches/branch-0.0/common/src/main/java/org/apache/hms/common/util/ZookeeperUtil.java Mon Oct 10 00:57:19 2011
@@ -58,4 +58,20 @@ public class ZookeeperUtil {
     nodesPath.append(id);
     return nodesPath.toString();
   }
+
+  public static String getSoftwareManifestPath(String id) {
+    StringBuilder nodesPath = new StringBuilder();
+    nodesPath.append(CommonConfigurationKeys.ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT);
+    nodesPath.append("/");
+    nodesPath.append(id);
+    return nodesPath.toString();
+  }
+  
+  public static String getConfigManifestPath(String id) {
+    StringBuilder configPath = new StringBuilder();
+    configPath.append(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT);
+    configPath.append("/");
+    configPath.append(id);
+    return configPath.toString();
+  }
 }

Modified: incubator/ambari/branches/branch-0.0/controller/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/pom.xml?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/pom.xml (original)
+++ incubator/ambari/branches/branch-0.0/controller/pom.xml Mon Oct 10 00:57:19 2011
@@ -15,6 +15,64 @@
     <version>0.1.0-SNAPSHOT</version>
     <description>Hadoop Management System Controller</description>
 
+    <build>
+      <resources>
+        <resource>
+         <directory>src/main/resources</directory>
+        </resource>
+      </resources>
+      <pluginManagement>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <version>2.4</version>
+          </plugin>
+        </plugins>
+      </pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>javadoc</goal>
+                </goals>
+                <phase>compile</phase>
+              </execution>
+            </executions>
+            <configuration>
+              <encoding>UTF-8</encoding>
+              <verbose>false</verbose>
+              <show>public</show>
+              <subpackages>org.apache.ambari.controller.rest.resources</subpackages>
+              <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
+              <docletPath>${path.separator}${project.build.outputDirectory}</docletPath>
+              <docletArtifacts>
+                <docletArtifact>
+                  <groupId>com.sun.jersey.contribs</groupId>
+                  <artifactId>wadl-resourcedoc-doclet</artifactId>
+                  <version>1.8</version>
+                </docletArtifact>
+                <docletArtifact>
+                  <groupId>com.sun.jersey</groupId>
+                  <artifactId>jersey-server</artifactId>
+                  <version>1.8</version>
+                </docletArtifact>
+                <docletArtifact>
+                  <groupId>xerces</groupId>
+                  <artifactId>xercesImpl</artifactId>
+                  <version>2.6.1</version>
+                </docletArtifact>
+              </docletArtifacts>
+              <useStandardDocletOptions>false</useStandardDocletOptions>
+              <additionalparam>-output ${project.build.outputDirectory}/resourcedoc.xml</additionalparam>
+            </configuration>
+          </plugin>
+      </plugins>
+    </build>
+
     <dependencies>
       <dependency>
         <groupId>org.apache.hms</groupId>
@@ -27,4 +85,18 @@
         <version>1.6</version>
       </dependency>
     </dependencies>
+
+    <pluginRepositories>
+        <pluginRepository>
+            <id>maven2-repository.dev.java.net</id>
+            <name>Java.net Repository for Maven</name>
+            <url>http://download.java.net/maven/2/</url>
+            <layout>default</layout>
+        </pluginRepository>
+        <pluginRepository>
+            <id>maven2-glassfish-repository.dev.java.net</id>
+            <name>Java.net Repository for Maven</name>
+            <url>http://download.java.net/maven/glassfish/</url>
+        </pluginRepository>
+    </pluginRepositories>
 </project>

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/Controller.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/Controller.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/Controller.java (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/Controller.java Mon Oct 10 00:57:19 2011
@@ -189,7 +189,9 @@ public class Controller implements Watch
         CommonConfigurationKeys.ZOOKEEPER_LOCK_QUEUE_PATH_DEFAULT,
         CommonConfigurationKeys.ZOOKEEPER_LIVE_CONTROLLER_PATH_DEFAULT,
         CommonConfigurationKeys.ZOOKEEPER_NODES_MANIFEST_PATH_DEFAULT,
-        CommonConfigurationKeys.ZOOKEEPER_STATUS_QUEUE_PATH_DEFAULT
+        CommonConfigurationKeys.ZOOKEEPER_STATUS_QUEUE_PATH_DEFAULT,
+        CommonConfigurationKeys.ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT,
+        CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT
     };
     for(String path : list) {
       createDirectory(path);

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/ConfigManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/ConfigManager.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/ConfigManager.java (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/ConfigManager.java Mon Oct 10 00:57:19 2011
@@ -24,11 +24,20 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hms.common.conf.CommonConfigurationKeys;
 import org.apache.hms.common.entity.Status;
 import org.apache.hms.common.entity.action.Action;
 import org.apache.hms.common.entity.action.ActionDependency;
@@ -38,6 +47,15 @@ import org.apache.hms.common.entity.acti
 import org.apache.hms.common.entity.cluster.MachineState.StateEntry;
 import org.apache.hms.common.entity.cluster.MachineState.StateType;
 import org.apache.hms.common.entity.manifest.ConfigManifest;
+import org.apache.hms.common.util.ExceptionUtil;
+import org.apache.hms.common.util.JAXBUtil;
+import org.apache.hms.common.util.ZookeeperUtil;
+import org.apache.hms.controller.Controller;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.data.Stat;
 
 
 @Path("config")
@@ -46,7 +64,7 @@ public class ConfigManager {
   
   @GET
   @Path("manifest/create-hadoop-cluster")
-  public ConfigManifest getSample() {
+  public ConfigManifest getSample(@Context UriInfo uri) {
     List<Action> actions = new ArrayList<Action>();
 
     // Install software
@@ -135,9 +153,9 @@ public class ConfigManager {
     dep.add(new ActionDependency(roles, states));
     dataNodeAction.setDependencies(dep);
     // Setup expected result
-    List<StateEntry> expectedDatanodeResults = new LinkedList<StateEntry>();
-    expectedDatanodeResults.add(new StateEntry(StateType.DAEMON, "hadoop-datanode", Status.STARTED));
-    dataNodeAction.setExpectedResults(expectedDatanodeResults);
+//    List<StateEntry> expectedDatanodeResults = new LinkedList<StateEntry>();
+//    expectedDatanodeResults.add(new StateEntry(StateType.DAEMON, "hadoop-datanode", Status.STARTED));
+//    dataNodeAction.setExpectedResults(expectedDatanodeResults);
     actions.add(dataNodeAction);
 
     // Start Jobtracker
@@ -154,9 +172,9 @@ public class ConfigManager {
     dep.add(new ActionDependency(roles, states));
     jobTrackerAction.setDependencies(dep);
     // Setup expected result
-    List<StateEntry> expectedJobtrackerResults = new LinkedList<StateEntry>();
-    expectedJobtrackerResults.add(new StateEntry(StateType.DAEMON, "hadoop-jobtracker", Status.STARTED));
-    jobTrackerAction.setExpectedResults(expectedJobtrackerResults);
+//    List<StateEntry> expectedJobtrackerResults = new LinkedList<StateEntry>();
+//    expectedJobtrackerResults.add(new StateEntry(StateType.DAEMON, "hadoop-jobtracker", Status.STARTED));
+//    jobTrackerAction.setExpectedResults(expectedJobtrackerResults);
     actions.add(jobTrackerAction);
     
     // Start Tasktrackers
@@ -173,12 +191,17 @@ public class ConfigManager {
     dep.add(new ActionDependency(roles, states));
     taskTrackerAction.setDependencies(dep);
     // Setup expected result
-    List<StateEntry> expectedTasktrackerResults = new LinkedList<StateEntry>();
-    expectedTasktrackerResults.add(new StateEntry(StateType.DAEMON, "hadoop-tasktracker", Status.STARTED));
-    taskTrackerAction.setExpectedResults(expectedTasktrackerResults);
+//    List<StateEntry> expectedTasktrackerResults = new LinkedList<StateEntry>();
+//    expectedTasktrackerResults.add(new StateEntry(StateType.DAEMON, "hadoop-tasktracker", Status.STARTED));
+//    taskTrackerAction.setExpectedResults(expectedTasktrackerResults);
     actions.add(taskTrackerAction);
     
     ConfigManifest cm = new ConfigManifest();
+//    try {
+//      cm.setUrl(uri.getAbsolutePath().toURL());
+//    } catch (MalformedURLException e) {
+//      throw new WebApplicationException(500);
+//    }
     cm.setActions(actions);
     return cm;
   }
@@ -189,24 +212,24 @@ public class ConfigManager {
   public ConfigManifest getDestroyCluster() {
     List<Action> actions = new ArrayList<Action>();
     ScriptAction nuke = new ScriptAction();
-    nuke.setScript("killall");
+    nuke.setScript("ps");
     int i=0;
-    String[] parameters = new String[2];
-    parameters[i++] = "java";
-    parameters[i++] = "|| exit 0";
+    String[] parameters = new String[3];
+    parameters[i++] = "ax | grep hms/apps | grep -v grep | cut -b 1-5 | xargs kill -9 || exit 0";
     nuke.setParameters(parameters);
     actions.add(nuke);
 
     ScriptAction nuke2 = new ScriptAction();
     nuke2.setScript("killall");
     i=0;
-    String[] jsvcParameters = new String[2];
+    String[] jsvcParameters = new String[3];
+    jsvcParameters[i++] = "-9";
     jsvcParameters[i++] = "jsvc";
     jsvcParameters[i++] = "|| exit 0";
     nuke2.setParameters(jsvcParameters);
     nuke2.setRole("datanode");
     actions.add(nuke2);
-    
+
     ScriptAction nukePackages = new ScriptAction();
     nukePackages.setScript("rpm");
     i=0;
@@ -311,4 +334,122 @@ public class ConfigManager {
     cm.setActions(actions);
     return cm;
   }
+  
+  @POST
+  @Path("blueprint/{name}")
+  public Response createBlueprint(@Context UriInfo uri, 
+      @PathParam("name") String name, ConfigManifest blueprint) {
+    Response res;
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      blueprint.setUrl(uri.getAbsolutePath().toURL());
+      byte[] data = JAXBUtil.write(blueprint);
+      Stat stat = zk.exists(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+name, false);
+      if(stat==null) {
+        zk.create(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+name, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+      } else {
+        throw new WebApplicationException(409);
+      }
+      res = Response.created(uri.getAbsolutePath()).build();
+      return res;
+    } catch(WebApplicationException e) {
+      throw e;
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+  }
+  
+  @PUT
+  @Path("blueprint/{name}")
+  public Response updateBlueprint(@Context UriInfo uri, 
+      @PathParam("name") String oldName, ConfigManifest blueprint) {
+    Response res;
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      String newName = oldName;
+      if(blueprint.getUrl()!=null) {
+        newName = ZookeeperUtil.getBaseURL(blueprint.getUrl().toString());
+      } else {
+        blueprint.setUrl(uri.getAbsolutePath().toURL());
+      }
+      byte[] data = JAXBUtil.write(blueprint);
+      Stat stat = zk.exists(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+newName, false);
+      if(stat!=null && oldName.equals(newName)) {
+        // Update existing blueprint
+        String path = CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+oldName; 
+        zk.delete(path, stat.getVersion());
+        zk.create(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+newName, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+      } else if(stat!=null) {
+        // Conflict in name change
+        throw new WebApplicationException(409);
+      } else {
+        // Create new blueprint
+        try {
+          zk.create(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT+'/'+newName, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+        } catch(KeeperException.NodeExistsException e) {
+          throw new WebApplicationException(409);
+        }
+      }
+      res = Response.noContent().build();
+      return res;
+    } catch(WebApplicationException e) {
+      throw e;
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+  }
+  
+  @GET
+  @Path("blueprint/{name}")
+  public ConfigManifest getBlueprint(@PathParam("name") String name) {
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      Stat current = new Stat();
+      String path = ZookeeperUtil.getConfigManifestPath(name);
+      byte[] data = zk.getData(path, false, current);
+      ConfigManifest res = JAXBUtil.read(data, ConfigManifest.class);
+      return res;
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);      
+    }
+  }
+  
+  @GET
+  @Path("blueprint")
+  public List<ConfigManifest> getList() {
+    List<ConfigManifest> list = new ArrayList<ConfigManifest>();
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      List<String> blueprints = zk.getChildren(CommonConfigurationKeys.ZOOKEEPER_CONFIG_BLUEPRINT_PATH_DEFAULT, false);
+      Stat current = new Stat();
+      for(String blueprint : blueprints) {
+        byte[] data = zk.getData(ZookeeperUtil.getConfigManifestPath(blueprint), false, current);
+        ConfigManifest x = JAXBUtil.read(data, ConfigManifest.class);
+        list.add(x);
+      }
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+    return list;
+  }
+  
+  @DELETE
+  @Path("blueprint/{name}")
+  public Response deleteStack(@PathParam("name") String name) {
+    ZooKeeper zk = Controller.getInstance().getZKInstance();
+    try {
+      String path = ZookeeperUtil.getConfigManifestPath(name);
+      Stat current = zk.exists(path, false);
+      zk.delete(path, current.getVersion());
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);      
+    }
+    Response res = Response.noContent().build();
+    return res;
+  }
 }

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/SoftwareManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/SoftwareManager.java?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/SoftwareManager.java (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/SoftwareManager.java Mon Oct 10 00:57:19 2011
@@ -21,21 +21,41 @@ package org.apache.hms.controller.rest;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hms.common.conf.CommonConfigurationKeys;
+import org.apache.hms.common.entity.Response;
+import org.apache.hms.common.entity.manifest.NodesManifest;
 import org.apache.hms.common.entity.manifest.PackageInfo;
 import org.apache.hms.common.entity.manifest.Role;
 import org.apache.hms.common.entity.manifest.SoftwareManifest;
+import org.apache.hms.common.util.ExceptionUtil;
+import org.apache.hms.common.util.HostUtil;
+import org.apache.hms.common.util.JAXBUtil;
+import org.apache.hms.common.util.ZookeeperUtil;
+import org.apache.hms.controller.Controller;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.data.Stat;
 
 @Path("software")
 public class SoftwareManager {
   private static Log LOG = LogFactory.getLog(SoftwareManager.class);
   
   @GET
-  @Path("manifest/sample")
+  @Path("stack/sample")
   public SoftwareManifest getSample() {
     SoftwareManifest sm = new SoftwareManifest();
     sm.setName("hadoop");
@@ -68,4 +88,95 @@ public class SoftwareManager {
     sm.setRoles(roles);
     return sm;
   }
+  
+  @GET
+  @Path("stack")
+  public List<SoftwareManifest> getList() {
+    List<SoftwareManifest> list = new ArrayList<SoftwareManifest>();
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      List<String> stacks = zk.getChildren(CommonConfigurationKeys.ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT, false);
+      Stat current = new Stat();
+      for(String stack : stacks) {
+        byte[] data = zk.getData(ZookeeperUtil.getSoftwareManifestPath(stack), false, current);
+        SoftwareManifest x = JAXBUtil.read(data, SoftwareManifest.class);
+        list.add(x);
+      }
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+    return list;
+  }
+  
+  @GET
+  @Path("stack/{id}")
+  public SoftwareManifest getSoftwareStack(@PathParam("id") String id) {
+    try {
+      ZooKeeper zk = Controller.getInstance().getZKInstance();
+      Stat current = new Stat();
+      String path = ZookeeperUtil.getSoftwareManifestPath(id);
+      byte[] data = zk.getData(path, false, current);
+      SoftwareManifest result = JAXBUtil.read(data, SoftwareManifest.class);
+      return result;
+    } catch(KeeperException.NoNodeException e) {
+      throw new WebApplicationException(404);
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+  }
+  
+  @POST
+  @Path("stack")
+  public Response createStack(@Context UriInfo uri, SoftwareManifest stack) {
+    ZooKeeper zk = Controller.getInstance().getZKInstance();
+    String[] parts = stack.getUrl().toString().split("/");
+    String label = ZookeeperUtil.getSoftwareManifestPath(parts[parts.length -1]);
+    try {
+      byte[] data = JAXBUtil.write(stack);      
+      String id = zk.create(label, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+      Response r = new Response();
+      r.setOutput(id);
+      return r;
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+  }
+  
+  @PUT
+  @Path("stack")
+  public Response updateStack(SoftwareManifest stack) {
+    ZooKeeper zk = Controller.getInstance().getZKInstance();
+    try {
+      byte[] data = JAXBUtil.write(stack);
+      String id = ZookeeperUtil.getBaseURL(stack.getUrl().toString());
+      Stat stat = zk.exists(CommonConfigurationKeys.ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT+'/'+id, false);
+      zk.setData(CommonConfigurationKeys.ZOOKEEPER_SOFTWARE_MANIFEST_PATH_DEFAULT+'/'+id, data, stat.getVersion());
+      Response r = new Response();
+      r.setOutput("Update successful.");
+      return r;
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
+  }
+  
+  @DELETE
+  @Path("stack/{id}")
+  public Response deleteStack(@PathParam("id") String id) {
+    ZooKeeper zk = Controller.getInstance().getZKInstance();
+    try {
+      String path = ZookeeperUtil.getSoftwareManifestPath(id);
+      Stat current = zk.exists(path, false);
+      zk.delete(path, current.getVersion());
+    } catch(Exception e) {
+      LOG.error(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);      
+    }
+    Response r = new Response();
+    r.setOutput("Software list: " + id + " deleted.");
+    return r;
+  }
 }

Added: incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/WadlResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/WadlResource.java?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/WadlResource.java (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/WadlResource.java Mon Oct 10 00:57:19 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.hms.controller.rest;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.bind.Marshaller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.sun.jersey.server.wadl.WadlApplicationContext;
+import com.sun.jersey.spi.resource.Singleton;
+import com.sun.research.ws.wadl.Application;
+
+@Produces({"application/vnd.sun.wadl+xml", "application/xml"})
+@Singleton
+@Path("wadl")
+public class WadlResource {
+ 
+    private static final Log LOG = LogFactory.getLog(WadlResource.class);
+ 
+    private static final String XML_HEADERS = "com.sun.xml.bind.xmlHeaders";
+ 
+    private WadlApplicationContext wadlContext;
+ 
+    private Application application;
+ 
+    private byte[] wadlXmlRepresentation;
+ 
+    public WadlResource(@Context WadlApplicationContext wadlContext) {
+        this.wadlContext = wadlContext;
+        this.application = wadlContext.getApplication();
+    }
+ 
+    @GET
+    public synchronized Response getWadl(@Context UriInfo uriInfo) {
+        if (wadlXmlRepresentation == null) {
+            if (application.getResources().getBase() == null) {
+                application.getResources().setBase(uriInfo.getBaseUri().toString());
+            }
+            try {
+                final Marshaller marshaller = wadlContext.getJAXBContext().createMarshaller();
+                marshaller.setProperty(XML_HEADERS, "<?xml-stylesheet type='text/xsl' href='/wadl.xsl'?>");
+                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+                final ByteArrayOutputStream os = new ByteArrayOutputStream();
+                marshaller.marshal(application, os);
+                wadlXmlRepresentation = os.toByteArray();
+                os.close();
+            } catch (Exception e) {
+                LOG.warn("Could not marshal wadl Application.");
+                return javax.ws.rs.core.Response.ok(application).build();
+            }
+        }
+        return Response.ok(new ByteArrayInputStream(wadlXmlRepresentation)).build();
+    }
+}

Added: incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/config/ExtendedWadlGeneratorConfig.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/config/ExtendedWadlGeneratorConfig.java?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/config/ExtendedWadlGeneratorConfig.java (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/java/org/apache/hms/controller/rest/config/ExtendedWadlGeneratorConfig.java Mon Oct 10 00:57:19 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.hms.controller.rest.config;
+
+import java.util.List;
+
+import com.sun.jersey.api.wadl.config.WadlGeneratorConfig;
+import com.sun.jersey.api.wadl.config.WadlGeneratorDescription;
+import com.sun.jersey.server.wadl.WadlGenerator;
+import com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc;
+import com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport;
+import com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorResourceDocSupport;
+
+/**
+ * This subclass of {@link WadlGeneratorConfig} defines/configures 
+ * {@link WadlGenerator}s to be used for generating WADL.
+ */
+public class ExtendedWadlGeneratorConfig extends WadlGeneratorConfig {
+
+  @Override
+  public List<WadlGeneratorDescription> configure() {
+    return generator( WadlGeneratorApplicationDoc.class )
+      .prop( "applicationDocsStream", "application-doc.xml" )
+      .generator(WadlGeneratorGrammarsSupport.class)
+      .prop("grammarsStream", "application-grammars.xml")
+      .generator(WadlGeneratorResourceDocSupport.class)
+      .prop("resourceDocStream", "resourcedoc.xml")
+      .descriptions();
+    }
+}

Added: incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-doc.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-doc.xml?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-doc.xml (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-doc.xml Mon Oct 10 00:57:19 2011
@@ -0,0 +1,27 @@
+<!--
+
+ 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.
+
+-->
+
+<applicationDocs targetNamespace="http://research.sun.com/wadl/2006/10">
+
+    <doc xml:lang="en" title="HMS REST API">
+        HMS public REST API.
+    </doc>
+
+</applicationDocs>

Added: incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-grammars.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-grammars.xml?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-grammars.xml (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/resources/application-grammars.xml Mon Oct 10 00:57:19 2011
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+    Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
+
+    The contents of this file are subject to the terms of either the GNU
+    General Public License Version 2 only ("GPL") or the Common Development
+    and Distribution License("CDDL") (collectively, the "License").  You
+    may not use this file except in compliance with the License.  You can
+    obtain a copy of the License at
+    http://glassfish.java.net/public/CDDL+GPL_1_1.html
+    or packager/legal/LICENSE.txt.  See the License for the specific
+    language governing permissions and limitations under the License.
+
+    When distributing the software, include this License Header Notice in each
+    file and include the License file at packager/legal/LICENSE.txt.
+
+    GPL Classpath Exception:
+    Oracle designates this particular file as subject to the "Classpath"
+    exception as provided by Oracle in the GPL Version 2 section of the License
+    file that accompanied this code.
+
+    Modifications:
+    If applicable, add the following below the License Header, with the fields
+    enclosed by brackets [] replaced by your own identifying information:
+    "Portions Copyright [year] [name of copyright owner]"
+
+    Contributor(s):
+    If you wish your version of this file to be governed by only the CDDL or
+    only the GPL Version 2, indicate your decision by adding "[Contributor]
+    elects to include this software in this distribution under the [CDDL or GPL
+    Version 2] license."  If you don't indicate a single choice of license, a
+    recipient has the option to distribute your version of this file under
+    either the CDDL, the GPL Version 2 or to extend the choice of license to
+    its licensees as provided above.  However, if you add GPL Version 2 code
+    and therefore, elected the GPL Version 2 license, then the option applies
+    only if the new code is made subject to such option by the copyright
+    holder.
+
+-->
+
+<grammars xmlns="http://research.sun.com/wadl/2006/10"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xi="http://www.w3.org/1999/XML/xinclude">
+    <include href="schema.xsd" />
+</grammars>
+

Added: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-blueprint.html
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-blueprint.html?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-blueprint.html (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-blueprint.html Mon Oct 10 00:57:19 2011
@@ -0,0 +1,169 @@
+<!DOCTYPE HTML>
+<html>
+  <script src="lib/codemirror.js"></script>
+  <link rel="stylesheet" href="lib/codemirror.css">
+  <script src="lib/mode/xml/xml.js"></script>
+  <link rel="stylesheet" href="lib/theme/night.css">
+  <style type="text/css">
+    .CodeMirror {
+      border: 1px solid #AAAAAA;
+      border-radius: 5px 5px 5px 5px;
+      height: 900px;
+    }
+    .CodeMirror-scroll {
+      height: 900px;
+    }
+  </style>
+  <body style="height:100%">
+    <section>
+      <h3>Define A Blue Print</h3>
+      <form class="form">
+        <p>
+          Blue print name<br>
+          <input type="text" id="name">
+          <span id="name_message" class="warn"></span>
+        </p>
+        <p>
+          Configuration steps<br>
+          <textarea id="blueprint"/>
+        </p>
+        <p>
+          <button type="submit" id="save" onclick="return verifySyntax()" value="save">Save</button>
+          <button type="cancel" onclick="javasccript:window.location='/';">Cancel</button>
+        </p>
+      </form>
+    </section>
+    <script type="text/javascript">
+      var myCodeMirror;
+
+      function verifySyntax() {
+        var name = $('#name').val();
+        var blueprint = $('#blueprint').val();
+        var bailout = false;
+        if(name=="") {
+          $('#name_message').text("Name can not be empty.");
+          bailout = true;
+        }
+        if(blueprint=="") {
+          $('#blueprint_message').text("Blueprint can not be empty.");
+          bailout = true;
+        }
+        if(bailout) {
+          return false;
+        }
+        return saveBlueprint();
+      }
+
+      function formatXML(xml) {
+        var formatted = '';
+        var reg = /(>)(<)(\/*)/g;
+        xml = xml.replace(reg, '$1\r\n$2$3');
+        var pad = 0;
+        jQuery.each(xml.split('\r\n'), function(index, node) {
+          var indent = 0;
+          if (node.match( /.+<\/\w[^>]*>$/ )) {
+            indent = 0;
+          } else if (node.match( /^<\/\w/ )) {
+            if (pad != 0) {
+              pad -= 1;
+            }
+          } else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
+            indent = 1;
+          } else {
+            indent = 0;
+          }
+
+          var padding = '';
+          for (var i = 0; i < pad; i++) {
+            padding += '  ';
+          }
+
+          formatted += padding + node + '\r\n';
+          pad += indent;
+        });
+        return formatted;
+      }
+
+      function formatJSON(val) {
+        var retval = '';
+        var str = val;
+        var pos = 0;
+        var strLen = str.length;
+        var indentStr = '    ';
+        var newLine = '\n';
+        var char = '';
+        var isString = false;
+        for (var i=0; i<strLen; i++) {
+          char = str.substring(i,i+1);
+          if (char == '"') {
+            isString = !isString;
+          }
+          if(!isString) {
+            if (char == '}' || char == ']') {
+              retval = retval + newLine;
+              pos = pos - 1;
+              for (var j=0; j<pos; j++) {
+                retval = retval + indentStr;
+              }
+            }
+          }
+          retval = retval + char;	
+          if(!isString) {
+            if (char == '{' || char == '[' || char == ',') {
+              retval = retval + newLine;
+              if (char == '{' || char == '[') {
+                pos = pos + 1;
+              }
+              for (var k=0; k<pos; k++) {
+                retval = retval + indentStr;
+              }
+            }
+          }
+        }
+	return retval;
+      }
+
+      function saveBlueprint() {
+        var prefix = window.location.protocol+'//'+window.location.hostname+':'+window.location.port;
+        var data = myCodeMirror.getValue();
+        var name = $('#name').val();
+        /*var blueprint = jQuery.parseJSON(data);
+        blueprint['url'] = prefix+'/v1/config/blueprint/'+name;
+        data = JSON.stringify(blueprint);*/
+        $.ajax({
+          type: 'PUT',
+          url: '/v1/config/blueprint/'+name,
+          contentType: "application/xml; charset=utf-8",
+          data: data,
+          success: function(data) {
+            var url = '/?func=list-blueprint';
+            window.location.href = url;
+          },
+          dataType:'json'
+        });
+        return false;
+      }
+
+      $(document).ready(function() {
+        var url = '/v1/config/manifest/create-hadoop-cluster';
+        /*$.getJSON(url,
+          function(data) {
+            $('#blueprint').val(formatJSON(JSON.stringify(data)));
+          }
+        );*/
+        $.ajax({
+          type: 'GET',
+          url: url,
+          success: function(data) {
+            $('#blueprint').text(formatXML(data));
+            myCodeMirror = CodeMirror.fromTextArea(document.getElementById("blueprint"), {
+              lineNumbers: false,
+              theme: "night"
+            });
+          },
+          dataType:'text'
+        });
+      });
+    </script>
+  </body>
+</html>

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-cluster.html
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-cluster.html?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-cluster.html (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-cluster.html Mon Oct 10 00:57:19 2011
@@ -8,17 +8,17 @@
   <input type="text" id="cluster" value="" size="50">
   <span id="cluster_message" class="warn"></span>
 </p>
-<p>Nodes Manifest</p>
+<p>Nodes List</p>
 <p>
   <input type="text" id="nodes" value="http://localhost:4080/v1/nodes/manifest/sample" class="formInput">
   <span id="nodes_message" class="warn"></span>
 </p>
-<p>Software Manifest</p>
+<p>Software Stack</p>
 <p>
   <input type="text" id="software" value="http://localhost:4080/v1/software/manifest/sample" class="formInput">
   <span id="software_message" class="warn"></span>
 </p>
-<p>Configuration Manifest</p>
+<p>Configuration Blue Print</p>
 <p>
   <input type="text" id="config" value="http://localhost:4080/v1/config/manifest/create-hadoop-cluster" class="formInput">
   <span id="config_message" class="warn"></span>
@@ -42,17 +42,17 @@ function createCluster() {
   }
 
   if(nodes=="") {
-    $('#nodes_message').text("Nodes manifest URL can not be empty.");
+    $('#nodes_message').text("Nodes list URL can not be empty.");
     bailout = true;
   }
 
   if(software=="") {
-    $('#software_message').text("Software manifest URL can not be empty.");
+    $('#software_message').text("Software stack URL can not be empty.");
     bailout = true;
   }
 
   if(config=="") {
-    $('#config_message').text("Config manifest URL can not be empty.");
+    $('#config_message').text("Config blueprint URL can not be empty.");
     bailout = true;
   }
 
@@ -77,7 +77,6 @@ function createCluster() {
 
 $(document).ready(function() {
   var prefix = window.location.protocol+'//'+window.location.hostname+':'+window.location.port;
-  $('#nodes').val(prefix+'/v1/nodes/manifest/sample');
   $.ajax({
     type: 'GET',
     url: '/v1/nodes/manifest',
@@ -96,13 +95,51 @@ $(document).ready(function() {
       if(list.length>0) {
         $('#nodes').val(list[0]);
       }
-      $('#nodes').autocomplete({ source: list });
+      $('input#nodes').autocomplete({ source : list });
     }
   }); 
-  $('#software').val('http://hrt8n36.cc1.ygridcore.net/hadoop-0.20.204.0.xml');
-  $('#config').val('http://hrt8n36.cc1.ygridcore.net/create-hadoop-0.20.204.0.xml');
-  //$('#software').val(prefix+'/v1/software/manifest/sample');
-  //$('#config').val(prefix+'/v1/config/manifest/create-hadoop-cluster');
+  $.ajax({
+    type: 'GET',
+    url: '/v1/software/stack',
+    dataType:'json',
+    success: function(data) {
+      var stacks = data['softwareManifest'];
+      var list = [];
+      var x = 0;
+      if(stacks.constructor.toString().indexOf('Array') == -1) {
+        list[x++] = stacks['@url'];
+      } else {
+        for(var stack in stacks) {
+          list[x++] = stacks[stack]['@url'];
+        }
+      }
+      if(list.length>0) {
+        $('#software').val(list[0]);
+      }
+      $('#software').autocomplete({ source : list });
+    }
+  }); 
+  $.ajax({
+    type: 'GET',
+    url: '/v1/config/blueprint',
+    dataType:'json',
+    success: function(data) {
+      var blueprints = data['configManifest'];
+      var list = [];
+      var x = 0;
+      if(blueprints.constructor.toString().indexOf('Array') == -1) {
+        list[x++] = blueprints['@url'];
+      } else {
+        for(var blueprint in blueprints) {
+          list[x++] = blueprints[blueprint]['@url'];
+        }
+      }
+      if(list.length>0) {
+        $('#config').val(list[0]);
+      }
+      $('#config').autocomplete({ source : list });
+    }
+  });
   $("#navigation").load("/nav.html");
 });
 

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-nodes.html
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-nodes.html?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-nodes.html (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-nodes.html Mon Oct 10 00:57:19 2011
@@ -4,6 +4,10 @@
     <section>
       <h3>Define A Node List</h3>
       <form class="form">
+        <p>
+          Choose nodes layout from software stack<br>
+          <select id="software" onclick="loadRoles()" />
+        </p>
         <table id="form" class="display">
           <thead>
             <th width="200px">Role</th><th>Host(s)</th>
@@ -79,9 +83,31 @@
         return false;
       }
 
+      function loadRoles() {
+        roles = $('#software').val().split(/,/);
+        $('#form').dataTable().fnClearTable();
+        for(type in roles) {
+          $('#form').dataTable().fnAddData(addRole(roles[type]));
+        }
+      }
+
       var label = "Label <input type='text' id='label' value='' />";
       $(document).ready(function() {
         $("#navigation").load("/nav.html");
+        jQuery.getJSON('/v1/software/stack',
+          function(data) {
+            var $software = $("#software");
+            $software.empty();
+            $.each(data["softwareManifest"], function () {
+              var roles = [];
+              var i = 0;
+              $.each(this['roles'], function() {
+                roles[i++] = this['@name'];
+              });
+              $software.append($('<option></option>').attr("value", roles).text(this['@url']));
+            });
+          }
+        );
         $('#form').dataTable({
           "bJQueryUI": true, 
           "sPaginationType": "full_numbers",

Added: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-software.html
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-software.html?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-software.html (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/create-software.html Mon Oct 10 00:57:19 2011
@@ -0,0 +1,142 @@
+<!DOCTYPE HTML>
+<html>
+  <body>
+    <section>
+      <h3>Define A Software Stack</h3>
+      <form class="form">
+        <div class="column">
+        <p>
+          Software stack name<br>
+          <input type="text" id="name">
+          <span id="name_message" class="warn"></span>
+        </p>
+        <p>
+          Software stack version<br>
+          <input type="text" id="version">
+          <span id="version_message" class="warn"></span>
+        </p>
+        </div>
+        Specify the download URL(s) to compose the stack:
+        <p>
+          Java<br>
+          <input type="text" id="java_url" class="formInput">
+          <span id="java_message" class="warn"></span>
+        </p>
+        <p>
+          Hadoop<br>
+          <input type="text" id="hadoop_url" class="formInput">
+        </p>
+        <p>
+          HBase<br>
+          <input type="text" id="hbase_url" class="formInput">
+        </p>
+        <p>
+          Pig<br>
+          <input type="text" id="pig_url" class="formInput">
+        </p>
+        <p>
+          HCatalog/Hive<br>
+          <input type="text" id="hcatalog_url" class="formInput">
+        </p>
+        <p>
+          <button type="submit" id="save" onclick="return verifySoftwareStack()" value="save">Save</button>
+          <button type="cancel" onclick="javasccript:window.location='/';">Cancel</button>
+        </p>
+      </form>
+    </section>
+    <script type="text/javascript">
+      var software = {
+        'hadoop'   : [ 'namenode', 'secondary-namenode', 'datanode', 'jobtracker', 'tasktracker', 'gateway' ],
+        'hbase'    : [ 'hbase-master', 'hbase-regionserver', 'gateway' ],
+        'pig'      : [ 'gateway' ],
+        'hcatalog' : [ 'hcatalog-server', 'gateway' ]
+      };
+      function verifySoftwareStack() {
+        var name = $('#name').val();
+        var version = $('#version').val();
+        var java = $('#java_url').val();
+        var hadoop = $('#hadoop_url').val();
+        var hbase = $('#hbase_url').val();
+        var pig = $('#pig_url').val();
+        var hcatalog = $('hcatalog_url').val();
+
+        var bailout = false;
+        if(name=="") {
+          $('#name_message').text("Name can not be empty.");
+          bailout = true;
+        }
+        if(version=="") {
+          $('#version_message').text("Version can not be empty.");
+          bailout = true;
+        }
+        if(java=="") {
+          $('#java_message').text("Java URL can not be empty.");
+          bailout = true;
+        }
+        if(bailout) {
+          return false;
+        }
+        return saveSoftwareStack()
+      }
+
+      function saveSoftwareStack() {
+        var stack = { 
+                      '@url'     : window.location.protocol+"//"+window.location.host+"/v1/software/stack/"+$('#name').val()+'-'+$('#version').val(),
+                      '@name'    : $('#name').val(),
+                      '@version' : $('#version').val(),
+                      'roles'   : []
+        };
+        var roles = {};
+        for(var component in software) {
+          var components = software[component];
+          for(var roleIndex in components) {
+            if($('#'+component+'_url').val()!=null &&
+               $('#'+component+'_url').val()!="") {
+              var roleName = components[roleIndex];
+              var packages;
+              var found = false;
+              var role;
+              for(x in roles) {
+                if(x==roleName) {
+                  role = roles[x];
+                  var size = role['package'].length;
+                  role['package'][size] = { 'name' : $('#'+component+'_url').val() };
+                  found = true;
+                  break;
+                }
+              }
+              if(!found) {
+                packages = [
+                  { 'name' : $('#java_url').val() },
+                  { 'name' : $('#'+component+'_url').val() }
+                ]; 
+                role = { 
+                  '@name' : roleName,
+                  'package' : packages
+                };
+              }
+              roles[roleName] = role;
+            }
+          }
+        }
+        for(var index in roles) {
+          var size = stack['roles'].length;
+          stack['roles'][size] = roles[index];
+        }
+        var data = JSON.stringify(stack);
+        $.ajax({
+          type: 'POST',
+          url: '/v1/software/stack',
+          contentType: "application/json; charset=utf-8",
+          data: data,
+          success: function(data) {
+            var url = '/?func=list-software';
+            window.location.href = url;
+          },
+          dataType:'json'
+        });
+        return false;
+      }
+    </script>
+  </body>
+</html>

Modified: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/css/default.css
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/css/default.css?rev=1180754&r1=1180753&r2=1180754&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/css/default.css (original)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/css/default.css Mon Oct 10 00:57:19 2011
@@ -23,7 +23,7 @@ a {
   cursor: pointer;
 }
 
-.form input, .form button {
+.form input, .form button, .form select {
   -moz-border-radius: 5px;
   border-radius: 5px;
   padding: 13px 10px 13px;
@@ -57,7 +57,6 @@ a {
 
 section {
   border-bottom: 1px solid #D8D8D8;
-  box-shadow: 0 1px 0 #FFFFFF;
 }
 
 .block {
@@ -109,7 +108,18 @@ header, footer, section, nav, article, a
 }
 
 #main {
+  border: 0px;
   min-width: 1020px;
   height: 100%;
 }
 
+.column {
+  -moz-column-count: 2;
+  -moz-column-gap: 1.5em;
+  -o-column-count: 2;
+  -o-column-gap: 1.5em;
+  -webkit-column-count: 2;
+  -webkit-column-gap: 1.5em;
+  column-count: 2;
+}
+

Added: incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.css
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.css?rev=1180754&view=auto
==============================================================================
--- incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.css (added)
+++ incubator/ambari/branches/branch-0.0/controller/src/main/webapps/lib/codemirror.css Mon Oct 10 00:57:19 2011
@@ -0,0 +1,68 @@
+.CodeMirror {
+  line-height: 1em;
+  font-family: monospace;
+}
+
+.CodeMirror-scroll {
+  overflow: auto;
+  height: 300px;
+  /* This is needed to prevent an IE[67] bug where the scrolled content
+     is visible outside of the scrolling box. */
+  position: relative;
+}
+
+.CodeMirror-gutter {
+  position: absolute; left: 0; top: 0;
+  z-index: 10;
+  background-color: #f7f7f7;
+  border-right: 1px solid #eee;
+  min-width: 2em;
+  height: 100%;
+}
+.CodeMirror-gutter-text {
+  color: #aaa;
+  text-align: right;
+  padding: .4em .2em .4em .4em;
+}
+.CodeMirror-lines {
+  padding: .4em;
+}
+
+.CodeMirror pre {
+  -moz-border-radius: 0;
+  -webkit-border-radius: 0;
+  -o-border-radius: 0;
+  border-radius: 0;
+  border-width: 0; margin: 0; padding: 0; background: transparent;
+  font-family: inherit;
+  font-size: inherit;
+  padding: 0; margin: 0;
+  white-space: pre;
+  word-wrap: normal;
+}
+
+.CodeMirror textarea {
+  font-family: inherit !important;
+  font-size: inherit !important;
+}
+
+.CodeMirror-cursor {
+  z-index: 10;
+  position: absolute;
+  visibility: hidden;
+  border-left: 1px solid black !important;
+}
+.CodeMirror-focused .CodeMirror-cursor {
+  visibility: visible;
+}
+
+span.CodeMirror-selected {
+  background: #ccc !important;
+  color: HighlightText !important;
+}
+.CodeMirror-focused span.CodeMirror-selected {
+  background: Highlight !important;
+}
+
+.CodeMirror-matchingbracket {color: #0f0 !important;}
+.CodeMirror-nonmatchingbracket {color: #f22 !important;}



Mime
View raw message