You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/09/13 01:51:00 UTC

svn commit: r1384161 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/src/main/python/ambari_agent/ ambari-project/ ambari-server/ ambari-server/src/main/java/org/apache/ambari/server/agent/ ambari-server/src/main/java/org/apache/ambari/serv...

Author: mahadev
Date: Wed Sep 12 23:50:59 2012
New Revision: 1384161

URL: http://svn.apache.org/viewvc?rev=1384161&view=rev
Log:
AMBARI-725. Add commandstatus/result/error objects into the rest API between server and agent. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Register.py
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationStatus.java
Removed:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeStatus.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/HeartBeatResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/RegistrationResponse.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Controller.py
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
    incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Sep 12 23:50:59 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-725. Add commandstatus/result/error objects into the rest API between
+  server and agent. (mahadev)
+
   AMBARI-723. Implement Installer Welcome page and Install Options page
  (Jaimin Jetly via yusaku)
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Controller.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Controller.py?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Controller.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Controller.py Wed Sep 12 23:50:59 2012
@@ -29,7 +29,9 @@ import threading
 import urllib2
 from urllib2 import Request, urlopen, URLError
 import AmbariConfig
+import pprint
 from Heartbeat import Heartbeat
+from Register import Register
 from ActionQueue import ActionQueue
 from optparse import OptionParser
 from wsgiref.simple_server import ServerHandler
@@ -50,48 +52,88 @@ class Controller(threading.Thread):
     #  self.credential = { 'user' : config.get('controller', 'user'),
     #                      'password' : config.get('controller', 'password')
     #  }
-    self.url = config.get('server', 'url') + '/agent/register/' + socket.gethostname()
-
+    self.hostname = socket.gethostname()
+    self.registerUrl = config.get('server', 'url') + \
+      '/agent/register/' + self.hostname
+    self.heartbeatUrl = config.get('server', 'url') + \
+       '/agent/heartbeat/' + self.hostname
+     
   def start(self):
     self.actionQueue = ActionQueue(self.config)
     self.actionQueue.start()
+    self.register = Register()
     self.heartbeat = Heartbeat(self.actionQueue)
-
+    pass
+  
   def __del__(self):
     logger.info("Server connection disconnected.")
-
-  def run(self):
-    id='-1'
-    opener = urllib2.build_opener()
-    urllib2.install_opener(opener)
+    pass
+  
+  def registerWithServer(self):
     retry=False
     firstTime=True
+    registered=False
+    id = -1
+    ret = {}
+    while registered == False:
+      try:
+        data = json.dumps(self.register.build(id))
+        req = urllib2.Request(self.registerUrl, data, {'Content-Type': 
+                                                      'application/json'})
+        stream = urllib2.urlopen(req)
+        response = stream.read()
+        stream.close()
+        ret = json.loads(response)
+        logger.info("Registered with the server with " + pprint.pformat(ret))
+        registered = True
+        pass
+      except Exception, err:
+        logger.info("Unable to connect to: " + self.registerUrl, exc_info = True)
+        """ sleep for 30 seconds and then retry again """
+        time.sleep(30)
+        pass
+      pass  
+    return ret
+  
+  def heartbeatWithServer(self):
+    retry = False
+    #TODO make sure the response id is monotonically increasing
+    id = 0
     while True:
       try:
         if retry==False:
           data = json.dumps(self.heartbeat.build(id))
-        req = urllib2.Request(self.url, data, {'Content-Type': 'application/json'})
+        req = urllib2.Request(self.heartbeatUrl, data, {'Content-Type': 'application/json'})
         f = urllib2.urlopen(req)
         response = f.read()
         f.close()
         data = json.loads(response)
         id=int(data['responseId'])
-        self.actionQueue.put(data)
-        if retry==True or firstTime==True:
-          logger.info("Controller connection established")
-          firstTime=False
+        logger.info("HeartBeat Response from Server: \n" + pprint.pformat(data))
         retry=False
       except Exception, err:
         retry=True
         if "code" in err:
           logger.error(err.code)
         else:
-          logger.error("Unable to connect to: "+self.url,exc_info=True)
+          logger.error("Unable to connect to: "+self.heartbeatUrl,exc_info=True)
       if self.actionQueue.isIdle():
         time.sleep(30)
       else:
-        time.sleep(1)
+        time.sleep(1) 
+    pass
+  
 
+  def run(self):
+    opener = urllib2.build_opener()
+    urllib2.install_opener(opener)
+    
+    registerResponse = self.registerWithServer()
+    message = registerResponse['response']
+    logger.info("Response from server = " + message)
+    self.heartbeatWithServer()
+    pass
+    
 def main(argv=None):
   # Allow Ctrl-C
   signal.signal(signal.SIGINT, signal.SIG_DFL)

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py Wed Sep 12 23:50:59 2012
@@ -30,7 +30,8 @@ class Heartbeat:
 
   def __init__(self, actionQueue):
     self.actionQueue = actionQueue
-    self.hardware = Hardware()
+    self.reports = []
+    self.componentStatus = []
 
   def build(self, id='-1'):
     global clusterId, clusterDefinitionRevision, firstContact
@@ -41,16 +42,11 @@ class Heartbeat:
     heartbeat = { 'responseId'        : int(id),
                   'timestamp'         : timestamp,
                   'hostname'          : socket.gethostname(),
-                  'hardwareProfile'   : self.hardware.get(),
-                  'idle'              : self.actionQueue.isIdle(),
-                  'installScriptHash' : self.actionQueue.getInstallScriptHash(),
-                  'firstContact'      : firstContact
+                  'reports'           : self.reports,
+                  'componentStatus'   : self.componentStatus
                 }
-    if len(queueResult)!=0:
-      heartbeat['actionResults'] = queueResult
-    if len(installedRoleStates)!=0:
-      heartbeat['installedRoleStates'] = installedRoleStates
-    firstContact = False
+  
+    
     return heartbeat
 
 def main(argv=None):

Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Register.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Register.py?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Register.py (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Register.py Wed Sep 12 23:50:59 2012
@@ -0,0 +1,51 @@
+#!/usr/bin/env python2.6
+
+'''
+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.
+'''
+
+import json
+from Hardware import Hardware
+from ActionQueue import ActionQueue
+from ServerStatus import ServerStatus
+import socket
+import time
+
+
+firstContact = True
+class Register:
+  """ Registering with the server. Get the hardware profile and 
+  declare success for now """
+  def __init__(self):
+    self.hardware = Hardware()
+
+  def build(self, id='-1'):
+    global clusterId, clusterDefinitionRevision, firstContact
+    timestamp = int(time.time()*1000)
+    register = { 'responseId'        : int(id),
+                  'timestamp'         : timestamp,
+                  'hostname'          : socket.gethostname(),
+                  'hardwareProfile'   : self.hardware.get(),
+                }
+    return register
+  
+def main(argv=None):
+  register = Register()
+  print json.dumps(register.build())
+
+if __name__ == '__main__':
+  main()

Modified: incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml Wed Sep 12 23:50:59 2012
@@ -78,7 +78,7 @@
               </execution>
             </executions>
           </plugin>
-       </plugins>
+        </plugins>
       </build>
     </profile>
   </profiles>
@@ -114,7 +114,7 @@
         <artifactId>postgresql</artifactId>
         <version>9.1-901.jdbc4</version>
       </dependency>
-      <dependency>
+     <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
         <version>1.8.5</version>
@@ -175,6 +175,11 @@
         <version>1.8</version>
       </dependency>
       <dependency>
+        <groupId>com.sun.jersey.contribs</groupId>
+        <artifactId>jersey-guice</artifactId>
+        <version>1.8</version>
+      </dependency>
+      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.15</version>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Wed Sep 12 23:50:59 2012
@@ -125,6 +125,10 @@
       <groupId>com.sun.jersey.contribs</groupId>
       <artifactId>jersey-multipart</artifactId>
     </dependency>
+     <dependency>
+      <groupId>com.sun.jersey.contribs</groupId>
+      <artifactId>jersey-guice</artifactId>
+    </dependency>
     <dependency>
       <groupId>com.sun.jersey.jersey-test-framework</groupId>
       <artifactId>jersey-test-framework-external</artifactId>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java Wed Sep 12 23:50:59 2012
@@ -17,6 +17,24 @@
  */
 package org.apache.ambari.server.agent;
 
-public class AgentCommand {
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public abstract class AgentCommand {
+  @XmlElement
   private String commandId;
+  
+  public String getCommandId() {
+    return this.commandId;
+  }
+  
+  public void setCommandId(String commandId) {
+    this.commandId = commandId;
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java Wed Sep 12 23:50:59 2012
@@ -17,10 +17,56 @@
  */
 package org.apache.ambari.server.agent;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
 public class CommandReport {
+  @XmlElement
   String actionId;
+  @XmlElement
   String stdout;
+  @XmlElement
   String stderr;
+  @XmlElement
   String status;
+  @XmlElement
   int exitCode;
+ 
+  public String getActionId() {
+    return this.actionId;
+  }
+ 
+  public void setActionId(String actionId) {
+    this.actionId = actionId;
+  }
+  
+  public String getStdErr() {
+    return this.stderr;
+  }
+  
+  public void setStdErr(String stderr) {
+    this.stderr = stderr;
+  }
+  
+  public int getExitCode() {
+    return this.exitCode;
+  }
+  
+  public void setExitCode(int exitCode) {
+    this.exitCode = exitCode;
+  }
+  
+  public String getStdOut() {
+    return this.stdout;
+  }
+  
+  public void setStdOut(String stdout) {
+    this.stdout = stdout;
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java Wed Sep 12 23:50:59 2012
@@ -17,8 +17,44 @@
  */
 package org.apache.ambari.server.agent;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
 public class ComponentStatus {
+  @XmlElement
   String componentName;
+  @XmlElement
   String msg;
+  @XmlElement
   String status;
+
+  public String getComponentName() {
+    return this.componentName;
+  }
+
+  public void setComponentName(String componentName) {
+    this.componentName = componentName;
+  }
+  
+  public String getMessage() {
+    return this.msg;
+  }
+  
+  public void setMessage(String msg) {
+    this.msg = msg;
+  }
+  
+  public String getStatus() {
+    return this.status;
+  }
+  
+  public void setStatus(String status) {
+    this.status = status;
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java Wed Sep 12 23:50:59 2012
@@ -65,7 +65,7 @@ public class DiskInfo {
   }
 
   /**
-   * Needed for JAXB
+   * Needed for Serialization
    */
   public DiskInfo() {}
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java Wed Sep 12 23:50:59 2012
@@ -17,6 +17,24 @@
  */
 package org.apache.ambari.server.agent;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
 public class ExecutionCommand extends AgentCommand {
+  @XmlElement
   String manifest;
+  
+  public String getManifest() {
+    return this.manifest;
+  }
+  
+  public void setManifest(String manifest) {
+    this.manifest = manifest;
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java Wed Sep 12 23:50:59 2012
@@ -1,4 +1,4 @@
-/*
+/**
  * 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
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.agent;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -34,35 +35,26 @@ import javax.xml.bind.annotation.XmlType
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"responseId","timestamp",
-    "hostname", "hardwareProfile", "installedRoleStates", "installScriptHash",
-    "actionResults", "firstContact", "idle"})
+@XmlType(name = "", propOrder = {})
 public class HeartBeat {
-  //TODO add serialization
-  List<CommandReport> reports;
-  //TODO add serialization
-  List<ComponentStatus> componentStatus;
-  //TODO add serialization
-  NodeStatus nodeStatus;
-
   @XmlElement
-  private short responseId = -1;
+  private long responseId = -1;
   @XmlElement
   private long timestamp;
   @XmlElement
   private String hostname;
   @XmlElement
-  private int installScriptHash;
+  List<CommandReport> reports = new ArrayList<CommandReport>();
   @XmlElement
-  private boolean firstContact;
+  List<ComponentStatus> componentStatus = new ArrayList<ComponentStatus>();
   @XmlElement
-  private boolean idle;
-
-  public short getResponseId() {
+  HostStatus nodeStatus;
+  
+  public long getResponseId() {
     return responseId;
   }
 
-  public void setResponseId(short responseId) {
+  public void setResponseId(long responseId) {
     this.responseId=responseId;
   }
 
@@ -74,18 +66,6 @@ public class HeartBeat {
     return hostname;
   }
 
-  public boolean getFirstContact() {
-    return firstContact;
-  }
-
-  public boolean getIdle() {
-    return idle;
-  }
-
-  public int getInstallScriptHash() {
-    return installScriptHash;
-  }
-
   public void setTimestamp(long timestamp) {
     this.timestamp = timestamp;
   }
@@ -93,16 +73,4 @@ public class HeartBeat {
   public void setHostname(String hostname) {
     this.hostname = hostname;
   }
-
-  public void setFirstContact(boolean firstContact) {
-    this.firstContact = firstContact;
-  }
-
-  public void setIdle(boolean idle) {
-    this.idle = idle;
-  }
-
-  public void setInstallScriptHash(int hash) {
-    this.installScriptHash = hash;
-  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java Wed Sep 12 23:50:59 2012
@@ -17,17 +17,28 @@
  */
 package org.apache.ambari.server.agent;
 
-import org.apache.ambari.server.agent.rest.HeartBeatResponse;
+import java.util.ArrayList;
+
+import com.google.inject.Singleton;
+
 
 /**
  * This class handles the heartbeats coming from the agent, passes on the information
  * to other modules and processes the queue to send heartbeat response.
  */
+@Singleton
 public class HeartBeatHandler {
-  private String lastCompletedActionId;
-
   public HeartBeatResponse handleHeartBeat(HeartBeat heartbeat) {
-    System.out.println(heartbeat.toString());
-    return null;
+    HeartBeatResponse response = new HeartBeatResponse();
+    response.setAgentCommands(new ArrayList<AgentCommand>());
+    response.setClusterId("test");
+    response.setResponseId(999L);
+    return response;    
+  }
+  
+  public RegistrationResponse handleRegistration(Register register) {
+    RegistrationResponse registrationResponse = new RegistrationResponse();
+    registrationResponse.setResponseStatus(RegistrationStatus.OK);
+    return registrationResponse;
   }
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java Wed Sep 12 23:50:59 2012
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.agent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+
+/**
+ *
+ * Controller to Agent response data model.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class HeartBeatResponse {
+
+  @XmlElement
+  private long responseId;
+  @XmlElement
+  private String clusterId;
+  @XmlElement
+  List<AgentCommand> cmds = new ArrayList<AgentCommand>();
+
+  public long getResponseId() {
+    return responseId;
+  }
+
+  public void setResponseId(long responseId) {
+    this.responseId=responseId;
+  }
+
+  public String getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(String clusterId) {
+    this.clusterId = clusterId;
+  }
+
+  public List<AgentCommand> getAgentCommands() {
+    return this.cmds;
+  }
+  
+  public void setAgentCommands(List<AgentCommand> cmds) {
+    this.cmds = cmds;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java Wed Sep 12 23:50:59 2012
@@ -0,0 +1,374 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.agent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * Data model for Ambari Agent to send hardware profile to Ambari Server.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class HostInfo {
+  @XmlElement
+  private String architecture;
+  @XmlElement
+  private String domain;
+  @XmlElement
+  private String fqdn;
+  @XmlElement
+  private String hardwareisa;
+  @XmlElement
+  private String hardwaremodel;
+  @XmlElement
+  private String hostname;
+  @XmlElement
+  private String id;
+  @XmlElement
+  private String interfaces;
+  @XmlElement
+  private String ipaddress;
+  @XmlElement
+  private boolean is_virtual;
+  @XmlElement
+  private String kernel;
+  @XmlElement
+  private String kernelmajversion;
+  @XmlElement
+  private String kernelrelease;
+  @XmlElement
+  private String kernelversion;
+  @XmlElement
+  private String macaddress;
+  @XmlElement
+  private long memoryfree;
+  @XmlElement
+  private long memorysize;
+  @XmlElement
+  private List<DiskInfo> mounts = new ArrayList<DiskInfo>();
+  @XmlElement
+  private long memorytotal;
+  @XmlElement
+  private String netmask;
+  @XmlElement
+  private String operatingsystem;
+  @XmlElement
+  private String operatingsystemrelease;
+  @XmlElement
+  private String osfamily;
+  @XmlElement
+  private int physicalprocessorcount;
+  @XmlElement
+  private int processorcount;
+  @XmlElement
+  private boolean selinux;
+  @XmlElement
+  private String swapfree;
+  @XmlElement
+  private String swapsize;
+  @XmlElement
+  private String timezone;
+  @XmlElement
+  private String uptime;
+  @XmlElement
+  private long uptime_days;
+  @XmlElement
+  private long uptime_hours;
+
+  public String getArchitecture() {
+    return this.architecture;
+  }
+
+  public void setArchitecture(String architecture) {
+    this.architecture = architecture;
+  }
+
+  public String getDomain() {
+    return this.domain;
+  }
+
+  public void setDomain(String domain) {
+    this.domain = domain;
+  }
+
+  public String getFQDN() {
+    return this.fqdn;
+  }
+
+  public void setFQDN(String fqdn) {
+    this.fqdn = fqdn;
+  }
+
+  public String getHardwareIsa() {
+    return hardwareisa;
+  }
+
+  public void setHardwareIsa(String hardwareisa) {
+    this.hardwareisa = hardwareisa;
+  }
+
+  public String getHardwareModel() {
+    return this.hardwaremodel;
+  }
+
+  public void setHardwareModel(String hardwaremodel) {
+    this.hardwaremodel = hardwaremodel;
+  }
+
+  public String getHostName() {
+    return this.hostname;
+  }
+
+  public void setHostName(String hostname) {
+    this.hostname = hostname;
+  }
+
+  public String getAgentUserId() {
+    return id;
+  }
+
+  public void setAgentUserId(String id) {
+    this.id = id;
+  }
+
+  public String getInterfaces() {
+    return this.interfaces;
+  }
+
+  public void setInterfaces(String interfaces) {
+    this.interfaces = interfaces;
+  }
+
+  public String getIPAddress() {
+    return this.ipaddress;
+  }
+
+  public void setIPAddress(String ipaddress) {
+    this.ipaddress = ipaddress;
+  }
+
+  public boolean isVirtual() {
+    return this.is_virtual;
+  }
+
+  public void setVirtual(boolean is_virtual) {
+    this.is_virtual = is_virtual;
+  }
+
+  public String getKernel() {
+    return this.kernel;
+  }
+
+  public void setKernel(String kernel) {
+    this.kernel = kernel;
+  }
+
+  public String getKernelMajVersion() {
+    return this.kernelmajversion;
+  }
+
+  public void setKernelMajVersion(String kernelmajversion) {
+    this.kernelmajversion = kernelmajversion;
+  }
+
+  public String getKernelRelease() {
+    return this.kernelrelease;
+  }
+
+  public void setKernelRelease(String kernelrelease) {
+    this.kernelrelease = kernelrelease;
+  }
+
+  public String getKernelVersion() {
+    return this.kernelversion;
+  }
+
+  public void setKernelVersion(String kernelversion) {
+    this.kernelversion = kernelversion;
+  }
+
+  public String getMacAddress() {
+    return this.macaddress;
+  }
+
+  public void setMacAddress(String macaddress) {
+    this.macaddress = macaddress;
+  }
+
+  public long getFreeMemory() {
+    return this.memoryfree;
+  }
+
+  public void setFreeMemory(long memoryfree) {
+    this.memoryfree = memoryfree;
+  }
+
+  public long getMemorySize() {
+    return this.memorysize;
+  }
+
+  public void setMemorySize(long memorysize) {
+    this.memorysize = memorysize;
+  }
+
+  public List<DiskInfo> getMounts() {
+    return this.mounts;
+  }
+
+  public void setMounts(List<DiskInfo> mounts) {
+    this.mounts = mounts;
+  }
+
+  public long getMemoryTotal() {
+    return this.memorytotal;
+  }
+
+  public void setMemoryTotal(long memorytotal) {
+    this.memorytotal = memorytotal;
+  }
+
+  public String getNetMask() {
+    return this.netmask;
+  }
+
+  public void setNetMask(String netmask) {
+    this.netmask = netmask;
+  }
+
+  public String getOS() {
+    return this.operatingsystem;
+  }
+
+  public void setOS(String operatingsystem) {
+    this.operatingsystem = operatingsystem;
+  }
+
+  public String getOSRelease() {
+    return this.operatingsystemrelease;
+  }
+
+  public void setOSRelease(String operatingsystemrelease) {
+    this.operatingsystemrelease = operatingsystemrelease;
+  }
+
+  public String getOSFamily() {
+    return this.osfamily;
+  }
+
+  public void setOSFamily(String osfamily) {
+    this.osfamily = osfamily;
+  }
+
+  public int getPhysicalProcessorCount() {
+    return this.physicalprocessorcount;
+  }
+
+  public void setPhysicalProcessorCount(int physicalprocessorcount) {
+    this.physicalprocessorcount = physicalprocessorcount;
+  }
+
+  public int getProcessorCount() {
+    return this.processorcount;
+  }
+
+  public void setProcessorCount(int processorcount) {
+    this.processorcount = processorcount;
+  }
+
+  public boolean getSeLinux() {
+    return selinux;
+  }
+
+  public void setSeLinux(boolean selinux) {
+    this.selinux = selinux;
+  }
+
+  public String getSwapFree() {
+    return this.swapfree;
+  }
+
+  public void setSwapFree(String swapfree) {
+    this.swapfree = swapfree;
+  }
+
+  public String getSwapSize() {
+    return swapsize;
+  }
+
+  public void setSwapSize(String swapsize) {
+    this.swapsize = swapsize;
+  }
+
+  public String getTimeZone() {
+    return this.timezone;
+  }
+
+  public void setTimeZone(String timezone) {
+    this.timezone = timezone;
+  }
+
+  public String getUptime() {
+    return this.uptime;
+  }
+
+  public void setUpTime(String uptime) {
+    this.uptime = uptime;
+  }
+
+  public long getUptimeHours() {
+    return this.uptime_hours;
+  }
+
+  public void setUpTimeHours(long uptime_hours) {
+    this.uptime_hours = uptime_hours;
+  }
+
+  public long getUpTimeDays() {
+    return this.uptime_days;
+  }
+
+  public void setUpTimeDays(long uptime_days) {
+    this.uptime_days = uptime_days;
+  }
+
+  private String getDiskString() {
+    String ret = "";
+    for (DiskInfo diskInfo : mounts) {
+      ret = ret + "(" + diskInfo.toString() + ")";
+    }
+    return ret;
+  }
+
+  public String toString() {
+    return "[memory=" + this.memorytotal + "," +
+        "uptime_hours=" + this.uptime_hours + "," +
+        "operatingsystem=" + this.operatingsystem + "," +
+        "mounts=" + getDiskString() + "]\n";
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java Wed Sep 12 23:50:59 2012
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.agent;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class HostStatus {
+  @XmlType
+  @XmlEnum
+  public enum Status {
+    HEALTHY,
+    UNHEALTHY
+  }
+  @XmlElement
+  Status status;
+  @XmlElement
+  String cause;
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java Wed Sep 12 23:50:59 2012
@@ -43,8 +43,8 @@ public class Register {
   @XmlElement
   private String hostname;
   @XmlElement
-  private NodeInfo hardwareProfile;
-
+  private HostInfo hardwareProfile;
+  
   public short getResponseId() {
     return responseId;
   }
@@ -60,8 +60,8 @@ public class Register {
   public String getHostname() {
     return hostname;
   }
-
-  public NodeInfo getHardwareProfile() {
+ 
+  public HostInfo getHardwareProfile() {
     return hardwareProfile;
   }
 
@@ -72,9 +72,9 @@ public class Register {
   public void setHostname(String hostname) {
     this.hostname = hostname;
   }
-
-  public void setHardwareProfile(NodeInfo hardwareProfile) {
-    this.hardwareProfile = hardwareProfile;
+ 
+  public void setHardwareProfile(HostInfo hardwareProfile) {
+    this.hardwareProfile = hardwareProfile;    
   }
 
   @Override

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java Wed Sep 12 23:50:59 2012
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.agent;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * Controller to Agent response data model.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class RegistrationResponse {
+  @XmlElement
+  public RegistrationStatus response;
+
+
+  public RegistrationStatus getResponseStatus() {
+    return response;
+  }
+
+  public void setResponseStatus(RegistrationStatus response) {
+    this.response = response;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationStatus.java?rev=1384161&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationStatus.java Wed Sep 12 23:50:59 2012
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.agent;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name="registrationstatus")
+@XmlEnum
+public enum RegistrationStatus {
+  OK,
+  FAILED
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java Wed Sep 12 23:50:59 2012
@@ -29,7 +29,9 @@ import javax.ws.rs.core.MediaType;
 
 import org.apache.ambari.server.agent.HeartBeat;
 import org.apache.ambari.server.agent.HeartBeatHandler;
+import org.apache.ambari.server.agent.HeartBeatResponse;
 import org.apache.ambari.server.agent.Register;
+import org.apache.ambari.server.agent.RegistrationResponse;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -47,10 +49,10 @@ public class AgentResource {
   private static Log LOG = LogFactory.getLog(AgentResource.class);
 
   @Inject
-  static void setHandler(HeartBeatHandler handler) {
-    hh = handler;
+  static void init(HeartBeatHandler instance) {
+    hh = instance;
   }
-
+  
   /**
    * Register information about the host (Internal API to be used for
    * Ambari Agent)
@@ -69,9 +71,9 @@ public class AgentResource {
   public RegistrationResponse register(Register message,
       @Context HttpServletRequest req)
       throws WebApplicationException {
-    LOG.info("Post input = " + req.toString());
-    RegistrationResponse response = new RegistrationResponse();
     LOG.info("Received message from agent " + message.toString());
+    /* Call into the heartbeat handler */
+    RegistrationResponse response = hh.handleRegistration(message);
     return response;
   }
 
@@ -86,15 +88,16 @@ public class AgentResource {
    * @param message Heartbeat message
    * @throws Exception
    */
-  @Path("heartbeat/{hostname}")
+  @Path("heartbeat/{hostName}")
   @POST
   @Consumes(MediaType.APPLICATION_JSON)
   @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
   public HeartBeatResponse heartbeat(HeartBeat message)
       throws WebApplicationException {
+    LOG.info("Received Heartbeat message " + message);
     HeartBeatResponse heartBeatResponse = new HeartBeatResponse();
     try {
-      heartBeatResponse = new HeartBeatResponse();
+      heartBeatResponse = hh.handleHeartBeat(message);
     } catch (Exception e) {
       LOG.info("Error in HeartBeat", e);
       throw new WebApplicationException(500);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java Wed Sep 12 23:50:59 2012
@@ -30,8 +30,9 @@ import javax.ws.rs.core.MediaType;
 
 @Path("/check")
 public class HealthCheck {
-  private static final String status = "RUNNING";
+  private  final String status = "RUNNING";
   // This method is called if TEXT_PLAIN is request
+ 
   @GET
   @Produces(MediaType.TEXT_PLAIN)
   public String plainTextCheck() {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java Wed Sep 12 23:50:59 2012
@@ -21,6 +21,7 @@ package org.apache.ambari.server.control
 
 import java.io.IOException;
 
+import org.apache.ambari.server.agent.HeartBeatHandler;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.Server;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java Wed Sep 12 23:50:59 2012
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 package org.apache.ambari.server.controller;
+import org.apache.ambari.server.agent.rest.AgentResource;
+
 import com.google.inject.AbstractModule;
 
 /**
@@ -26,5 +28,6 @@ public class ControllerModule extends Ab
 
   @Override
   protected void configure() {
+    requestStaticInjection(AgentResource.class);
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java Wed Sep 12 23:50:59 2012
@@ -27,7 +27,7 @@ import java.util.concurrent.locks.ReadWr
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.ambari.server.agent.DiskInfo;
-import org.apache.ambari.server.agent.NodeInfo;
+import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.fsm.SingleArcTransition;
 import org.apache.ambari.server.state.fsm.StateMachine;
@@ -299,7 +299,7 @@ public class NodeImpl implements Node {
     }
   }
 
-  void importNodeInfo(NodeInfo nodeInfo) {
+  void importNodeInfo(HostInfo nodeInfo) {
     try {
       writeLock.lock();
       this.hostName = nodeInfo.getHostName();

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java Wed Sep 12 23:50:59 2012
@@ -18,19 +18,19 @@
 
 package org.apache.ambari.server.state.live.node;
 
-import org.apache.ambari.server.agent.NodeInfo;
+import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.state.live.AgentVersion;
 
 public class NodeRegistrationRequestEvent extends NodeEvent {
 
   final long registrationTime;
 
-  final NodeInfo nodeInfo;
+  final HostInfo nodeInfo;
 
   final AgentVersion agentVersion;
 
   public NodeRegistrationRequestEvent(String nodeName,
-      AgentVersion agentVersion, long registrationTime, NodeInfo nodeInfo) {
+      AgentVersion agentVersion, long registrationTime, HostInfo nodeInfo) {
     super(nodeName, NodeEventType.NODE_REGISTRATION_REQUEST);
     this.registrationTime = registrationTime;
     this.nodeInfo = nodeInfo;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java?rev=1384161&r1=1384160&r2=1384161&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java Wed Sep 12 23:50:59 2012
@@ -24,7 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.ambari.server.agent.DiskInfo;
-import org.apache.ambari.server.agent.NodeInfo;
+import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
 import org.junit.Assert;
@@ -34,7 +34,7 @@ public class TestNodeImpl {
 
   @Test
   public void testNodeInfoImport() {
-    NodeInfo info = new NodeInfo();
+    HostInfo info = new HostInfo();
     info.setMemorySize(100);
     info.setProcessorCount(10);
     List<DiskInfo> mounts = new ArrayList<DiskInfo>();
@@ -61,7 +61,7 @@ public class TestNodeImpl {
   }
 
   private void registerNode(NodeImpl node) throws Exception {
-    NodeInfo info = new NodeInfo();
+    HostInfo info = new HostInfo();
     info.setMemorySize(100);
     info.setProcessorCount(10);
     List<DiskInfo> mounts = new ArrayList<DiskInfo>();