incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject svn commit: r1382216 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-server/src/main/java/org/apache/ambari/server/state/fsm/ ambari-server/src/main/java/org/apache/ambari/server/state/live/ ambari-server/src/main/java/org/apache/ambari/server/st...
Date Sat, 08 Sep 2012 00:03:35 GMT
Author: hitesh
Date: Sat Sep  8 00:03:34 2012
New Revision: 1382216

URL: http://svn.apache.org/viewvc?rev=1382216&view=rev
Log:
AMBARI-707. More work on Node FSM and additional tests/cleanup. (Contributed by hitesh)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Sat Sep  8 00:03:34 2012
@@ -12,7 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
-  AMBARI-706. Basic tests for Node FSM (hitesh)
+  AMBARI-707. More work on Node FSM and additional tests/cleanup. (hitesh)
+
+  AMBARI-706. Basic tests for Node FSM. (hitesh)
 
   AMBARI-705. Initial work on Node FSM. (hitesh)
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/fsm/InvalidStateTransitonException.java
Sat Sep  8 00:03:34 2012
@@ -18,7 +18,10 @@
 
 package org.apache.ambari.server.state.fsm;
 
-// TODO
+/**
+ * Exception thrown when a StateMachine encounters an invalid 
+ * event at its current state.
+ */
 @SuppressWarnings("serial")
 public class InvalidStateTransitonException extends Exception {
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/AgentVersion.java
Sat Sep  8 00:03:34 2012
@@ -18,7 +18,22 @@
 
 package org.apache.ambari.server.state.live;
 
-// TODO
+/**
+ * Agent Version representation
+ */
 public class AgentVersion {
 
-}
+  private final String version;
+  
+  public AgentVersion(String version) {
+    this.version = version;
+  }
+
+  /**
+   * @return the version
+   */
+  public String getVersion() {
+    return version;
+  }
+  
+} 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/Job.java
Sat Sep  8 00:03:34 2012
@@ -29,7 +29,7 @@ public interface Job {
   public JobId getId();
 
   // TODO requires some form of JobType to ensure only one running
-  // action per action type
+  // job per job type
   // There may be gotchas such as de-commissioning should be allowed to happen
   // on more than one node at a time  
   

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/JobEvent.java
Sat Sep  8 00:03:34 2012
@@ -20,12 +20,18 @@ package org.apache.ambari.server.state.l
 
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 
+/**
+ * Base class for all events that affect the Job FSM
+ */
 public class JobEvent extends AbstractEvent<JobEventType> {
 
-  // TODO
-  // this should have some action identifier
-  public JobEvent(JobEventType type) {
+  /**
+   * JobId identifying the job
+   */
+  final JobId jobId;
+  
+  public JobEvent(JobEventType type, JobId jobId) {
     super(type);
-    // TODO Auto-generated constructor stub
+    this.jobId = jobId;
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java
Sat Sep  8 00:03:34 2012
@@ -20,12 +20,27 @@ package org.apache.ambari.server.state.l
 
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 
+/**
+ * Base class for all events that affect the ServiceComponentNode FSM
+ */
 public class ServiceComponentNodeEvent
     extends AbstractEvent<ServiceComponentNodeEventType> {
 
-  public ServiceComponentNodeEvent(ServiceComponentNodeEventType type) {
+  /**
+   * ServiceComponent that this event relates to
+   */
+  final String serviceComponentName;
+
+  /**
+   * Hostname of the Node that this event relates to
+   */
+  final String nodeName;
+  
+  public ServiceComponentNodeEvent(ServiceComponentNodeEventType type,
+      String serviceComponentName, String nodeName) {
     super(type);
-    // TODO Auto-generated constructor stub
+    this.serviceComponentName = serviceComponentName;
+    this.nodeName = nodeName;
   }
 
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java
Sat Sep  8 00:03:34 2012
@@ -20,12 +20,16 @@ package org.apache.ambari.server.state.l
 
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 
+/**
+ * Base class for all events that affect the Node FSM
+ */
 public class NodeEvent extends AbstractEvent<NodeEventType> {
 
+  /**
+   * Hostname of the Node
+   */
   final String nodeName;
   
-  // TODO
-  // this should have some node identifier
   public NodeEvent(String nodeName, NodeEventType type) {
     super(type);
     this.nodeName = nodeName;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java
Sat Sep  8 00:03:34 2012
@@ -16,9 +16,40 @@
  * limitations under the License.
  */
 
-
 package org.apache.ambari.server.state.live.node;
 
-public interface NodeHealthStatus {
+public class NodeHealthStatus {
+
+  private HealthStatus healthStatus;
+  
+  private String healthReport;
+  
+  public NodeHealthStatus(HealthStatus healthStatus, String healthReport) {
+    super();
+    this.healthStatus = healthStatus;
+    this.healthReport = healthReport;
+  }
+
+  public synchronized HealthStatus getHealthStatus() {
+    return healthStatus;
+  }
+  
+  public synchronized void setHealthStatus(HealthStatus healthStatus) {
+    this.healthStatus = healthStatus;
+  }
+  
+  public synchronized void setHealthReport(String healthReport) {
+    this.healthReport = healthReport;
+  }
 
+  public synchronized String getHealthReport() {
+    return healthReport;
+  }
+  
+  public static enum HealthStatus {
+    UNKNOWN,
+    HEALTHY,
+    UNHEALTHY
+  }
+  
 }

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=1382216&r1=1382215&r2=1382216&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
Sat Sep  8 00:03:34 2012
@@ -33,6 +33,7 @@ import org.apache.ambari.server.state.fs
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.DiskInfo;
 import org.apache.ambari.server.state.live.Job;
+import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -205,6 +206,7 @@ public class NodeImpl implements Node {
     ReadWriteLock rwLock = new ReentrantReadWriteLock();
     this.readLock = rwLock.readLock();
     this.writeLock = rwLock.writeLock();
+    this.healthStatus = new NodeHealthStatus(HealthStatus.UNKNOWN, "");
   }
 
   static class NodeRegistrationReceived
@@ -262,7 +264,7 @@ public class NodeImpl implements Node {
       LOG.info("Node transitioned to a healthy state"
           + ", node=" + e.nodeName
           + ", heartbeatTime=" + e.getHeartbeatTime());
-      // TODO update health status to healthy
+      node.getHealthStatus().setHealthStatus(HealthStatus.HEALTHY);      
     }
   }
 
@@ -292,7 +294,7 @@ public class NodeImpl implements Node {
       LOG.info("Node transitioned to heartbeat timed out state"
           + ", node=" + e.nodeName
           + ", lastHeartbeatTime=" + node.getLastHeartbeatTime());
-      // TODO update health status to ???
+      node.getHealthStatus().setHealthStatus(HealthStatus.UNKNOWN);
     }
   } 
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java?rev=1382216&r1=1382215&r2=1382216&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/node/TestNodeImpl.java
Sat Sep  8 00:03:34 2012
@@ -10,6 +10,7 @@ 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 {
 
@@ -91,7 +92,8 @@ public class TestNodeImpl {
   }
 
   private void sendUnhealthyHeartbeat(NodeImpl node, long counter) throws Exception {
-    NodeHealthStatus healthStatus = null;
+    NodeHealthStatus healthStatus = new NodeHealthStatus(HealthStatus.UNHEALTHY,
+        "Unhealthy server");
     NodeUnhealthyHeartbeatEvent e = new NodeUnhealthyHeartbeatEvent(
         node.getHostName(), counter, healthStatus);
     node.handleEvent(e);
@@ -158,38 +160,56 @@ public class TestNodeImpl {
     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);
     
   }
 }



Mime
View raw message