Forráskód Böngészése

AMBARI-691. More basic classes for new design. (Contributed by hitesh)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1380767 13f79535-47bb-0310-9956-ffa450edef68
Hitesh Shah 12 éve
szülő
commit
d7b3ccddfb
38 módosított fájl, 655 hozzáadás és 597 törlés
  1. 2 0
      AMBARI-666-CHANGES.txt
  2. 0 18
      ambari-server/src/main/java/org/apache/ambari/server/Action.java
  3. 23 0
      ambari-server/src/main/java/org/apache/ambari/server/Cluster.java
  4. 11 0
      ambari-server/src/main/java/org/apache/ambari/server/Config.java
  5. 12 0
      ambari-server/src/main/java/org/apache/ambari/server/ConfigVersion.java
  6. 23 0
      ambari-server/src/main/java/org/apache/ambari/server/Job.java
  7. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/JobId.java
  8. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/JobState.java
  9. 7 0
      ambari-server/src/main/java/org/apache/ambari/server/Node.java
  10. 0 361
      ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java
  11. 15 8
      ambari-server/src/main/java/org/apache/ambari/server/Service.java
  12. 19 5
      ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java
  13. 37 0
      ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNode.java
  14. 52 0
      ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNodeState.java
  15. 21 0
      ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java
  16. 21 0
      ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java
  17. 0 8
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java
  18. 0 5
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java
  19. 0 31
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java
  20. 1 1
      ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java
  21. 2 2
      ambari-server/src/main/java/org/apache/ambari/server/fsm/JobEvent.java
  22. 20 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/JobEventType.java
  23. 13 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/JobFSM.java
  24. 58 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/JobFSMImpl.java
  25. 15 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java
  26. 8 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java
  27. 25 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java
  28. 0 12
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java
  29. 0 13
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java
  30. 0 5
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java
  31. 0 101
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java
  32. 0 16
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java
  33. 0 9
      ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java
  34. 7 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/Role.java
  35. 13 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeEvent.java
  36. 40 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeEventType.java
  37. 14 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeFSM.java
  38. 194 0
      ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeFSMImpl.java

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
 
   NEW FEATURES
   NEW FEATURES
 
 
+  AMBARI-691. More basic classes for new design. (hitesh)
+
   AMBARI-693. Classes for request objects. (jitendra)
   AMBARI-693. Classes for request objects. (jitendra)
 
 
   AMBARI-685. Basic classes. (hitesh via jitendra)
   AMBARI-685. Basic classes. (hitesh via jitendra)

+ 0 - 18
ambari-server/src/main/java/org/apache/ambari/server/Action.java

@@ -1,18 +0,0 @@
-package org.apache.ambari.server;
-
-
-public interface Action {
-
-  /**
-   * Get the Action ID for the action
-   * @return ActionId
-   */
-  public ActionId getId();
-
-  /**
-   * Get the current state of the Action
-   * @return ActionState
-   */
-  public ActionState getState();
-
-}

+ 23 - 0
ambari-server/src/main/java/org/apache/ambari/server/Cluster.java

@@ -1,5 +1,7 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
+import java.util.List;
+
 /**
 /**
  * Cluster represents a set of Nodes and Services deployed on these Nodes
  * Cluster represents a set of Nodes and Services deployed on these Nodes
  */
  */
@@ -11,4 +13,25 @@ public interface Cluster {
    */
    */
   public String getName();
   public String getName();
 
 
+  /**
+   * Get enabled Services for this Cluster
+   * @return List of Services
+   */
+  public List<Service> getServices();
+
+  /**
+   * Get the Nodes that belong to this Cluster
+   * @return List of Nodes
+   */
+  public List<Node> getNodes();
+
+  /**
+   * Get the list of Actions that are currently being tracked at the
+   * Cluster level
+   * @return List of Actions
+   */
+  public List<Job> getActions();
+
+
+
 }
 }

+ 11 - 0
ambari-server/src/main/java/org/apache/ambari/server/Config.java

@@ -0,0 +1,11 @@
+package org.apache.ambari.server;
+
+// TODO
+public interface Config {
+
+  public int getSnapshotId();
+
+  // TODO
+  // public ConfigSnapshot getSnapshot();
+
+}

+ 12 - 0
ambari-server/src/main/java/org/apache/ambari/server/ConfigVersion.java

@@ -0,0 +1,12 @@
+package org.apache.ambari.server;
+
+// TODO
+public interface ConfigVersion {
+
+  public Config getServiceConfig();
+
+  public Config getServiceComponentConfig();
+
+  public Config getServiceComponentNodeConfig();
+
+}

+ 23 - 0
ambari-server/src/main/java/org/apache/ambari/server/Job.java

@@ -0,0 +1,23 @@
+package org.apache.ambari.server;
+
+
+public interface Job {
+
+  /**
+   * Get the Action ID for the action
+   * @return ActionId
+   */
+  public JobId getId();
+
+  /**
+   * Get the current state of the Action
+   * @return ActionState
+   */
+  public JobState getState();
+
+
+  // TODO requires some form of ActionType to ensure only one running
+  // action per action type
+  // There may be gotchas such as decomissioning should be allowed to happen
+  // on more than one node at a time
+}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/ActionId.java → ambari-server/src/main/java/org/apache/ambari/server/JobId.java

@@ -1,6 +1,6 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
 // TODO
 // TODO
-public class ActionId {
+public class JobId {
 
 
 }
 }

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/ActionState.java → ambari-server/src/main/java/org/apache/ambari/server/JobState.java

@@ -1,6 +1,6 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
-public enum ActionState {
+public enum JobState {
   /**
   /**
    * Initial state for the Action.
    * Initial state for the Action.
    * When a new action is triggered or set in motion.
    * When a new action is triggered or set in motion.

+ 7 - 0
ambari-server/src/main/java/org/apache/ambari/server/Node.java

@@ -197,4 +197,11 @@ public interface Node {
    */
    */
   public NodeState getNodeState();
   public NodeState getNodeState();
 
 
+  /**
+   * Get the list of Actions that are currently being tracked at the
+   * Node level
+   * @return List of Actions
+   */
+  public List<Job> getActions();
+
 }
 }

+ 0 - 361
ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java

@@ -1,361 +0,0 @@
-package org.apache.ambari.server;
-
-import java.util.List;
-import java.util.Map;
-
-// TODO
-// Just a placeholder for now
-// Should be replaced by ORM layer
-public class NodeImpl implements Node {
-
-  /**
-   * Hostname
-   */
-  String hostName;
-
-  /**
-   * IP of the given node
-   */
-  // TODO change type
-  String ipv4;
-
-  /**
-   * IP of the given node
-   */
-  // TODO change type
-  String ipv6;
-
-  /**
-   * Count of cores
-   */
-  int cpuCount;
-
-  /**
-   * Amount of total physical memory for the Node
-   */
-  int totalMemBytes;
-
-  /**
-   * Amount of available memory for the Node.
-   * In most cases, available should be same as total unless
-   * the agent on the node is configured to not use all
-   * available memory
-   */
-  int availableMemBytes;
-
-  /**
-   * OS Architecture.
-   * i386, x86_64, etc.
-   */
-  // TODO should we make this an enum?
-  String osArch;
-
-  /**
-   * General OS information.
-   * uname -a, /etc/*-release dump
-   */
-  String osInfo;
-
-  /**
-   * OS Type: RHEL5/RHEL6/CentOS5/...
-   * Defined and match-able OS type
-   */
-  // TODO should this be an enum?
-  String osType;
-
-  /*
-   // TODO Add later if needed
-   * Additional CPU information
-   * CPU coumt, clock speed, etc
-  CpuInfo cpuInfo;
-  */
-
-  /**
-   * Information on disks available on the node
-   */
-  List<DiskInfo> disksInfo;
-
-  /**
-   * Node Health Status
-   */
-  NodeHealthStatus healthStatus;
-
-  /**
-   * Additional host attributes to capture misc. information
-   * For example, public/hostname/IP for AWS
-   */
-  Map<String, String> hostAttributes;
-
-  /**
-   * Rack information for topology-awareness
-   */
-  String rackInfo;
-
-  /**
-   * Last time the node registered with the Ambari Server
-   * ( Unix timestamp )
-   */
-  int lastRegistrationTime;
-
-  /**
-   * Last time the server received a heartbeat from the node
-   * ( Unix timestamp )
-   */
-  int lastHeartbeatTime;
-
-  /**
-   * Version of the Agent running on the node
-   */
-  AgentVersion agentVersion;
-
-  /**
-   * @return the hostName
-   */
-  @Override
-  public String getHostName() {
-    return hostName;
-  }
-
-  /**
-   * @param hostName the hostName to set
-   */
-  @Override
-  public void setHostName(String hostName) {
-    this.hostName = hostName;
-  }
-
-  @Override
-  public String getIPv4() {
-    return ipv4;
-  }
-
-  @Override
-  public void setIPv4(String ipv4) {
-    this.ipv4 = ipv4;
-  }
-
-  @Override
-  public String getIPv6() {
-    return ipv6;
-  }
-
-  @Override
-  public void setIPv6(String ipv6) {
-    this.ipv6 = ipv6;
-  }
-
-  /**
-   * @return the cpuCount
-   */
-  @Override
-  public int getCpuCount() {
-    return cpuCount;
-  }
-
-  /**
-   * @param cpuCount the cpuCount to set
-   */
-  @Override
-  public void setCpuCount(int cpuCount) {
-    this.cpuCount = cpuCount;
-  }
-
-  /**
-   * @return the totalMemBytes
-   */
-  @Override
-  public int getTotalMemBytes() {
-    return totalMemBytes;
-  }
-
-  /**
-   * @param totalMemBytes the totalMemBytes to set
-   */
-  @Override
-  public void setTotalMemBytes(int totalMemBytes) {
-    this.totalMemBytes = totalMemBytes;
-  }
-
-  /**
-   * @return the availableMemBytes
-   */
-  @Override
-  public int getAvailableMemBytes() {
-    return availableMemBytes;
-  }
-
-  /**
-   * @param availableMemBytes the availableMemBytes to set
-   */
-  @Override
-  public void setAvailableMemBytes(int availableMemBytes) {
-    this.availableMemBytes = availableMemBytes;
-  }
-
-  /**
-   * @return the osArch
-   */
-  @Override
-  public String getOsArch() {
-    return osArch;
-  }
-
-  /**
-   * @param osArch the osArch to set
-   */
-  @Override
-  public void setOsArch(String osArch) {
-    this.osArch = osArch;
-  }
-
-  /**
-   * @return the osInfo
-   */
-  @Override
-  public String getOsInfo() {
-    return osInfo;
-  }
-
-  /**
-   * @param osInfo the osInfo to set
-   */
-  @Override
-  public void setOsInfo(String osInfo) {
-    this.osInfo = osInfo;
-  }
-
-  /**
-   * @return the osType
-   */
-  @Override
-  public String getOsType() {
-    return osType;
-  }
-
-  /**
-   * @param osType the osType to set
-   */
-  @Override
-  public void setOsType(String osType) {
-    this.osType = osType;
-  }
-
-  /**
-   * @return the disksInfo
-   */
-  @Override
-  public List<DiskInfo> getDisksInfo() {
-    return disksInfo;
-  }
-
-  /**
-   * @param disksInfo the disksInfo to set
-   */
-  @Override
-  public void setDisksInfo(List<DiskInfo> disksInfo) {
-    this.disksInfo = disksInfo;
-  }
-
-  /**
-   * @return the healthStatus
-   */
-  @Override
-  public NodeHealthStatus getHealthStatus() {
-    return healthStatus;
-  }
-
-  /**
-   * @param healthStatus the healthStatus to set
-   */
-  @Override
-  public void setHealthStatus(NodeHealthStatus healthStatus) {
-    this.healthStatus = healthStatus;
-  }
-
-  /**
-   * @return the hostAttributes
-   */
-  @Override
-  public Map<String, String> getHostAttributes() {
-    return hostAttributes;
-  }
-
-  /**
-   * @param hostAttributes the hostAttributes to set
-   */
-  @Override
-  public void setHostAttributes(Map<String, String> hostAttributes) {
-    this.hostAttributes = hostAttributes;
-  }
-
-  /**
-   * @return the rackInfo
-   */
-  @Override
-  public String getRackInfo() {
-    return rackInfo;
-  }
-
-  /**
-   * @param rackInfo the rackInfo to set
-   */
-  @Override
-  public void setRackInfo(String rackInfo) {
-    this.rackInfo = rackInfo;
-  }
-
-  /**
-   * @return the lastRegistrationTime
-   */
-  @Override
-  public int getLastRegistrationTime() {
-    return lastRegistrationTime;
-  }
-
-  /**
-   * @param lastRegistrationTime the lastRegistrationTime to set
-   */
-  @Override
-  public void setLastRegistrationTime(int lastRegistrationTime) {
-    this.lastRegistrationTime = lastRegistrationTime;
-  }
-
-  /**
-   * @return the lastHeartbeatTime
-   */
-  @Override
-  public int getLastHeartbeatTime() {
-    return lastHeartbeatTime;
-  }
-
-  /**
-   * @param lastHeartbeatTime the lastHeartbeatTime to set
-   */
-  @Override
-  public void setLastHeartbeatTime(int lastHeartbeatTime) {
-    this.lastHeartbeatTime = lastHeartbeatTime;
-  }
-
-  /**
-   * @return the agentVersion
-   */
-  @Override
-  public AgentVersion getAgentVersion() {
-    return agentVersion;
-  }
-
-  /**
-   * @param agentVersion the agentVersion to set
-   */
-  @Override
-  public void setAgentVersion(AgentVersion agentVersion) {
-    this.agentVersion = agentVersion;
-  }
-
-  @Override
-  public NodeState getNodeState() {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-}

+ 15 - 8
ambari-server/src/main/java/org/apache/ambari/server/Service.java

@@ -1,6 +1,6 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
-import java.util.Map;
+import java.util.List;
 
 
 /**
 /**
  * Service Interface for representing various products in the
  * Service Interface for representing various products in the
@@ -20,21 +20,28 @@ public interface Service {
   public ServiceType getType();
   public ServiceType getType();
 
 
   /**
   /**
-   * Get the ServiceComponents for this Service
-   * @return ServiceComponents mapped by their names
+   * Get the ServiceComponents enabled for this Service
+   * @return List of ServiceComponents
    */
    */
-  public Map<String, ServiceComponent> getServiceComponents();
+  public List<ServiceComponent> getServiceComponents();
 
 
   /**
   /**
    * Get the list of services that this Service depends on
    * Get the list of services that this Service depends on
-   * @return Services mapped by their names
+   * @return List of Services
    */
    */
-  public Map<String, Service> getDependencies();
+  public List<Service> getDependencies();
 
 
   /**
   /**
    * Get the list of services that depend on this Service
    * Get the list of services that depend on this Service
-   * @return Services mapped by their names
+   * @return List of Services
    */
    */
-  public Map<String, Service> getDependents();
+  public List<Service> getDependents();
+
+  /**
+   * Get the list of Actions that are currently being tracked at the
+   * Service level
+   * @return List of Actions
+   */
+  public List<Job> getActions();
 
 
 }
 }

+ 19 - 5
ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java

@@ -1,6 +1,6 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
-import java.util.Map;
+import java.util.List;
 
 
 /**
 /**
  * ServiceComponent Interface for representing components of the various
  * ServiceComponent Interface for representing components of the various
@@ -27,13 +27,27 @@ public interface ServiceComponent {
 
 
   /**
   /**
    * Get the list of components that this ServiceComponent depends on
    * Get the list of components that this ServiceComponent depends on
-   * @return ServiceComponents mapped by their names
+   * @return List of ServiceComponents
    */
    */
-  public Map<String, ServiceComponent> getDependencies();
+  public List<ServiceComponent> getDependencies();
 
 
   /**
   /**
    * Get the list of components that depend on this ServiceComponent
    * Get the list of components that depend on this ServiceComponent
-   * @return ServiceComponents mapped by their names
+   * @return List of ServiceComponents
    */
    */
-  public Map<String, ServiceComponent> getDependents();
+  public List<ServiceComponent> getDependents();
+
+  /**
+   * Get the Nodes assigned to this ServiceComponent
+   * @return List of ServiceComponentNodes
+   */
+  public List<ServiceComponentNode> getServiceComponentNodes();
+
+  /**
+   * Get the list of Actions that are currently being tracked at the
+   * ServiceComponent level
+   * @return List of Actions
+   */
+  public List<Job> getActions();
+
 }
 }

+ 37 - 0
ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNode.java

@@ -0,0 +1,37 @@
+package org.apache.ambari.server;
+
+import java.util.List;
+
+public interface ServiceComponentNode {
+
+  /**
+   * Get the ServiceComponent that this object is mapped to
+   * @return ServiceComponent
+   */
+  public ServiceComponent getServiceComponent();
+
+  /**
+   * Get the Node that this object is mapped to
+   * @return Node
+   */
+  public Node getNode();
+
+  /**
+   * Get the State for this ServiceComponentNode
+   * @return
+   */
+  public ServiceComponentNodeState getServiceComponentNodeState();
+
+  /**
+   * Get the Config Version
+   * @return ConfigVersion
+   */
+  public ConfigVersion getConfigVersion();
+
+  /**
+   * Get the list of Actions that are currently being tracked at the
+   * ServiceComponentNode level
+   * @return List of Actions
+   */
+  public List<Job> getActions();
+}

+ 52 - 0
ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNodeState.java

@@ -0,0 +1,52 @@
+package org.apache.ambari.server;
+
+public enum ServiceComponentNodeState {
+  /**
+   * Initial/Clean state
+   */
+  INIT,
+  /**
+   * In the process of installing.
+   */
+  INSTALLING,
+  /**
+   * Install failed
+   */
+  INSTALL_FAILED,
+  /**
+   * State when install completed successfully
+   */
+  INSTALLED,
+  /**
+   * In the process of starting.
+   */
+  STARTING,
+  /**
+   * Start failed.
+   */
+  START_FAILED,
+  /**
+   * State when start completed successfully.
+   */
+  STARTED,
+  /**
+   * In the process of stopping.
+   */
+  STOPPING,
+  /**
+   * Stop failed
+   */
+  STOP_FAILED,
+  /**
+   * In the process of uninstalling.
+   */
+  UNINSTALLING,
+  /**
+   * Uninstall failed.
+   */
+  UNINSTALL_FAILED,
+  /**
+   * State when uninstall completed successfully.
+   */
+  UNINSTALLED
+}

+ 21 - 0
ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java

@@ -1,8 +1,29 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
+import java.util.List;
+
 /**
 /**
  * TODO
  * TODO
  * Meta-data object for ServiceComponent
  * Meta-data object for ServiceComponent
  */
  */
 public interface ServiceComponentType {
 public interface ServiceComponentType {
+
+  /**
+   * Get the ServiceType to which this ServiceComponent belongs to
+   * @return ServiceType of which this ServiceComponent is part of
+   */
+  public ServiceType getServiceType();
+
+  /**
+   * Get the list of components that this ServiceComponent depends on
+   * @return List of ServiceComponentTypes
+   */
+  public List<ServiceComponentType> getDependencies();
+
+  /**
+   * Get the list of components that depend on this ServiceComponent
+   * @return List of ServiceComponentTypes
+   */
+  public List<ServiceComponentType> getDependents();
+
 }
 }

+ 21 - 0
ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java

@@ -1,9 +1,30 @@
 package org.apache.ambari.server;
 package org.apache.ambari.server;
 
 
+import java.util.List;
+
 /**
 /**
  * TODO
  * TODO
  * Meta-data object for Service
  * Meta-data object for Service
  */
  */
 public interface ServiceType {
 public interface ServiceType {
 
 
+  /**
+   * Get the list of ServiceComponentTypes for this Service
+   * @return List of ServiceComponentTypes
+   */
+  public List<ServiceComponentType> getServiceComponents();
+
+  /**
+   * Get the list of services that this Service depends on
+   * @return List of ServiceTypes
+   */
+  public List<ServiceType> getDependencies();
+
+  /**
+   * Get the list of services that depend on this Service
+   * @return List of ServiceTypes
+   */
+  public List<ServiceType> getDependents();
+
+
 }
 }

+ 0 - 8
ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java

@@ -1,8 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public enum ActionEventType {
-  ACTION_INIT,
-  ACTION_IN_PROGRESS,
-  ACTION_COMPLETED,
-  ACTION_FAILED
-}

+ 0 - 5
ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java

@@ -1,5 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public interface ActionFSM {
-
-}

+ 0 - 31
ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java

@@ -1,31 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-import org.apache.ambari.server.ActionState;
-import org.apache.ambari.server.fsm.StateMachineFactory;
-
-public class ActionFSMImpl implements ActionFSM {
-
-  private static final StateMachineFactory
-    <ActionFSMImpl, ActionState, ActionEventType, ActionEvent>
-      stateMachineFactory
-        = new StateMachineFactory<ActionFSMImpl, ActionState,
-          ActionEventType, ActionEvent>
-            (ActionState.INIT)
-
-    // define the state machine of a Action
-
-    .addTransition(ActionState.INIT, ActionState.IN_PROGRESS,
-        ActionEventType.ACTION_IN_PROGRESS)
-    .addTransition(ActionState.IN_PROGRESS, ActionState.IN_PROGRESS,
-        ActionEventType.ACTION_IN_PROGRESS)
-    .addTransition(ActionState.IN_PROGRESS, ActionState.COMPLETED,
-        ActionEventType.ACTION_COMPLETED)
-    .addTransition(ActionState.IN_PROGRESS, ActionState.FAILED,
-        ActionEventType.ACTION_FAILED)
-    .addTransition(ActionState.COMPLETED, ActionState.INIT,
-        ActionEventType.ACTION_INIT)
-    .addTransition(ActionState.FAILED, ActionState.INIT,
-        ActionEventType.ACTION_INIT)
-    .installTopology();
-
-}

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java

@@ -21,7 +21,7 @@ package org.apache.ambari.server.fsm;
 // TODO
 // TODO
 public class InvalidStateTransitonException extends Exception {
 public class InvalidStateTransitonException extends Exception {
 
 
- private Enum<?> currentState;
+  private Enum<?> currentState;
   private Enum<?> event;
   private Enum<?> event;
 
 
   public InvalidStateTransitonException(Enum<?> currentState, Enum<?> event) {
   public InvalidStateTransitonException(Enum<?> currentState, Enum<?> event) {

+ 2 - 2
ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java → ambari-server/src/main/java/org/apache/ambari/server/fsm/JobEvent.java

@@ -2,11 +2,11 @@ package org.apache.ambari.server.fsm;
 
 
 import org.apache.ambari.server.fsm.event.AbstractEvent;
 import org.apache.ambari.server.fsm.event.AbstractEvent;
 
 
-public class ActionEvent extends AbstractEvent<ActionEventType> {
+public class JobEvent extends AbstractEvent<JobEventType> {
 
 
   // TODO
   // TODO
   // this should have some action identifier
   // this should have some action identifier
-  public ActionEvent(ActionEventType type) {
+  public JobEvent(JobEventType type) {
     super(type);
     super(type);
     // TODO Auto-generated constructor stub
     // TODO Auto-generated constructor stub
   }
   }

+ 20 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/JobEventType.java

@@ -0,0 +1,20 @@
+package org.apache.ambari.server.fsm;
+
+public enum JobEventType {
+  /**
+   * Initial state for the action when triggered.
+   */
+  ACTION_INIT,
+  /**
+   * Action still in progress.
+   */
+  ACTION_IN_PROGRESS,
+  /**
+   * Action completed successfully.
+   */
+  ACTION_COMPLETED,
+  /**
+   * Action failed to complete successfully.
+   */
+  ACTION_FAILED
+}

+ 13 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/JobFSM.java

@@ -0,0 +1,13 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.JobState;
+
+public interface JobFSM {
+
+  public JobState getState();
+
+  public void setState(JobState state);
+
+  public void handleEvent(JobEvent event)
+      throws InvalidStateTransitonException;
+}

+ 58 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/JobFSMImpl.java

@@ -0,0 +1,58 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.JobState;
+import org.apache.ambari.server.fsm.StateMachineFactory;
+
+public class JobFSMImpl implements JobFSM {
+
+  private static final StateMachineFactory
+    <JobFSMImpl, JobState, JobEventType, JobEvent>
+      stateMachineFactory
+        = new StateMachineFactory<JobFSMImpl, JobState,
+          JobEventType, JobEvent>
+            (JobState.INIT)
+
+    // define the state machine of a Action
+
+    .addTransition(JobState.INIT, JobState.IN_PROGRESS,
+        JobEventType.ACTION_IN_PROGRESS)
+    .addTransition(JobState.IN_PROGRESS, JobState.IN_PROGRESS,
+        JobEventType.ACTION_IN_PROGRESS)
+    .addTransition(JobState.IN_PROGRESS, JobState.COMPLETED,
+        JobEventType.ACTION_COMPLETED)
+    .addTransition(JobState.IN_PROGRESS, JobState.FAILED,
+        JobEventType.ACTION_FAILED)
+    .addTransition(JobState.COMPLETED, JobState.INIT,
+        JobEventType.ACTION_INIT)
+    .addTransition(JobState.FAILED, JobState.INIT,
+        JobEventType.ACTION_INIT)
+    .installTopology();
+
+  private final StateMachine<JobState, JobEventType, JobEvent>
+      stateMachine;
+
+  public JobFSMImpl() {
+    super();
+    this.stateMachine = stateMachineFactory.make(this);
+  }
+
+  @Override
+  public JobState getState() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public void setState(JobState state) {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void handleEvent(JobEvent event)
+      throws InvalidStateTransitonException {
+    // TODO
+    stateMachine.doTransition(event.getType(), event);
+  }
+
+}

+ 15 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java

@@ -1,9 +1,24 @@
 package org.apache.ambari.server.fsm;
 package org.apache.ambari.server.fsm;
 
 
 public enum NodeEventType {
 public enum NodeEventType {
+  /**
+   * Event to denote when a registration request is received from a Node
+   */
   NODE_REGISTRATION_REQUEST,
   NODE_REGISTRATION_REQUEST,
+  /**
+   * Node authenticated/verified.
+   */
   NODE_VERIFIED,
   NODE_VERIFIED,
+  /**
+   * A healthy heartbeat event received from the Node.
+   */
   NODE_HEARTBEAT_HEALTHY,
   NODE_HEARTBEAT_HEALTHY,
+  /**
+   * No heartbeat received from the Node within the defined expiry interval.
+   */
   NODE_HEARTBEAT_TIMED_OUT,
   NODE_HEARTBEAT_TIMED_OUT,
+  /**
+   * A non-healthy heartbeat event received from the Node.
+   */
   NODE_HEARTBEAT_UNHEALTHY
   NODE_HEARTBEAT_UNHEALTHY
 }
 }

+ 8 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java

@@ -1,5 +1,13 @@
 package org.apache.ambari.server.fsm;
 package org.apache.ambari.server.fsm;
 
 
+import org.apache.ambari.server.NodeState;
+
 public interface NodeFSM {
 public interface NodeFSM {
 
 
+  public NodeState getState();
+
+  public void setState(NodeState state);
+
+  public void handleEvent(NodeEvent event)
+      throws InvalidStateTransitonException;
 }
 }

+ 25 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java

@@ -44,6 +44,12 @@ public class NodeFSMImpl implements NodeFSM {
        NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
        NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
    .installTopology();
    .installTopology();
 
 
+  private final StateMachine<NodeState, NodeEventType, NodeEvent> stateMachine;
+
+  public NodeFSMImpl() {
+    super();
+    this.stateMachine = stateMachineFactory.make(this);
+  }
 
 
   static class NodeVerifiedTransition
   static class NodeVerifiedTransition
       implements SingleArcTransition<NodeFSMImpl, NodeEvent> {
       implements SingleArcTransition<NodeFSMImpl, NodeEvent> {
@@ -55,4 +61,23 @@ public class NodeFSMImpl implements NodeFSM {
 
 
   }
   }
 
 
+  @Override
+  public NodeState getState() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public void setState(NodeState state) {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void handleEvent(NodeEvent event)
+      throws InvalidStateTransitonException {
+    // TODO Auto-generated method stub
+    stateMachine.doTransition(event.getType(), event);
+  }
+
 }
 }

+ 0 - 12
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java

@@ -1,12 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-import org.apache.ambari.server.fsm.event.AbstractEvent;
-
-public class NodeServiceComponentEvent extends AbstractEvent<ActionEventType> {
-
-  public NodeServiceComponentEvent(ActionEventType type) {
-    super(type);
-    // TODO Auto-generated constructor stub
-  }
-
-}

+ 0 - 13
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java

@@ -1,13 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public enum NodeServiceComponentEventType {
-  NODE_SVCCOMP_OP_IN_PROGRESS,
-  NODE_SVCCOMP_OP_SUCCEEDED,
-  NODE_SVCCOMP_OP_FAILED,
-  NODE_SVCCOMP_OP_RESTART,
-  NODE_SVCCOMP_INSTALL,
-  NODE_SVCCOMP_START,
-  NODE_SVCCOMP_STOP,
-  NODE_SVCCOMP_UNINSTALL,
-  NODE_SVCCOMP_WIPEOUT  
-}

+ 0 - 5
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java

@@ -1,5 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public interface NodeServiceComponentFSM {
-
-}

+ 0 - 101
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java

@@ -1,101 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-import org.apache.ambari.server.fsm.StateMachineFactory;
-
-public class NodeServiceComponentFSMImpl implements NodeServiceComponentFSM {
-
-  private static final StateMachineFactory
-  <NodeServiceComponentFSMImpl, NodeServiceComponentState,
-  NodeServiceComponentEventType, NodeServiceComponentEvent>
-    stateMachineFactory
-      = new StateMachineFactory<NodeServiceComponentFSMImpl,
-          NodeServiceComponentState, NodeServiceComponentEventType,
-          NodeServiceComponentEvent>
-          (NodeServiceComponentState.INIT)
-
-  // define the state machine of a NodeServiceComponent
-
-     .addTransition(NodeServiceComponentState.INIT,
-         NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_INSTALL)
-
-     .addTransition(NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentState.INSTALLED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_SUCCEEDED)
-     .addTransition(NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
-     .addTransition(NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentState.INSTALL_FAILED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_FAILED)
-
-     .addTransition(NodeServiceComponentState.INSTALL_FAILED,
-         NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_RESTART)
-
-     .addTransition(NodeServiceComponentState.INSTALLED,
-         NodeServiceComponentState.STARTING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_START)
-     .addTransition(NodeServiceComponentState.INSTALLED,
-         NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_UNINSTALL)
-     .addTransition(NodeServiceComponentState.INSTALLED,
-         NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_INSTALL)
-
-     .addTransition(NodeServiceComponentState.STARTING,
-         NodeServiceComponentState.STARTING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
-     .addTransition(NodeServiceComponentState.STARTING,
-         NodeServiceComponentState.STARTED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_SUCCEEDED)
-     .addTransition(NodeServiceComponentState.STARTING,
-         NodeServiceComponentState.START_FAILED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_FAILED)
-
-     .addTransition(NodeServiceComponentState.START_FAILED,
-         NodeServiceComponentState.STARTING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_RESTART)
-
-     .addTransition(NodeServiceComponentState.STARTED,
-         NodeServiceComponentState.STOPPING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_STOP)
-
-     .addTransition(NodeServiceComponentState.STOPPING,
-         NodeServiceComponentState.STOPPING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
-     .addTransition(NodeServiceComponentState.STOPPING,
-         NodeServiceComponentState.INSTALLED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_SUCCEEDED)
-     .addTransition(NodeServiceComponentState.STOPPING,
-         NodeServiceComponentState.STOP_FAILED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_FAILED)
-
-     .addTransition(NodeServiceComponentState.STOP_FAILED,
-         NodeServiceComponentState.STOPPING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_RESTART)
-
-     .addTransition(NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
-     .addTransition(NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentState.UNINSTALLED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_SUCCEEDED)
-     .addTransition(NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentState.UNINSTALL_FAILED,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_FAILED)
-
-     .addTransition(NodeServiceComponentState.UNINSTALL_FAILED,
-         NodeServiceComponentState.UNINSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_OP_RESTART)
-
-     .addTransition(NodeServiceComponentState.UNINSTALLED,
-         NodeServiceComponentState.INSTALLING,
-         NodeServiceComponentEventType.NODE_SVCCOMP_INSTALL)
-
-     .addTransition(NodeServiceComponentState.UNINSTALLED,
-         NodeServiceComponentState.INIT,
-         NodeServiceComponentEventType.NODE_SVCCOMP_WIPEOUT)
-         
-     .installTopology();
-}

+ 0 - 16
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java

@@ -1,16 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public enum NodeServiceComponentState {
-  INIT,
-  INSTALLING,
-  INSTALL_FAILED,
-  INSTALLED,
-  STARTING,
-  START_FAILED,
-  STARTED,
-  STOPPING,
-  STOP_FAILED,
-  UNINSTALLING,
-  UNINSTALL_FAILED,
-  UNINSTALLED
-}

+ 0 - 9
ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java

@@ -1,9 +0,0 @@
-package org.apache.ambari.server.fsm;
-
-public enum NodeState {
-  INIT,
-  WAITING_FOR_VERIFICATION,
-  HEALTHY,
-  HEARTBEAT_LOST,
-  UNHEALTHY
-}

+ 7 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/Role.java

@@ -0,0 +1,7 @@
+package org.apache.ambari.server.fsm;
+
+public interface Role {
+
+  public String getRoleName();
+  
+}

+ 13 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeEvent.java

@@ -0,0 +1,13 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.fsm.event.AbstractEvent;
+
+public class ServiceComponentNodeEvent
+    extends AbstractEvent<ServiceComponentNodeEventType> {
+
+  public ServiceComponentNodeEvent(ServiceComponentNodeEventType type) {
+    super(type);
+    // TODO Auto-generated constructor stub
+  }
+
+}

+ 40 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeEventType.java

@@ -0,0 +1,40 @@
+package org.apache.ambari.server.fsm;
+
+public enum ServiceComponentNodeEventType {
+  /**
+   * Operation in progress
+   */
+  NODE_SVCCOMP_OP_IN_PROGRESS,
+  /**
+   * Operation succeeded
+   */
+  NODE_SVCCOMP_OP_SUCCEEDED,
+  /**
+   * Operation failed.
+   */
+  NODE_SVCCOMP_OP_FAILED,
+  /**
+   * Re-starting a failed operation.
+   */
+  NODE_SVCCOMP_OP_RESTART,
+  /**
+   * Triggering an install.
+   */
+  NODE_SVCCOMP_INSTALL,
+  /**
+   * Triggering a start.
+   */
+  NODE_SVCCOMP_START,
+  /**
+   * Triggering a stop.
+   */
+  NODE_SVCCOMP_STOP,
+  /**
+   * Triggering an uninstall.
+   */
+  NODE_SVCCOMP_UNINSTALL,
+  /**
+   * Triggering a wipe-out ( restore to clean state ).
+   */
+  NODE_SVCCOMP_WIPEOUT
+}

+ 14 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeFSM.java

@@ -0,0 +1,14 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.ServiceComponentNodeState;;
+
+public interface ServiceComponentNodeFSM {
+
+  public ServiceComponentNodeState getState();
+
+  public void setState(ServiceComponentNodeState state);
+
+  public void handleEvent(ServiceComponentNodeEvent event)
+      throws InvalidStateTransitonException;
+
+}

+ 194 - 0
ambari-server/src/main/java/org/apache/ambari/server/fsm/ServiceComponentNodeFSMImpl.java

@@ -0,0 +1,194 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.ServiceComponentNodeState;
+import org.apache.ambari.server.fsm.StateMachineFactory;
+
+public class ServiceComponentNodeFSMImpl implements ServiceComponentNodeFSM {
+
+  private static final StateMachineFactory
+  <ServiceComponentNodeFSMImpl, ServiceComponentNodeState,
+  ServiceComponentNodeEventType, ServiceComponentNodeEvent>
+    daemonStateMachineFactory
+      = new StateMachineFactory<ServiceComponentNodeFSMImpl,
+          ServiceComponentNodeState, ServiceComponentNodeEventType,
+          ServiceComponentNodeEvent>
+          (ServiceComponentNodeState.INIT)
+
+  // define the state machine of a NodeServiceComponent
+
+     .addTransition(ServiceComponentNodeState.INIT,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALL_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.INSTALL_FAILED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_START)
+     .addTransition(ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL)
+     .addTransition(ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeState.STARTED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeState.START_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.START_FAILED,
+         ServiceComponentNodeState.STARTING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.STARTED,
+         ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_STOP)
+
+     .addTransition(ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeState.STOP_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.STOP_FAILED,
+         ServiceComponentNodeState.STOPPING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALL_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALL_FAILED,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeState.INIT,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT)
+
+     .installTopology();
+
+  private static final StateMachineFactory
+  <ServiceComponentNodeFSMImpl, ServiceComponentNodeState,
+  ServiceComponentNodeEventType, ServiceComponentNodeEvent>
+    clientStateMachineFactory
+      = new StateMachineFactory<ServiceComponentNodeFSMImpl,
+          ServiceComponentNodeState, ServiceComponentNodeEventType,
+          ServiceComponentNodeEvent>
+          (ServiceComponentNodeState.INIT)
+
+  // define the state machine of a NodeServiceComponent
+
+     .addTransition(ServiceComponentNodeState.INIT,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeState.INSTALL_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.INSTALL_FAILED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_UNINSTALL)
+     .addTransition(ServiceComponentNodeState.INSTALLED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_IN_PROGRESS)
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_SUCCEEDED)
+     .addTransition(ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeState.UNINSTALL_FAILED,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_FAILED)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALL_FAILED,
+         ServiceComponentNodeState.UNINSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_OP_RESTART)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeState.INSTALLING,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_INSTALL)
+
+     .addTransition(ServiceComponentNodeState.UNINSTALLED,
+         ServiceComponentNodeState.INIT,
+         ServiceComponentNodeEventType.NODE_SVCCOMP_WIPEOUT)
+
+     .installTopology();
+
+
+  private final StateMachine<ServiceComponentNodeState,
+      ServiceComponentNodeEventType, ServiceComponentNodeEvent> stateMachine;
+
+  public ServiceComponentNodeFSMImpl(boolean isClient) {
+    super();
+    if (isClient) {
+      this.stateMachine = clientStateMachineFactory.make(this);
+    } else {
+      this.stateMachine = daemonStateMachineFactory.make(this);
+    }
+  }
+
+  @Override
+  public ServiceComponentNodeState getState() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public void setState(ServiceComponentNodeState state) {
+    // TODO Auto-generated method stub
+  }
+
+  @Override
+  public void handleEvent(ServiceComponentNodeEvent event)
+      throws InvalidStateTransitonException {
+    // TODO
+    stateMachine.doTransition(event.getType(), event);
+  }
+
+}