You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ey...@apache.org on 2011/10/18 23:30:41 UTC
svn commit: r1185876 - in /incubator/ambari/trunk/controller/src/main:
java/org/apache/ambari/controller/rest/agent/ControllerResource.java
webapps/wadl.xsl
Author: eyang
Date: Tue Oct 18 21:30:41 2011
New Revision: 1185876
URL: http://svn.apache.org/viewvc?rev=1185876&view=rev
Log:
AMBARI-81. Added example and proper status code for xslt stylesheet. (Eric Yang)
Modified:
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java
incubator/ambari/trunk/controller/src/main/webapps/wadl.xsl
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java?rev=1185876&r1=1185875&r2=1185876&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java Tue Oct 18 21:30:41 2011
@@ -18,7 +18,6 @@
package org.apache.ambari.controller.rest.agent;
-import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -33,7 +32,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
-import javax.xml.datatype.DatatypeConfigurationException;
import org.apache.ambari.common.rest.entities.agent.Action;
import org.apache.ambari.common.rest.entities.agent.Action.Kind;
@@ -67,7 +65,6 @@ public class ControllerResource {
* @response.representation.200.doc This API is invoked by Ambari agent running
* on a cluster to update the state of various services running on the node.
* @response.representation.200.mediaType application/json
- * @response.representation.200.example { "a" : "b" }
* @response.representation.406.doc Error in heartbeat message format
* @response.representation.408.doc Request Timed out
* @param message Heartbeat message
@@ -79,7 +76,7 @@ public class ControllerResource {
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ControllerResponse heartbeat(HeartBeat message)
throws WebApplicationException {
- ControllerResponse controllerResponse = new ControllerResponse();
+ ControllerResponse controllerResponse = getControllerResponse();
try {
controllerResponse = hh.processHeartBeat(message);
} catch (Exception e) {
@@ -154,6 +151,55 @@ public class ControllerResource {
/**
* Sample Ambari heartbeat message
*
+ * @response.representation.200.example
+ * {
+ "responseId": "-1",
+ "timestamp": "1318955147616",
+ "hostname": "host.example.com",
+ "hardwareProfile": {
+ "coreCount": "8",
+ "diskCount": "4",
+ "ramSize": "16442752",
+ "cpuSpeed": "2003",
+ "netSpeed": "1000",
+ "cpuFlags": "vmx est tm2..."
+ },
+ "installedRoleStates": [
+ {
+ "clusterId": "cluster-003",
+ "clusterDefinitionRevision": "2",
+ "componentName": "hdfs",
+ "roleName": "datanode",
+ "serverStatus": "STARTED"
+ }
+ ],
+ "actionResults": [
+ {
+ "clusterId": "cluster-001",
+ "id": "action-001",
+ "kind": "STOP_ACTION",
+ "clusterDefinitionRevision": "1"
+ },
+ {
+ "clusterId": "cluster-002",
+ "kind": "START_ACTION",
+ "commandResult": {
+ "exitCode": "0",
+ "stdout": "stdout",
+ "stderr": "stderr"
+ },
+ "cleanUpCommandResult": {
+ "exitCode": "0",
+ "stdout": "stdout",
+ "stderr": "stderr"
+ },
+ "component": "hdfs",
+ "role": "datanode",
+ "clusterDefinitionRevision": "2"
+ }
+ ],
+ "idle": "false"
+ }
* @response.representation.200.doc Print example of Ambari heartbeat message
* @response.representation.200.mediaType application/json
* @param stackId Stack ID
@@ -220,7 +266,106 @@ public class ControllerResource {
/**
* Sample controller to agent response message
*
- * @response.representation.200.example { "a" : "b" }
+ * @response.representation.200.example
+ * {
+ "responseId": "2",
+ "actions": [
+ {
+ "kind": "CREATE_STRUCTURE_ACTION",
+ "clusterId": "cluster-001",
+ "id": "action-000",
+ "component": "hdfs",
+ "role": "datanode",
+ "clusterDefinitionRevision": "0"
+ },
+ {
+ "kind": "STOP_ACTION",
+ "clusterId": "cluster-001",
+ "user": "hdfs",
+ "id": "action-001",
+ "component": "hdfs",
+ "role": "datanode",
+ "signal": "KILL",
+ "clusterDefinitionRevision": "2"
+ },
+ {
+ "kind": "START_ACTION",
+ "clusterId": "cluster-001",
+ "user": "hdfs",
+ "id": "action-002",
+ "component": "hdfs",
+ "role": "datanode",
+ "command": {
+ "script": "import os\nos._exit(0)",
+ "param": [
+ "cluster",
+ "role"
+ ],
+ "user": "root"
+ },
+ "cleanUpCommand": {
+ "script": "import os\nos._exit(0)",
+ "param": [
+ "cluster",
+ "role"
+ ],
+ "user": "root"
+ },
+ "clusterDefinitionRevision": "3"
+ },
+ {
+ "kind": "RUN_ACTION",
+ "clusterId": "cluster-001",
+ "user": "hdfs",
+ "id": "action-003",
+ "component": "hdfs",
+ "role": "datanode",
+ "command": {
+ "script": "import os\nos._exit(0)",
+ "param": [
+ "cluster",
+ "role"
+ ],
+ "user": "root"
+ },
+ "cleanUpCommand": {
+ "script": "import os\nos._exit(0)",
+ "param": [
+ "cluster",
+ "role"
+ ],
+ "user": "root"
+ },
+ "clusterDefinitionRevision": "3"
+ },
+ {
+ "kind": "WRITE_FILE_ACTION",
+ "clusterId": "cluster-001",
+ "user": "hdfs",
+ "id": "action-004",
+ "component": "hdfs",
+ "role": "datanode",
+ "clusterDefinitionRevision": "4",
+ "file": {
+ "data": "Content of the file",
+ "umask": "022",
+ "path": "config",
+ "owner": "hdfs",
+ "group": "hadoop",
+ "permission": "0700"
+ }
+ },
+ {
+ "kind": "DELETE_STRUCTURE_ACTION",
+ "clusterId": "cluster-001",
+ "user": "hdfs",
+ "id": "action-005",
+ "component": "hdfs",
+ "role": "datanode",
+ "clusterDefinitionRevision": "0"
+ }
+ ]
+ }
* @response.representation.200.doc Print an example of Controller Response to Agent
* @response.representation.200.mediaType application/json
* @return ControllerResponse A list of command to execute on agent
@@ -239,6 +384,8 @@ public class ControllerResource {
Command cleanUp = new Command("root", script, param);
Action action = new Action();
+ action.setClusterId("cluster-001");
+ action.setId("action-000");
action.setKind(Kind.CREATE_STRUCTURE_ACTION);
action.setComponent("hdfs");
action.setRole("datanode");
@@ -256,12 +403,12 @@ public class ControllerResource {
Action action2 = new Action();
action2.setClusterDefinitionRevision(3);
- action2.setUser("hdfs");
action2.setKind(Kind.START_ACTION);
action2.setId("action-002");
- action2.setClusterId("cluster-002");
+ action2.setClusterId("cluster-001");
action2.setCommand(command);
action2.setCleanUpCommand(cleanUp);
+ action2.setUser("hdfs");
action2.setComponent("hdfs");
action2.setRole("datanode");
@@ -270,29 +417,34 @@ public class ControllerResource {
action3.setUser("hdfs");
action3.setKind(Kind.RUN_ACTION);
action3.setId("action-003");
- action3.setClusterId("cluster-002");
+ action3.setClusterId("cluster-001");
action3.setCommand(command);
action3.setCleanUpCommand(cleanUp);
action3.setUser("hdfs");
action3.setComponent("hdfs");
+ action3.setRole("datanode");
Action action4 = new Action();
+ action4.setId("action-004");
+ action4.setClusterId("cluster-001");
action4.setClusterDefinitionRevision(4);
- action4.setUser("hdfs");
action4.setKind(Kind.WRITE_FILE_ACTION);
action4.setUser("hdfs");
action4.setComponent("hdfs");
- action4.setRole("namenode");
+ action4.setRole("datanode");
String owner ="hdfs";
String group = "hadoop";
String permission = "0700";
- String path = "$prefix/config";
+ String path = "config";
String umask = "022";
String data = "Content of the file";
action4.setFile(new ConfigFile(owner, group, permission, path, umask, data));
Action action5 = new Action();
action5.setKind(Kind.DELETE_STRUCTURE_ACTION);
+ action5.setId("action-005");
+ action5.setClusterId("cluster-001");
+ action5.setUser("hdfs");
action5.setComponent("hdfs");
action5.setRole("datanode");
@@ -302,6 +454,7 @@ public class ControllerResource {
actions.add(action2);
actions.add(action3);
actions.add(action4);
+ actions.add(action5);
controllerResponse.setActions(actions);
return controllerResponse;
}
Modified: incubator/ambari/trunk/controller/src/main/webapps/wadl.xsl
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/webapps/wadl.xsl?rev=1185876&r1=1185875&r2=1185876&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/webapps/wadl.xsl (original)
+++ incubator/ambari/trunk/controller/src/main/webapps/wadl.xsl Tue Oct 18 21:30:41 2011
@@ -270,7 +270,7 @@
<xsl:choose>
<xsl:when test="wadl:response">
<xsl:for-each select="wadl:response">
- <div class="h8">status: </div>
+<!-- <div class="h8">status: </div>
<xsl:choose>
<xsl:when test="@status">
<xsl:value-of select="@status"/>
@@ -286,7 +286,7 @@
<xsl:if test="text()">
- <xsl:value-of select="text()"/>
</xsl:if>
- </xsl:for-each>
+ </xsl:for-each> -->
<!-- Get response headers/representations -->
<xsl:if test="wadl:param or wadl:representation">
@@ -475,6 +475,7 @@
<table>
<xsl:for-each select="wadl:representation">
<tr>
+ <td><xsl:value-of select="@status"/></td>
<td><xsl:value-of select="@mediaType"/></td>
<xsl:if test="wadl:doc">
<td>