Selaa lähdekoodia

AMBARI-738. s/Node/Host/g. (Contributed by hitesh)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1384984 13f79535-47bb-0310-9956-ffa450edef68
Hitesh Shah 12 vuotta sitten
vanhempi
commit
9a525ef022
33 muutettua tiedostoa jossa 1188 lisäystä ja 1186 poistoa
  1. 2 0
      AMBARI-666-CHANGES.txt
  2. 27 27
      ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java
  3. 13 13
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHost.java
  4. 11 11
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostEvent.java
  5. 10 10
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostEventType.java
  6. 536 0
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostImpl.java
  7. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostInstallEvent.java
  8. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostLiveState.java
  9. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpFailedEvent.java
  10. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpInProgressEvent.java
  11. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpRestartedEvent.java
  12. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpSucceededEvent.java
  13. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostStartEvent.java
  14. 8 8
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostState.java
  15. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostStopEvent.java
  16. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostUninstallEvent.java
  17. 6 6
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostWipeoutEvent.java
  18. 0 536
      ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java
  19. 25 25
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/Host.java
  20. 7 7
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostEvent.java
  21. 12 12
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostEventType.java
  22. 3 3
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHealthStatus.java
  23. 4 4
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHealthyHeartbeatEvent.java
  24. 4 4
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHeartbeatTimedOutEvent.java
  25. 130 130
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java
  26. 7 7
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java
  27. 10 10
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostState.java
  28. 7 7
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostUnhealthyHeartbeatEvent.java
  29. 4 4
      ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostVerifiedEvent.java
  30. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java
  31. 88 88
      ambari-server/src/test/java/org/apache/ambari/server/state/live/TestServiceComponentHostImpl.java
  32. 224 0
      ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java
  33. 0 224
      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
   NEW FEATURES
 
 
+  AMBARI-738. s/Node/Host/g. (hitesh)
+
   AMBARI-737. ServiceComponentNode FSM implementation. (hitesh)
   AMBARI-737. ServiceComponentNode FSM implementation. (hitesh)
 
 
   AMBARI-734. Initial work for adding DataNode/TaskTracker/RegionServer
   AMBARI-734. Initial work for adding DataNode/TaskTracker/RegionServer

+ 27 - 27
ambari-server/src/main/java/org/apache/ambari/server/state/live/Cluster.java

@@ -19,63 +19,63 @@
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
-import org.apache.ambari.server.state.live.node.NodeEvent;
-import org.apache.ambari.server.state.live.node.NodeState;
+import org.apache.ambari.server.state.live.host.HostEvent;
+import org.apache.ambari.server.state.live.host.HostState;
 
 
 public interface Cluster {
 public interface Cluster {
 
 
   /**
   /**
-   * Get the State for a given Node
-   * @param nodeName Node hostname for which to retrieve state
+   * Get the State for a given Host
+   * @param hostName Host hostname for which to retrieve state
    * @return
    * @return
    */
    */
-  public NodeState getNodeState(String nodeName);
+  public HostState getHostState(String hostName);
 
 
   /**
   /**
-   * Set the State for a given Node
-   * @param nodeName Node's hostname for which state is to be set
-   * @param state NodeState to set
+   * Set the State for a given Host
+   * @param hostName Host's hostname for which state is to be set
+   * @param state HostState to set
    */
    */
-  public void setNodeState(String nodeName, NodeState state);
+  public void setHostState(String hostName, HostState state);
 
 
   /**
   /**
-   * Send event to the given Node
-   * @param nodeName Node's hostname
+   * Send event to the given Host
+   * @param hostName Host's hostname
    * @param event Event to be handled
    * @param event Event to be handled
    */
    */
-  public void handleNodeEvent(String nodeName, NodeEvent event)
+  public void handleHostEvent(String hostName, HostEvent event)
       throws InvalidStateTransitonException;
       throws InvalidStateTransitonException;
 
 
   /**
   /**
-   * Get the State for a given ServiceComponentNode
+   * Get the State for a given ServiceComponentHost
    * @param service Service name
    * @param service Service name
    * @param serviceComponent ServiceComponent name
    * @param serviceComponent ServiceComponent name
-   * @param nodeName Node name
-   * @return ServiceComponentNodeState
+   * @param hostName Host name
+   * @return ServiceComponentHostState
    */
    */
-  public ServiceComponentNodeState getServiceComponentNodeState(String service,
-      String serviceComponent, String nodeName);
+  public ServiceComponentHostState getServiceComponentHostState(String service,
+      String serviceComponent, String hostName);
 
 
   /**
   /**
-   * Set the State for a given ServiceComponentNode
+   * Set the State for a given ServiceComponentHost
    * @param service Service name
    * @param service Service name
    * @param serviceComponent ServiceComponent name
    * @param serviceComponent ServiceComponent name
-   * @param nodeName Node name
+   * @param hostName Host name
    * @param state State to set
    * @param state State to set
    */
    */
-  public void setServiceComponentNodeState(String service,
-      String serviceComponent, String nodeName,
-      ServiceComponentNodeState state);
+  public void setServiceComponentHostState(String service,
+      String serviceComponent, String hostName,
+      ServiceComponentHostState state);
 
 
   /**
   /**
-   * Send an Event to a given ServiceComponentNode
+   * Send an Event to a given ServiceComponentHost
    * @param service Service name
    * @param service Service name
    * @param serviceComponent ServiceComponent name
    * @param serviceComponent ServiceComponent name
-   * @param nodeName Node name
+   * @param hostName Host name
    * @param event Event to be handled
    * @param event Event to be handled
    */
    */
-  public void handleServiceComponentNodeEvent(String service,
-      String serviceComponent, String nodeName,
-      ServiceComponentNodeEvent event) throws InvalidStateTransitonException;
+  public void handleServiceComponentHostEvent(String service,
+      String serviceComponent, String hostName,
+      ServiceComponentHostEvent event) throws InvalidStateTransitonException;
 
 
 }
 }

+ 13 - 13
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNode.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHost.java

@@ -24,7 +24,7 @@ import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.live.job.Job;
 import org.apache.ambari.server.state.live.job.Job;
 
 
 
 
-public interface ServiceComponentNode {
+public interface ServiceComponentHost {
 
 
   /**
   /**
    * Get the ServiceComponent this object maps to
    * Get the ServiceComponent this object maps to
@@ -33,37 +33,37 @@ public interface ServiceComponentNode {
   public String getServiceComponentName();
   public String getServiceComponentName();
 
 
   /**
   /**
-   * Get the Node this object maps to
-   * @return Node's hostname
+   * Get the Host this object maps to
+   * @return Host's hostname
    */
    */
-  public String getNodeName();
+  public String getHostName();
 
 
   /**
   /**
    * Get the list of Jobs that are currently being tracked at the
    * Get the list of Jobs that are currently being tracked at the
-   * ServiceComponentNode level
+   * ServiceComponentHost level
    * @return List of Jobs
    * @return List of Jobs
    */
    */
   public List<Job> getJobs();
   public List<Job> getJobs();
 
 
 
 
   /**
   /**
-   * Get ServiceComponent-Node State
-   * @return ServiceComponentNodeState
+   * Get ServiceComponent-Host State
+   * @return ServiceComponentHostState
    */
    */
-  public ServiceComponentNodeState getState();
+  public ServiceComponentHostState getState();
 
 
   /**
   /**
-   * Set the State for this ServiceComponent-Node
-   * @param state ServiceComponentNodeState to set to
+   * Set the State for this ServiceComponent-Host
+   * @param state ServiceComponentHostState to set to
    */
    */
-  public void setState(ServiceComponentNodeState state);
+  public void setState(ServiceComponentHostState state);
 
 
   /**
   /**
-   * Send a ServiceComponentNodeState event to the StateMachine
+   * Send a ServiceComponentHostState event to the StateMachine
    * @param event Event to handle
    * @param event Event to handle
    * @throws InvalidStateTransitonException
    * @throws InvalidStateTransitonException
    */
    */
-  public void handleEvent(ServiceComponentNodeEvent event)
+  public void handleEvent(ServiceComponentHostEvent event)
       throws InvalidStateTransitonException;
       throws InvalidStateTransitonException;
 
 
 }
 }

+ 11 - 11
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostEvent.java

@@ -21,10 +21,10 @@ package org.apache.ambari.server.state.live;
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 
 
 /**
 /**
- * Base class for all events that affect the ServiceComponentNode FSM
+ * Base class for all events that affect the ServiceComponentHost FSM
  */
  */
-public class ServiceComponentNodeEvent
-    extends AbstractEvent<ServiceComponentNodeEventType> {
+public class ServiceComponentHostEvent
+    extends AbstractEvent<ServiceComponentHostEventType> {
 
 
   /**
   /**
    * ServiceComponent that this event relates to
    * ServiceComponent that this event relates to
@@ -32,20 +32,20 @@ public class ServiceComponentNodeEvent
   private final String serviceComponentName;
   private final String serviceComponentName;
 
 
   /**
   /**
-   * Hostname of the Node that this event relates to
+   * Hostname of the Host that this event relates to
    */
    */
-  private final String nodeName;
+  private final String hostName;
 
 
   /**
   /**
    * Time when the event was triggered
    * Time when the event was triggered
    */
    */
   private final long opTimestamp;
   private final long opTimestamp;
 
 
-  public ServiceComponentNodeEvent(ServiceComponentNodeEventType type,
-      String serviceComponentName, String nodeName, long opTimestamp) {
+  public ServiceComponentHostEvent(ServiceComponentHostEventType type,
+      String serviceComponentName, String hostName, long opTimestamp) {
     super(type);
     super(type);
     this.serviceComponentName = serviceComponentName;
     this.serviceComponentName = serviceComponentName;
-    this.nodeName = nodeName;
+    this.hostName = hostName;
     this.opTimestamp = opTimestamp;
     this.opTimestamp = opTimestamp;
   }
   }
 
 
@@ -57,10 +57,10 @@ public class ServiceComponentNodeEvent
   }
   }
 
 
   /**
   /**
-   * @return the nodeName
+   * @return the hostName
    */
    */
-  public String getNodeName() {
-    return nodeName;
+  public String getHostName() {
+    return hostName;
   }
   }
 
 
   /**
   /**

+ 10 - 10
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeEventType.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostEventType.java

@@ -18,41 +18,41 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public enum ServiceComponentNodeEventType {
+public enum ServiceComponentHostEventType {
   /**
   /**
    * Operation in progress
    * Operation in progress
    */
    */
-  NODE_SVCCOMP_OP_IN_PROGRESS,
+  HOST_SVCCOMP_OP_IN_PROGRESS,
   /**
   /**
    * Operation succeeded
    * Operation succeeded
    */
    */
-  NODE_SVCCOMP_OP_SUCCEEDED,
+  HOST_SVCCOMP_OP_SUCCEEDED,
   /**
   /**
    * Operation failed.
    * Operation failed.
    */
    */
-  NODE_SVCCOMP_OP_FAILED,
+  HOST_SVCCOMP_OP_FAILED,
   /**
   /**
    * Re-starting a failed operation.
    * Re-starting a failed operation.
    */
    */
-  NODE_SVCCOMP_OP_RESTART,
+  HOST_SVCCOMP_OP_RESTART,
   /**
   /**
    * Triggering an install.
    * Triggering an install.
    */
    */
-  NODE_SVCCOMP_INSTALL,
+  HOST_SVCCOMP_INSTALL,
   /**
   /**
    * Triggering a start.
    * Triggering a start.
    */
    */
-  NODE_SVCCOMP_START,
+  HOST_SVCCOMP_START,
   /**
   /**
    * Triggering a stop.
    * Triggering a stop.
    */
    */
-  NODE_SVCCOMP_STOP,
+  HOST_SVCCOMP_STOP,
   /**
   /**
    * Triggering an uninstall.
    * Triggering an uninstall.
    */
    */
-  NODE_SVCCOMP_UNINSTALL,
+  HOST_SVCCOMP_UNINSTALL,
   /**
   /**
    * Triggering a wipe-out ( restore to clean state ).
    * Triggering a wipe-out ( restore to clean state ).
    */
    */
-  NODE_SVCCOMP_WIPEOUT
+  HOST_SVCCOMP_WIPEOUT
 }
 }

+ 536 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostImpl.java

@@ -0,0 +1,536 @@
+/**
+ * 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;
+
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+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.job.Job;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ServiceComponentHostImpl implements ServiceComponentHost {
+
+  private static final Log LOG =
+      LogFactory.getLog(ServiceComponentHostImpl.class);
+
+  private final Lock readLock;
+  private final Lock writeLock;
+
+  private ServiceComponentHostState state;
+
+  private final String serviceComponentName;
+  private final String hostName;
+
+  private long lastOpStartTime;
+  private long lastOpEndTime;
+  private long lastOpLastUpdateTime;
+
+  private static final StateMachineFactory
+  <ServiceComponentHostImpl, ServiceComponentHostLiveState,
+  ServiceComponentHostEventType, ServiceComponentHostEvent>
+    daemonStateMachineFactory
+      = new StateMachineFactory<ServiceComponentHostImpl,
+          ServiceComponentHostLiveState, ServiceComponentHostEventType,
+          ServiceComponentHostEvent>
+          (ServiceComponentHostLiveState.INIT)
+
+  // define the state machine of a HostServiceComponent for runnable
+  // components
+
+     .addTransition(ServiceComponentHostLiveState.INIT,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALL_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.INSTALL_FAILED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_START,
+         new ServiceComponentHostOpStartedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
+         new ServiceComponentHostOpStartedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostLiveState.STARTED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostLiveState.START_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.START_FAILED,
+         ServiceComponentHostLiveState.STARTING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.STARTED,
+         ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_STOP,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostLiveState.STOP_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.STOP_FAILED,
+         ServiceComponentHostLiveState.STOPPING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALL_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALL_FAILED,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.INIT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.WIPEOUT_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPEOUT_FAILED,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .installTopology();
+
+  private static final StateMachineFactory
+  <ServiceComponentHostImpl, ServiceComponentHostLiveState,
+  ServiceComponentHostEventType, ServiceComponentHostEvent>
+    clientStateMachineFactory
+      = new StateMachineFactory<ServiceComponentHostImpl,
+          ServiceComponentHostLiveState, ServiceComponentHostEventType,
+          ServiceComponentHostEvent>
+          (ServiceComponentHostLiveState.INIT)
+
+  // define the state machine of a HostServiceComponent for client only
+  // components
+
+     .addTransition(ServiceComponentHostLiveState.INIT,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostLiveState.INSTALL_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.INSTALL_FAILED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
+         new ServiceComponentHostOpStartedTransition())
+     .addTransition(ServiceComponentHostLiveState.INSTALLED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostLiveState.UNINSTALL_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALL_FAILED,
+         ServiceComponentHostLiveState.UNINSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostLiveState.INSTALLING,
+         ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
+         new ServiceComponentHostOpStartedTransition())
+
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+         new ServiceComponentHostOpInProgressTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.INIT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostLiveState.WIPEOUT_FAILED,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+         new ServiceComponentHostOpCompletedTransition())
+     .addTransition(ServiceComponentHostLiveState.WIPEOUT_FAILED,
+         ServiceComponentHostLiveState.WIPING_OUT,
+         ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+         new ServiceComponentHostOpStartedTransition())
+
+     .installTopology();
+
+
+  private final StateMachine<ServiceComponentHostLiveState,
+      ServiceComponentHostEventType, ServiceComponentHostEvent> stateMachine;
+
+  static class ServiceComponentHostOpCompletedTransition
+     implements SingleArcTransition<ServiceComponentHostImpl,
+         ServiceComponentHostEvent> {
+
+    @Override
+    public void transition(ServiceComponentHostImpl impl,
+        ServiceComponentHostEvent event) {
+      // TODO Audit logs
+      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
+    }
+
+  }
+
+  static class ServiceComponentHostOpStartedTransition
+    implements SingleArcTransition<ServiceComponentHostImpl,
+        ServiceComponentHostEvent> {
+
+    @Override
+    public void transition(ServiceComponentHostImpl impl,
+        ServiceComponentHostEvent event) {
+      // TODO Audit logs
+      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
+    }
+  }
+
+  static class ServiceComponentHostOpInProgressTransition
+    implements SingleArcTransition<ServiceComponentHostImpl,
+        ServiceComponentHostEvent> {
+
+    @Override
+    public void transition(ServiceComponentHostImpl impl,
+        ServiceComponentHostEvent event) {
+      // TODO Audit logs
+      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
+    }
+  }
+
+
+  private void resetLastOpInfo() {
+    try {
+      writeLock.lock();
+      setLastOpStartTime(-1);
+      setLastOpLastUpdateTime(-1);
+      setLastOpEndTime(-1);
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+  private void updateLastOpInfo(ServiceComponentHostEventType eventType,
+      long time) {
+    try {
+      writeLock.lock();
+      switch (eventType) {
+        case HOST_SVCCOMP_INSTALL:
+        case HOST_SVCCOMP_START:
+        case HOST_SVCCOMP_STOP:
+        case HOST_SVCCOMP_UNINSTALL:
+        case HOST_SVCCOMP_WIPEOUT:
+        case HOST_SVCCOMP_OP_RESTART:
+          resetLastOpInfo();
+          setLastOpStartTime(time);
+          break;
+        case HOST_SVCCOMP_OP_FAILED:
+        case HOST_SVCCOMP_OP_SUCCEEDED:
+          setLastOpLastUpdateTime(time);
+          setLastOpEndTime(time);
+          break;
+        case HOST_SVCCOMP_OP_IN_PROGRESS:
+          setLastOpLastUpdateTime(time);
+          break;
+      }
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+  public ServiceComponentHostImpl(String serviceComponentName,
+      String hostName, boolean isClient) {
+    super();
+    if (isClient) {
+      this.stateMachine = clientStateMachineFactory.make(this);
+    } else {
+      this.stateMachine = daemonStateMachineFactory.make(this);
+    }
+    ReadWriteLock rwLock = new ReentrantReadWriteLock();
+    this.readLock = rwLock.readLock();
+    this.writeLock = rwLock.writeLock();
+    this.serviceComponentName = serviceComponentName;
+    this.hostName = hostName;
+    this.state = new ServiceComponentHostState();
+    this.resetLastOpInfo();
+  }
+
+  @Override
+  public ServiceComponentHostState getState() {
+    try {
+      readLock.lock();
+      return state;
+    }
+    finally {
+      readLock.unlock();
+    }
+  }
+
+  @Override
+  public void setState(ServiceComponentHostState state) {
+    try {
+      writeLock.lock();
+      this.state = state;
+      stateMachine.setCurrentState(state.getLiveState());
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+  @Override
+  public void handleEvent(ServiceComponentHostEvent event)
+      throws InvalidStateTransitonException {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Handling ServiceComponentHostEvent event,"
+          + " eventType=" + event.getType().name()
+          + ", event=" + event.toString());
+    }
+    ServiceComponentHostState oldState = getState();
+    try {
+      writeLock.lock();
+      try {
+        stateMachine.doTransition(event.getType(), event);
+        state.setState(stateMachine.getCurrentState());
+        // TODO Audit logs
+      } catch (InvalidStateTransitonException e) {
+        LOG.error("Can't handle ServiceComponentHostEvent event at"
+            + " current state"
+            + ", serviceComponentName=" + this.getServiceComponentName()
+            + ", hostName=" + this.getHostName()
+            + ", currentState=" + oldState
+            + ", eventType=" + event.getType()
+            + ", event=" + event);
+        throw e;
+      }
+    }
+    finally {
+      writeLock.unlock();
+    }
+    if (oldState.getLiveState() != getState().getLiveState()) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("ServiceComponentHost transitioned to a new state"
+            + ", serviceComponentName=" + this.getServiceComponentName()
+            + ", hostName=" + this.getHostName()
+            + ", oldState=" + oldState
+            + ", currentState=" + getState()
+            + ", eventType=" + event.getType().name()
+            + ", event=" + event);
+      }
+    }
+  }
+
+  @Override
+  public List<Job> getJobs() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public String getServiceComponentName() {
+    return serviceComponentName;
+  }
+
+  @Override
+  public String getHostName() {
+    return hostName;
+  }
+
+  /**
+   * @return the lastOpStartTime
+   */
+  public long getLastOpStartTime() {
+    try {
+      readLock.lock();
+      return lastOpStartTime;
+    }
+    finally {
+      readLock.unlock();
+    }
+  }
+
+  /**
+   * @param lastOpStartTime the lastOpStartTime to set
+   */
+  public void setLastOpStartTime(long lastOpStartTime) {
+    try {
+      writeLock.lock();
+      this.lastOpStartTime = lastOpStartTime;
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+  /**
+   * @return the lastOpEndTime
+   */
+  public long getLastOpEndTime() {
+    try {
+      readLock.lock();
+      return lastOpEndTime;
+    }
+    finally {
+      readLock.unlock();
+    }
+  }
+
+  /**
+   * @param lastOpEndTime the lastOpEndTime to set
+   */
+  public void setLastOpEndTime(long lastOpEndTime) {
+    try {
+      writeLock.lock();
+      this.lastOpEndTime = lastOpEndTime;
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+  /**
+   * @return the lastOpLastUpdateTime
+   */
+  public long getLastOpLastUpdateTime() {
+    try {
+      readLock.lock();
+      return lastOpLastUpdateTime;
+    }
+    finally {
+      readLock.unlock();
+    }
+  }
+
+  /**
+   * @param lastOpLastUpdateTime the lastOpLastUpdateTime to set
+   */
+  public void setLastOpLastUpdateTime(long lastOpLastUpdateTime) {
+    try {
+      writeLock.lock();
+      this.lastOpLastUpdateTime = lastOpLastUpdateTime;
+    }
+    finally {
+      writeLock.unlock();
+    }
+  }
+
+}

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeInstallEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostInstallEvent.java

@@ -18,14 +18,14 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeInstallEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostInstallEvent extends
+    ServiceComponentHostEvent {
 
 
 
 
-  public ServiceComponentNodeInstallEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostInstallEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+        serviceComponentName, hostName, opTimestamp);
   }
   }
 
 
 }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeLiveState.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostLiveState.java

@@ -18,7 +18,7 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public enum ServiceComponentNodeLiveState {
+public enum ServiceComponentHostLiveState {
   /**
   /**
    * Initial/Clean state
    * Initial/Clean state
    */
    */

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeOpFailedEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpFailedEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeOpFailedEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostOpFailedEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeOpFailedEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostOpFailedEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 }
 }

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeOpInProgressEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpInProgressEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeOpInProgressEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostOpInProgressEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeOpInProgressEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostOpInProgressEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeOpRestartedEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpRestartedEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeOpRestartedEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostOpRestartedEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeOpRestartedEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostOpRestartedEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeOpSucceededEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostOpSucceededEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeOpSucceededEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostOpSucceededEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeOpSucceededEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostOpSucceededEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeStartEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostStartEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeStartEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostStartEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeStartEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_START,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostStartEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_START,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 8 - 8
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeState.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostState.java

@@ -21,25 +21,25 @@ package org.apache.ambari.server.state.live;
 import org.apache.ambari.server.state.ConfigVersion;
 import org.apache.ambari.server.state.ConfigVersion;
 import org.apache.ambari.server.state.StackVersion;
 import org.apache.ambari.server.state.StackVersion;
 
 
-public class ServiceComponentNodeState {
+public class ServiceComponentHostState {
 
 
   private ConfigVersion configVersion;
   private ConfigVersion configVersion;
   private StackVersion stackVersion;
   private StackVersion stackVersion;
-  private ServiceComponentNodeLiveState state;
+  private ServiceComponentHostLiveState state;
 
 
-  public ServiceComponentNodeState(ConfigVersion configVersion,
-      StackVersion stackVersion, ServiceComponentNodeLiveState state) {
+  public ServiceComponentHostState(ConfigVersion configVersion,
+      StackVersion stackVersion, ServiceComponentHostLiveState state) {
     super();
     super();
     this.configVersion = configVersion;
     this.configVersion = configVersion;
     this.stackVersion = stackVersion;
     this.stackVersion = stackVersion;
     this.state = state;
     this.state = state;
   }
   }
 
 
-  public ServiceComponentNodeState() {
+  public ServiceComponentHostState() {
     super();
     super();
     this.configVersion = null;
     this.configVersion = null;
     this.stackVersion = null;
     this.stackVersion = null;
-    this.state = ServiceComponentNodeLiveState.INIT;
+    this.state = ServiceComponentHostLiveState.INIT;
   }
   }
 
 
 
 
@@ -70,13 +70,13 @@ public class ServiceComponentNodeState {
   /**
   /**
    * @return the state
    * @return the state
    */
    */
-  public ServiceComponentNodeLiveState getLiveState() {
+  public ServiceComponentHostLiveState getLiveState() {
     return state;
     return state;
   }
   }
   /**
   /**
    * @param state the state to set
    * @param state the state to set
    */
    */
-  public void setState(ServiceComponentNodeLiveState state) {
+  public void setState(ServiceComponentHostLiveState state) {
     this.state = state;
     this.state = state;
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeStopEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostStopEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeStopEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostStopEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeStopEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_STOP,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostStopEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_STOP,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeUninstallEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostUninstallEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeUninstallEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostUninstallEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeUninstallEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostUninstallEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 6 - 6
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeWipeoutEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentHostWipeoutEvent.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.ambari.server.state.live;
 package org.apache.ambari.server.state.live;
 
 
-public class ServiceComponentNodeWipeoutEvent extends
-    ServiceComponentNodeEvent {
+public class ServiceComponentHostWipeoutEvent extends
+    ServiceComponentHostEvent {
 
 
-  public ServiceComponentNodeWipeoutEvent(String serviceComponentName,
-      String nodeName, long opTimestamp) {
-    super(ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT,
-        serviceComponentName, nodeName, opTimestamp);
+  public ServiceComponentHostWipeoutEvent(String serviceComponentName,
+      String hostName, long opTimestamp) {
+    super(ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
+        serviceComponentName, hostName, opTimestamp);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }
 
 

+ 0 - 536
ambari-server/src/main/java/org/apache/ambari/server/state/live/ServiceComponentNodeImpl.java

@@ -1,536 +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;
-
-import java.util.List;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-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.job.Job;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class ServiceComponentNodeImpl implements ServiceComponentNode {
-
-  private static final Log LOG =
-      LogFactory.getLog(ServiceComponentNodeImpl.class);
-
-  private final Lock readLock;
-  private final Lock writeLock;
-
-  private ServiceComponentNodeState state;
-
-  private final String serviceComponentName;
-  private final String hostName;
-
-  private long lastOpStartTime;
-  private long lastOpEndTime;
-  private long lastOpLastUpdateTime;
-
-  private static final StateMachineFactory
-  <ServiceComponentNodeImpl, ServiceComponentNodeLiveState,
-  ServiceComponentNodeEventType, ServiceComponentNodeEvent>
-    daemonStateMachineFactory
-      = new StateMachineFactory<ServiceComponentNodeImpl,
-          ServiceComponentNodeLiveState, ServiceComponentNodeEventType,
-          ServiceComponentNodeEvent>
-          (ServiceComponentNodeLiveState.INIT)
-
-  // define the state machine of a NodeServiceComponent for runnable
-  // components
-
-     .addTransition(ServiceComponentNodeLiveState.INIT,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALL_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.INSTALL_FAILED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_START,
-         new ServiceComponentNodeOpStartedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeLiveState.STARTED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeLiveState.START_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.START_FAILED,
-         ServiceComponentNodeLiveState.STARTING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.STARTED,
-         ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_STOP,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeLiveState.STOP_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.STOP_FAILED,
-         ServiceComponentNodeLiveState.STOPPING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.INIT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .installTopology();
-
-  private static final StateMachineFactory
-  <ServiceComponentNodeImpl, ServiceComponentNodeLiveState,
-  ServiceComponentNodeEventType, ServiceComponentNodeEvent>
-    clientStateMachineFactory
-      = new StateMachineFactory<ServiceComponentNodeImpl,
-          ServiceComponentNodeLiveState, ServiceComponentNodeEventType,
-          ServiceComponentNodeEvent>
-          (ServiceComponentNodeLiveState.INIT)
-
-  // define the state machine of a NodeServiceComponent for client only
-  // components
-
-     .addTransition(ServiceComponentNodeLiveState.INIT,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeLiveState.INSTALL_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.INSTALL_FAILED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-     .addTransition(ServiceComponentNodeLiveState.INSTALLED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-         ServiceComponentNodeLiveState.UNINSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeLiveState.INSTALLING,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.UNINSTALLED,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS,
-         new ServiceComponentNodeOpInProgressTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.INIT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED,
-         new ServiceComponentNodeOpCompletedTransition())
-     .addTransition(ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-         ServiceComponentNodeLiveState.WIPING_OUT,
-         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART,
-         new ServiceComponentNodeOpStartedTransition())
-
-     .installTopology();
-
-
-  private final StateMachine<ServiceComponentNodeLiveState,
-      ServiceComponentNodeEventType, ServiceComponentNodeEvent> stateMachine;
-
-  static class ServiceComponentNodeOpCompletedTransition
-     implements SingleArcTransition<ServiceComponentNodeImpl,
-         ServiceComponentNodeEvent> {
-
-    @Override
-    public void transition(ServiceComponentNodeImpl impl,
-        ServiceComponentNodeEvent event) {
-      // TODO Audit logs
-      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
-    }
-
-  }
-
-  static class ServiceComponentNodeOpStartedTransition
-    implements SingleArcTransition<ServiceComponentNodeImpl,
-        ServiceComponentNodeEvent> {
-
-    @Override
-    public void transition(ServiceComponentNodeImpl impl,
-        ServiceComponentNodeEvent event) {
-      // TODO Audit logs
-      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
-    }
-  }
-
-  static class ServiceComponentNodeOpInProgressTransition
-    implements SingleArcTransition<ServiceComponentNodeImpl,
-        ServiceComponentNodeEvent> {
-
-    @Override
-    public void transition(ServiceComponentNodeImpl impl,
-        ServiceComponentNodeEvent event) {
-      // TODO Audit logs
-      impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
-    }
-  }
-
-
-  private void resetLastOpInfo() {
-    try {
-      writeLock.lock();
-      setLastOpStartTime(-1);
-      setLastOpLastUpdateTime(-1);
-      setLastOpEndTime(-1);
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-  private void updateLastOpInfo(ServiceComponentNodeEventType eventType,
-      long time) {
-    try {
-      writeLock.lock();
-      switch (eventType) {
-        case NODE_SVCCOMP_INSTALL:
-        case NODE_SVCCOMP_START:
-        case NODE_SVCCOMP_STOP:
-        case NODE_SVCCOMP_UNINSTALL:
-        case NODE_SVCCOMP_WIPEOUT:
-        case NODE_SVCCOMP_OP_RESTART:
-          resetLastOpInfo();
-          setLastOpStartTime(time);
-          break;
-        case NODE_SVCCOMP_OP_FAILED:
-        case NODE_SVCCOMP_OP_SUCCEEDED:
-          setLastOpLastUpdateTime(time);
-          setLastOpEndTime(time);
-          break;
-        case NODE_SVCCOMP_OP_IN_PROGRESS:
-          setLastOpLastUpdateTime(time);
-          break;
-      }
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-  public ServiceComponentNodeImpl(String serviceComponentName,
-      String hostName, boolean isClient) {
-    super();
-    if (isClient) {
-      this.stateMachine = clientStateMachineFactory.make(this);
-    } else {
-      this.stateMachine = daemonStateMachineFactory.make(this);
-    }
-    ReadWriteLock rwLock = new ReentrantReadWriteLock();
-    this.readLock = rwLock.readLock();
-    this.writeLock = rwLock.writeLock();
-    this.serviceComponentName = serviceComponentName;
-    this.hostName = hostName;
-    this.state = new ServiceComponentNodeState();
-    this.resetLastOpInfo();
-  }
-
-  @Override
-  public ServiceComponentNodeState getState() {
-    try {
-      readLock.lock();
-      return state;
-    }
-    finally {
-      readLock.unlock();
-    }
-  }
-
-  @Override
-  public void setState(ServiceComponentNodeState state) {
-    try {
-      writeLock.lock();
-      this.state = state;
-      stateMachine.setCurrentState(state.getLiveState());
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-  @Override
-  public void handleEvent(ServiceComponentNodeEvent event)
-      throws InvalidStateTransitonException {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Handling ServiceComponentNodeEvent event,"
-          + " eventType=" + event.getType().name()
-          + ", event=" + event.toString());
-    }
-    ServiceComponentNodeState oldState = getState();
-    try {
-      writeLock.lock();
-      try {
-        stateMachine.doTransition(event.getType(), event);
-        state.setState(stateMachine.getCurrentState());
-        // TODO Audit logs
-      } catch (InvalidStateTransitonException e) {
-        LOG.error("Can't handle ServiceComponentNodeEvent event at"
-            + " current state"
-            + ", serviceComponentName=" + this.getServiceComponentName()
-            + ", hostName=" + this.getNodeName()
-            + ", currentState=" + oldState
-            + ", eventType=" + event.getType()
-            + ", event=" + event);
-        throw e;
-      }
-    }
-    finally {
-      writeLock.unlock();
-    }
-    if (oldState.getLiveState() != getState().getLiveState()) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("ServiceComponentNode transitioned to a new state"
-            + ", serviceComponentName=" + this.getServiceComponentName()
-            + ", hostName=" + this.getNodeName()
-            + ", oldState=" + oldState
-            + ", currentState=" + getState()
-            + ", eventType=" + event.getType().name()
-            + ", event=" + event);
-      }
-    }
-  }
-
-  @Override
-  public List<Job> getJobs() {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public String getServiceComponentName() {
-    return serviceComponentName;
-  }
-
-  @Override
-  public String getNodeName() {
-    return hostName;
-  }
-
-  /**
-   * @return the lastOpStartTime
-   */
-  public long getLastOpStartTime() {
-    try {
-      readLock.lock();
-      return lastOpStartTime;
-    }
-    finally {
-      readLock.unlock();
-    }
-  }
-
-  /**
-   * @param lastOpStartTime the lastOpStartTime to set
-   */
-  public void setLastOpStartTime(long lastOpStartTime) {
-    try {
-      writeLock.lock();
-      this.lastOpStartTime = lastOpStartTime;
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-  /**
-   * @return the lastOpEndTime
-   */
-  public long getLastOpEndTime() {
-    try {
-      readLock.lock();
-      return lastOpEndTime;
-    }
-    finally {
-      readLock.unlock();
-    }
-  }
-
-  /**
-   * @param lastOpEndTime the lastOpEndTime to set
-   */
-  public void setLastOpEndTime(long lastOpEndTime) {
-    try {
-      writeLock.lock();
-      this.lastOpEndTime = lastOpEndTime;
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-  /**
-   * @return the lastOpLastUpdateTime
-   */
-  public long getLastOpLastUpdateTime() {
-    try {
-      readLock.lock();
-      return lastOpLastUpdateTime;
-    }
-    finally {
-      readLock.unlock();
-    }
-  }
-
-  /**
-   * @param lastOpLastUpdateTime the lastOpLastUpdateTime to set
-   */
-  public void setLastOpLastUpdateTime(long lastOpLastUpdateTime) {
-    try {
-      writeLock.lock();
-      this.lastOpLastUpdateTime = lastOpLastUpdateTime;
-    }
-    finally {
-      writeLock.unlock();
-    }
-  }
-
-}

+ 25 - 25
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/Node.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/Host.java

@@ -16,7 +16,7 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -26,7 +26,7 @@ import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.job.Job;
 import org.apache.ambari.server.state.live.job.Job;
 
 
-public interface Node {
+public interface Host {
 
 
   /**
   /**
    * @return the hostName
    * @return the hostName
@@ -39,7 +39,7 @@ public interface Node {
   public void setHostName(String hostName);
   public void setHostName(String hostName);
 
 
   /**
   /**
-   * IPv4 assigned to the Node
+   * IPv4 assigned to the Host
    * @return the ip or null if no IPv4 interface
    * @return the ip or null if no IPv4 interface
    */
    */
   public String getIPv4();
   public String getIPv4();
@@ -50,7 +50,7 @@ public interface Node {
   public void setIPv4(String ip);
   public void setIPv4(String ip);
 
 
   /**
   /**
-   * IPv6 assigned to the Node
+   * IPv6 assigned to the Host
    * @return the ip or null if no IPv6 interface
    * @return the ip or null if no IPv6 interface
    */
    */
   public String getIPv6();
   public String getIPv6();
@@ -71,28 +71,28 @@ public interface Node {
   public void setCpuCount(int cpuCount);
   public void setCpuCount(int cpuCount);
 
 
   /**
   /**
-   * Get the Amount of physical memory for the Node.
+   * Get the Amount of physical memory for the Host.
    * @return the totalMemBytes
    * @return the totalMemBytes
    */
    */
   public long getTotalMemBytes();
   public long getTotalMemBytes();
 
 
   /**
   /**
-   * Set the Amount of physical memory for the Node.
+   * Set the Amount of physical memory for the Host.
    * @param totalMemBytes the totalMemBytes to set
    * @param totalMemBytes the totalMemBytes to set
    */
    */
   public void setTotalMemBytes(long totalMemBytes);
   public void setTotalMemBytes(long totalMemBytes);
 
 
   /**
   /**
-   * Get the Amount of available memory for the Node.
+   * Get the Amount of available memory for the Host.
    * In most cases, available should be same as total unless
    * In most cases, available should be same as total unless
-   * the agent on the node is configured to not use all
+   * the agent on the host is configured to not use all
    * available memory
    * available memory
    * @return the availableMemBytes
    * @return the availableMemBytes
    */
    */
   public long getAvailableMemBytes();
   public long getAvailableMemBytes();
 
 
   /**
   /**
-   * Set the Amount of available memory for the Node.
+   * Set the Amount of available memory for the Host.
    * @param availableMemBytes the availableMemBytes to set
    * @param availableMemBytes the availableMemBytes to set
    */
    */
   public void setAvailableMemBytes(long availableMemBytes);
   public void setAvailableMemBytes(long availableMemBytes);
@@ -134,7 +134,7 @@ public interface Node {
   public void setOsType(String osType);
   public void setOsType(String osType);
 
 
   /**
   /**
-   * Get information on disks available on the node.
+   * Get information on disks available on the host.
    * @return the disksInfo
    * @return the disksInfo
    */
    */
   public List<DiskInfo> getDisksInfo();
   public List<DiskInfo> getDisksInfo();
@@ -147,12 +147,12 @@ public interface Node {
   /**
   /**
    * @return the healthStatus
    * @return the healthStatus
    */
    */
-  public NodeHealthStatus getHealthStatus();
+  public HostHealthStatus getHealthStatus();
 
 
   /**
   /**
    * @param healthStatus the healthStatus to set
    * @param healthStatus the healthStatus to set
    */
    */
-  public void setHealthStatus(NodeHealthStatus healthStatus);
+  public void setHealthStatus(HostHealthStatus healthStatus);
 
 
   /**
   /**
    * Get additional host attributes
    * Get additional host attributes
@@ -176,7 +176,7 @@ public interface Node {
   public void setRackInfo(String rackInfo);
   public void setRackInfo(String rackInfo);
 
 
   /**
   /**
-   * Last time the node registered with the Ambari Server
+   * Last time the host registered with the Ambari Server
    * ( Unix timestamp )
    * ( Unix timestamp )
    * @return the lastRegistrationTime
    * @return the lastRegistrationTime
    */
    */
@@ -188,7 +188,7 @@ public interface Node {
   public void setLastRegistrationTime(long lastRegistrationTime);
   public void setLastRegistrationTime(long lastRegistrationTime);
 
 
   /**
   /**
-   * Last time the Ambari Server received a heartbeat from the Node
+   * Last time the Ambari Server received a heartbeat from the Host
    * ( Unix timestamp )
    * ( Unix timestamp )
    * @return the lastHeartbeatTime
    * @return the lastHeartbeatTime
    */
    */
@@ -200,7 +200,7 @@ public interface Node {
   public void setLastHeartbeatTime(long lastHeartbeatTime);
   public void setLastHeartbeatTime(long lastHeartbeatTime);
 
 
   /**
   /**
-   * Version of the Ambari Agent running on the node
+   * Version of the Ambari Agent running on the host
    * @return the agentVersion
    * @return the agentVersion
    */
    */
   public AgentVersion getAgentVersion();
   public AgentVersion getAgentVersion();
@@ -212,28 +212,28 @@ public interface Node {
 
 
   /**
   /**
    * Get the list of Jobs that are currently being tracked at the
    * Get the list of Jobs that are currently being tracked at the
-   * Node level
+   * Host level
    * @return List of Jobs
    * @return List of Jobs
    */
    */
   public List<Job> getJobs();
   public List<Job> getJobs();
 
 
   /**
   /**
-   * Get Current Node State
-   * @return NodeState
+   * Get Current Host State
+   * @return HostState
    */
    */
-  public NodeState getState();
+  public HostState getState();
 
 
   /**
   /**
-   * Set the State of the Node
-   * @param state Node State
+   * Set the State of the Host
+   * @param state Host State
    */
    */
-  public void setState(NodeState state);
+  public void setState(HostState state);
 
 
   /**
   /**
-   * Send an event to the Node's StateMachine
-   * @param event NodeEvent
+   * Send an event to the Host's StateMachine
+   * @param event HostEvent
    * @throws InvalidStateTransitonException
    * @throws InvalidStateTransitonException
    */
    */
-  public void handleEvent(NodeEvent event)
+  public void handleEvent(HostEvent event)
       throws InvalidStateTransitonException;
       throws InvalidStateTransitonException;
 }
 }

+ 7 - 7
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostEvent.java

@@ -16,23 +16,23 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 import org.apache.ambari.server.state.fsm.event.AbstractEvent;
 
 
 /**
 /**
- * Base class for all events that affect the Node FSM
+ * Base class for all events that affect the Host FSM
  */
  */
-public class NodeEvent extends AbstractEvent<NodeEventType> {
+public class HostEvent extends AbstractEvent<HostEventType> {
 
 
   /**
   /**
-   * Hostname of the Node
+   * Hostname of the Host
    */
    */
-  final String nodeName;
+  final String hostName;
 
 
-  public NodeEvent(String nodeName, NodeEventType type) {
+  public HostEvent(String hostName, HostEventType type) {
     super(type);
     super(type);
-    this.nodeName = nodeName;
+    this.hostName = hostName;
   }
   }
 
 
 }
 }

+ 12 - 12
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeEventType.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostEventType.java

@@ -16,27 +16,27 @@
 * limitations under the License.
 * limitations under the License.
 */
 */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public enum NodeEventType {
+public enum HostEventType {
   /**
   /**
-   * Event to denote when a registration request is received from a Node
+   * Event to denote when a registration request is received from a Host
    */
    */
-  NODE_REGISTRATION_REQUEST,
+  HOST_REGISTRATION_REQUEST,
   /**
   /**
-   * Node authenticated/verified.
+   * Host authenticated/verified.
    */
    */
-  NODE_VERIFIED,
+  HOST_VERIFIED,
   /**
   /**
-   * A healthy heartbeat event received from the Node.
+   * A healthy heartbeat event received from the Host.
    */
    */
-  NODE_HEARTBEAT_HEALTHY,
+  HOST_HEARTBEAT_HEALTHY,
   /**
   /**
-   * No heartbeat received from the Node within the defined expiry interval.
+   * No heartbeat received from the Host within the defined expiry interval.
    */
    */
-  NODE_HEARTBEAT_TIMED_OUT,
+  HOST_HEARTBEAT_TIMED_OUT,
   /**
   /**
-   * A non-healthy heartbeat event received from the Node.
+   * A non-healthy heartbeat event received from the Host.
    */
    */
-  NODE_HEARTBEAT_UNHEALTHY
+  HOST_HEARTBEAT_UNHEALTHY
 }
 }

+ 3 - 3
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthStatus.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHealthStatus.java

@@ -16,15 +16,15 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public class NodeHealthStatus {
+public class HostHealthStatus {
 
 
   private HealthStatus healthStatus;
   private HealthStatus healthStatus;
 
 
   private String healthReport;
   private String healthReport;
 
 
-  public NodeHealthStatus(HealthStatus healthStatus, String healthReport) {
+  public HostHealthStatus(HealthStatus healthStatus, String healthReport) {
     super();
     super();
     this.healthStatus = healthStatus;
     this.healthStatus = healthStatus;
     this.healthReport = healthReport;
     this.healthReport = healthReport;

+ 4 - 4
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHealthyHeartbeatEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHealthyHeartbeatEvent.java

@@ -17,14 +17,14 @@
  */
  */
 
 
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public class NodeHealthyHeartbeatEvent extends NodeEvent {
+public class HostHealthyHeartbeatEvent extends HostEvent {
 
 
   private final long heartbeatTime;
   private final long heartbeatTime;
 
 
-  public NodeHealthyHeartbeatEvent(String nodeName, long heartbeatTime) {
-    super(nodeName, NodeEventType.NODE_HEARTBEAT_HEALTHY);
+  public HostHealthyHeartbeatEvent(String hostName, long heartbeatTime) {
+    super(hostName, HostEventType.HOST_HEARTBEAT_HEALTHY);
     this.heartbeatTime = heartbeatTime;
     this.heartbeatTime = heartbeatTime;
   }
   }
 
 

+ 4 - 4
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeHeartbeatTimedOutEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostHeartbeatTimedOutEvent.java

@@ -17,12 +17,12 @@
  */
  */
 
 
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public class NodeHeartbeatTimedOutEvent extends NodeEvent {
+public class HostHeartbeatTimedOutEvent extends HostEvent {
 
 
-  public NodeHeartbeatTimedOutEvent(String nodeName) {
-    super(nodeName, NodeEventType.NODE_HEARTBEAT_TIMED_OUT);
+  public HostHeartbeatTimedOutEvent(String hostName) {
+    super(hostName, HostEventType.HOST_HEARTBEAT_TIMED_OUT);
   }
   }
 
 
 }
 }

+ 130 - 130
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeImpl.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java

@@ -17,7 +17,7 @@
  */
  */
 
 
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
@@ -34,34 +34,34 @@ import org.apache.ambari.server.state.fsm.StateMachine;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.job.Job;
 import org.apache.ambari.server.state.live.job.Job;
-import org.apache.ambari.server.state.live.node.NodeHealthStatus.HealthStatus;
+import org.apache.ambari.server.state.live.host.HostHealthStatus.HealthStatus;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.LogFactory;
 
 
-public class NodeImpl implements Node {
+public class HostImpl implements Host {
 
 
-  private static final Log LOG = LogFactory.getLog(NodeImpl.class);
+  private static final Log LOG = LogFactory.getLog(HostImpl.class);
 
 
   private final Lock readLock;
   private final Lock readLock;
   private final Lock writeLock;
   private final Lock writeLock;
 
 
   /**
   /**
-   * Node hostname
+   * Host hostname
    */
    */
   private String hostName;
   private String hostName;
 
 
   /**
   /**
-   * Node IP if ipv4 interface available
+   * Host IP if ipv4 interface available
    */
    */
   private String ipv4;
   private String ipv4;
 
 
   /**
   /**
-   * Node IP if ipv6 interface available
+   * Host IP if ipv6 interface available
    */
    */
   private String ipv6;
   private String ipv6;
 
 
   /**
   /**
-   * Count of cores on Node
+   * Count of cores on Host
    */
    */
   private int cpuCount;
   private int cpuCount;
 
 
@@ -81,168 +81,168 @@ public class NodeImpl implements Node {
   private String osInfo;
   private String osInfo;
 
 
   /**
   /**
-   * Amount of available memory for the Node
+   * Amount of available memory for the Host
    */
    */
   private long availableMemBytes;
   private long availableMemBytes;
 
 
   /**
   /**
-   * Amount of physical memory for the Node
+   * Amount of physical memory for the Host
    */
    */
   private long totalMemBytes;
   private long totalMemBytes;
 
 
   /**
   /**
-   * Disks mounted on the Node
+   * Disks mounted on the Host
    */
    */
   private List<DiskInfo> disksInfo;
   private List<DiskInfo> disksInfo;
 
 
   /**
   /**
-   * Last heartbeat timestamp from the Node
+   * Last heartbeat timestamp from the Host
    */
    */
   private long lastHeartbeatTime;
   private long lastHeartbeatTime;
 
 
   /**
   /**
-   * Last registration timestamp for the Node
+   * Last registration timestamp for the Host
    */
    */
   private long lastRegistrationTime;
   private long lastRegistrationTime;
 
 
   /**
   /**
-   * Rack to which the Node belongs to
+   * Rack to which the Host belongs to
    */
    */
   private String rackInfo;
   private String rackInfo;
 
 
   /**
   /**
-   * Additional Node attributes
+   * Additional Host attributes
    */
    */
   private Map<String, String> hostAttributes;
   private Map<String, String> hostAttributes;
 
 
   /**
   /**
-   * Version of agent running on the Node
+   * Version of agent running on the Host
    */
    */
   private AgentVersion agentVersion;
   private AgentVersion agentVersion;
 
 
   /**
   /**
-   * Node Health Status
+   * Host Health Status
    */
    */
-  private NodeHealthStatus healthStatus;
+  private HostHealthStatus healthStatus;
 
 
   private static final StateMachineFactory
   private static final StateMachineFactory
-    <NodeImpl, NodeState, NodeEventType, NodeEvent>
+    <HostImpl, HostState, HostEventType, HostEvent>
       stateMachineFactory
       stateMachineFactory
-        = new StateMachineFactory<NodeImpl, NodeState, NodeEventType, NodeEvent>
-        (NodeState.INIT)
+        = new StateMachineFactory<HostImpl, HostState, HostEventType, HostEvent>
+        (HostState.INIT)
 
 
-   // define the state machine of a Node
+   // define the state machine of a Host
 
 
    // Transition from INIT state
    // Transition from INIT state
    // when the initial registration request is received
    // when the initial registration request is received
-   .addTransition(NodeState.INIT, NodeState.WAITING_FOR_VERIFICATION,
-       NodeEventType.NODE_REGISTRATION_REQUEST, new NodeRegistrationReceived())
+   .addTransition(HostState.INIT, HostState.WAITING_FOR_VERIFICATION,
+       HostEventType.HOST_REGISTRATION_REQUEST, new HostRegistrationReceived())
 
 
    // Transition from WAITING_FOR_VERIFICATION state
    // Transition from WAITING_FOR_VERIFICATION state
-   // when the node is authenticated
-   .addTransition(NodeState.WAITING_FOR_VERIFICATION, NodeState.VERIFIED,
-       NodeEventType.NODE_VERIFIED, new NodeVerifiedTransition())
+   // when the host is authenticated
+   .addTransition(HostState.WAITING_FOR_VERIFICATION, HostState.VERIFIED,
+       HostEventType.HOST_VERIFIED, new HostVerifiedTransition())
 
 
    // Transitions from VERIFIED state
    // Transitions from VERIFIED state
    // when a normal heartbeat is received
    // when a normal heartbeat is received
-   .addTransition(NodeState.VERIFIED, NodeState.HEALTHY,
-       NodeEventType.NODE_HEARTBEAT_HEALTHY,
-       new NodeBecameHealthyTransition())
+   .addTransition(HostState.VERIFIED, HostState.HEALTHY,
+       HostEventType.HOST_HEARTBEAT_HEALTHY,
+       new HostBecameHealthyTransition())
    // when a heartbeat is not received within the configured timeout period
    // when a heartbeat is not received within the configured timeout period
-   .addTransition(NodeState.VERIFIED, NodeState.HEARTBEAT_LOST,
-       NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
-       new NodeHeartbeatTimedOutTransition())
-   // when a heartbeart denoting node as unhealthy is received
-   .addTransition(NodeState.VERIFIED, NodeState.UNHEALTHY,
-       NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
-       new NodeBecameUnhealthyTransition())
+   .addTransition(HostState.VERIFIED, HostState.HEARTBEAT_LOST,
+       HostEventType.HOST_HEARTBEAT_TIMED_OUT,
+       new HostHeartbeatTimedOutTransition())
+   // when a heartbeart denoting host as unhealthy is received
+   .addTransition(HostState.VERIFIED, HostState.UNHEALTHY,
+       HostEventType.HOST_HEARTBEAT_UNHEALTHY,
+       new HostBecameUnhealthyTransition())
 
 
    // Transitions from HEALTHY state
    // Transitions from HEALTHY state
    // when a normal heartbeat is received
    // when a normal heartbeat is received
-   .addTransition(NodeState.HEALTHY, NodeState.HEALTHY,
-       NodeEventType.NODE_HEARTBEAT_HEALTHY,
-       new NodeHeartbeatReceivedTransition())
+   .addTransition(HostState.HEALTHY, HostState.HEALTHY,
+       HostEventType.HOST_HEARTBEAT_HEALTHY,
+       new HostHeartbeatReceivedTransition())
    // when a heartbeat is not received within the configured timeout period
    // when a heartbeat is not received within the configured timeout period
-   .addTransition(NodeState.HEALTHY, NodeState.HEARTBEAT_LOST,
-       NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
-       new NodeHeartbeatTimedOutTransition())
-   // when a heartbeart denoting node as unhealthy is received
-   .addTransition(NodeState.HEALTHY, NodeState.UNHEALTHY,
-       NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
-       new NodeBecameUnhealthyTransition())
+   .addTransition(HostState.HEALTHY, HostState.HEARTBEAT_LOST,
+       HostEventType.HOST_HEARTBEAT_TIMED_OUT,
+       new HostHeartbeatTimedOutTransition())
+   // when a heartbeart denoting host as unhealthy is received
+   .addTransition(HostState.HEALTHY, HostState.UNHEALTHY,
+       HostEventType.HOST_HEARTBEAT_UNHEALTHY,
+       new HostBecameUnhealthyTransition())
 
 
    // Transitions from UNHEALTHY state
    // Transitions from UNHEALTHY state
    // when a normal heartbeat is received
    // when a normal heartbeat is received
-   .addTransition(NodeState.UNHEALTHY, NodeState.HEALTHY,
-       NodeEventType.NODE_HEARTBEAT_HEALTHY,
-       new NodeBecameHealthyTransition())
-   // when a heartbeart denoting node as unhealthy is received
-   .addTransition(NodeState.UNHEALTHY, NodeState.UNHEALTHY,
-       NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
-       new NodeHeartbeatReceivedTransition())
+   .addTransition(HostState.UNHEALTHY, HostState.HEALTHY,
+       HostEventType.HOST_HEARTBEAT_HEALTHY,
+       new HostBecameHealthyTransition())
+   // when a heartbeart denoting host as unhealthy is received
+   .addTransition(HostState.UNHEALTHY, HostState.UNHEALTHY,
+       HostEventType.HOST_HEARTBEAT_UNHEALTHY,
+       new HostHeartbeatReceivedTransition())
    // when a heartbeat is not received within the configured timeout period
    // when a heartbeat is not received within the configured timeout period
-   .addTransition(NodeState.UNHEALTHY, NodeState.HEARTBEAT_LOST,
-       NodeEventType.NODE_HEARTBEAT_TIMED_OUT,
-       new NodeHeartbeatTimedOutTransition())
+   .addTransition(HostState.UNHEALTHY, HostState.HEARTBEAT_LOST,
+       HostEventType.HOST_HEARTBEAT_TIMED_OUT,
+       new HostHeartbeatTimedOutTransition())
 
 
    // Transitions from HEARTBEAT_LOST state
    // Transitions from HEARTBEAT_LOST state
    // when a normal heartbeat is received
    // when a normal heartbeat is received
-   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEALTHY,
-       NodeEventType.NODE_HEARTBEAT_HEALTHY,
-       new NodeBecameHealthyTransition())
-   // when a heartbeart denoting node as unhealthy is received
-   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.UNHEALTHY,
-       NodeEventType.NODE_HEARTBEAT_UNHEALTHY,
-       new NodeBecameUnhealthyTransition())
+   .addTransition(HostState.HEARTBEAT_LOST, HostState.HEALTHY,
+       HostEventType.HOST_HEARTBEAT_HEALTHY,
+       new HostBecameHealthyTransition())
+   // when a heartbeart denoting host as unhealthy is received
+   .addTransition(HostState.HEARTBEAT_LOST, HostState.UNHEALTHY,
+       HostEventType.HOST_HEARTBEAT_UNHEALTHY,
+       new HostBecameUnhealthyTransition())
    // when a heartbeat is not received within the configured timeout period
    // when a heartbeat is not received within the configured timeout period
-   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEARTBEAT_LOST,
-       NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
+   .addTransition(HostState.HEARTBEAT_LOST, HostState.HEARTBEAT_LOST,
+       HostEventType.HOST_HEARTBEAT_TIMED_OUT)
    .installTopology();
    .installTopology();
 
 
-  private final StateMachine<NodeState, NodeEventType, NodeEvent> stateMachine;
+  private final StateMachine<HostState, HostEventType, HostEvent> stateMachine;
 
 
-  public NodeImpl() {
+  public HostImpl() {
     super();
     super();
     this.stateMachine = stateMachineFactory.make(this);
     this.stateMachine = stateMachineFactory.make(this);
     ReadWriteLock rwLock = new ReentrantReadWriteLock();
     ReadWriteLock rwLock = new ReentrantReadWriteLock();
     this.readLock = rwLock.readLock();
     this.readLock = rwLock.readLock();
     this.writeLock = rwLock.writeLock();
     this.writeLock = rwLock.writeLock();
-    this.healthStatus = new NodeHealthStatus(HealthStatus.UNKNOWN, "");
+    this.healthStatus = new HostHealthStatus(HealthStatus.UNKNOWN, "");
   }
   }
 
 
-  static class NodeRegistrationReceived
-      implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostRegistrationReceived
+      implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
-      NodeRegistrationRequestEvent e = (NodeRegistrationRequestEvent) event;
-      node.importNodeInfo(e.nodeInfo);
-      node.setLastRegistrationTime(e.registrationTime);
-      node.setAgentVersion(e.agentVersion);
+    public void transition(HostImpl host, HostEvent event) {
+      HostRegistrationRequestEvent e = (HostRegistrationRequestEvent) event;
+      host.importHostInfo(e.hostInfo);
+      host.setLastRegistrationTime(e.registrationTime);
+      host.setAgentVersion(e.agentVersion);
     }
     }
   }
   }
 
 
-  static class NodeVerifiedTransition
-      implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostVerifiedTransition
+      implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
+    public void transition(HostImpl host, HostEvent event) {
       // TODO Auto-generated method stub
       // TODO Auto-generated method stub
     }
     }
   }
   }
 
 
-  static class NodeHeartbeatReceivedTransition
-    implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostHeartbeatReceivedTransition
+    implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
+    public void transition(HostImpl host, HostEvent event) {
       long heartbeatTime = 0;
       long heartbeatTime = 0;
       switch (event.getType()) {
       switch (event.getType()) {
-        case NODE_HEARTBEAT_HEALTHY:
-          heartbeatTime = ((NodeHealthyHeartbeatEvent)event).getHeartbeatTime();
+        case HOST_HEARTBEAT_HEALTHY:
+          heartbeatTime = ((HostHealthyHeartbeatEvent)event).getHeartbeatTime();
           break;
           break;
-        case NODE_HEARTBEAT_UNHEALTHY:
-          heartbeatTime = ((NodeUnhealthyHeartbeatEvent)event).getHeartbeatTime();
+        case HOST_HEARTBEAT_UNHEALTHY:
+          heartbeatTime = ((HostUnhealthyHeartbeatEvent)event).getHeartbeatTime();
           break;
           break;
         default:
         default:
           break;
           break;
@@ -250,65 +250,65 @@ public class NodeImpl implements Node {
       if (0 == heartbeatTime) {
       if (0 == heartbeatTime) {
         // TODO handle error
         // TODO handle error
       }
       }
-      node.setLastHeartbeatTime(heartbeatTime);
+      host.setLastHeartbeatTime(heartbeatTime);
     }
     }
   }
   }
 
 
-  static class NodeBecameHealthyTransition
-      implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostBecameHealthyTransition
+      implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
-      NodeHealthyHeartbeatEvent e = (NodeHealthyHeartbeatEvent) event;
-      node.setLastHeartbeatTime(e.getHeartbeatTime());
+    public void transition(HostImpl host, HostEvent event) {
+      HostHealthyHeartbeatEvent e = (HostHealthyHeartbeatEvent) event;
+      host.setLastHeartbeatTime(e.getHeartbeatTime());
       // TODO Audit logs
       // TODO Audit logs
-      LOG.info("Node transitioned to a healthy state"
-          + ", node=" + e.nodeName
+      LOG.info("Host transitioned to a healthy state"
+          + ", host=" + e.hostName
           + ", heartbeatTime=" + e.getHeartbeatTime());
           + ", heartbeatTime=" + e.getHeartbeatTime());
-      node.getHealthStatus().setHealthStatus(HealthStatus.HEALTHY);
+      host.getHealthStatus().setHealthStatus(HealthStatus.HEALTHY);
     }
     }
   }
   }
 
 
-  static class NodeBecameUnhealthyTransition
-      implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostBecameUnhealthyTransition
+      implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
-      NodeUnhealthyHeartbeatEvent e = (NodeUnhealthyHeartbeatEvent) event;
-      node.setLastHeartbeatTime(e.getHeartbeatTime());
+    public void transition(HostImpl host, HostEvent event) {
+      HostUnhealthyHeartbeatEvent e = (HostUnhealthyHeartbeatEvent) event;
+      host.setLastHeartbeatTime(e.getHeartbeatTime());
       // TODO Audit logs
       // TODO Audit logs
-      LOG.info("Node transitioned to an unhealthy state"
-          + ", node=" + e.nodeName
+      LOG.info("Host transitioned to an unhealthy state"
+          + ", host=" + e.hostName
           + ", heartbeatTime=" + e.getHeartbeatTime()
           + ", heartbeatTime=" + e.getHeartbeatTime()
           + ", healthStatus=" + e.getHealthStatus());
           + ", healthStatus=" + e.getHealthStatus());
-      node.setHealthStatus(e.getHealthStatus());
+      host.setHealthStatus(e.getHealthStatus());
     }
     }
   }
   }
 
 
-  static class NodeHeartbeatTimedOutTransition
-      implements SingleArcTransition<NodeImpl, NodeEvent> {
+  static class HostHeartbeatTimedOutTransition
+      implements SingleArcTransition<HostImpl, HostEvent> {
 
 
     @Override
     @Override
-    public void transition(NodeImpl node, NodeEvent event) {
-      NodeHeartbeatTimedOutEvent e = (NodeHeartbeatTimedOutEvent) event;
+    public void transition(HostImpl host, HostEvent event) {
+      HostHeartbeatTimedOutEvent e = (HostHeartbeatTimedOutEvent) event;
       // TODO Audit logs
       // TODO Audit logs
-      LOG.info("Node transitioned to heartbeat timed out state"
-          + ", node=" + e.nodeName
-          + ", lastHeartbeatTime=" + node.getLastHeartbeatTime());
-      node.getHealthStatus().setHealthStatus(HealthStatus.UNKNOWN);
+      LOG.info("Host transitioned to heartbeat timed out state"
+          + ", host=" + e.hostName
+          + ", lastHeartbeatTime=" + host.getLastHeartbeatTime());
+      host.getHealthStatus().setHealthStatus(HealthStatus.UNKNOWN);
     }
     }
   }
   }
 
 
-  void importNodeInfo(HostInfo nodeInfo) {
+  void importHostInfo(HostInfo hostInfo) {
     try {
     try {
       writeLock.lock();
       writeLock.lock();
-      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();
+      this.hostName = hostInfo.getHostName();
+      this.availableMemBytes = hostInfo.getFreeMemory();
+      this.totalMemBytes = hostInfo.getMemoryTotal();
+      this.cpuCount = hostInfo.getProcessorCount();
+      this.osArch = hostInfo.getArchitecture();
+      this.osType = hostInfo.getOS();
+      this.disksInfo = hostInfo.getMounts();
     }
     }
     finally {
     finally {
       writeLock.unlock();
       writeLock.unlock();
@@ -316,7 +316,7 @@ public class NodeImpl implements Node {
   }
   }
 
 
   @Override
   @Override
-  public NodeState getState() {
+  public HostState getState() {
     try {
     try {
       readLock.lock();
       readLock.lock();
       return stateMachine.getCurrentState();
       return stateMachine.getCurrentState();
@@ -327,7 +327,7 @@ public class NodeImpl implements Node {
   }
   }
 
 
   @Override
   @Override
-  public void setState(NodeState state) {
+  public void setState(HostState state) {
     try {
     try {
       writeLock.lock();
       writeLock.lock();
       stateMachine.setCurrentState(state);
       stateMachine.setCurrentState(state);
@@ -338,20 +338,20 @@ public class NodeImpl implements Node {
   }
   }
 
 
   @Override
   @Override
-  public void handleEvent(NodeEvent event)
+  public void handleEvent(HostEvent event)
       throws InvalidStateTransitonException {
       throws InvalidStateTransitonException {
     if (LOG.isDebugEnabled()) {
     if (LOG.isDebugEnabled()) {
-      LOG.debug("Handling Node event, eventType=" + event.getType().name()
+      LOG.debug("Handling Host event, eventType=" + event.getType().name()
           + ", event=" + event.toString());
           + ", event=" + event.toString());
     }
     }
-    NodeState oldState = getState();
+    HostState oldState = getState();
     try {
     try {
       writeLock.lock();
       writeLock.lock();
       try {
       try {
         stateMachine.doTransition(event.getType(), event);
         stateMachine.doTransition(event.getType(), event);
       } catch (InvalidStateTransitonException e) {
       } catch (InvalidStateTransitonException e) {
-        LOG.error("Can't handle Node event at current state"
-            + ", node=" + this.getHostName()
+        LOG.error("Can't handle Host event at current state"
+            + ", host=" + this.getHostName()
             + ", currentState=" + oldState
             + ", currentState=" + oldState
             + ", eventType=" + event.getType()
             + ", eventType=" + event.getType()
             + ", event=" + event);
             + ", event=" + event);
@@ -363,8 +363,8 @@ public class NodeImpl implements Node {
     }
     }
     if (oldState != getState()) {
     if (oldState != getState()) {
       if (LOG.isDebugEnabled()) {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Node transitioned to a new state"
-            + ", node=" + this.getHostName()
+        LOG.debug("Host transitioned to a new state"
+            + ", host=" + this.getHostName()
             + ", oldState=" + oldState
             + ", oldState=" + oldState
             + ", currentState=" + getState()
             + ", currentState=" + getState()
             + ", eventType=" + event.getType().name()
             + ", eventType=" + event.getType().name()
@@ -594,7 +594,7 @@ public class NodeImpl implements Node {
   }
   }
 
 
   @Override
   @Override
-  public NodeHealthStatus getHealthStatus() {
+  public HostHealthStatus getHealthStatus() {
     try {
     try {
       readLock.lock();
       readLock.lock();
       return healthStatus;
       return healthStatus;
@@ -605,7 +605,7 @@ public class NodeImpl implements Node {
   }
   }
 
 
   @Override
   @Override
-  public void setHealthStatus(NodeHealthStatus healthStatus) {
+  public void setHealthStatus(HostHealthStatus healthStatus) {
     try {
     try {
       writeLock.lock();
       writeLock.lock();
       this.healthStatus = healthStatus;
       this.healthStatus = healthStatus;

+ 7 - 7
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeRegistrationRequestEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java

@@ -16,24 +16,24 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
 import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.AgentVersion;
 
 
-public class NodeRegistrationRequestEvent extends NodeEvent {
+public class HostRegistrationRequestEvent extends HostEvent {
 
 
   final long registrationTime;
   final long registrationTime;
 
 
-  final HostInfo nodeInfo;
+  final HostInfo hostInfo;
 
 
   final AgentVersion agentVersion;
   final AgentVersion agentVersion;
 
 
-  public NodeRegistrationRequestEvent(String nodeName,
-      AgentVersion agentVersion, long registrationTime, HostInfo nodeInfo) {
-    super(nodeName, NodeEventType.NODE_REGISTRATION_REQUEST);
+  public HostRegistrationRequestEvent(String hostName,
+      AgentVersion agentVersion, long registrationTime, HostInfo hostInfo) {
+    super(hostName, HostEventType.HOST_REGISTRATION_REQUEST);
     this.registrationTime = registrationTime;
     this.registrationTime = registrationTime;
-    this.nodeInfo = nodeInfo;
+    this.hostInfo = hostInfo;
     this.agentVersion = agentVersion;
     this.agentVersion = agentVersion;
   }
   }
 
 

+ 10 - 10
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeState.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostState.java

@@ -16,34 +16,34 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public enum NodeState {
+public enum HostState {
   /**
   /**
-   * New node state
+   * New host state
    */
    */
   INIT,
   INIT,
   /**
   /**
-   * State when a registration request is received from the Node but
-   * the node has not been verified/authenticated.
+   * State when a registration request is received from the Host but
+   * the host has not been verified/authenticated.
    */
    */
   WAITING_FOR_VERIFICATION,
   WAITING_FOR_VERIFICATION,
   /**
   /**
-   * State when the node has been verified/authenticated
+   * State when the host has been verified/authenticated
    */
    */
   VERIFIED,
   VERIFIED,
   /**
   /**
-   * State when the server is receiving heartbeats regularly from the Node
-   * and the state of the Node is healthy
+   * State when the server is receiving heartbeats regularly from the Host
+   * and the state of the Host is healthy
    */
    */
   HEALTHY,
   HEALTHY,
   /**
   /**
-   * State when the server has not received a heartbeat from the Node in the
+   * State when the server has not received a heartbeat from the Host in the
    * configured heartbeat expiry window.
    * configured heartbeat expiry window.
    */
    */
   HEARTBEAT_LOST,
   HEARTBEAT_LOST,
   /**
   /**
-   * Node is in unhealthy state as reported either by the Node itself or via
+   * Host is in unhealthy state as reported either by the Host itself or via
    * any other additional means ( monitoring layer )
    * any other additional means ( monitoring layer )
    */
    */
   UNHEALTHY
   UNHEALTHY

+ 7 - 7
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeUnhealthyHeartbeatEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostUnhealthyHeartbeatEvent.java

@@ -16,17 +16,17 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public class NodeUnhealthyHeartbeatEvent extends NodeEvent {
+public class HostUnhealthyHeartbeatEvent extends HostEvent {
 
 
   private final long heartbeatTime;
   private final long heartbeatTime;
 
 
-  private final NodeHealthStatus healthStatus;
+  private final HostHealthStatus healthStatus;
 
 
-  public NodeUnhealthyHeartbeatEvent(String nodeName, long heartbeatTime,
-      NodeHealthStatus healthStatus) {
-    super(nodeName, NodeEventType.NODE_HEARTBEAT_UNHEALTHY);
+  public HostUnhealthyHeartbeatEvent(String hostName, long heartbeatTime,
+      HostHealthStatus healthStatus) {
+    super(hostName, HostEventType.HOST_HEARTBEAT_UNHEALTHY);
     this.heartbeatTime = heartbeatTime;
     this.heartbeatTime = heartbeatTime;
     this.healthStatus = healthStatus;
     this.healthStatus = healthStatus;
   }
   }
@@ -41,7 +41,7 @@ public class NodeUnhealthyHeartbeatEvent extends NodeEvent {
   /**
   /**
    * @return the healthStatus
    * @return the healthStatus
    */
    */
-  public NodeHealthStatus getHealthStatus() {
+  public HostHealthStatus getHealthStatus() {
     return healthStatus;
     return healthStatus;
   }
   }
 
 

+ 4 - 4
ambari-server/src/main/java/org/apache/ambari/server/state/live/node/NodeVerifiedEvent.java → ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostVerifiedEvent.java

@@ -16,14 +16,14 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-package org.apache.ambari.server.state.live.node;
+package org.apache.ambari.server.state.live.host;
 
 
-public class NodeVerifiedEvent extends NodeEvent {
+public class HostVerifiedEvent extends HostEvent {
 
 
   // TODO need to add any additional information required for verification
   // TODO need to add any additional information required for verification
   // tracking
   // tracking
-  public NodeVerifiedEvent(String nodeName) {
-    super(nodeName, NodeEventType.NODE_VERIFIED);
+  public HostVerifiedEvent(String hostName) {
+    super(hostName, HostEventType.HOST_VERIFIED);
   }
   }
 
 
 }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/live/job/Job.java

@@ -31,7 +31,7 @@ public interface Job {
   // TODO requires some form of JobType to ensure only one running
   // TODO requires some form of JobType to ensure only one running
   // job per job type
   // job per job type
   // There may be gotchas such as de-commissioning should be allowed to happen
   // There may be gotchas such as de-commissioning should be allowed to happen
-  // on more than one node at a time
+  // on more than one host at a time
 
 
 
 
   /**
   /**

+ 88 - 88
ambari-server/src/test/java/org/apache/ambari/server/state/live/TestServiceComponentNodeImpl.java → ambari-server/src/test/java/org/apache/ambari/server/state/live/TestServiceComponentHostImpl.java

@@ -21,44 +21,44 @@ package org.apache.ambari.server.state.live;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.Test;
 
 
-public class TestServiceComponentNodeImpl {
+public class TestServiceComponentHostImpl {
 
 
-  private ServiceComponentNodeImpl createNewServiceComponentNode(String svcComponent,
+  private ServiceComponentHostImpl createNewServiceComponentHost(String svcComponent,
       String hostName, boolean isClient) {
       String hostName, boolean isClient) {
-    ServiceComponentNodeImpl impl = new ServiceComponentNodeImpl(svcComponent,
+    ServiceComponentHostImpl impl = new ServiceComponentHostImpl(svcComponent,
         hostName, isClient);
         hostName, isClient);
-    Assert.assertEquals(ServiceComponentNodeLiveState.INIT,
+    Assert.assertEquals(ServiceComponentHostLiveState.INIT,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
     return impl;
     return impl;
   }
   }
 
 
   @Test
   @Test
-  public void testNewServiceComponentNodeImpl() {
-    createNewServiceComponentNode("svcComp", "h1", false);
-    createNewServiceComponentNode("svcComp", "h1", true);
+  public void testNewServiceComponentHostImpl() {
+    createNewServiceComponentHost("svcComp", "h1", false);
+    createNewServiceComponentHost("svcComp", "h1", true);
   }
   }
 
 
-  private ServiceComponentNodeEvent createEvent(ServiceComponentNodeImpl impl,
-      long timestamp, ServiceComponentNodeEventType eventType) {
-    ServiceComponentNodeEvent event = new ServiceComponentNodeEvent(eventType,
-          impl.getServiceComponentName(), impl.getNodeName(), timestamp);
+  private ServiceComponentHostEvent createEvent(ServiceComponentHostImpl impl,
+      long timestamp, ServiceComponentHostEventType eventType) {
+    ServiceComponentHostEvent event = new ServiceComponentHostEvent(eventType,
+          impl.getServiceComponentName(), impl.getHostName(), timestamp);
     return event;
     return event;
   }
   }
 
 
 
 
 
 
-  private void runStateChanges(ServiceComponentNodeImpl impl,
-      ServiceComponentNodeEventType startEvent,
-      ServiceComponentNodeLiveState startState,
-      ServiceComponentNodeLiveState inProgressState,
-      ServiceComponentNodeLiveState failedState,
-      ServiceComponentNodeLiveState completedState)
+  private void runStateChanges(ServiceComponentHostImpl impl,
+      ServiceComponentHostEventType startEvent,
+      ServiceComponentHostLiveState startState,
+      ServiceComponentHostLiveState inProgressState,
+      ServiceComponentHostLiveState failedState,
+      ServiceComponentHostLiveState completedState)
     throws Exception {
     throws Exception {
     long timestamp = 0;
     long timestamp = 0;
 
 
     Assert.assertEquals(startState,
     Assert.assertEquals(startState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
-    ServiceComponentNodeEvent installEvent = createEvent(impl, ++timestamp,
+    ServiceComponentHostEvent installEvent = createEvent(impl, ++timestamp,
         startEvent);
         startEvent);
 
 
     long startTime = timestamp;
     long startTime = timestamp;
@@ -69,7 +69,7 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(inProgressState,
     Assert.assertEquals(inProgressState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeEvent installEvent2 = createEvent(impl, ++timestamp,
+    ServiceComponentHostEvent installEvent2 = createEvent(impl, ++timestamp,
         startEvent);
         startEvent);
     boolean exceptionThrown = false;
     boolean exceptionThrown = false;
     try {
     try {
@@ -84,9 +84,9 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(inProgressState,
     Assert.assertEquals(inProgressState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeOpInProgressEvent inProgressEvent1 = new
-        ServiceComponentNodeOpInProgressEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpInProgressEvent inProgressEvent1 = new
+        ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     impl.handleEvent(inProgressEvent1);
     impl.handleEvent(inProgressEvent1);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
@@ -94,9 +94,9 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(inProgressState,
     Assert.assertEquals(inProgressState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeOpInProgressEvent inProgressEvent2 = new
-        ServiceComponentNodeOpInProgressEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpInProgressEvent inProgressEvent2 = new
+        ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     impl.handleEvent(inProgressEvent2);
     impl.handleEvent(inProgressEvent2);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
@@ -105,9 +105,9 @@ public class TestServiceComponentNodeImpl {
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
 
 
-    ServiceComponentNodeOpFailedEvent failEvent = new
-        ServiceComponentNodeOpFailedEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpFailedEvent failEvent = new
+        ServiceComponentHostOpFailedEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     long endTime = timestamp;
     long endTime = timestamp;
     impl.handleEvent(failEvent);
     impl.handleEvent(failEvent);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
@@ -116,9 +116,9 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(failedState,
     Assert.assertEquals(failedState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeOpRestartedEvent restartEvent = new
-        ServiceComponentNodeOpRestartedEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpRestartedEvent restartEvent = new
+        ServiceComponentHostOpRestartedEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     startTime = timestamp;
     startTime = timestamp;
     impl.handleEvent(restartEvent);
     impl.handleEvent(restartEvent);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
@@ -127,9 +127,9 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(inProgressState,
     Assert.assertEquals(inProgressState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeOpInProgressEvent inProgressEvent3 = new
-        ServiceComponentNodeOpInProgressEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpInProgressEvent inProgressEvent3 = new
+        ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     impl.handleEvent(inProgressEvent3);
     impl.handleEvent(inProgressEvent3);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
     Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
@@ -137,9 +137,9 @@ public class TestServiceComponentNodeImpl {
     Assert.assertEquals(inProgressState,
     Assert.assertEquals(inProgressState,
         impl.getState().getLiveState());
         impl.getState().getLiveState());
 
 
-    ServiceComponentNodeOpSucceededEvent succeededEvent = new
-        ServiceComponentNodeOpSucceededEvent(impl.getServiceComponentName(),
-            impl.getNodeName(), ++timestamp);
+    ServiceComponentHostOpSucceededEvent succeededEvent = new
+        ServiceComponentHostOpSucceededEvent(impl.getServiceComponentName(),
+            impl.getHostName(), ++timestamp);
     endTime = timestamp;
     endTime = timestamp;
     impl.handleEvent(succeededEvent);
     impl.handleEvent(succeededEvent);
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
     Assert.assertEquals(startTime, impl.getLastOpStartTime());
@@ -152,76 +152,76 @@ public class TestServiceComponentNodeImpl {
 
 
   @Test
   @Test
   public void testClientStateFlow() throws Exception {
   public void testClientStateFlow() throws Exception {
-    ServiceComponentNodeImpl impl = createNewServiceComponentNode("svcComp",
+    ServiceComponentHostImpl impl = createNewServiceComponentHost("svcComp",
         "h1", true);
         "h1", true);
 
 
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-        ServiceComponentNodeLiveState.INIT,
-        ServiceComponentNodeLiveState.INSTALLING,
-        ServiceComponentNodeLiveState.INSTALL_FAILED,
-        ServiceComponentNodeLiveState.INSTALLED);
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+        ServiceComponentHostLiveState.INIT,
+        ServiceComponentHostLiveState.INSTALLING,
+        ServiceComponentHostLiveState.INSTALL_FAILED,
+        ServiceComponentHostLiveState.INSTALLED);
 
 
     boolean exceptionThrown = false;
     boolean exceptionThrown = false;
     try {
     try {
-      runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_START,
-        ServiceComponentNodeLiveState.INSTALLED,
-        ServiceComponentNodeLiveState.STARTING,
-        ServiceComponentNodeLiveState.START_FAILED,
-        ServiceComponentNodeLiveState.STARTED);
+      runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_START,
+        ServiceComponentHostLiveState.INSTALLED,
+        ServiceComponentHostLiveState.STARTING,
+        ServiceComponentHostLiveState.START_FAILED,
+        ServiceComponentHostLiveState.STARTED);
     }
     }
     catch (Exception e) {
     catch (Exception e) {
       exceptionThrown = true;
       exceptionThrown = true;
     }
     }
     Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown);
     Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown);
 
 
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL,
-        ServiceComponentNodeLiveState.INSTALLED,
-        ServiceComponentNodeLiveState.UNINSTALLING,
-        ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-        ServiceComponentNodeLiveState.UNINSTALLED);
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
+        ServiceComponentHostLiveState.INSTALLED,
+        ServiceComponentHostLiveState.UNINSTALLING,
+        ServiceComponentHostLiveState.UNINSTALL_FAILED,
+        ServiceComponentHostLiveState.UNINSTALLED);
 
 
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT,
-        ServiceComponentNodeLiveState.UNINSTALLED,
-        ServiceComponentNodeLiveState.WIPING_OUT,
-        ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-        ServiceComponentNodeLiveState.INIT);
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
+        ServiceComponentHostLiveState.UNINSTALLED,
+        ServiceComponentHostLiveState.WIPING_OUT,
+        ServiceComponentHostLiveState.WIPEOUT_FAILED,
+        ServiceComponentHostLiveState.INIT);
 
 
   }
   }
 
 
   @Test
   @Test
   public void testDaemonStateFlow() throws Exception {
   public void testDaemonStateFlow() throws Exception {
-    ServiceComponentNodeImpl impl = createNewServiceComponentNode("svcComp",
+    ServiceComponentHostImpl impl = createNewServiceComponentHost("svcComp",
         "h1", false);
         "h1", false);
 
 
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL,
-        ServiceComponentNodeLiveState.INIT,
-        ServiceComponentNodeLiveState.INSTALLING,
-        ServiceComponentNodeLiveState.INSTALL_FAILED,
-        ServiceComponentNodeLiveState.INSTALLED);
-
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_START,
-      ServiceComponentNodeLiveState.INSTALLED,
-      ServiceComponentNodeLiveState.STARTING,
-      ServiceComponentNodeLiveState.START_FAILED,
-      ServiceComponentNodeLiveState.STARTED);
-
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_STOP,
-      ServiceComponentNodeLiveState.STARTED,
-      ServiceComponentNodeLiveState.STOPPING,
-      ServiceComponentNodeLiveState.STOP_FAILED,
-      ServiceComponentNodeLiveState.INSTALLED);
-
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL,
-        ServiceComponentNodeLiveState.INSTALLED,
-        ServiceComponentNodeLiveState.UNINSTALLING,
-        ServiceComponentNodeLiveState.UNINSTALL_FAILED,
-        ServiceComponentNodeLiveState.UNINSTALLED);
-
-    runStateChanges(impl, ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT,
-        ServiceComponentNodeLiveState.UNINSTALLED,
-        ServiceComponentNodeLiveState.WIPING_OUT,
-        ServiceComponentNodeLiveState.WIPEOUT_FAILED,
-        ServiceComponentNodeLiveState.INIT);
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
+        ServiceComponentHostLiveState.INIT,
+        ServiceComponentHostLiveState.INSTALLING,
+        ServiceComponentHostLiveState.INSTALL_FAILED,
+        ServiceComponentHostLiveState.INSTALLED);
+
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_START,
+      ServiceComponentHostLiveState.INSTALLED,
+      ServiceComponentHostLiveState.STARTING,
+      ServiceComponentHostLiveState.START_FAILED,
+      ServiceComponentHostLiveState.STARTED);
+
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_STOP,
+      ServiceComponentHostLiveState.STARTED,
+      ServiceComponentHostLiveState.STOPPING,
+      ServiceComponentHostLiveState.STOP_FAILED,
+      ServiceComponentHostLiveState.INSTALLED);
+
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
+        ServiceComponentHostLiveState.INSTALLED,
+        ServiceComponentHostLiveState.UNINSTALLING,
+        ServiceComponentHostLiveState.UNINSTALL_FAILED,
+        ServiceComponentHostLiveState.UNINSTALLED);
+
+    runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
+        ServiceComponentHostLiveState.UNINSTALLED,
+        ServiceComponentHostLiveState.WIPING_OUT,
+        ServiceComponentHostLiveState.WIPEOUT_FAILED,
+        ServiceComponentHostLiveState.INIT);
 
 
   }
   }
 
 

+ 224 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java

@@ -0,0 +1,224 @@
+/**
+ * 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.host;
+
+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.HostInfo;
+import org.apache.ambari.server.state.live.AgentVersion;
+import org.apache.ambari.server.state.live.host.HostHealthStatus.HealthStatus;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestHostImpl {
+
+  @Test
+  public void testHostInfoImport() {
+    HostInfo info = new HostInfo();
+    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);
+
+    HostImpl host = new HostImpl();
+    host.importHostInfo(info);
+
+    Assert.assertEquals(info.getHostName(), host.getHostName());
+    Assert.assertEquals(info.getFreeMemory(), host.getAvailableMemBytes());
+    Assert.assertEquals(info.getMemoryTotal(), host.getTotalMemBytes());
+    Assert.assertEquals(info.getProcessorCount(), host.getCpuCount());
+    Assert.assertEquals(info.getMounts().size(), host.getDisksInfo().size());
+    Assert.assertEquals(info.getArchitecture(), host.getOsArch());
+    Assert.assertEquals(info.getOS(), host.getOsType());
+  }
+
+  private void registerHost(HostImpl host) throws Exception {
+    HostInfo info = new HostInfo();
+    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();
+
+    HostRegistrationRequestEvent e =
+        new HostRegistrationRequestEvent("foo", agentVersion, currentTime,
+            info);
+    host.handleEvent(e);
+    Assert.assertEquals(currentTime, host.getLastRegistrationTime());
+  }
+
+  private void verifyHost(HostImpl host) throws Exception {
+    HostVerifiedEvent e = new HostVerifiedEvent(host.getHostName());
+    host.handleEvent(e);
+  }
+
+  private void verifyHostState(HostImpl host, HostState state) {
+    Assert.assertEquals(state, host.getState());
+  }
+
+  private void sendHealthyHeartbeat(HostImpl host, long counter) throws Exception {
+    HostHealthyHeartbeatEvent e = new HostHealthyHeartbeatEvent(
+        host.getHostName(), counter);
+    host.handleEvent(e);
+  }
+
+  private void sendUnhealthyHeartbeat(HostImpl host, long counter) throws Exception {
+    HostHealthStatus healthStatus = new HostHealthStatus(HealthStatus.UNHEALTHY,
+        "Unhealthy server");
+    HostUnhealthyHeartbeatEvent e = new HostUnhealthyHeartbeatEvent(
+        host.getHostName(), counter, healthStatus);
+    host.handleEvent(e);
+  }
+
+  private void timeoutHost(HostImpl host) throws Exception {
+    HostHeartbeatTimedOutEvent e = new HostHeartbeatTimedOutEvent(
+        host.getHostName());
+    host.handleEvent(e);
+  }
+
+  @Test
+  public void testHostFSMInit() {
+    HostImpl host = new HostImpl();
+    verifyHostState(host, HostState.INIT);
+  }
+
+  @Test
+  public void testHostRegistrationFlow() throws Exception {
+    HostImpl host = new HostImpl();
+    registerHost(host);
+    verifyHostState(host, HostState.WAITING_FOR_VERIFICATION);
+
+    boolean exceptionThrown = false;
+    try {
+      registerHost(host);
+    } catch (Exception e) {
+      // Expected
+      exceptionThrown = true;
+    }
+    if (!exceptionThrown) {
+      fail("Expected invalid transition exception to be thrown");
+    }
+
+    verifyHost(host);
+    verifyHostState(host, HostState.VERIFIED);
+
+    exceptionThrown = false;
+    try {
+      verifyHost(host);
+    } catch (Exception e) {
+      // Expected
+      exceptionThrown = true;
+    }
+    if (!exceptionThrown) {
+      fail("Expected invalid transition exception to be thrown");
+    }
+  }
+
+  @Test
+  public void testHostHeartbeatFlow() throws Exception {
+    HostImpl host = new HostImpl();
+    registerHost(host);
+    verifyHost(host);
+
+    // TODO need to verify audit logs generated
+    // TODO need to verify health status updated properly
+
+    long counter = 0;
+    sendHealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.HEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+
+    sendHealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.HEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.HEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+    sendUnhealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.UNHEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNHEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+    sendUnhealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.UNHEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNHEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+    sendHealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.HEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.HEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+    timeoutHost(host);
+    verifyHostState(host, HostState.HEARTBEAT_LOST);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNKNOWN,
+        host.getHealthStatus().getHealthStatus());
+
+    timeoutHost(host);
+    verifyHostState(host, HostState.HEARTBEAT_LOST);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNKNOWN,
+        host.getHealthStatus().getHealthStatus());
+
+    sendUnhealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.UNHEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNHEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+    timeoutHost(host);
+    verifyHostState(host, HostState.HEARTBEAT_LOST);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.UNKNOWN,
+        host.getHealthStatus().getHealthStatus());
+
+    sendHealthyHeartbeat(host, ++counter);
+    verifyHostState(host, HostState.HEALTHY);
+    Assert.assertEquals(counter, host.getLastHeartbeatTime());
+    Assert.assertEquals(HealthStatus.HEALTHY,
+        host.getHealthStatus().getHealthStatus());
+
+  }
+}

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

@@ -1,224 +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 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.HostInfo;
-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() {
-    HostInfo info = new HostInfo();
-    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 {
-    HostInfo info = new HostInfo();
-    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(currentTime, node.getLastRegistrationTime());
-  }
-
-  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(state, node.getState());
-  }
-
-  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(counter, node.getLastHeartbeatTime());
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.HEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNHEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNHEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.HEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNKNOWN,
-        node.getHealthStatus().getHealthStatus());
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNKNOWN,
-        node.getHealthStatus().getHealthStatus());
-
-    sendUnhealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.UNHEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNHEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-    timeoutNode(node);
-    verifyNodeState(node, NodeState.HEARTBEAT_LOST);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.UNKNOWN,
-        node.getHealthStatus().getHealthStatus());
-
-    sendHealthyHeartbeat(node, ++counter);
-    verifyNodeState(node, NodeState.HEALTHY);
-    Assert.assertEquals(counter, node.getLastHeartbeatTime());
-    Assert.assertEquals(HealthStatus.HEALTHY,
-        node.getHealthStatus().getHealthStatus());
-
-  }
-}