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/10 07:26:35 UTC

svn commit: r1382641 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/src/main/python/ambari_agent/ ambari-server/src/main/java/org/apache/ambari/controller/agent/ ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/ ambari-s...

Author: mahadev
Date: Mon Sep 10 05:26:34 2012
New Revision: 1382641

URL: http://svn.apache.org/viewvc?rev=1382641&view=rev
Log:
AMBARI-710. Basic registration and heartbeat protocol implementation between the server and the agent. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java
Removed:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.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-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.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=1382641&r1=1382640&r2=1382641&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Mon Sep 10 05:26:34 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-710. Basic registration and heartbeat protocol implementation between
+  the server and the agent. (mahadev)
+
   AMBARI-709. Getting hardware info on disks/cpu/others using facter and using
   it during registeration. (mahadev)
 

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=1382641&r1=1382640&r2=1382641&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 Mon Sep 10 05:26:34 2012
@@ -50,7 +50,7 @@ class Controller(threading.Thread):
     #  self.credential = { 'user' : config.get('controller', 'user'),
     #                      'password' : config.get('controller', 'password')
     #  }
-    self.url = config.get('server', 'url') + '/agent/heartbeat/' + socket.gethostname()
+    self.url = config.get('server', 'url') + '/agent/register/' + socket.gethostname()
 
   def start(self):
     self.actionQueue = ActionQueue(self.config)
@@ -70,7 +70,7 @@ class Controller(threading.Thread):
       try:
         if retry==False:
           data = json.dumps(self.heartbeat.build(id))
-          logger.debug(data)
+          logger.info(data)
         req = urllib2.Request(self.url, data, {'Content-Type': 'application/json'})
         f = urllib2.urlopen(req)
         response = f.read()

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,102 @@
+/**
+ * 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.controller.agent.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.ambari.server.agentprotocol.HeartbeatHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.inject.Inject;
+
+/** 
+ * Agent Resource represents Ambari agent controller.
+ * It provides API for Ambari agents to get the cluster configuration changes
+ * as well as report the node attributes and state of services running the on 
+ * the cluster nodes
+ */
+@Path("/")
+public class AgentResource {
+  private static HeartbeatHandler hh;
+  private static Log LOG = LogFactory.getLog(AgentResource.class);
+
+  @Inject
+  static void setHandler(HeartbeatHandler handler) {
+    hh = handler;
+  }
+
+  /**
+   * Register information about the host (Internal API to be used for 
+   * Ambari Agent)
+   * @response.representation.200.doc This API is invoked by Ambari agent running
+   *  on a cluster to register with the server.
+   * @response.representation.200.mediaType application/json
+   * @response.representation.406.doc Error in register message format
+   * @response.representation.408.doc Request Timed out
+   * @param message Register message
+   * @throws Exception 
+   */
+  @Path("register/{hostName}")
+  @POST
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+  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());
+    return response;
+  }
+  
+  /** 
+   * Update state of the node (Internal API to be used by Ambari agent).
+   *  
+   * @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.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 HeartBeatResponse heartbeat(HeartBeat message) 
+      throws WebApplicationException {
+    HeartBeatResponse heartBeatResponse = new HeartBeatResponse();
+    try {
+      heartBeatResponse = new HeartBeatResponse();
+    } catch (Exception e) {
+      LOG.info("Error in HeartBeat", e);
+      throw new WebApplicationException(500);
+    }
+    return heartBeatResponse;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HardwareProfile.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,131 @@
+/*
+ * 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.controller.agent.rest;
+
+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 HardwareProfile {
+  @XmlElement
+  private String architecture;
+  @XmlElement
+  private String augeasversion;
+  @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 lsbdistcodename;
+  @XmlElement
+  private String lsbdistdescription;
+  @XmlElement
+  private String lsbdistid;
+  @XmlElement
+  private String lsbdistrelease;
+  @XmlElement
+  private String lsbmajdistrelease;
+  @XmlElement
+  private String lsbrelease;
+  @XmlElement
+  private String macaddress;
+  @XmlElement
+  private String memoryfree;
+  @XmlElement
+  private String memorysize;
+  @XmlElement
+  private String mounts;
+  @XmlElement
+  private String memorytotal;
+  @XmlElement
+  private String netmask;
+  @XmlElement
+  private String operatingsystem;
+  @XmlElement
+  private String operatingsystemrelease;
+  @XmlElement
+  private String osfamily;
+  @XmlElement
+  private String physicalprocessorcount;
+  @XmlElement
+  private String processorcount;
+  @XmlElement
+  private String puppetversion;
+  @XmlElement
+  private String rubyversion;
+  @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 long getUpTimeDays() {
+    return this.uptime_days;
+  }
+  
+  public void setUpTimeDays(long uptime_days) {
+    this.uptime_days = uptime_days;
+  }
+  
+  public String toString() {
+    return "memory=" + this.memorytotal + "\n" +
+           "uptime_hours=" + this.uptime_hours;
+   }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,111 @@
+/*
+ * 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.controller.agent.rest;
+
+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 heartbeat to Ambari Controller.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"responseId","timestamp", 
+    "hostname", "hardwareProfile", "installedRoleStates", "installScriptHash",
+    "actionResults", "firstContact", "idle"})
+public class HeartBeat {
+  @XmlElement
+  private short responseId = -1;
+  @XmlElement
+  private long timestamp;
+  @XmlElement
+  private String hostname;
+  @XmlElement
+  private HardwareProfile hardwareProfile;
+  @XmlElement
+  private int installScriptHash;
+  @XmlElement
+  private boolean firstContact;
+  @XmlElement
+  private boolean idle;
+  
+  public short getResponseId() {
+    return responseId;
+  }
+  
+  public void setResponseId(short responseId) {
+    this.responseId=responseId;
+  }
+  
+  public long getTimestamp() {
+    return timestamp;
+  }
+  
+  public String getHostname() {
+    return hostname;
+  }
+  
+  public boolean getFirstContact() {
+    return firstContact;
+  }
+  
+  public boolean getIdle() {
+    return idle;
+  }
+  
+  public HardwareProfile getHardwareProfile() {
+    return hardwareProfile;
+  }
+  
+  
+  public int getInstallScriptHash() {
+    return installScriptHash;
+  }
+  
+  public void setTimestamp(long timestamp) {
+    this.timestamp = timestamp;
+  }
+  
+  public void setHostname(String hostname) {
+    this.hostname = hostname;
+  }
+ 
+  public void setHardwareProfile(HardwareProfile hardwareProfile) {
+    this.hardwareProfile = hardwareProfile;    
+  }
+  
+  
+  public void setFirstContact(boolean firstContact) {
+    this.firstContact = firstContact;
+  }
+  
+  public void setIdle(boolean idle) {
+    this.idle = idle;
+  }
+  
+  public void setInstallScriptHash(int hash) {
+    this.installScriptHash = hash;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.controller.agent.rest;
+
+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
+  public short responseId;
+  @XmlElement
+  public String clusterId;
+ 
+
+  public short getResponseId() {
+    return responseId;
+  }
+  
+  public void setResponseId(short responseId) {
+    this.responseId=responseId;
+  }
+  
+  public String getClusterId() {
+    return clusterId;
+  }
+  
+  public void setClusterId(String clusterId) {
+    this.clusterId = clusterId;
+  }
+  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,86 @@
+/**
+ * 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.controller.agent.rest;
+
+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 heartbeat to Ambari Controller.
+ *
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"responseId","timestamp", 
+    "hostname", "hardwareProfile"})
+public class Register {
+  @XmlElement
+  private short responseId = -1;
+  @XmlElement
+  private long timestamp;
+  @XmlElement
+  private String hostname;
+  @XmlElement
+  private HardwareProfile hardwareProfile;
+  
+  public short getResponseId() {
+    return responseId;
+  }
+  
+  public void setResponseId(short responseId) {
+    this.responseId=responseId;
+  }
+  
+  public long getTimestamp() {
+    return timestamp;
+  }
+  
+  public String getHostname() {
+    return hostname;
+  }
+ 
+  public HardwareProfile getHardwareProfile() {
+    return hardwareProfile;
+  }
+  
+  public void setTimestamp(long timestamp) {
+    this.timestamp = timestamp;
+  }
+  
+  public void setHostname(String hostname) {
+    this.hostname = hostname;
+  }
+ 
+  public void setHardwareProfile(HardwareProfile hardwareProfile) {
+    this.hardwareProfile = hardwareProfile;    
+  }
+  
+  @Override
+  public String toString() {
+    return "responseId=" + responseId + "\n" +
+           "timestamp=" + timestamp + "\n" +
+           "hostname="  + hostname + "\n" +
+           "hardwareprofile=" + this.hardwareProfile.toString();
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java Mon Sep 10 05:26:34 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.controller.agent.rest;
+
+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 short responseId;
+ 
+
+  public short getResponseId() {
+    return responseId;
+  }
+  
+  public void setResponseId(short responseId) {
+    this.responseId=responseId;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java?rev=1382641&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java Mon Sep 10 05:26:34 2012
@@ -0,0 +1,56 @@
+/**
+ * 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.controller.api.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * A simple POJO to do a health check on the server to see if its running
+ * or not
+ */
+
+@Path("/check")
+public class HealthCheck {
+  private static final String status = "RUNNING";
+  // This method is called if TEXT_PLAIN is request
+  @GET
+  @Produces(MediaType.TEXT_PLAIN)
+  public String plainTextCheck() {
+    return status;
+  }
+
+  // This method is called if XML is request
+  @GET
+  @Produces(MediaType.TEXT_XML)
+  public String xmlCheck() {
+    return "<?xml version=\"1.0\"?>" + "<status> " + status + "</status>";
+  }
+
+  // This method is called if HTML is request
+  @GET
+  @Produces(MediaType.TEXT_HTML)
+  public String  htmlCheck() {
+    return "<html> " + "<title>" + "Status" + "</title>"
+        + "<body><h1>" + status + "</body></h1>" + "</html> ";
+  }
+} 
+

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=1382641&r1=1382640&r2=1382641&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 Mon Sep 10 05:26:34 2012
@@ -36,12 +36,12 @@ import com.sun.jersey.spi.container.serv
 @Singleton
 public class AmbariServer {
  private static Log LOG = LogFactory.getLog(AmbariServer.class);
- public static int CONTROLLER_PORT = 4080;
+ public static int CLIENT_PORT = 4080;
  private Server server = null;
  public volatile boolean running = true; // true while controller runs
  
  public void run() {
-   server = new Server(CONTROLLER_PORT);
+   server = new Server(CLIENT_PORT);
 
    try {
      Context root = new Context(server, "/", Context.SESSIONS);
@@ -52,10 +52,18 @@ public class AmbariServer {
      sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", 
        "com.sun.jersey.api.core.PackagesResourceConfig");
      sh.setInitParameter("com.sun.jersey.config.property.packages", 
-       "org.apache.ambari.controller.rest.resources");
+       "org.apache.ambari.controller.api.rest");
      root.addServlet(sh, "/api/*");
      sh.setInitOrder(2);
 
+     ServletHolder agent = new ServletHolder(ServletContainer.class);
+     agent.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", 
+       "com.sun.jersey.api.core.PackagesResourceConfig");
+     agent.setInitParameter("com.sun.jersey.config.property.packages", 
+       "org.apache.ambari.controller.agent.rest");
+     root.addServlet(agent, "/agent/*");
+     agent.setInitOrder(3);
+     
      server.setStopAtShutdown(true);
      
      /*