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/11 08:48:20 UTC

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

Author: mahadev
Date: Tue Sep 11 06:48:20 2012
New Revision: 1383257

URL: http://svn.apache.org/viewvc?rev=1383257&view=rev
Log:
AMBARI-716. Add back TestNodeImpl and fix memory types and disk info serialization. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
Removed:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/DiskInfo.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml
    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/Hardware.py
    incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
    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/NodeInfo.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/pom.xml

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=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Sep 11 06:48:20 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-716. Add back TestNodeImpl and fix memory types and disk info
+  serialization. (mahadev)
+
   AMBARI-717. Starter implementation for Installer Customize Services page.
   Stylize top nav and implement static footer.  Stylize login page. (yusaku)
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml?rev=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml Tue Sep 11 06:48:20 2012
@@ -21,7 +21,7 @@
   <artifactId>ambari-agent</artifactId>
   <packaging>pom</packaging>
   <version>1.0.3-SNAPSHOT</version>
-  <name>agent</name>
+  <name>Ambari Agent</name>
   <description>Ambari Agent</description>
   <properties>
     <final.name>${project.artifactId}-${project.version}</final.name>

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=1383257&r1=1383256&r2=1383257&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 Tue Sep 11 06:48:20 2012
@@ -70,7 +70,6 @@ class Controller(threading.Thread):
       try:
         if retry==False:
           data = json.dumps(self.heartbeat.build(id))
-          logger.info(data)
         req = urllib2.Request(self.url, data, {'Content-Type': 'application/json'})
         f = urllib2.urlopen(req)
         response = f.read()

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Hardware.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Hardware.py?rev=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Hardware.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Hardware.py Tue Sep 11 06:48:20 2012
@@ -25,6 +25,8 @@ import os.path
 import shell
 import logging
 import subprocess
+import pprint
+import traceback
 
 logger = logging.getLogger()
 
@@ -41,7 +43,7 @@ class Hardware:
     """ Run df to find out the disks on the host. Only works on linux 
     platforms. Note that this parser ignores any filesystems with spaces 
     and any mounts with spaces. """
-    mounts = {}
+    mounts = []
     df = subprocess.Popen(["df", "-kP"], stdout=subprocess.PIPE)
     dfdata = df.communicate()[0]
     lines = dfdata.splitlines()
@@ -50,13 +52,15 @@ class Hardware:
       """ this ignores any spaces in the filesystemname and mounts """
       if (len(split)) == 6:
         device, size, used, available, percent, mountpoint = split
-        mountinfo = { 'size' : size,
-             'used' : used,
-             'available' : available,
-             'percent' : percent,
-             'mountpoint' : mountpoint}
+        mountinfo = { 
+                     'size' : size,
+                     'used' : used,
+                     'available' : available,
+                     'percent' : percent,
+                     'mountpoint' : mountpoint,
+                     'device' : device }
 
-        mounts[device ] = mountinfo
+        mounts.append(mountinfo)
         pass
       pass
     return mounts
@@ -77,9 +81,22 @@ class Hardware:
       if (len(keyValue) == 2):
         """Ignoring values that are just spaces or do not confirm to the 
         format"""
-        retDict[keyValue[0].strip()] = keyValue[1].strip()
+        strippedKey = keyValue[0].strip()
+        logger.info("Stripped key is " + strippedKey)
+        if strippedKey in ["memoryfree", "memorysize", "memorytotal"]:
+          value = keyValue[1].strip()
+          """Convert to KB"""
+          parts = value.split()
+          #TODO need better parsing for detecting KB/GB
+          mem_in_kb = long(float(parts[0]) * 1024 * 1024);
+          retDict[strippedKey] = mem_in_kb
+          pass
+        else:
+          retDict[strippedKey] = keyValue[1].strip()
+          pass
         pass
       pass
+    logger.info("Facter info : \n" + pprint.pformat(retDict))
     return retDict
   
   def facterInfo(self):   
@@ -87,31 +104,35 @@ class Hardware:
     facterEnv = os.environ
     logger.info("Using facter home as: " + facterHome)
     facterInfo = {}
-    if os.path.exists(facterHome):
-      rubyLib = ""
-      if os.environ.has_key("RUBYLIB"):
-        rubyLib = os.environ["RUBYLIB"]
-        logger.info("Ruby Lib env from Env " + rubyLib)
-      rubyLib = rubyLib + ":" + self.facterLib(facterHome)
-      facterEnv["RUBYLIB"] = rubyLib
-      logger.info("Setting RUBYLIB as: " + rubyLib)
-      facter = subprocess.Popen([self.facterBin(facterHome)],
-                                 stdout=subprocess.PIPE,
-                                 stderr=subprocess.PIPE,
-                                 env=facterEnv)
-      stderr_out = facter.communicate()
-      if facter.returncode != 0:
-        logging.error("Error getting facter info: " + stderr_out[1])
+    try:
+      if os.path.exists(facterHome):
+        rubyLib = ""
+        if os.environ.has_key("RUBYLIB"):
+          rubyLib = os.environ["RUBYLIB"]
+          logger.info("Ruby Lib env from Env " + rubyLib)
+        rubyLib = rubyLib + ":" + self.facterLib(facterHome)
+        facterEnv["RUBYLIB"] = rubyLib
+        logger.info("Setting RUBYLIB as: " + rubyLib)
+        facter = subprocess.Popen([self.facterBin(facterHome)],
+                                  stdout=subprocess.PIPE,
+                                  stderr=subprocess.PIPE,
+                                  env=facterEnv)
+        stderr_out = facter.communicate()
+        if facter.returncode != 0:
+          logging.error("Error getting facter info: " + stderr_out[1])
+          pass
+        facterOutput = stderr_out[0]
+        infoDict = self.parseFacterOutput(facterOutput)
+        facterInfo = infoDict
         pass
-      facterOutput = stderr_out[0]
-      infoDict = self.parseFacterOutput(facterOutput)
-      facterInfo = infoDict
-    else:
+      else:
+        pass
+    except:
+      logger.info("Traceback " + traceback.format_exc())
       pass
     return facterInfo
   
   def get(self):
-    logger.info("Hardware Info for the agent: " + str(self.hardware))
     return self.hardware
 
 def main(argv=None):

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=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Tue Sep 11 06:48:20 2012
@@ -20,7 +20,7 @@
   <groupId>org.apache.ambari</groupId>
   <artifactId>ambari-server</artifactId>
   <packaging>jar</packaging>
-  <name>ambari-server</name>
+  <name>Ambari Server</name>
   <version>1.0.3-SNAPSHOT</version>
   <description>Ambari Server</description>
   <build>

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=1383257&r1=1383256&r2=1383257&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 Tue Sep 11 06:48:20 2012
@@ -24,17 +24,21 @@ import javax.xml.bind.annotation.XmlElem
 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 = {})
+//TODO convert the type safe ints/longs for used/percent/size.  
 public class DiskInfo {
   @XmlElement
   String available;
   @XmlElement
-  String mountpount;
+  String mountpoint;
+  @XmlElement
+  String device;
   @XmlElement
   String used;
   @XmlElement
@@ -42,12 +46,35 @@ public class DiskInfo {
   @XmlElement
   String size;
   
+  /**
+   * DiskInfo object that tracks information about a disk.
+   * @param mountpoint 
+   * @param available
+   * @param used
+   * @param percent
+   * @param size
+   */
+  public DiskInfo(String device, String mountpoint, String available, 
+      String used, String percent, String size) {
+    this.device = device;
+    this.mountpoint = mountpoint;
+    this.available = available;
+    this.used = used;
+    this.percent = percent;
+    this.size = size;
+  }
+  
+  /**
+   * Needed for JAXB
+   */
+  public DiskInfo() {}
+  
   public String getAvailable() {
     return this.available;
   }
   
   public String getMountPoint() {
-    return this.mountpount;
+    return this.mountpoint;
   }
   
   public String getUsed() {
@@ -60,8 +87,8 @@ public class DiskInfo {
   
   @Override
   public String toString() {
-    return "available=" + this.available + " mountpoint=" + this.mountpount
-         + " used=" + this.used + " percent=" + this.percent + " size=" + 
-        this.size;
+    return "available=" + this.available + ",mountpoint=" + this.mountpoint
+         + ",used=" + this.used + ",percent=" + this.percent + ",size=" + 
+        this.size + ",device=" + this.device;
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java?rev=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/NodeInfo.java Tue Sep 11 06:48:20 2012
@@ -18,8 +18,8 @@
 
 package org.apache.ambari.server.agent;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -67,13 +67,13 @@ public class NodeInfo {
   @XmlElement
   private String macaddress;
   @XmlElement
-  private String memoryfree;
+  private long memoryfree;
   @XmlElement
-  private String memorysize;
+  private long memorysize;
   @XmlElement
-  private HashMap<String, DiskInfo> mounts;
+  private List<DiskInfo> mounts = new ArrayList<DiskInfo>();
   @XmlElement
-  private String memorytotal;
+  private long memorytotal;
   @XmlElement
   private String netmask;
   @XmlElement
@@ -221,35 +221,35 @@ public class NodeInfo {
     this.macaddress = macaddress;
   }
 
-  public String getFreeMemory() {
+  public long getFreeMemory() {
     return this.memoryfree;
   }
 
-  public void setFreeMemory(String memoryfree) {
+  public void setFreeMemory(long memoryfree) {
     this.memoryfree = memoryfree;
   }
 
-  public String getMemorySize() {
+  public long getMemorySize() {
     return this.memorysize;
   }
 
-  public void setMemorySize(String memorysize) {
+  public void setMemorySize(long memorysize) {
     this.memorysize = memorysize;
   }
 
-  public Map<String, DiskInfo> getMounts() {
+  public List<DiskInfo> getMounts() {
     return this.mounts;
   }
 
-  public void setMounts(HashMap<String, DiskInfo> mounts) {
+  public void setMounts(List<DiskInfo> mounts) {
     this.mounts = mounts;
   }
 
-  public String getMemoryTotal() {
+  public long getMemoryTotal() {
     return this.memorytotal;
   }
 
-  public void setMemoryTotal(String memorytotal) {
+  public void setMemoryTotal(long memorytotal) {
     this.memorytotal = memorytotal;
   }
 
@@ -359,15 +359,16 @@ public class NodeInfo {
 
   private String getDiskString() {
     String ret = "";
-    for (Map.Entry<String, DiskInfo> entry: mounts.entrySet()) {
-      ret = ret + " diskname = " + entry.getKey() + "value=" + entry.getValue();
+    for (DiskInfo diskInfo : mounts) {
+      ret = ret + "(" + diskInfo.toString() + ")";
     }
     return ret;
   }
   
   public String toString() {
-    return "memory=" + this.memorytotal + "\n" +
-        "uptime_hours=" + this.uptime_hours + "\n" +
-        "operatingsystem=" + this.operatingsystem + "\n";
+    return "[memory=" + this.memorytotal + "," +
+        "uptime_hours=" + this.uptime_hours + "," +
+        "operatingsystem=" + this.operatingsystem + "," +
+        "mounts=" + getDiskString() + "]\n";
   }
 }

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=1383257&r1=1383256&r2=1383257&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 Tue Sep 11 06:48:20 2012
@@ -302,20 +302,13 @@ public class NodeImpl implements Node {
   void importNodeInfo(NodeInfo nodeInfo) {
     try {
       writeLock.lock();
-      /*
-      this.hostName = nodeInfo.hostName;
-      this.ipv4 = nodeInfo.ipv4;
-      this.ipv6 = nodeInfo.ipv6;
-      this.availableMemBytes = nodeInfo.availableMemBytes;
-      this.totalMemBytes = nodeInfo.totalMemBytes;
-      this.cpuCount = nodeInfo.cpuCount;
-      this.osArch = nodeInfo.osArch;
-      this.osType = nodeInfo.osType;
-      this.osInfo = nodeInfo.osInfo;
-      this.disksInfo = nodeInfo.disksInfo;
-      this.rackInfo = nodeInfo.rackInfo;
-      this.hostAttributes = nodeInfo.hostAttributes;
-      */
+      this.hostName = nodeInfo.getHostName();
+      this.availableMemBytes = nodeInfo.getFreeMemory();
+      this.totalMemBytes = nodeInfo.getMemoryTotal();
+      this.cpuCount = nodeInfo.getProcessorCount();
+      this.osArch = nodeInfo.getArchitecture();
+      this.osType = nodeInfo.getOS();
+      this.disksInfo = nodeInfo.getMounts();
     }
     finally {
       writeLock.unlock();

Added: 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=1383257&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java Tue Sep 11 06:48:20 2012
@@ -0,0 +1,206 @@
+package org.apache.ambari.server.state.live.node;
+
+import static org.junit.Assert.fail;
+
+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.state.live.AgentVersion;
+import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestNodeImpl {
+
+  @Test
+  public void testNodeInfoImport() {
+    NodeInfo info = new NodeInfo();
+    info.setMemorySize(100);
+    info.setProcessorCount(10);
+    List<DiskInfo> mounts = new ArrayList<DiskInfo>();
+    mounts.add(new DiskInfo("/dev/sda", "/mnt/disk1",
+        "5000000", "4000000", "10%", "size"));
+    info.setMounts(mounts);
+    
+    info.setHostName("foo");
+    info.setInterfaces("fip_4");
+    info.setArchitecture("os_arch");
+    info.setOS("os_type");
+    info.setMemoryTotal(10);
+
+    NodeImpl node = new NodeImpl();
+    node.importNodeInfo(info);
+   
+    Assert.assertEquals(info.getHostName(), node.getHostName());
+    Assert.assertEquals(info.getFreeMemory(), node.getAvailableMemBytes());
+    Assert.assertEquals(info.getMemoryTotal(), node.getTotalMemBytes());
+    Assert.assertEquals(info.getProcessorCount(), node.getCpuCount());
+    Assert.assertEquals(info.getMounts().size(), node.getDisksInfo().size());
+    Assert.assertEquals(info.getArchitecture(), node.getOsArch());
+    Assert.assertEquals(info.getOS(), node.getOsType());
+  }
+
+  private void registerNode(NodeImpl node) throws Exception {
+    NodeInfo info = new NodeInfo();
+    info.setMemorySize(100);
+    info.setProcessorCount(10);
+    List<DiskInfo> mounts = new ArrayList<DiskInfo>();
+    mounts.add(new DiskInfo("/dev/sda", "/mnt/disk1",
+        "5000000", "4000000", "10%", "size"));
+    info.setMounts(mounts);
+    
+    info.setHostName("foo");
+    info.setInterfaces("fip_4");
+    info.setArchitecture("os_arch");
+    info.setOS("os_type");
+    info.setMemoryTotal(10);
+
+    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);
+
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/pom.xml?rev=1383257&r1=1383256&r2=1383257&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/pom.xml Tue Sep 11 06:48:20 2012
@@ -20,7 +20,7 @@
   <groupId>org.apache.ambari</groupId>
   <artifactId>ambari</artifactId>
   <packaging>pom</packaging>
-  <name>ambari</name>
+  <name>Ambari Main</name>
   <version>1.0.3-SNAPSHOT</version>
   <description>Ambari</description>
   <pluginRepositories>