Prechádzať zdrojové kódy

AMBARI-715. Integrate domain objects and Rest serialized objects. (mahadev)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1383228 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 12 rokov pred
rodič
commit
fdfc5b1af1
26 zmenil súbory, kde vykonal 507 pridanie a 363 odobranie
  1. 2 0
      AMBARI-666-CHANGES.txt
  2. 2 1
      ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
  3. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java
  4. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
  5. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java
  6. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
  7. 67 0
      ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java
  8. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
  9. 14 17
      ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java
  10. 5 3
      ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
  11. 373 0
      ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java
  12. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/NodeStatus.java
  13. 9 8
      ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java
  14. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
  15. 6 4
      ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
  16. 10 2
      ambari-server/src/main/java/org/apache/ambari/server/agent/rest/HeartBeatResponse.java
  17. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/agent/rest/RegistrationResponse.java
  18. 0 33
      ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java
  19. 0 25
      ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/HeartbeatResponse.java
  20. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java
  21. 4 4
      ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
  22. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java
  23. 4 1
      ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
  24. 0 40
      ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java
  25. 1 0
      ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java
  26. 0 215
      ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-715. Integrate domain objects and Rest serialized objects. (mahadev)
+
   AMBARI-713. Initial work on Job FSM. (hitesh)
 
   AMBARI-712. Action manager skeleton. (jitendra)

+ 2 - 1
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java

@@ -19,7 +19,8 @@ package org.apache.ambari.server.actionmanager;
 
 import java.util.List;
 
-import org.apache.ambari.server.agentprotocol.CommandReport;
+import org.apache.ambari.server.agent.CommandReport;
+
 
 /**
  * This class acts as the interface for action manager with other components.

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ActionQueue.java → ambari-server/src/main/java/org/apache/ambari/server/agent/ActionQueue.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 import java.util.ArrayList;
 import java.util.List;

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/AgentCommand.java → ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 public class AgentCommand {
   private String commandId;

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/CommandReport.java → ambari-server/src/main/java/org/apache/ambari/server/agent/CommandReport.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 public class CommandReport {
   String actionId;

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ComponentStatus.java → ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 public class ComponentStatus {
   String componentName;

+ 67 - 0
ambari-server/src/main/java/org/apache/ambari/server/agent/DiskInfo.java

@@ -0,0 +1,67 @@
+/**
+ * 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;
+
+/**
+ * Information about a mounted disk on a given node
+ */
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {})
+public class DiskInfo {
+  @XmlElement
+  String available;
+  @XmlElement
+  String mountpount;
+  @XmlElement
+  String used;
+  @XmlElement
+  String percent;
+  @XmlElement
+  String size;
+  
+  public String getAvailable() {
+    return this.available;
+  }
+  
+  public String getMountPoint() {
+    return this.mountpount;
+  }
+  
+  public String getUsed() {
+    return this.used;
+  }
+  
+  public String getPercent() {
+    return this.percent;
+  }
+  
+  @Override
+  public String toString() {
+    return "available=" + this.available + " mountpoint=" + this.mountpount
+         + " used=" + this.used + " percent=" + this.percent + " size=" + 
+        this.size;
+  }
+}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/ExecutionCommand.java → ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 public class ExecutionCommand extends AgentCommand {
   String manifest;

+ 14 - 17
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeat.java → ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeat.java

@@ -16,7 +16,9 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.agent.rest;
+package org.apache.ambari.server.agent;
+
+import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -24,10 +26,10 @@ 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.
+ * 
+ * Data model for Ambari Agent to send heartbeat to Ambari Server.
  *
  */
 @XmlRootElement
@@ -36,6 +38,13 @@ import javax.xml.bind.annotation.XmlType;
     "hostname", "hardwareProfile", "installedRoleStates", "installScriptHash",
     "actionResults", "firstContact", "idle"})
 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;
   @XmlElement
@@ -43,8 +52,6 @@ public class HeartBeat {
   @XmlElement
   private String hostname;
   @XmlElement
-  private HardwareProfile hardwareProfile;
-  @XmlElement
   private int installScriptHash;
   @XmlElement
   private boolean firstContact;
@@ -73,13 +80,8 @@ public class HeartBeat {
 
   public boolean getIdle() {
     return idle;
-  }
-
-  public HardwareProfile getHardwareProfile() {
-    return hardwareProfile;
-  }
-
-
+  }  
+  
   public int getInstallScriptHash() {
     return installScriptHash;
   }
@@ -92,11 +94,6 @@ public class HeartBeat {
     this.hostname = hostname;
   }
 
-  public void setHardwareProfile(HardwareProfile hardwareProfile) {
-    this.hardwareProfile = hardwareProfile;
-  }
-
-
   public void setFirstContact(boolean firstContact) {
     this.firstContact = firstContact;
   }

+ 5 - 3
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/HeartbeatHandler.java → ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java

@@ -15,16 +15,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
+
+import org.apache.ambari.server.agent.rest.HeartBeatResponse;
 
 /**
  * This class handles the heartbeats coming from the agent, passes on the information
  * to other modules and processes the queue to send heartbeat response.
  */
-public class HeartbeatHandler {
+public class HeartBeatHandler {
   private String lastCompletedActionId;
   
-  public HeartbeatResponse handleHeartBeat(Heartbeat heartbeat) {
+  public HeartBeatResponse handleHeartBeat(HeartBeat heartbeat) {
     System.out.println(heartbeat.toString());
     return null;
   }

+ 373 - 0
ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java

@@ -0,0 +1,373 @@
+/**
+ * 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.HashMap;
+import java.util.Map;
+
+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 NodeInfo {
+  @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 String memoryfree;
+  @XmlElement
+  private String memorysize;
+  @XmlElement
+  private HashMap<String, DiskInfo> mounts;
+  @XmlElement
+  private String 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 String getFreeMemory() {
+    return this.memoryfree;
+  }
+
+  public void setFreeMemory(String memoryfree) {
+    this.memoryfree = memoryfree;
+  }
+
+  public String getMemorySize() {
+    return this.memorysize;
+  }
+
+  public void setMemorySize(String memorysize) {
+    this.memorysize = memorysize;
+  }
+
+  public Map<String, DiskInfo> getMounts() {
+    return this.mounts;
+  }
+
+  public void setMounts(HashMap<String, DiskInfo> mounts) {
+    this.mounts = mounts;
+  }
+
+  public String getMemoryTotal() {
+    return this.memorytotal;
+  }
+
+  public void setMemoryTotal(String 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 (Map.Entry<String, DiskInfo> entry: mounts.entrySet()) {
+      ret = ret + " diskname = " + entry.getKey() + "value=" + entry.getValue();
+    }
+    return ret;
+  }
+  
+  public String toString() {
+    return "memory=" + this.memorytotal + "\n" +
+        "uptime_hours=" + this.uptime_hours + "\n" +
+        "operatingsystem=" + this.operatingsystem + "\n";
+  }
+}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/NodeStatus.java → ambari-server/src/main/java/org/apache/ambari/server/agent/NodeStatus.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 public class NodeStatus {
   public enum Status {

+ 9 - 8
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/Register.java → ambari-server/src/main/java/org/apache/ambari/server/agent/Register.java

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.agent.rest;
+package org.apache.ambari.server.agent;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 
+
 /**
  *
  * Data model for Ambari Agent to send heartbeat to Ambari Controller.
@@ -42,8 +43,8 @@ public class Register {
   @XmlElement
   private String hostname;
   @XmlElement
-  private HardwareProfile hardwareProfile;
-
+  private NodeInfo hardwareProfile;
+  
   public short getResponseId() {
     return responseId;
   }
@@ -59,8 +60,8 @@ public class Register {
   public String getHostname() {
     return hostname;
   }
-
-  public HardwareProfile getHardwareProfile() {
+ 
+  public NodeInfo getHardwareProfile() {
     return hardwareProfile;
   }
 
@@ -71,9 +72,9 @@ public class Register {
   public void setHostname(String hostname) {
     this.hostname = hostname;
   }
-
-  public void setHardwareProfile(HardwareProfile hardwareProfile) {
-    this.hardwareProfile = hardwareProfile;
+ 
+  public void setHardwareProfile(NodeInfo hardwareProfile) {
+    this.hardwareProfile = hardwareProfile;    
   }
 
   @Override

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/StatusCommand.java → ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java

@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.ambari.server.agentprotocol;
+package org.apache.ambari.server.agent;
 
 import java.util.List;
 

+ 6 - 4
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/AgentResource.java → ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.agent.rest;
+package org.apache.ambari.server.agent.rest;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
@@ -27,7 +27,9 @@ 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.ambari.server.agent.HeartBeat;
+import org.apache.ambari.server.agent.HeartBeatHandler;
+import org.apache.ambari.server.agent.Register;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -41,11 +43,11 @@ import com.google.inject.Inject;
  */
 @Path("/")
 public class AgentResource {
-  private static HeartbeatHandler hh;
+  private static HeartBeatHandler hh;
   private static Log LOG = LogFactory.getLog(AgentResource.class);
 
   @Inject
-  static void setHandler(HeartbeatHandler handler) {
+  static void setHandler(HeartBeatHandler handler) {
     hh = handler;
   }
 

+ 10 - 2
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/HeartBeatResponse.java → ambari-server/src/main/java/org/apache/ambari/server/agent/rest/HeartBeatResponse.java

@@ -16,7 +16,9 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.agent.rest;
+package org.apache.ambari.server.agent.rest;
+
+import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -24,6 +26,9 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.ambari.server.agent.AgentCommand;
+
+
 /**
  *
  * Controller to Agent response data model.
@@ -33,11 +38,14 @@ import javax.xml.bind.annotation.XmlType;
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "", propOrder = {})
 public class HeartBeatResponse {
+  
+  String lastCompletedActionId;
   @XmlElement
   public short responseId;
   @XmlElement
   public String clusterId;
-
+  
+  List<AgentCommand> cmds = null;
 
   public short getResponseId() {
     return responseId;

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/controller/agent/rest/RegistrationResponse.java → ambari-server/src/main/java/org/apache/ambari/server/agent/rest/RegistrationResponse.java

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.agent.rest;
+package org.apache.ambari.server.agent.rest;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;

+ 0 - 33
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/Heartbeat.java

@@ -1,33 +0,0 @@
-/**
- * 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.agentprotocol;
-
-import java.util.List;
-
-public class Heartbeat {
-  String hostname;
-  long timestamp;
-  List<CommandReport> reports;
-  List<ComponentStatus> componentStatus;
-  NodeInfo nodeInfo;
-  NodeStatus nodeStatus;
-
-  public class NodeInfo {
-
-  }
-}

+ 0 - 25
ambari-server/src/main/java/org/apache/ambari/server/agentprotocol/HeartbeatResponse.java

@@ -1,25 +0,0 @@
-/**
- * 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.agentprotocol;
-
-import java.util.List;
-
-public class HeartbeatResponse {
-  String lastCompletedActionId;
-  List<AgentCommand> cmds = null;
-}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/controller/api/rest/HealthCheck.java → ambari-server/src/main/java/org/apache/ambari/server/api/rest/HealthCheck.java

@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.ambari.controller.api.rest;
+package org.apache.ambari.server.api.rest;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;

+ 4 - 4
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java

@@ -51,16 +51,16 @@ public class AmbariServer {
      ServletHolder sh = new ServletHolder(ServletContainer.class);
      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.api.rest");
+     sh.setInitParameter("com.sun.jersey.config.property.packages", 
+       "org.apache.ambari.server.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");
+     agent.setInitParameter("com.sun.jersey.config.property.packages", 
+       "org.apache.ambari.server.agent.rest");
      root.addServlet(agent, "/agent/*");
      agent.setInitOrder(3);
 

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java

@@ -21,9 +21,9 @@ package org.apache.ambari.server.state.live.node;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.ambari.server.agent.DiskInfo;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.live.AgentVersion;
-import org.apache.ambari.server.state.live.DiskInfo;
 import org.apache.ambari.server.state.live.job.Job;
 
 public interface Node {

+ 4 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java

@@ -26,12 +26,13 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 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.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.fsm.SingleArcTransition;
 import org.apache.ambari.server.state.fsm.StateMachine;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
 import org.apache.ambari.server.state.live.AgentVersion;
-import org.apache.ambari.server.state.live.DiskInfo;
 import org.apache.ambari.server.state.live.job.Job;
 import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
 import org.apache.commons.logging.Log;
@@ -301,6 +302,7 @@ public class NodeImpl implements Node {
   void importNodeInfo(NodeInfo nodeInfo) {
     try {
       writeLock.lock();
+      /*
       this.hostName = nodeInfo.hostName;
       this.ipv4 = nodeInfo.ipv4;
       this.ipv6 = nodeInfo.ipv6;
@@ -313,6 +315,7 @@ public class NodeImpl implements Node {
       this.disksInfo = nodeInfo.disksInfo;
       this.rackInfo = nodeInfo.rackInfo;
       this.hostAttributes = nodeInfo.hostAttributes;
+      */
     }
     finally {
       writeLock.unlock();

+ 0 - 40
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeInfo.java

@@ -1,40 +0,0 @@
-/**
- * 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.state.live.node;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ambari.server.state.live.DiskInfo;
-
-public class NodeInfo {
-  public String hostName;
-  public String ipv4;
-  public String ipv6;
-  public int cpuCount;
-  public String osArch;
-  public String osType;
-  public String osInfo;
-  public long availableMemBytes;
-  public long totalMemBytes;
-  public List<DiskInfo> disksInfo;
-  public String rackInfo;
-  public Map<String, String> hostAttributes;
-}

+ 1 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java

@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.state.live.node;
 
+import org.apache.ambari.server.agent.NodeInfo;
 import org.apache.ambari.server.state.live.AgentVersion;
 
 public class NodeRegistrationRequestEvent extends NodeEvent {

+ 0 - 215
ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java

@@ -1,215 +0,0 @@
-package org.apache.ambari.server.state.live.node;
-
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.ambari.server.state.live.AgentVersion;
-import org.apache.ambari.server.state.live.DiskInfo;
-import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
-
-public class TestNodeImpl {
-
-
-  @Test
-  public void testNodeInfoImport() {
-    NodeInfo info = new NodeInfo();
-    info.availableMemBytes = 100;
-    info.cpuCount = 10;
-    info.disksInfo = new ArrayList<DiskInfo>();
-    info.disksInfo.add(new DiskInfo("/dev/sda", "ext3", "/mnt/disk1",
-        5000000, 4000000));
-    info.hostAttributes = new HashMap<String, String>();
-    info.hostName = "foo";
-    info.ipv4 = "fip_4";
-    info.osArch = "os_arch";
-    info.osType = "os_type";
-    info.osInfo = "os_info";
-    info.rackInfo = "/default-rack";
-    info.totalMemBytes = 200;
-
-    NodeImpl node = new NodeImpl();
-    node.importNodeInfo(info);
-
-    Assert.assertEquals(info.hostName, node.getHostName());
-    Assert.assertEquals(info.ipv4, node.getIPv4());
-    Assert.assertEquals(info.ipv6, node.getIPv6());
-    Assert.assertEquals(info.availableMemBytes, node.getAvailableMemBytes());
-    Assert.assertEquals(info.totalMemBytes, node.getTotalMemBytes());
-    Assert.assertEquals(info.cpuCount, node.getCpuCount());
-    Assert.assertEquals(info.disksInfo.size(), node.getDisksInfo().size());
-    Assert.assertEquals(info.hostAttributes.size(),
-        node.getHostAttributes().size());
-    Assert.assertEquals(info.osArch, node.getOsArch());
-    Assert.assertEquals(info.osType, node.getOsType());
-    Assert.assertEquals(info.osInfo, node.getOsInfo());
-    Assert.assertEquals(info.rackInfo, node.getRackInfo());
-
-  }
-
-  private void registerNode(NodeImpl node) throws Exception {
-    NodeInfo info = new NodeInfo();
-    info.availableMemBytes = 100;
-    info.cpuCount = 10;
-    info.disksInfo = new ArrayList<DiskInfo>();
-    info.disksInfo.add(new DiskInfo("/dev/sda", "ext3", "/mnt/disk1",
-        5000000, 4000000));
-    info.hostAttributes = new HashMap<String, String>();
-    info.hostName = "foo";
-    info.ipv4 = "fip_4";
-    info.osArch = "os_arch";
-    info.osType = "os_type";
-    info.osInfo = "os_info";
-    info.rackInfo = "/default-rack";
-    info.totalMemBytes = 200;
-    AgentVersion agentVersion = null;
-    long currentTime = System.currentTimeMillis();
-
-    NodeRegistrationRequestEvent e =
-        new NodeRegistrationRequestEvent("foo", agentVersion, currentTime,
-            info);
-    node.handleEvent(e);
-    Assert.assertEquals(node.getLastRegistrationTime(), currentTime);
-  }
-
-  private void verifyNode(NodeImpl node) throws Exception {
-    NodeVerifiedEvent e = new NodeVerifiedEvent(node.getHostName());
-    node.handleEvent(e);
-  }
-
-  private void verifyNodeState(NodeImpl node, NodeState state) {
-    Assert.assertEquals(node.getState(), state);
-  }
-
-  private void sendHealthyHeartbeat(NodeImpl node, long counter) throws Exception {
-    NodeHealthyHeartbeatEvent e = new NodeHealthyHeartbeatEvent(
-        node.getHostName(), counter);
-    node.handleEvent(e);
-  }
-
-  private void sendUnhealthyHeartbeat(NodeImpl node, long counter) throws Exception {
-    NodeHealthStatus healthStatus = new NodeHealthStatus(HealthStatus.UNHEALTHY,
-        "Unhealthy server");
-    NodeUnhealthyHeartbeatEvent e = new NodeUnhealthyHeartbeatEvent(
-        node.getHostName(), counter, healthStatus);
-    node.handleEvent(e);
-  }
-
-  private void timeoutNode(NodeImpl node) throws Exception {
-    NodeHeartbeatTimedOutEvent e = new NodeHeartbeatTimedOutEvent(
-        node.getHostName());
-    node.handleEvent(e);
-  }
-
-  @Test
-  public void testNodeFSMInit() {
-    NodeImpl node = new NodeImpl();
-    verifyNodeState(node, NodeState.INIT);
-  }
-
-  @Test
-  public void testNodeRegistrationFlow() throws Exception {
-    NodeImpl node = new NodeImpl();
-    registerNode(node);
-    verifyNodeState(node, NodeState.WAITING_FOR_VERIFICATION);
-
-    boolean exceptionThrown = false;
-    try {
-      registerNode(node);
-    } catch (Exception e) {
-      // Expected
-      exceptionThrown = true;
-    }
-    if (!exceptionThrown) {
-      fail("Expected invalid transition exception to be thrown");
-    }
-
-    verifyNode(node);
-    verifyNodeState(node, NodeState.VERIFIED);
-
-    exceptionThrown = false;
-    try {
-      verifyNode(node);
-    } catch (Exception e) {
-      // Expected
-      exceptionThrown = true;
-    }
-    if (!exceptionThrown) {
-      fail("Expected invalid transition exception to be thrown");
-    }
-  }
-
-  @Test
-  public void testNodeHeartbeatFlow() throws Exception {
-    NodeImpl node = new NodeImpl();
-    registerNode(node);
-    verifyNode(node);
-
-    // TODO need to verify audit logs generated
-    // TODO need to verify health status updated properly
-
-    long counter = 0;
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.HEALTHY);
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNHEALTHY);
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNHEALTHY);
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.HEALTHY);
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNKNOWN);
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNKNOWN);
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNHEALTHY);
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.UNKNOWN);
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(node.getLastHeartbeatTime(), counter);
-    Assert.assertEquals(node.getHealthStatus().getHealthStatus(),
-        HealthStatus.HEALTHY);
-
-  }
-}