You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dd...@apache.org on 2011/10/17 01:11:14 UTC

svn commit: r1184954 - in /incubator/ambari/trunk: ./ agent/src/main/python/ambari_agent/ client/src/main/java/org/apache/ambari/common/rest/entities/agent/ controller/src/main/java/org/apache/ambari/controller/ controller/src/main/java/org/apache/amba...

Author: ddas
Date: Sun Oct 16 23:11:13 2011
New Revision: 1184954

URL: http://svn.apache.org/viewvc?rev=1184954&view=rev
Log:
AMBARI-78. Change the datatype of responseId in the heartbeat messages to short.

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py
    incubator/ambari/trunk/agent/src/main/python/ambari_agent/Heartbeat.py
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/ControllerResponse.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/HeartBeat.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/agent/ControllerResource.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sun Oct 16 23:11:13 2011
@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
+  AMBARI-78. Change the datatype of responseId in the heartbeat messages to short (ddas)
+
   AMBARI-77. create default blueprint containing HDFS component (vgogate)
 
   AMBARI-76. Register new node w/ Ambari controller (vgogate)

Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py Sun Oct 16 23:11:13 2011
@@ -60,7 +60,7 @@ class Controller(threading.Thread):
     logger.info("Controller connection disconnected.")
 
   def run(self):
-    id='unknown'
+    id='-1'
     if self.credential!=None:
       auth_handler = urllib2.HTTPBasicAuthHandler()
       auth_handler.add_password(realm="Controller",
@@ -78,7 +78,7 @@ class Controller(threading.Thread):
         response = f.read()
         f.close()
         data = json.loads(response)
-        id=data['responseId']
+        id=int(data['responseId'])
         self.actionQueue.put(data)
       except URLError, err:
         if "code" in err:

Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/Heartbeat.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/Heartbeat.py?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/Heartbeat.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/Heartbeat.py Sun Oct 16 23:11:13 2011
@@ -31,11 +31,11 @@ class Heartbeat:
     self.actionQueue = actionQueue
     self.hardware = Hardware()
 
-  def build(self, id='unknown'):
+  def build(self, id='-1'):
     global clusterId, clusterDefinitionRevision
     serverStatus = ServerStatus()
     timestamp = int(time.time()*1000)
-    heartbeat = { 'responseId'          : id,
+    heartbeat = { 'responseId'          : int(id),
                   'timestamp'           : timestamp,
                   'hostname'            : socket.gethostname(),
                   'hardwareProfile'     : self.hardware.get(),

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/ControllerResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/ControllerResponse.java?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/ControllerResponse.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/ControllerResponse.java Sun Oct 16 23:11:13 2011
@@ -36,17 +36,17 @@ import javax.xml.bind.annotation.XmlType
 @XmlType(name = "", propOrder = {})
 public class ControllerResponse {
   @XmlElement
-  public String responseId;
+  public short responseId;
   @XmlElement
   public String clusterId;
   @XmlElement
   public List<Action> actions;
 
-  public String getResponseId() {
+  public short getResponseId() {
     return responseId;
   }
   
-  public void setResponseId(String responseId) {
+  public void setResponseId(short responseId) {
     this.responseId=responseId;
   }
   

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/HeartBeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/HeartBeat.java?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/HeartBeat.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/agent/HeartBeat.java Sun Oct 16 23:11:13 2011
@@ -39,7 +39,7 @@ import javax.xml.bind.annotation.XmlType
     "actionResults", "idle"})
 public class HeartBeat {
   @XmlElement
-  private String responseId;
+  private short responseId = -1;
   @XmlElement
   private long timestamp;
   @XmlElement
@@ -53,11 +53,11 @@ public class HeartBeat {
   @XmlElement
   private boolean idle;
   
-  public String getResponseId() {
+  public short getResponseId() {
     return responseId;
   }
   
-  public void setResponseId(String responseId) {
+  public void setResponseId(short responseId) {
     this.responseId=responseId;
   }
   

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=1184954&r1=1184953&r2=1184954&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 Sun Oct 16 23:11:13 2011
@@ -440,7 +440,7 @@ public class Clusters {
                 }    
             } else {
                 Date epoch = new Date(0);
-                Nodes.getInstance().registerNewNode(node_name, epoch);
+                Nodes.getInstance().checkAndUpdateNode(node_name, epoch);
                 Node node = Nodes.getInstance().getNode(node_name);
                 /*
                  * TODO: Set agentInstalled = true, unless controller uses SSH to setup the agent

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java Sun Oct 16 23:11:13 2011
@@ -52,14 +52,18 @@ import org.apache.ambari.resource.statem
 import org.apache.ambari.resource.statemachine.ServiceFSM;
 import org.apache.ambari.resource.statemachine.ServiceState;
 import org.apache.ambari.resource.statemachine.StateMachineInvoker;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class HeartbeatHandler {
   
   private Map<String, ControllerResponse> agentToHeartbeatResponseMap = 
       Collections.synchronizedMap(new HashMap<String, ControllerResponse>());
   
+  private static Log LOG = LogFactory.getLog(HeartbeatHandler.class);
+  
   public ControllerResponse processHeartBeat(HeartBeat heartbeat) 
-      throws DatatypeConfigurationException, IOException {
+      throws Exception {
     ControllerResponse response = 
         agentToHeartbeatResponseMap.get(heartbeat.getHostname());
     if (response != null) {
@@ -67,128 +71,130 @@ public class HeartbeatHandler {
         return response; //duplicate heartbeat
       }
     }
-    
-    short responseId = 
-        (short) (Short.parseShort(response.getResponseId()) + 1);
-    
+
+    short responseId = (short)(heartbeat.getResponseId() + 1);
+
     String hostname = heartbeat.getHostname();
+    Date heartbeatTime = new Date(System.currentTimeMillis());
+    String clusterId = null;
+
+    Nodes.getInstance().checkAndUpdateNode(hostname, heartbeatTime);
 
-    Node node = Nodes.getInstance().getNodes().get(hostname);
-    NodeState state = node.getNodeState();
-    GregorianCalendar c = new GregorianCalendar();
-    c.setTime(new Date());
-    state.setLastHeartbeatTime(
-        DatatypeFactory.newInstance().newXMLGregorianCalendar(c));
-    
-    Cluster cluster = 
-        Clusters.getInstance().getClusterByID(state.getClusterID());
-    
     List<Action> allActions = new ArrayList<Action>();
+
+    clusterId = Nodes.getInstance().getNode(hostname)
+        .getNodeState().getClusterID();
     
-    if (heartbeat.getIdle()) {
-      //if the command-execution takes longer than one heartbeat interval
-      //the check for idleness will prevent the same node getting the same 
-      //command more than once. In the future this could be improved
-      //to reflect the command execution state more accurately.
-      
-      String desiredClusterId = cluster.getID();
-      
-      InstalledOrStartedComponents componentStates = 
-          new InstalledOrStartedComponents();
-      //get the state machine reference to the cluster
-      ClusterFSM clusterFsm = StateMachineInvoker
-          .getStateMachineClusterInstance(desiredClusterId);
-      
-      //get the list of uninstall actions
-      //also, create a map from component/role to 'started' & 'installed' 
-      //for easy lookup later
-      allActions = 
-          inspectAgentState(heartbeat, cluster, componentStates, clusterFsm);
+    if (clusterId != null) {
+      Cluster cluster = 
+          Clusters.getInstance().getClusterByID(clusterId);
+      LOG.info("IDLE : " + heartbeat.getIdle());
 
-      //check/create the special actions (like safemode check)
-      checkAndCreateActions(cluster, clusterFsm, heartbeat, allActions);
-      
-      //Install software for roles like gateways (note that client role 
-      //start/stops are not tracked through FSM).
-      getGatewayInstallActions(cluster, allActions, componentStates);
-      
-      //the state machine reference to the services
-      List<ServiceFSM> clusterServices = clusterFsm.getServices();
-      //go through all the services, and check which role should be started
-      //TODO: Given that we already look at what is running/installed in 
-      //inspectAgentState, having this for loop is inefficient. We
-      //should combine the two aspects.
-      for (ServiceFSM service : clusterServices) {
-        List<RoleFSM> roles = service.getRoles();
-        
-        for (RoleFSM role : roles) {
-          boolean roleInstalled = componentStates.isInstalled(
-             role.getAssociatedService().getServiceName(), role.getRoleName());     
-          boolean roleServerRunning = componentStates.isStarted(
-              role.getAssociatedService().getServiceName(),
-              role.getRoleName());
-          ComponentPlugin plugin = 
-              cluster.getComponentDefinition(service.getServiceName());
-          //check whether the agent should start any server
-          if (role.shouldStart()) {
-            if (!roleInstalled) {
-              //send action for installing the role
-              Action action = plugin.install(cluster.getName(), 
-                                             role.getRoleName());
-              fillDetailsAndAddAction(action, allActions, desiredClusterId,
-                  cluster.getLatestRevision(), service.getServiceName(), 
-                  role.getRoleName());
-              //send action for configuring
-              action = plugin.configure(desiredClusterId, role.getRoleName());
-              fillDetailsAndAddAction(action, allActions, desiredClusterId,
-                  cluster.getLatestRevision(), service.getServiceName(), 
-                  role.getRoleName());
-              continue;
-            }
-            if (!roleServerRunning) {
-              //TODO: keep track of retries (via checkActionResults)
-              Action action = 
-                  plugin.startServer(cluster.getName(), role.getRoleName());
-              fillDetailsAndAddAction(action, allActions, desiredClusterId,
-                  cluster.getLatestRevision(), service.getServiceName(), 
-                  role.getRoleName());
-            }
-            //raise an event to the state machine for a successful role-start
-            if (roleServerRunning) {
-              StateMachineInvoker.getAMBARIEventHandler()
-              .handle(new RoleEvent(RoleEventType.START_SUCCESS, role));
-            }
-          }
-          //check whether the agent should stop any server
-          if (role.shouldStop()) {
-            if (roleServerRunning) {
-              //TODO: keep track of retries (via checkActionResults)
-              addAction(getStopRoleAction(cluster.getID(), 
-                  cluster.getLatestRevision(), 
-                  role.getAssociatedService().getServiceName(), 
-                  role.getRoleName()), allActions);
+      if (heartbeat.getIdle()) {
+        //if the command-execution takes longer than one heartbeat interval
+        //the check for idleness will prevent the same node getting the same 
+        //command more than once. In the future this could be improved
+        //to reflect the command execution state more accurately.
+
+        String desiredClusterId = cluster.getID();
+
+        InstalledOrStartedComponents componentStates = 
+            new InstalledOrStartedComponents();
+        //get the state machine reference to the cluster
+        ClusterFSM clusterFsm = StateMachineInvoker
+            .getStateMachineClusterInstance(desiredClusterId);
+
+        //get the list of uninstall actions
+        //also, create a map from component/role to 'started' & 'installed' 
+        //for easy lookup later
+        allActions = 
+            inspectAgentState(heartbeat, cluster, componentStates, clusterFsm);
+
+        //check/create the special actions (like safemode check)
+        checkAndCreateActions(cluster, clusterFsm, heartbeat, allActions);
+
+        //Install software for roles like gateways (note that client role 
+        //start/stops are not tracked through FSM).
+        getGatewayInstallActions(cluster, allActions, componentStates);
+
+        //the state machine reference to the services
+        List<ServiceFSM> clusterServices = clusterFsm.getServices();
+        //go through all the services, and check which role should be started
+        //TODO: Given that we already look at what is running/installed in 
+        //inspectAgentState, having this for loop is inefficient. We
+        //should combine the two aspects.
+        for (ServiceFSM service : clusterServices) {
+          List<RoleFSM> roles = service.getRoles();
+
+          for (RoleFSM role : roles) {
+            boolean roleInstalled = componentStates.isInstalled(
+                role.getAssociatedService().getServiceName(), role.getRoleName());     
+            boolean roleServerRunning = componentStates.isStarted(
+                role.getAssociatedService().getServiceName(),
+                role.getRoleName());
+            ComponentPlugin plugin = 
+                cluster.getComponentDefinition(service.getServiceName());
+            //check whether the agent should start any server
+            if (role.shouldStart()) {
+              if (!roleInstalled) {
+                //send action for installing the role
+                Action action = plugin.install(cluster.getName(), 
+                    role.getRoleName());
+                fillDetailsAndAddAction(action, allActions, desiredClusterId,
+                    cluster.getLatestRevision(), service.getServiceName(), 
+                    role.getRoleName());
+                //send action for configuring
+                action = plugin.configure(desiredClusterId, role.getRoleName());
+                fillDetailsAndAddAction(action, allActions, desiredClusterId,
+                    cluster.getLatestRevision(), service.getServiceName(), 
+                    role.getRoleName());
+                continue;
+              }
+              if (!roleServerRunning) {
+                //TODO: keep track of retries (via checkActionResults)
+                Action action = 
+                    plugin.startServer(cluster.getName(), role.getRoleName());
+                fillDetailsAndAddAction(action, allActions, desiredClusterId,
+                    cluster.getLatestRevision(), service.getServiceName(), 
+                    role.getRoleName());
+              }
+              //raise an event to the state machine for a successful role-start
+              if (roleServerRunning) {
+                StateMachineInvoker.getAMBARIEventHandler()
+                .handle(new RoleEvent(RoleEventType.START_SUCCESS, role));
+              }
             }
-            //raise an event to the state machine for a successful role-stop
-            if (!roleServerRunning) {
-              StateMachineInvoker.getAMBARIEventHandler()
+            //check whether the agent should stop any server
+            if (role.shouldStop()) {
+              if (roleServerRunning) {
+                //TODO: keep track of retries (via checkActionResults)
+                addAction(getStopRoleAction(cluster.getID(), 
+                    cluster.getLatestRevision(), 
+                    role.getAssociatedService().getServiceName(), 
+                    role.getRoleName()), allActions);
+              }
+              //raise an event to the state machine for a successful role-stop
+              if (!roleServerRunning) {
+                StateMachineInvoker.getAMBARIEventHandler()
                 .handle(new RoleEvent(RoleEventType.STOP_SUCCESS, role));
-            }
-            if (roleInstalled && 
-                clusterFsm.getClusterState()
+              }
+              if (roleInstalled && 
+                  clusterFsm.getClusterState()
                   .equals(ClusterState.CLUSTER_STATE_ATTIC)) {
-              Action action = plugin.uninstall(cluster.getName(), 
-                                               role.getRoleName());
-              fillDetailsAndAddAction(action, allActions, cluster.getID(), 
-                  cluster.getLatestRevision(), 
-                  role.getAssociatedService().getServiceName(), 
-                  role.getRoleName());
+                Action action = plugin.uninstall(cluster.getName(), 
+                    role.getRoleName());
+                fillDetailsAndAddAction(action, allActions, cluster.getID(), 
+                    cluster.getLatestRevision(), 
+                    role.getAssociatedService().getServiceName(), 
+                    role.getRoleName());
+              }
             }
           }
         }
       }
     }
     ControllerResponse r = new ControllerResponse();
-    r.setResponseId(String.valueOf(responseId));
+    r.setResponseId(responseId);
     r.setActions(allActions);
     agentToHeartbeatResponseMap.put(heartbeat.getHostname(), r);
     return r;

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java?rev=1184954&r1=1184953&r2=1184954&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java Sun Oct 16 23:11:13 2011
@@ -171,7 +171,7 @@ public class Nodes {
     /*
      * Register new node
      */
-    public synchronized void registerNewNode (String name, Date hearbeatTime) throws Exception {
+    public synchronized void checkAndUpdateNode (String name, Date hearbeatTime) throws Exception {
         Node node = this.nodes.get(name);
         
         if (node == null) {

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=1184954&r1=1184953&r2=1184954&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 Sun Oct 16 23:11:13 2011
@@ -46,7 +46,10 @@ import org.apache.ambari.common.rest.ent
 import org.apache.ambari.common.rest.entities.agent.ConfigFile;
 import org.apache.ambari.common.rest.entities.agent.HardwareProfile;
 import org.apache.ambari.common.rest.entities.agent.HeartBeat;
+import org.apache.ambari.common.util.ExceptionUtil;
 import org.apache.ambari.controller.HeartbeatHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /** 
  * Controller Resource represents Ambari controller.
@@ -57,7 +60,7 @@ import org.apache.ambari.controller.Hear
 @Path("controller")
 public class ControllerResource {
   private HeartbeatHandler hh = new HeartbeatHandler();
-	
+	private static Log LOG = LogFactory.getLog(ControllerResource.class);
   /** 
    * Update state of the node (Internal API to be used by Ambari agent).
    *  
@@ -68,82 +71,83 @@ public class ControllerResource {
    * @response.representation.406.doc Error in heartbeat message format
    * @response.representation.408.doc Request Timed out
    * @param message Heartbeat message
+   * @throws Exception 
    */
   @Path("heartbeat/{hostname}")
   @POST
   @Consumes(MediaType.APPLICATION_JSON)
   @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-  public ControllerResponse heartbeat(HeartBeat message) {
+  public ControllerResponse heartbeat(HeartBeat message) 
+      throws WebApplicationException {
     ControllerResponse controllerResponse = new ControllerResponse();
-//    try {
-//      controllerResponse = hh.processHeartBeat(message);
-//    } catch (DatatypeConfigurationException e) {
-//      throw new WebApplicationException(406);
-//    } catch (IOException e) {
-//      throw new WebApplicationException(408);
-//    }
-
-    controllerResponse.setResponseId("id-00002");    
-    String script = "import os\nos._exit(0)";
-    String[] param = { "cluster", "role" };
-    Command command = new Command("root", script, param);
-
-    Command cleanUp = new Command("root", script, param);
-    
-    Action action = new Action();
-    action.setUser("hdfs");
-    action.setKind(Kind.STOP_ACTION);
-    action.setSignal(Signal.KILL);
-    action.setClusterId("cluster-001");
-    action.setClusterDefinitionRevision(1);
-    action.setComponent("hdfs");
-    action.setRole("datanode");
-    action.setId("action-001");
-
-    Action action2 = new Action();
-    action2.setUser("hdfs");
-    action2.setKind(Kind.START_ACTION);
-    action2.setId("action-002");
-    action2.setClusterId("cluster-002");
-    action2.setCommand(command);
-    action2.setCleanUpCommand(cleanUp);
-    action2.setClusterDefinitionRevision(1);
-    action2.setComponent("hdfs");
-    action2.setRole("datanode");
-
-    Action action3 = new Action();
-    action3.setUser("hdfs");
-    action3.setKind(Kind.RUN_ACTION);
-    action3.setId("action-003");
-    action3.setClusterId("cluster-002");
-    action3.setClusterDefinitionRevision(1);
-    action3.setComponent("hdfs");
-    action3.setRole("datanode");
-    action3.setCommand(command);
-    action3.setCleanUpCommand(cleanUp);
+    try {
+      controllerResponse = hh.processHeartBeat(message);
+    } catch (Exception e) {
+      LOG.info(ExceptionUtil.getStackTrace(e));
+      throw new WebApplicationException(500);
+    }
 
-    Action action4 = new Action();
-    action4.setId("action-004");
-    action4.setClusterId("cluster-002");
-    action4.setClusterDefinitionRevision(1);
-    action4.setUser("hdfs");
-    action4.setKind(Kind.WRITE_FILE_ACTION);
-    action4.setComponent("hdfs");    
-    action4.setRole("namenode");
-    String owner ="hdfs";
-    String group = "hadoop";
-    String permission = "0700";
-    String path = "$prefix/config";
-    String umask = "022";
-    String data = "Content of the file";
-    action4.setFile(new ConfigFile(owner, group, permission, path, umask, data));
-    
-    List<Action> actions = new ArrayList<Action>();
-    actions.add(action);
-    actions.add(action2);
-    actions.add(action3);
-    actions.add(action4);
-    controllerResponse.setActions(actions);
+//    controllerResponse.setResponseId("id-00002");    
+//    String script = "import os\nos._exit(0)";
+//    String[] param = { "cluster", "role" };
+//    Command command = new Command("root", script, param);
+//
+//    Command cleanUp = new Command("root", script, param);
+//    
+//    Action action = new Action();
+//    action.setUser("hdfs");
+//    action.setKind(Kind.STOP_ACTION);
+//    action.setSignal(Signal.KILL);
+//    action.setClusterId("cluster-001");
+//    action.setClusterDefinitionRevision(1);
+//    action.setComponent("hdfs");
+//    action.setRole("datanode");
+//    action.setId("action-001");
+//
+//    Action action2 = new Action();
+//    action2.setUser("hdfs");
+//    action2.setKind(Kind.START_ACTION);
+//    action2.setId("action-002");
+//    action2.setClusterId("cluster-002");
+//    action2.setCommand(command);
+//    action2.setCleanUpCommand(cleanUp);
+//    action2.setClusterDefinitionRevision(1);
+//    action2.setComponent("hdfs");
+//    action2.setRole("datanode");
+//
+//    Action action3 = new Action();
+//    action3.setUser("hdfs");
+//    action3.setKind(Kind.RUN_ACTION);
+//    action3.setId("action-003");
+//    action3.setClusterId("cluster-002");
+//    action3.setClusterDefinitionRevision(1);
+//    action3.setComponent("hdfs");
+//    action3.setRole("datanode");
+//    action3.setCommand(command);
+//    action3.setCleanUpCommand(cleanUp);
+//
+//    Action action4 = new Action();
+//    action4.setId("action-004");
+//    action4.setClusterId("cluster-002");
+//    action4.setClusterDefinitionRevision(1);
+//    action4.setUser("hdfs");
+//    action4.setKind(Kind.WRITE_FILE_ACTION);
+//    action4.setComponent("hdfs");    
+//    action4.setRole("namenode");
+//    String owner ="hdfs";
+//    String group = "hadoop";
+//    String permission = "0700";
+//    String path = "$prefix/config";
+//    String umask = "022";
+//    String data = "Content of the file";
+//    action4.setFile(new ConfigFile(owner, group, permission, path, umask, data));
+//    
+//    List<Action> actions = new ArrayList<Action>();
+//    actions.add(action);
+//    actions.add(action2);
+//    actions.add(action3);
+//    actions.add(action4);
+//    controllerResponse.setActions(actions);
     return controllerResponse;
   }
 
@@ -200,7 +204,7 @@ public class ControllerResource {
       agentRoles.add(agentRole1);
       
       HeartBeat hb = new HeartBeat();
-      hb.setResponseId("unknown");
+      hb.setResponseId((short)-1);
       hb.setTimestamp(System.currentTimeMillis());
       hb.setHostname(addr.getHostName());
       hb.setActionResults(actionResults);
@@ -226,7 +230,7 @@ public class ControllerResource {
   @Produces("application/json")
   public ControllerResponse getControllerResponse() {
     ControllerResponse controllerResponse = new ControllerResponse();
-    controllerResponse.setResponseId("id-00002");    
+    controllerResponse.setResponseId((short)2);    
     
     String script = "import os\nos._exit(0)";
     String[] param = { "cluster", "role" };