incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiten...@apache.org
Subject svn commit: r1378479 [1/2] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/ ambari-server/ ambari-server/src/main/java/org/apache/ambari/configuration/ ambari-server/src/main/java/org/apache/ambari/server/ ambari-server/src/main/java/org/ap...
Date Wed, 29 Aug 2012 08:49:32 GMT
Author: jitendra
Date: Wed Aug 29 08:49:31 2012
New Revision: 1378479

URL: http://svn.apache.org/viewvc?rev=1378479&view=rev
Log:
AMBARI-685. Basic classes. Contributed by Hitesh.

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Action.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionId.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionState.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AgentVersion.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Cluster.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/DiskInfo.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Node.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeHealthStatus.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeState.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Service.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/MultipleArcTransition.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/SingleArcTransition.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachine.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachineFactory.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/AbstractEvent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/Event.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/event/EventHandler.java
Removed:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/configuration/Configuration.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1378479&r1=1378478&r2=1378479&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Aug 29 08:49:31 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-685. Basic classes. (hitesh via jitendra)
+
   AMBARI-676. Seperate directory for ambari-server. (jitendra)
 
   IMPROVEMENTS

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml?rev=1378479&r1=1378478&r2=1378479&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/pom.xml Wed Aug 29 08:49:31 2012
@@ -37,66 +37,6 @@
   </dependencies>
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <version>1.6</version>
-        <configuration>
-          <createDependencyReducedPom>true</createDependencyReducedPom>
-          <filters>
-            <filter>
-              <artifact>*:*</artifact>
-              <excludes>
-                <exclude>META-INF/*.SF</exclude>
-                <exclude>META-INF/*.DSA</exclude>
-                <exclude>META-INF/*.RSA</exclude>
-              </excludes>
-            </filter>
-          </filters>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <transformers>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                  <mainClass>org.apache.ambari.agent.AmbariAgent</mainClass>
-                </transformer>
-              </transformers>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.mortbay.jetty</groupId>
-        <artifactId>jetty-maven-plugin</artifactId>
-        <version>7.0.0.pre5</version>
-        <configuration>
-          <connectors>
-            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
-              <port>8080</port>
-            </connector>
-            <connector implementation="org.mortbay.jetty.ssl.SslSelectChannelConnector">
-              <port>8140</port>
-              <keystore>src/test/resources/server.keystore</keystore>
-              <keyPassword>123456</keyPassword>
-              <password>123456</password>
-            </connector>
-          </connectors>
-        </configuration>
-        <dependencies>
-          <dependency>
-            <groupId>org.mortbay.jetty</groupId>
-            <artifactId>jetty-ssl</artifactId>
-            <version>7.0.0.pre5</version>
-          </dependency>
-        </dependencies>
-      </plugin>
     </plugins>
-    <finalName>ambari-agent</finalName>
   </build>
 </project>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml?rev=1378479&r1=1378478&r2=1378479&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Wed Aug 29 08:49:31 2012
@@ -1,21 +1,16 @@
 <?xml version="1.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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <groupId>org.apache.ambari</groupId>
     <artifactId>ambari-project</artifactId>
@@ -37,79 +32,12 @@
     </resources>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <version>1.6</version>
-        <configuration>
-          <createDependencyReducedPom>true</createDependencyReducedPom>
-          <filters>
-            <filter>
-              <artifact>*:*</artifact>
-              <excludes>
-                <exclude>META-INF/*.SF</exclude>
-                <exclude>META-INF/*.DSA</exclude>
-                <exclude>META-INF/*.RSA</exclude>
-              </excludes>
-            </filter>
-          </filters>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <transformers>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                  <mainClass>org.apache.ambari.controller.AmbariController</mainClass>
-                </transformer>
-              </transformers>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
       </plugin>
     </plugins>
   </build>
   <profiles>
-    <profile>
-      <id>docs</id>
-      <activation>
-        <file>
-          <exists>/usr/bin/xsltproc</exists>
-        </file>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>com.sun.jersey.contribs</groupId>
-          <artifactId>maven-wadl-plugin</artifactId>
-          <version>1.8</version>
-        </dependency>
-        <dependency>
-          <groupId>com.sun.jersey.contribs</groupId>
-          <artifactId>wadl-resourcedoc-doclet</artifactId>
-          <version>1.8</version>
-        </dependency>
-      </dependencies>
-    </profile>
   </profiles>
-  <pluginRepositories>
-    <pluginRepository>
-      <id>maven2-repository.dev.java.net</id>
-      <name>Java.net Repository for Maven</name>
-      <url>http://download.java.net/maven/2/</url>
-      <layout>default</layout>
-    </pluginRepository>
-    <pluginRepository>
-      <id>maven2-glassfish-repository.dev.java.net</id>
-      <name>Java.net Repository for Maven</name>
-      <url>http://download.java.net/maven/glassfish/</url>
-    </pluginRepository>
-  </pluginRepositories>
   <dependencies>
     <dependency>
       <groupId>org.testng</groupId>
@@ -172,11 +100,4 @@
       <artifactId>jersey-test-framework-external</artifactId>
     </dependency>
   </dependencies>
-  <distributionManagement>
-    <site>
-      <id>apache-website</id>
-      <name>Apache website</name>
-      <url>scpexe://people.apache.org/www/incubator.apache.org/ambari/ambari-controller</url>
-    </site>
-  </distributionManagement>
 </project>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Action.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Action.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Action.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Action.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,18 @@
+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();
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionId.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionId.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionId.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionId.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,6 @@
+package org.apache.ambari.server;
+
+// TODO
+public class ActionId {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionState.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionState.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ActionState.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,21 @@
+package org.apache.ambari.server;
+
+public enum ActionState {
+  /**
+   * Initial state for the Action.
+   * When a new action is triggered or set in motion.
+   */
+  INIT,
+  /**
+   * State when the action is triggered on the cluster,
+   */
+  IN_PROGRESS,
+  /**
+   * State of successful completion
+   */
+  COMPLETED,
+  /**
+   * Action failed to complete successfully
+   */
+  FAILED
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AgentVersion.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AgentVersion.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AgentVersion.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AgentVersion.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,6 @@
+package org.apache.ambari.server;
+
+// TODO
+public class AgentVersion {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/AmbariException.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,7 @@
+package org.apache.ambari.server;
+
+import java.io.IOException;
+
+// TODO
+public class AmbariException extends IOException {
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Cluster.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Cluster.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Cluster.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,14 @@
+package org.apache.ambari.server;
+
+/**
+ * Cluster represents a set of Nodes and Services deployed on these Nodes
+ */
+public interface Cluster {
+
+  /**
+   * Get the Name of the Cluster
+   * @return Cluster Name
+   */
+  public String getName();
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/DiskInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/DiskInfo.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/DiskInfo.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/DiskInfo.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,30 @@
+package org.apache.ambari.server;
+
+/**
+ * Information about a mounted disk on a given node
+ */
+public class DiskInfo {
+
+  /**
+   * Name of device
+   * For example: /dev/sda, /dev/sdb, etc
+   */
+  String device;
+
+  /**
+   * Filesystem Type
+   * For example: ext3, tmpfs, swap, etc
+   */
+  String fsType;
+
+  /**
+   * Path at which the device is mounted on
+   */
+  String mountPath;
+
+  /**
+   * Capacity of the disk in bytes
+   */
+  long capacityBytes;
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Node.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Node.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Node.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Node.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,200 @@
+package org.apache.ambari.server;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Interface for Node of a Cluster. Encapsulates all the required information
+ * about a given node.
+ */
+public interface Node {
+
+  /**
+   * @return the hostName
+   */
+  public String getHostName();
+
+  /**
+   * @param hostName the hostName to set
+   */
+  public void setHostName(String hostName);
+
+  /**
+   * IPv4 assigned to the Node
+   * @return the ip or null if no IPv4 interface
+   */
+  public String getIPv4();
+
+  /**
+   * @param ip the ip to set
+   */
+  public void setIPv4(String ip);
+
+  /**
+   * IPv6 assigned to the Node
+   * @return the ip or null if no IPv6 interface
+   */
+  public String getIPv6();
+
+  /**
+   * @param ip the ip to set
+   */
+  public void setIPv6(String ip);
+
+  /**
+   * @return the cpuCount
+   */
+  public int getCpuCount();
+
+  /**
+   * @param cpuCount the cpuCount to set
+   */
+  public void setCpuCount(int cpuCount);
+
+  /**
+   * Get the Amount of physical memory for the Node.
+   * @return the totalMemBytes
+   */
+  public int getTotalMemBytes();
+
+  /**
+   * Set the Amount of physical memory for the Node.
+   * @param totalMemBytes the totalMemBytes to set
+   */
+  public void setTotalMemBytes(int totalMemBytes);
+
+  /**
+   * Get the 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
+   * @return the availableMemBytes
+   */
+  public int getAvailableMemBytes();
+
+  /**
+   * Set the Amount of available memory for the Node.
+   * @param availableMemBytes the availableMemBytes to set
+   */
+  public void setAvailableMemBytes(int availableMemBytes);
+
+  /**
+   * Get the OS Architecture.
+   * i386, x86_64, etc.
+   * @return the osArch
+   */
+  public String getOsArch();
+
+  /**
+   * @param osArch the osArch to set
+   */
+  public void setOsArch(String osArch);
+
+  /**
+   * Get the General OS information.
+   * uname -a, /etc/*-release dump
+   * @return the osInfo
+   */
+  public String getOsInfo();
+
+  /**
+   * @param osInfo the osInfo to set
+   */
+  public void setOsInfo(String osInfo);
+
+  /**
+   * Get the OS Type: RHEL5/RHEL6/CentOS5/...
+   * Defined and match-able OS type
+   * @return the osType
+   */
+  public String getOsType();
+
+  /**
+   * @param osType the osType to set
+   */
+  public void setOsType(String osType);
+
+  /**
+   * Get information on disks available on the node.
+   * @return the disksInfo
+   */
+  public List<DiskInfo> getDisksInfo();
+
+  /**
+   * @param disksInfo the disksInfo to set
+   */
+  public void setDisksInfo(List<DiskInfo> disksInfo);
+
+  /**
+   * @return the healthStatus
+   */
+  public NodeHealthStatus getHealthStatus();
+
+  /**
+   * @param healthStatus the healthStatus to set
+   */
+  public void setHealthStatus(NodeHealthStatus healthStatus);
+
+  /**
+   * Get additional host attributes
+   * For example, public/hostname/IP for AWS
+   * @return the hostAttributes
+   */
+  public Map<String, String> getHostAttributes();
+
+  /**
+   * @param hostAttributes the hostAttributes to set
+   */
+  public void setHostAttributes(Map<String, String> hostAttributes);
+  /**
+   * @return the rackInfo
+   */
+  public String getRackInfo();
+
+  /**
+   * @param rackInfo the rackInfo to set
+   */
+  public void setRackInfo(String rackInfo);
+
+  /**
+   * Last time the node registered with the Ambari Server
+   * ( Unix timestamp )
+   * @return the lastRegistrationTime
+   */
+  public int getLastRegistrationTime();
+
+  /**
+   * @param lastRegistrationTime the lastRegistrationTime to set
+   */
+  public void setLastRegistrationTime(int lastRegistrationTime);
+
+  /**
+   * Last time the Ambari Server received a heartbeat from the Node
+   * ( Unix timestamp )
+   * @return the lastHeartbeatTime
+   */
+  public int getLastHeartbeatTime();
+
+  /**
+   * @param lastHeartbeatTime the lastHeartbeatTime to set
+   */
+  public void setLastHeartbeatTime(int lastHeartbeatTime);
+
+  /**
+   * Version of the Ambari Agent running on the node
+   * @return the agentVersion
+   */
+  public AgentVersion getAgentVersion();
+
+  /**
+   * @param agentVersion the agentVersion to set
+   */
+  public void setAgentVersion(AgentVersion agentVersion);
+
+  /**
+   * Get the current state of the Node
+   * @return NodeState
+   */
+  public NodeState getNodeState();
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeHealthStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeHealthStatus.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeHealthStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeHealthStatus.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,6 @@
+package org.apache.ambari.server;
+
+// TODO
+public class NodeHealthStatus {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeImpl.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,361 @@
+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;
+  }
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeState.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeState.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/NodeState.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,28 @@
+package org.apache.ambari.server;
+
+public enum NodeState {
+  /**
+   * New node state
+   */
+  INIT,
+  /**
+   * State when a registration request is received from the Node but
+   * the node has not been verified/authenticated.
+   */
+  WAITING_FOR_VERIFICATION,
+  /**
+   * State when the server is receiving heartbeats regularly from the Node
+   * and the state of the Node is healthy
+   */
+  HEALTHY,
+  /**
+   * State when the server has not received a heartbeat from the Node in the
+   * configured heartbeat expiry window.
+   */
+  HEARTBEAT_LOST,
+  /**
+   * Node is in unhealthy state as reported either by the Node itself or via
+   * any other additional means ( monitoring layer )
+   */
+  UNHEALTHY
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Service.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Service.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Service.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/Service.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,40 @@
+package org.apache.ambari.server;
+
+import java.util.Map;
+
+/**
+ * Service Interface for representing various products in the
+ * Hadoop eco-system such as HDFS, MAPREDUCE, HBASE.
+ */
+public interface Service {
+
+  /**
+   * @return Name of the Service Instance
+   */
+  public String getName();
+
+  /**
+   * Get the Service Type
+   * @return ServiceType
+   */
+  public ServiceType getType();
+
+  /**
+   * Get the ServiceComponents for this Service
+   * @return ServiceComponents mapped by their names
+   */
+  public Map<String, ServiceComponent> getServiceComponents();
+
+  /**
+   * Get the list of services that this Service depends on
+   * @return Services mapped by their names
+   */
+  public Map<String, Service> getDependencies();
+
+  /**
+   * Get the list of services that depend on this Service
+   * @return Services mapped by their names
+   */
+  public Map<String, Service> getDependents();
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponent.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,39 @@
+package org.apache.ambari.server;
+
+import java.util.Map;
+
+/**
+ * ServiceComponent Interface for representing components of the various
+ * products in the Hadoop eco-system such as NAMENODE, DATANODE for HDFS.
+ */
+public interface ServiceComponent {
+
+  /**
+   * @return Name of the ServiceComponent Instance
+   */
+  public String getName();
+
+  /**
+   * Get the ServiceComponentType for this instance
+   * @return ServiceComponentType
+   */
+  public ServiceComponentType getType();
+
+  /**
+   * Get the Service to which this ServiceComponent belongs to
+   * @return Service of which this ServiceComponent is part of
+   */
+  public Service getService();
+
+  /**
+   * Get the list of components that this ServiceComponent depends on
+   * @return ServiceComponents mapped by their names
+   */
+  public Map<String, ServiceComponent> getDependencies();
+
+  /**
+   * Get the list of components that depend on this ServiceComponent
+   * @return ServiceComponents mapped by their names
+   */
+  public Map<String, ServiceComponent> getDependents();
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentType.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,8 @@
+package org.apache.ambari.server;
+
+/**
+ * TODO
+ * Meta-data object for ServiceComponent
+ */
+public interface ServiceComponentType {
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/ServiceType.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,9 @@
+package org.apache.ambari.server;
+
+/**
+ * TODO
+ * Meta-data object for Service
+ */
+public interface ServiceType {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,92 @@
+/**
+ * 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.configuration;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Ambari configuration.
+ * Reads properties from ambari.properties
+ */
+public class Configuration {
+  private static final String AMBARI_CONF_VAR = "AMBARI_CONF_DIR";
+  private static final String CONFIG_FILE = "ambari.properties";
+
+  private static final Log LOG = LogFactory.getLog(Configuration.class);
+
+  private final URI dataStore;
+
+  Configuration() {
+    this(readConfigFile());
+  }
+
+  protected Configuration(Properties properties) {
+    // get the data store
+    String dataStoreString = properties.getProperty("data.store",
+                                                    "test://test/");
+    try {
+      dataStore = new URI(dataStoreString);
+    } catch (URISyntaxException e) {
+      throw new IllegalArgumentException("Can't parse data.store: " +
+                                         dataStoreString, e);
+    }
+  }
+
+  /**
+   * Find, read, and parse the configuration file.
+   * @return the properties that were found or empty if no file was found
+   */
+  private static Properties readConfigFile() {
+    Properties properties = new Properties();
+
+    // get the configuration directory and filename
+    String confDir = System.getenv(AMBARI_CONF_VAR);
+    if (confDir == null) {
+      confDir = "/etc/ambari";
+    }
+    String filename = confDir + "/" + CONFIG_FILE;
+
+    // load the properties
+    try {
+      properties.load(new FileInputStream(filename));
+    } catch (FileNotFoundException fnf) {
+      LOG.info("No configuration file " + filename + " found.", fnf);
+    } catch (IOException ie) {
+      throw new IllegalArgumentException("Can't read configuration file " +
+                                         filename, ie);
+    }
+    return properties;
+  }
+
+  /**
+   * Get the URI for the persistent data store.
+   * @return the data store URI
+   */
+  public URI getDataStore() {
+    return dataStore;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEvent.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,13 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.fsm.event.AbstractEvent;
+
+public class ActionEvent extends AbstractEvent<ActionEventType> {
+
+  // TODO
+  // this should have some action identifier
+  public ActionEvent(ActionEventType type) {
+    super(type);
+    // TODO Auto-generated constructor stub
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionEventType.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,8 @@
+package org.apache.ambari.server.fsm;
+
+public enum ActionEventType {
+  ACTION_INIT,
+  ACTION_IN_PROGRESS,
+  ACTION_COMPLETED,
+  ACTION_FAILED
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSM.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,5 @@
+package org.apache.ambari.server.fsm;
+
+public interface ActionFSM {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/ActionFSMImpl.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,31 @@
+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();
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/InvalidStateTransitonException.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,41 @@
+/**
+* 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.fsm;
+
+// TODO
+public class InvalidStateTransitonException extends Exception {
+
+ private Enum<?> currentState;
+  private Enum<?> event;
+
+  public InvalidStateTransitonException(Enum<?> currentState, Enum<?> event) {
+    super("Invalid event: " + event + " at " + currentState);
+    this.currentState = currentState;
+    this.event = event;
+  }
+
+  public Enum<?> getCurrentState() {
+    return currentState;
+  }
+
+  public Enum<?> getEvent() {
+    return event;
+  }
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/MultipleArcTransition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/MultipleArcTransition.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/MultipleArcTransition.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/MultipleArcTransition.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,39 @@
+/**
+* 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.fsm;
+
+/**
+ * Hook for Transition.
+ * Post state is decided by Transition hook. Post state must be one of the
+ * valid post states registered in StateMachine.
+ */
+public interface MultipleArcTransition
+        <OPERAND, EVENT, STATE extends Enum<STATE>> {
+
+  /**
+   * Transition hook.
+   * @return the postState. Post state must be one of the
+   *                      valid post states registered in StateMachine.
+   * @param operand the entity attached to the FSM, whose internal
+   *                state may change.
+   * @param event causal event
+   */
+  public STATE transition(OPERAND operand, EVENT event);
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEvent.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEvent.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,14 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.fsm.event.AbstractEvent;
+
+public class NodeEvent extends AbstractEvent<NodeEventType> {
+
+  // TODO
+  // this should have some node identifier
+  public NodeEvent(NodeEventType type) {
+    super(type);
+    // TODO Auto-generated constructor stub
+  }
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeEventType.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,9 @@
+package org.apache.ambari.server.fsm;
+
+public enum NodeEventType {
+  NODE_REGISTRATION_REQUEST,
+  NODE_VERIFIED,
+  NODE_HEARTBEAT_HEALTHY,
+  NODE_HEARTBEAT_TIMED_OUT,
+  NODE_HEARTBEAT_UNHEALTHY
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSM.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,5 @@
+package org.apache.ambari.server.fsm;
+
+public interface NodeFSM {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeFSMImpl.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,58 @@
+package org.apache.ambari.server.fsm;
+
+import org.apache.ambari.server.NodeState;
+import org.apache.ambari.server.fsm.SingleArcTransition;
+import org.apache.ambari.server.fsm.StateMachineFactory;
+
+public class NodeFSMImpl implements NodeFSM {
+
+  private static final StateMachineFactory
+    <NodeFSMImpl, NodeState, NodeEventType, NodeEvent>
+      stateMachineFactory
+        = new StateMachineFactory<NodeFSMImpl, NodeState, NodeEventType, NodeEvent>
+        (NodeState.INIT)
+
+   // define the state machine of a Node
+
+   .addTransition(NodeState.INIT, NodeState.WAITING_FOR_VERIFICATION,
+       NodeEventType.NODE_REGISTRATION_REQUEST)
+
+   .addTransition(NodeState.WAITING_FOR_VERIFICATION, NodeState.HEALTHY,
+       NodeEventType.NODE_VERIFIED, new NodeVerifiedTransition())
+
+   // TODO - should be able to combine multiple into a single multi-arc
+   // transition
+   .addTransition(NodeState.HEALTHY, NodeState.HEALTHY,
+       NodeEventType.NODE_HEARTBEAT_HEALTHY)
+   .addTransition(NodeState.HEALTHY, NodeState.HEARTBEAT_LOST,
+       NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
+   .addTransition(NodeState.HEALTHY, NodeState.UNHEALTHY,
+       NodeEventType.NODE_HEARTBEAT_UNHEALTHY)
+
+   .addTransition(NodeState.UNHEALTHY, NodeState.HEALTHY,
+       NodeEventType.NODE_HEARTBEAT_HEALTHY)
+   .addTransition(NodeState.UNHEALTHY, NodeState.UNHEALTHY,
+       NodeEventType.NODE_HEARTBEAT_UNHEALTHY)
+   .addTransition(NodeState.UNHEALTHY, NodeState.HEARTBEAT_LOST,
+       NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
+
+   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEALTHY,
+       NodeEventType.NODE_HEARTBEAT_HEALTHY)
+   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.UNHEALTHY,
+       NodeEventType.NODE_HEARTBEAT_UNHEALTHY)
+   .addTransition(NodeState.HEARTBEAT_LOST, NodeState.HEARTBEAT_LOST,
+       NodeEventType.NODE_HEARTBEAT_TIMED_OUT)
+   .installTopology();
+
+
+  static class NodeVerifiedTransition
+      implements SingleArcTransition<NodeFSMImpl, NodeEvent> {
+
+    @Override
+    public void transition(NodeFSMImpl node, NodeEvent event) {
+      // TODO Auto-generated method stub
+    }
+
+  }
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEvent.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,12 @@
+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
+  }
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentEventType.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,13 @@
+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  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSM.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,5 @@
+package org.apache.ambari.server.fsm;
+
+public interface NodeServiceComponentFSM {
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentFSMImpl.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,101 @@
+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();
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeServiceComponentState.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,16 @@
+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
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/NodeState.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,9 @@
+package org.apache.ambari.server.fsm;
+
+public enum NodeState {
+  INIT,
+  WAITING_FOR_VERIFICATION,
+  HEALTHY,
+  HEARTBEAT_LOST,
+  UNHEALTHY
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/SingleArcTransition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/SingleArcTransition.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/SingleArcTransition.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/SingleArcTransition.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,35 @@
+/**
+* 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.fsm;
+
+/**
+ * Hook for Transition. This lead to state machine to move to
+ * the post state as registered in the state machine.
+ */
+public interface SingleArcTransition<OPERAND, EVENT> {
+  /**
+   * Transition hook.
+   *
+   * @param operand the entity attached to the FSM, whose internal
+   *                state may change.
+   * @param event causal event
+   */
+  public void transition(OPERAND operand, EVENT event);
+
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachine.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachine.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachine.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachine.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,27 @@
+/**
+* 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.fsm;
+
+public interface StateMachine
+                 <STATE extends Enum<STATE>,
+                  EVENTTYPE extends Enum<EVENTTYPE>, EVENT> {
+  public STATE getCurrentState();
+  public STATE doTransition(EVENTTYPE eventType, EVENT event)
+        throws InvalidStateTransitonException;
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachineFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachineFactory.java?rev=1378479&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachineFactory.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/fsm/StateMachineFactory.java Wed Aug 29 08:49:31 2012
@@ -0,0 +1,480 @@
+/**
+* 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.fsm;
+
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+
+/**
+ * State machine topology.
+ * This object is semantically immutable.  If you have a
+ * StateMachineFactory there's no operation in the API that changes
+ * its semantic properties.
+ *
+ * @param <OPERAND> The object type on which this state machine operates.
+ * @param <STATE> The state of the entity.
+ * @param <EVENTTYPE> The external eventType to be handled.
+ * @param <EVENT> The event object.
+ *
+ */
+final public class StateMachineFactory
+             <OPERAND, STATE extends Enum<STATE>,
+              EVENTTYPE extends Enum<EVENTTYPE>, EVENT> {
+
+  private final TransitionsListNode transitionsListNode;
+
+  private Map<STATE, Map<EVENTTYPE,
+    Transition<OPERAND, STATE, EVENTTYPE, EVENT>>> stateMachineTable;
+
+  private STATE defaultInitialState;
+
+  private final boolean optimized;
+
+  /**
+   * Constructor
+   *
+   * This is the only constructor in the API.
+   *
+   */
+  public StateMachineFactory(STATE defaultInitialState) {
+    this.transitionsListNode = null;
+    this.defaultInitialState = defaultInitialState;
+    this.optimized = false;
+    this.stateMachineTable = null;
+  }
+
+  private StateMachineFactory
+      (StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> that,
+       ApplicableTransition t) {
+    this.defaultInitialState = that.defaultInitialState;
+    this.transitionsListNode
+        = new TransitionsListNode(t, that.transitionsListNode);
+    this.optimized = false;
+    this.stateMachineTable = null;
+  }
+
+  private StateMachineFactory
+      (StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> that,
+       boolean optimized) {
+    this.defaultInitialState = that.defaultInitialState;
+    this.transitionsListNode = that.transitionsListNode;
+    this.optimized = optimized;
+    if (optimized) {
+      makeStateMachineTable();
+    } else {
+      stateMachineTable = null;
+    }
+  }
+
+  private interface ApplicableTransition
+             <OPERAND, STATE extends Enum<STATE>,
+              EVENTTYPE extends Enum<EVENTTYPE>, EVENT> {
+    void apply(StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> subject);
+  }
+
+  private class TransitionsListNode {
+    final ApplicableTransition transition;
+    final TransitionsListNode next;
+
+    TransitionsListNode
+        (ApplicableTransition transition, TransitionsListNode next) {
+      this.transition = transition;
+      this.next = next;
+    }
+  }
+
+  static private class ApplicableSingleOrMultipleTransition
+             <OPERAND, STATE extends Enum<STATE>,
+              EVENTTYPE extends Enum<EVENTTYPE>, EVENT>
+          implements ApplicableTransition<OPERAND, STATE, EVENTTYPE, EVENT> {
+    final STATE preState;
+    final EVENTTYPE eventType;
+    final Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition;
+
+    ApplicableSingleOrMultipleTransition
+        (STATE preState, EVENTTYPE eventType,
+         Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition) {
+      this.preState = preState;
+      this.eventType = eventType;
+      this.transition = transition;
+    }
+
+    @Override
+    public void apply
+             (StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> subject) {
+      Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>> transitionMap
+        = subject.stateMachineTable.get(preState);
+      if (transitionMap == null) {
+        // I use HashMap here because I would expect most EVENTTYPE's to not
+        //  apply out of a particular state, so FSM sizes would be
+        //  quadratic if I use EnumMap's here as I do at the top level.
+        transitionMap = new HashMap<EVENTTYPE,
+          Transition<OPERAND, STATE, EVENTTYPE, EVENT>>();
+        subject.stateMachineTable.put(preState, transitionMap);
+      }
+      transitionMap.put(eventType, transition);
+    }
+  }
+
+  /**
+   * @return a NEW StateMachineFactory just like {@code this} with the current
+   *          transition added as a new legal transition.  This overload
+   *          has no hook object.
+   *
+   *         Note that the returned StateMachineFactory is a distinct
+   *         object.
+   *
+   *         This method is part of the API.
+   *
+   * @param preState pre-transition state
+   * @param postState post-transition state
+   * @param eventType stimulus for the transition
+   */
+  public StateMachineFactory
+             <OPERAND, STATE, EVENTTYPE, EVENT>
+          addTransition(STATE preState, STATE postState, EVENTTYPE eventType) {
+    return addTransition(preState, postState, eventType, null);
+  }
+
+  /**
+   * @return a NEW StateMachineFactory just like {@code this} with the current
+   *          transition added as a new legal transition.  This overload
+   *          has no hook object.
+   *
+   *
+   *         Note that the returned StateMachineFactory is a distinct
+   *         object.
+   *
+   *         This method is part of the API.
+   *
+   * @param preState pre-transition state
+   * @param postState post-transition state
+   * @param eventTypes List of stimuli for the transitions
+   */
+  public StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> addTransition(
+      STATE preState, STATE postState, Set<EVENTTYPE> eventTypes) {
+    return addTransition(preState, postState, eventTypes, null);
+  }
+
+  /**
+   * @return a NEW StateMachineFactory just like {@code this} with the current
+   *          transition added as a new legal transition
+   *
+   *         Note that the returned StateMachineFactory is a distinct
+   *         object.
+   *
+   *         This method is part of the API.
+   *
+   * @param preState pre-transition state
+   * @param postState post-transition state
+   * @param eventTypes List of stimuli for the transitions
+   * @param hook transition hook
+   */
+  public StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> addTransition(
+      STATE preState, STATE postState, Set<EVENTTYPE> eventTypes,
+      SingleArcTransition<OPERAND, EVENT> hook) {
+    StateMachineFactory<OPERAND, STATE, EVENTTYPE, EVENT> factory = null;
+    for (EVENTTYPE event : eventTypes) {
+      if (factory == null) {
+        factory = addTransition(preState, postState, event, hook);
+      } else {
+        factory = factory.addTransition(preState, postState, event, hook);
+      }
+    }
+    return factory;
+  }
+
+  /**
+   * @return a NEW StateMachineFactory just like {@code this} with the current
+   *          transition added as a new legal transition
+   *
+   *         Note that the returned StateMachineFactory is a distinct object.
+   *
+   *         This method is part of the API.
+   *
+   * @param preState pre-transition state
+   * @param postState post-transition state
+   * @param eventType stimulus for the transition
+   * @param hook transition hook
+   */
+  public StateMachineFactory
+             <OPERAND, STATE, EVENTTYPE, EVENT>
+          addTransition(STATE preState, STATE postState,
+                        EVENTTYPE eventType,
+                        SingleArcTransition<OPERAND, EVENT> hook){
+    return new StateMachineFactory
+        (this, new ApplicableSingleOrMultipleTransition
+           (preState, eventType, new SingleInternalArc(postState, hook)));
+  }
+
+  /**
+   * @return a NEW StateMachineFactory just like {@code this} with the current
+   *          transition added as a new legal transition
+   *
+   *         Note that the returned StateMachineFactory is a distinct object.
+   *
+   *         This method is part of the API.
+   *
+   * @param preState pre-transition state
+   * @param postStates valid post-transition states
+   * @param eventType stimulus for the transition
+   * @param hook transition hook
+   */
+  public StateMachineFactory
+             <OPERAND, STATE, EVENTTYPE, EVENT>
+          addTransition(STATE preState, Set<STATE> postStates,
+                        EVENTTYPE eventType,
+                        MultipleArcTransition<OPERAND, EVENT, STATE> hook){
+    return new StateMachineFactory
+        (this,
+         new ApplicableSingleOrMultipleTransition
+           (preState, eventType, new MultipleInternalArc(postStates, hook)));
+  }
+
+  /**
+   * @return a StateMachineFactory just like {@code this}, except that if
+   *         you won't need any synchronization to build a state machine
+   *
+   *         Note that the returned StateMachineFactory is a distinct object.
+   *
+   *         This method is part of the API.
+   *
+   *         The only way you could distinguish the returned
+   *         StateMachineFactory from {@code this} would be by
+   *         measuring the performance of the derived
+   *         {@code StateMachine} you can get from it.
+   *
+   * Calling this is optional.  It doesn't change the semantics of the factory,
+   *   if you call it then when you use the factory there is no synchronization.
+   */
+  public StateMachineFactory
+             <OPERAND, STATE, EVENTTYPE, EVENT>
+          installTopology() {
+    return new StateMachineFactory(this, true);
+  }
+
+  /**
+   * Effect a transition due to the effecting stimulus.
+   * @param state current state
+   * @param eventType trigger to initiate the transition
+   * @param cause causal eventType context
+   * @return transitioned state
+   */
+  private STATE doTransition
+           (OPERAND operand, STATE oldState, EVENTTYPE eventType, EVENT event)
+      throws InvalidStateTransitonException {
+    // We can assume that stateMachineTable is non-null because we call
+    //  maybeMakeStateMachineTable() when we build an InnerStateMachine ,
+    //  and this code only gets called from inside a working InnerStateMachine .
+    Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>> transitionMap
+      = stateMachineTable.get(oldState);
+    if (transitionMap != null) {
+      Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition
+          = transitionMap.get(eventType);
+      if (transition != null) {
+        return transition.doTransition(operand, oldState, event, eventType);
+      }
+    }
+    throw new InvalidStateTransitonException(oldState, eventType);
+  }
+
+  private synchronized void maybeMakeStateMachineTable() {
+    if (stateMachineTable == null) {
+      makeStateMachineTable();
+    }
+  }
+
+  private void makeStateMachineTable() {
+    Stack<ApplicableTransition> stack = new Stack<ApplicableTransition>();
+
+    Map<STATE, Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>>>
+      prototype = new HashMap<STATE, Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>>>();
+
+    prototype.put(defaultInitialState, null);
+
+    // I use EnumMap here because it'll be faster and denser.  I would
+    //  expect most of the states to have at least one transition.
+    stateMachineTable
+       = new EnumMap<STATE, Map<EVENTTYPE,
+                           Transition<OPERAND, STATE, EVENTTYPE, EVENT>>>(prototype);
+
+    for (TransitionsListNode cursor = transitionsListNode;
+         cursor != null;
+         cursor = cursor.next) {
+      stack.push(cursor.transition);
+    }
+
+    while (!stack.isEmpty()) {
+      stack.pop().apply(this);
+    }
+  }
+
+  private interface Transition<OPERAND, STATE extends Enum<STATE>,
+          EVENTTYPE extends Enum<EVENTTYPE>, EVENT> {
+    STATE doTransition(OPERAND operand, STATE oldState,
+                       EVENT event, EVENTTYPE eventType)
+       throws InvalidStateTransitonException;
+  }
+
+  private class SingleInternalArc
+                    implements Transition<OPERAND, STATE, EVENTTYPE, EVENT> {
+
+    private STATE postState;
+    private SingleArcTransition<OPERAND, EVENT> hook; // transition hook
+
+    SingleInternalArc(STATE postState,
+        SingleArcTransition<OPERAND, EVENT> hook) {
+      this.postState = postState;
+      this.hook = hook;
+    }
+
+    @Override
+    public STATE doTransition(OPERAND operand, STATE oldState,
+                              EVENT event, EVENTTYPE eventType) {
+      if (hook != null) {
+        hook.transition(operand, event);
+      }
+      return postState;
+    }
+  }
+
+  private class MultipleInternalArc
+              implements Transition<OPERAND, STATE, EVENTTYPE, EVENT>{
+
+    // Fields
+    private Set<STATE> validPostStates;
+    private MultipleArcTransition<OPERAND, EVENT, STATE> hook;  // transition hook
+
+    MultipleInternalArc(Set<STATE> postStates,
+                   MultipleArcTransition<OPERAND, EVENT, STATE> hook) {
+      this.validPostStates = postStates;
+      this.hook = hook;
+    }
+
+    @Override
+    public STATE doTransition(OPERAND operand, STATE oldState,
+                              EVENT event, EVENTTYPE eventType)
+        throws InvalidStateTransitonException {
+      STATE postState = hook.transition(operand, event);
+
+      if (!validPostStates.contains(postState)) {
+        throw new InvalidStateTransitonException(oldState, eventType);
+      }
+      return postState;
+    }
+  }
+
+  /*
+   * @return a {@link StateMachine} that starts in
+   *         {@code initialState} and whose {@link Transition} s are
+   *         applied to {@code operand} .
+   *
+   *         This is part of the API.
+   *
+   * @param operand the object upon which the returned
+   *                {@link StateMachine} will operate.
+   * @param initialState the state in which the returned
+   *                {@link StateMachine} will start.
+   *
+   */
+  public StateMachine<STATE, EVENTTYPE, EVENT>
+        make(OPERAND operand, STATE initialState) {
+    return new InternalStateMachine(operand, initialState);
+  }
+
+  /*
+   * @return a {@link StateMachine} that starts in the default initial
+   *          state and whose {@link Transition} s are applied to
+   *          {@code operand} .
+   *
+   *         This is part of the API.
+   *
+   * @param operand the object upon which the returned
+   *                {@link StateMachine} will operate.
+   *
+   */
+  public StateMachine<STATE, EVENTTYPE, EVENT> make(OPERAND operand) {
+    return new InternalStateMachine(operand, defaultInitialState);
+  }
+
+  private class InternalStateMachine
+        implements StateMachine<STATE, EVENTTYPE, EVENT> {
+    private final OPERAND operand;
+    private STATE currentState;
+
+    InternalStateMachine(OPERAND operand, STATE initialState) {
+      this.operand = operand;
+      this.currentState = initialState;
+      if (!optimized) {
+        maybeMakeStateMachineTable();
+      }
+    }
+
+    @Override
+    public synchronized STATE getCurrentState() {
+      return currentState;
+    }
+
+    @Override
+    public synchronized STATE doTransition(EVENTTYPE eventType, EVENT event)
+         throws InvalidStateTransitonException  {
+      currentState = StateMachineFactory.this.doTransition
+          (operand, currentState, eventType, event);
+      return currentState;
+    }
+  }
+
+  /*
+   * Generate a graph represents the state graph of this StateMachine
+   * @param name graph name
+   * @return Graph object generated
+  public Graph generateStateGraph(String name) {
+    maybeMakeStateMachineTable();
+    Graph g = new Graph(name);
+    for (STATE startState : stateMachineTable.keySet()) {
+      Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>> transitions
+          = stateMachineTable.get(startState);
+      for (Entry<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>> entry :
+         transitions.entrySet()) {
+        Transition<OPERAND, STATE, EVENTTYPE, EVENT> transition = entry.getValue();
+        if (transition instanceof StateMachineFactory.SingleInternalArc) {
+          StateMachineFactory.SingleInternalArc sa
+              = (StateMachineFactory.SingleInternalArc) transition;
+          Graph.Node fromNode = g.getNode(startState.toString());
+          Graph.Node toNode = g.getNode(sa.postState.toString());
+          fromNode.addEdge(toNode, entry.getKey().toString());
+        } else if (transition instanceof StateMachineFactory.MultipleInternalArc) {
+          StateMachineFactory.MultipleInternalArc ma
+              = (StateMachineFactory.MultipleInternalArc) transition;
+          Iterator<STATE> iter = ma.validPostStates.iterator();
+          while (iter.hasNext()) {
+            Graph.Node fromNode = g.getNode(startState.toString());
+            Graph.Node toNode = g.getNode(iter.next().toString());
+            fromNode.addEdge(toNode, entry.getKey().toString());
+          }
+        }
+      }
+    }
+    return g;
+  }
+  */
+}



Mime
View raw message