incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject svn commit: r1393753 [2/2] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ ambari-server/src/main/java/org/apache/ambari/server/agent/ ambari-server/src/main/java/org/apache/ambari/serv...
Date Wed, 03 Oct 2012 20:44:20 GMT
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostImpl.java
Wed Oct  3 20:44:18 2012
@@ -28,11 +28,11 @@ import java.util.concurrent.locks.Reentr
 
 import org.apache.ambari.server.agent.DiskInfo;
 import org.apache.ambari.server.agent.HostInfo;
+import org.apache.ambari.server.state.AgentVersion;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.fsm.SingleArcTransition;
 import org.apache.ambari.server.state.fsm.StateMachine;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
-import org.apache.ambari.server.state.live.AgentVersion;
 import org.apache.ambari.server.state.live.job.Job;
 import org.apache.ambari.server.state.live.host.HostHealthStatus.HealthStatus;
 import org.apache.commons.logging.Log;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/host/HostRegistrationRequestEvent.java
Wed Oct  3 20:44:18 2012
@@ -19,7 +19,7 @@
 package org.apache.ambari.server.state.live.host;
 
 import org.apache.ambari.server.agent.HostInfo;
-import org.apache.ambari.server.state.live.AgentVersion;
+import org.apache.ambari.server.state.AgentVersion;
 
 public class HostRegistrationRequestEvent extends HostEvent {
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/job/JobEvent.java
Wed Oct  3 20:44:18 2012
@@ -23,7 +23,7 @@ import org.apache.ambari.server.state.fs
 /**
  * Base class for all events that affect the Job FSM
  */
-public class JobEvent extends AbstractEvent<JobEventType> {
+public abstract class JobEvent extends AbstractEvent<JobEventType> {
 
   /**
    * JobId identifying the job

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHost.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHost.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHost.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHost.java
Wed Oct  3 20:44:18 2012
@@ -20,6 +20,7 @@ package org.apache.ambari.server.state.l
 
 import java.util.List;
 
+import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.live.job.Job;
 
@@ -61,13 +62,13 @@ public interface ServiceComponentHost {
    * Get ServiceComponent-Host State
    * @return ServiceComponentHostState
    */
-  public ServiceComponentHostState getState();
+  public State getState();
 
   /**
    * Set the State for this ServiceComponent-Host
    * @param state ServiceComponentHostState to set to
    */
-  public void setState(ServiceComponentHostState state);
+  public void setState(State state);
 
   /**
    * Send a ServiceComponentHostState event to the StateMachine

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostEvent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostEvent.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostEvent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostEvent.java
Wed Oct  3 20:44:18 2012
@@ -23,7 +23,7 @@ import org.apache.ambari.server.state.fs
 /**
  * Base class for all events that affect the ServiceComponentHost FSM
  */
-public class ServiceComponentHostEvent
+public abstract class ServiceComponentHostEvent
     extends AbstractEvent<ServiceComponentHostEventType> {
 
   /**

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostImpl.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/live/svccomphost/ServiceComponentHostImpl.java
Wed Oct  3 20:44:18 2012
@@ -23,23 +23,25 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.ambari.server.state.DeployState;
+import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.fsm.SingleArcTransition;
 import org.apache.ambari.server.state.fsm.StateMachine;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
 import org.apache.ambari.server.state.live.job.Job;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ServiceComponentHostImpl implements ServiceComponentHost {
 
-  private static final Log LOG =
-      LogFactory.getLog(ServiceComponentHostImpl.class);
+  private static final Logger LOG =
+      LoggerFactory.getLogger(ServiceComponentHostImpl.class);
 
   private final Lock readLock;
   private final Lock writeLock;
 
-  private ServiceComponentHostState state;
+  private State state;
 
   private final long clusterId;
   private final String serviceName;
@@ -51,233 +53,233 @@ public class ServiceComponentHostImpl im
   private long lastOpLastUpdateTime;
 
   private static final StateMachineFactory
-  <ServiceComponentHostImpl, ServiceComponentHostLiveState,
+  <ServiceComponentHostImpl, DeployState,
   ServiceComponentHostEventType, ServiceComponentHostEvent>
     daemonStateMachineFactory
       = new StateMachineFactory<ServiceComponentHostImpl,
-          ServiceComponentHostLiveState, ServiceComponentHostEventType,
+          DeployState, ServiceComponentHostEventType,
           ServiceComponentHostEvent>
-          (ServiceComponentHostLiveState.INIT)
+          (DeployState.INIT)
 
   // define the state machine of a HostServiceComponent for runnable
   // components
 
-     .addTransition(ServiceComponentHostLiveState.INIT,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INIT,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALLED,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALLED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALL_FAILED,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALL_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.INSTALL_FAILED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALL_FAILED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.INSTALLED,
-         ServiceComponentHostLiveState.STARTING,
+     .addTransition(DeployState.INSTALLED,
+         DeployState.STARTING,
          ServiceComponentHostEventType.HOST_SVCCOMP_START,
          new ServiceComponentHostOpStartedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLED,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.INSTALLED,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
          new ServiceComponentHostOpStartedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALLED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.STARTING,
-         ServiceComponentHostLiveState.STARTING,
+     .addTransition(DeployState.STARTING,
+         DeployState.STARTING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.STARTING,
-         ServiceComponentHostLiveState.STARTED,
+     .addTransition(DeployState.STARTING,
+         DeployState.STARTED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.STARTING,
-         ServiceComponentHostLiveState.START_FAILED,
+     .addTransition(DeployState.STARTING,
+         DeployState.START_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.START_FAILED,
-         ServiceComponentHostLiveState.STARTING,
+     .addTransition(DeployState.START_FAILED,
+         DeployState.STARTING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.STARTED,
-         ServiceComponentHostLiveState.STOPPING,
+     .addTransition(DeployState.STARTED,
+         DeployState.STOPPING,
          ServiceComponentHostEventType.HOST_SVCCOMP_STOP,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.STOPPING,
-         ServiceComponentHostLiveState.STOPPING,
+     .addTransition(DeployState.STOPPING,
+         DeployState.STOPPING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.STOPPING,
-         ServiceComponentHostLiveState.INSTALLED,
+     .addTransition(DeployState.STOPPING,
+         DeployState.INSTALLED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.STOPPING,
-         ServiceComponentHostLiveState.STOP_FAILED,
+     .addTransition(DeployState.STOPPING,
+         DeployState.STOP_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.STOP_FAILED,
-         ServiceComponentHostLiveState.STOPPING,
+     .addTransition(DeployState.STOP_FAILED,
+         DeployState.STOPPING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALLED,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALLED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALL_FAILED,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALL_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALL_FAILED,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.UNINSTALL_FAILED,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.UNINSTALLED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.UNINSTALLED,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.INIT,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.INIT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.WIPEOUT_FAILED,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.WIPEOUT_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPEOUT_FAILED,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.WIPEOUT_FAILED,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
      .installTopology();
 
   private static final StateMachineFactory
-  <ServiceComponentHostImpl, ServiceComponentHostLiveState,
+  <ServiceComponentHostImpl, DeployState,
   ServiceComponentHostEventType, ServiceComponentHostEvent>
     clientStateMachineFactory
       = new StateMachineFactory<ServiceComponentHostImpl,
-          ServiceComponentHostLiveState, ServiceComponentHostEventType,
+          DeployState, ServiceComponentHostEventType,
           ServiceComponentHostEvent>
-          (ServiceComponentHostLiveState.INIT)
+          (DeployState.INIT)
 
   // define the state machine of a HostServiceComponent for client only
   // components
 
-     .addTransition(ServiceComponentHostLiveState.INIT,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INIT,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALLED,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALLED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLING,
-         ServiceComponentHostLiveState.INSTALL_FAILED,
+     .addTransition(DeployState.INSTALLING,
+         DeployState.INSTALL_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.INSTALL_FAILED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALL_FAILED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.INSTALLED,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.INSTALLED,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
          new ServiceComponentHostOpStartedTransition())
-     .addTransition(ServiceComponentHostLiveState.INSTALLED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.INSTALLED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALLED,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALLED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLING,
-         ServiceComponentHostLiveState.UNINSTALL_FAILED,
+     .addTransition(DeployState.UNINSTALLING,
+         DeployState.UNINSTALL_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALL_FAILED,
-         ServiceComponentHostLiveState.UNINSTALLING,
+     .addTransition(DeployState.UNINSTALL_FAILED,
+         DeployState.UNINSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
-         ServiceComponentHostLiveState.INSTALLING,
+     .addTransition(DeployState.UNINSTALLED,
+         DeployState.INSTALLING,
          ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.UNINSTALLED,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.UNINSTALLED,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
          new ServiceComponentHostOpStartedTransition())
 
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_IN_PROGRESS,
          new ServiceComponentHostOpInProgressTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.INIT,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.INIT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_SUCCEEDED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPING_OUT,
-         ServiceComponentHostLiveState.WIPEOUT_FAILED,
+     .addTransition(DeployState.WIPING_OUT,
+         DeployState.WIPEOUT_FAILED,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_FAILED,
          new ServiceComponentHostOpCompletedTransition())
-     .addTransition(ServiceComponentHostLiveState.WIPEOUT_FAILED,
-         ServiceComponentHostLiveState.WIPING_OUT,
+     .addTransition(DeployState.WIPEOUT_FAILED,
+         DeployState.WIPING_OUT,
          ServiceComponentHostEventType.HOST_SVCCOMP_OP_RESTART,
          new ServiceComponentHostOpStartedTransition())
 
      .installTopology();
 
 
-  private final StateMachine<ServiceComponentHostLiveState,
+  private final StateMachine<DeployState,
       ServiceComponentHostEventType, ServiceComponentHostEvent> stateMachine;
 
   static class ServiceComponentHostOpCompletedTransition
@@ -375,12 +377,12 @@ public class ServiceComponentHostImpl im
     this.serviceName = serviceName;
     this.serviceComponentName = serviceComponentName;
     this.hostName = hostName;
-    this.state = new ServiceComponentHostState();
+    this.state = new State();
     this.resetLastOpInfo();
   }
 
   @Override
-  public ServiceComponentHostState getState() {
+  public State getState() {
     try {
       readLock.lock();
       return state;
@@ -391,7 +393,7 @@ public class ServiceComponentHostImpl im
   }
 
   @Override
-  public void setState(ServiceComponentHostState state) {
+  public void setState(State state) {
     try {
       writeLock.lock();
       this.state = state;
@@ -410,7 +412,7 @@ public class ServiceComponentHostImpl im
           + " eventType=" + event.getType().name()
           + ", event=" + event.toString());
     }
-    ServiceComponentHostState oldState = getState();
+    State oldState = getState();
     try {
       writeLock.lock();
       try {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/resources/TestResources.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/resources/TestResources.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/resources/TestResources.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/resources/TestResources.java
Wed Oct  3 20:44:18 2012
@@ -70,7 +70,7 @@ public class TestResources extends TestC
 	props.store(out, "");
 	out.close();
     resourceFile = tempFolder.newFile(RESOURCE_FILE_NAME);
-    FileUtils.write(resourceFile, RESOURCE_FILE_CONTENT);
+    FileUtils.writeStringToFile(resourceFile, RESOURCE_FILE_CONTENT);
     injector = Guice.createInjector(new ResourceModule());
     resMan = injector.getInstance(ResourceManager.class);
   }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/DeployStateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/DeployStateTest.java?rev=1393753&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/DeployStateTest.java
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/DeployStateTest.java
Wed Oct  3 20:44:18 2012
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.state;
+
+import junit.framework.Assert;
+
+import org.apache.ambari.server.state.ConfigVersion;
+import org.apache.ambari.server.state.DeployState;
+import org.apache.ambari.server.state.StackVersion;
+import org.apache.ambari.server.state.State;
+import org.junit.Test;
+
+public class DeployStateTest {
+
+  @Test
+  public void testEquals() {
+    State s1 = new State();
+    State s2 = new State();
+
+    Assert.assertTrue(s1.equals(s2));
+
+    s1.setConfigVersion(new ConfigVersion("x.y.z"));
+    Assert.assertFalse(s1.equals(s2));
+    Assert.assertFalse(s2.equals(s1));
+
+    s2.setConfigVersion(new ConfigVersion("x.y.foo"));
+    Assert.assertFalse(s1.equals(s2));
+    Assert.assertFalse(s2.equals(s1));
+
+    s2.setConfigVersion(new ConfigVersion("x.y.z"));
+    Assert.assertTrue(s1.equals(s2));
+
+    s2.setStackVersion(new StackVersion("1.x"));
+    Assert.assertFalse(s1.equals(s2));
+    Assert.assertFalse(s2.equals(s1));
+
+    s1.setStackVersion(new StackVersion("1.x"));
+    Assert.assertTrue(s1.equals(s2));
+
+    s1.setStackVersion(new StackVersion("2.x"));
+    Assert.assertFalse(s1.equals(s2));
+    Assert.assertFalse(s2.equals(s1));
+
+    s1.setState(DeployState.INSTALLED);
+    Assert.assertFalse(s1.equals(s2));
+
+  }
+
+}

Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/DeployStateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/TestClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/TestClusterImpl.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/TestClusterImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/TestClusterImpl.java
Wed Oct  3 20:44:18 2012
@@ -28,16 +28,17 @@ import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.agent.DiskInfo;
 import org.apache.ambari.server.agent.HostInfo;
+import org.apache.ambari.server.state.AgentVersion;
 import org.apache.ambari.server.state.ConfigVersion;
+import org.apache.ambari.server.state.DeployState;
 import org.apache.ambari.server.state.StackVersion;
+import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitonException;
 import org.apache.ambari.server.state.live.host.HostHealthyHeartbeatEvent;
 import org.apache.ambari.server.state.live.host.HostRegistrationRequestEvent;
 import org.apache.ambari.server.state.live.host.HostState;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostInstallEvent;
-import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostLiveState;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostOpRestartedEvent;
-import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostState;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -158,7 +159,7 @@ public class TestClusterImpl {
   @Test
   public void testGetServiceComponentHostState() throws AmbariException {
     Assert.assertNotNull(c1.getServiceComponentHostState(s1, sc1, h1));
-    Assert.assertEquals(ServiceComponentHostLiveState.INIT,
+    Assert.assertEquals(DeployState.INIT,
         c1.getServiceComponentHostState(s1, sc1, h1).getLiveState());
   }
 
@@ -166,17 +167,17 @@ public class TestClusterImpl {
   public void testSetServiceComponentHostState() throws AmbariException {
     ConfigVersion cVersion = new ConfigVersion("0.0.c");
     StackVersion sVersion = new StackVersion("hadoop-x.y.z");
-    ServiceComponentHostLiveState liveState =
-        ServiceComponentHostLiveState.INSTALL_FAILED;
-    ServiceComponentHostState expected =
-        new ServiceComponentHostState(cVersion, sVersion, liveState);
+    DeployState liveState =
+        DeployState.INSTALL_FAILED;
+    State expected =
+        new State(cVersion, sVersion, liveState);
     c1.setServiceComponentHostState(s1, sc1, h1, expected);
 
-    ServiceComponentHostState actual =
+    State actual =
         c1.getServiceComponentHostState(s1, sc1, h1);
 
     Assert.assertEquals(expected, actual);
-    Assert.assertEquals(ServiceComponentHostLiveState.INSTALL_FAILED,
+    Assert.assertEquals(DeployState.INSTALL_FAILED,
         actual.getLiveState());
 
   }
@@ -186,10 +187,10 @@ public class TestClusterImpl {
       throws AmbariException, InvalidStateTransitonException {
     ConfigVersion cVersion = new ConfigVersion("0.0.c");
     StackVersion sVersion = new StackVersion("hadoop-x.y.z");
-    ServiceComponentHostLiveState liveState =
-        ServiceComponentHostLiveState.INSTALL_FAILED;
-    ServiceComponentHostState expected =
-        new ServiceComponentHostState(cVersion, sVersion, liveState);
+    DeployState liveState =
+        DeployState.INSTALL_FAILED;
+    State expected =
+        new State(cVersion, sVersion, liveState);
     c1.setServiceComponentHostState(s1, sc1, h1, expected);
 
     try {
@@ -204,7 +205,7 @@ public class TestClusterImpl {
     c1.handleServiceComponentHostEvent(s1, sc1, h1,
         new ServiceComponentHostOpRestartedEvent(sc1, h1, 1002));
 
-    Assert.assertEquals(ServiceComponentHostLiveState.INSTALLING,
+    Assert.assertEquals(DeployState.INSTALLING,
         c1.getServiceComponentHostState(s1, sc1, h1).getLiveState());
 
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/host/TestHostImpl.java
Wed Oct  3 20:44:18 2012
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.ambari.server.agent.DiskInfo;
 import org.apache.ambari.server.agent.HostInfo;
-import org.apache.ambari.server.state.live.AgentVersion;
+import org.apache.ambari.server.state.AgentVersion;
 import org.apache.ambari.server.state.live.host.HostHealthStatus.HealthStatus;
 import org.junit.Assert;
 import org.junit.Test;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/svccomphost/TestServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/svccomphost/TestServiceComponentHostImpl.java?rev=1393753&r1=1393752&r2=1393753&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/svccomphost/TestServiceComponentHostImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/live/svccomphost/TestServiceComponentHostImpl.java
Wed Oct  3 20:44:18 2012
@@ -18,10 +18,10 @@
 
 package org.apache.ambari.server.state.live.svccomphost;
 
+import org.apache.ambari.server.state.DeployState;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostEvent;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostEventType;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostImpl;
-import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostLiveState;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostOpFailedEvent;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostOpInProgressEvent;
 import org.apache.ambari.server.state.live.svccomphost.ServiceComponentHostOpRestartedEvent;
@@ -37,7 +37,7 @@ public class TestServiceComponentHostImp
       String hostName, boolean isClient) {
     ServiceComponentHostImpl impl = new ServiceComponentHostImpl(clusterId, svc,
         svcComponent, hostName, isClient);
-    Assert.assertEquals(ServiceComponentHostLiveState.INIT,
+    Assert.assertEquals(DeployState.INIT,
         impl.getState().getLiveState());
     return impl;
   }
@@ -50,17 +50,44 @@ public class TestServiceComponentHostImp
 
   private ServiceComponentHostEvent createEvent(ServiceComponentHostImpl impl,
       long timestamp, ServiceComponentHostEventType eventType) {
-    ServiceComponentHostEvent event = new ServiceComponentHostEvent(eventType,
-          impl.getServiceComponentName(), impl.getHostName(), timestamp);
-    return event;
+    switch (eventType) {
+      case HOST_SVCCOMP_INSTALL:
+        return new ServiceComponentHostInstallEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_START:
+        return new ServiceComponentHostStartEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_STOP:
+        return new ServiceComponentHostStopEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_UNINSTALL:
+        return new ServiceComponentHostUninstallEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_OP_FAILED:
+        return new ServiceComponentHostOpFailedEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_OP_SUCCEEDED:
+        return new ServiceComponentHostOpSucceededEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_OP_IN_PROGRESS:
+        return new ServiceComponentHostOpInProgressEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_OP_RESTART:
+        return new ServiceComponentHostOpRestartedEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+      case HOST_SVCCOMP_WIPEOUT:
+        return new ServiceComponentHostWipeoutEvent(
+            impl.getServiceComponentName(), impl.getHostName(), timestamp);
+    }
+    return null;
   }
 
   private void runStateChanges(ServiceComponentHostImpl impl,
       ServiceComponentHostEventType startEvent,
-      ServiceComponentHostLiveState startState,
-      ServiceComponentHostLiveState inProgressState,
-      ServiceComponentHostLiveState failedState,
-      ServiceComponentHostLiveState completedState)
+      DeployState startState,
+      DeployState inProgressState,
+      DeployState failedState,
+      DeployState completedState)
     throws Exception {
     long timestamp = 0;
 
@@ -164,18 +191,18 @@ public class TestServiceComponentHostImp
         "svcComp", "h1", true);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
-        ServiceComponentHostLiveState.INIT,
-        ServiceComponentHostLiveState.INSTALLING,
-        ServiceComponentHostLiveState.INSTALL_FAILED,
-        ServiceComponentHostLiveState.INSTALLED);
+        DeployState.INIT,
+        DeployState.INSTALLING,
+        DeployState.INSTALL_FAILED,
+        DeployState.INSTALLED);
 
     boolean exceptionThrown = false;
     try {
       runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_START,
-        ServiceComponentHostLiveState.INSTALLED,
-        ServiceComponentHostLiveState.STARTING,
-        ServiceComponentHostLiveState.START_FAILED,
-        ServiceComponentHostLiveState.STARTED);
+        DeployState.INSTALLED,
+        DeployState.STARTING,
+        DeployState.START_FAILED,
+        DeployState.STARTED);
     }
     catch (Exception e) {
       exceptionThrown = true;
@@ -183,16 +210,16 @@ public class TestServiceComponentHostImp
     Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
-        ServiceComponentHostLiveState.INSTALLED,
-        ServiceComponentHostLiveState.UNINSTALLING,
-        ServiceComponentHostLiveState.UNINSTALL_FAILED,
-        ServiceComponentHostLiveState.UNINSTALLED);
+        DeployState.INSTALLED,
+        DeployState.UNINSTALLING,
+        DeployState.UNINSTALL_FAILED,
+        DeployState.UNINSTALLED);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
-        ServiceComponentHostLiveState.UNINSTALLED,
-        ServiceComponentHostLiveState.WIPING_OUT,
-        ServiceComponentHostLiveState.WIPEOUT_FAILED,
-        ServiceComponentHostLiveState.INIT);
+        DeployState.UNINSTALLED,
+        DeployState.WIPING_OUT,
+        DeployState.WIPEOUT_FAILED,
+        DeployState.INIT);
 
   }
 
@@ -202,34 +229,34 @@ public class TestServiceComponentHostImp
         "svcComp", "h1", false);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
-        ServiceComponentHostLiveState.INIT,
-        ServiceComponentHostLiveState.INSTALLING,
-        ServiceComponentHostLiveState.INSTALL_FAILED,
-        ServiceComponentHostLiveState.INSTALLED);
+        DeployState.INIT,
+        DeployState.INSTALLING,
+        DeployState.INSTALL_FAILED,
+        DeployState.INSTALLED);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_START,
-      ServiceComponentHostLiveState.INSTALLED,
-      ServiceComponentHostLiveState.STARTING,
-      ServiceComponentHostLiveState.START_FAILED,
-      ServiceComponentHostLiveState.STARTED);
+      DeployState.INSTALLED,
+      DeployState.STARTING,
+      DeployState.START_FAILED,
+      DeployState.STARTED);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_STOP,
-      ServiceComponentHostLiveState.STARTED,
-      ServiceComponentHostLiveState.STOPPING,
-      ServiceComponentHostLiveState.STOP_FAILED,
-      ServiceComponentHostLiveState.INSTALLED);
+      DeployState.STARTED,
+      DeployState.STOPPING,
+      DeployState.STOP_FAILED,
+      DeployState.INSTALLED);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_UNINSTALL,
-        ServiceComponentHostLiveState.INSTALLED,
-        ServiceComponentHostLiveState.UNINSTALLING,
-        ServiceComponentHostLiveState.UNINSTALL_FAILED,
-        ServiceComponentHostLiveState.UNINSTALLED);
+        DeployState.INSTALLED,
+        DeployState.UNINSTALLING,
+        DeployState.UNINSTALL_FAILED,
+        DeployState.UNINSTALLED);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_WIPEOUT,
-        ServiceComponentHostLiveState.UNINSTALLED,
-        ServiceComponentHostLiveState.WIPING_OUT,
-        ServiceComponentHostLiveState.WIPEOUT_FAILED,
-        ServiceComponentHostLiveState.INIT);
+        DeployState.UNINSTALLED,
+        DeployState.WIPING_OUT,
+        DeployState.WIPEOUT_FAILED,
+        DeployState.INIT);
 
   }
 



Mime
View raw message