incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1205189 - in /incubator/ambari/trunk: ./ controller/src/main/java/org/apache/ambari/components/ controller/src/main/java/org/apache/ambari/components/impl/ controller/src/main/java/org/apache/ambari/controller/ controller/src/main/java/org...
Date Tue, 22 Nov 2011 22:07:30 GMT
Author: ddas
Date: Tue Nov 22 22:07:25 2011
New Revision: 1205189

URL: http://svn.apache.org/viewvc?rev=1205189&view=rev
Log:
AMBARI-135. Simplifies the heartbeat handling to not deal with install/configure methods on
component plugin definitions.

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/impl/XmlComponentDefinition.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/RoleImpl.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1205189&r1=1205188&r2=1205189&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Nov 22 22:07:25 2011
@@ -2,6 +2,9 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
+  AMBARI-135. Simplifies the heartbeat handling to not deal with 
+  install/configure methods on component plugin definitions (ddas)
+
   AMBARI-134. Add Google analytics to the site. (omalley)
 
   AMBARI-132. Fix update agent environment script location. (Ahmed

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java?rev=1205189&r1=1205188&r2=1205189&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
Tue Nov 22 22:07:25 2011
@@ -46,23 +46,6 @@ public abstract class ComponentPlugin {
    */
   public abstract String[] getRequiredComponents() throws IOException;
   
-  /**
-   * Get the commands to write the configuration for this component.
-   * @param cluster the cluster that is being configured
-   * @return the commands to run on each node
-   * @throws IOException
-   */
-  public abstract Action configure(String cluster,
-                                   String role) throws IOException;
-  
-  /**
-   * Get the commands to finalize the installation on the machine.
-   * @param cluster the cluster that is being installed
-   * @return the commands to execute
-   * @throws IOException
-   */
-  public abstract Action install(String cluster,
-                                 String role) throws IOException;
   
   /**
    * Get the commands to start a role's server.
@@ -100,16 +83,6 @@ public abstract class ComponentPlugin {
                                       String role) throws IOException;
 
   /**
-   * Get the commands to run before the software is uninstalled.
-   * @param cluster the cluster that is being uninstalled
-   * @return the commands to execute
-   * @throws IOException
-   */
-  public abstract Action uninstall(String cluster,
-                                   String role
-                                   ) throws IOException;
-  
-  /**
    * Get the commands to run to preinstall a component
    * For example, MapReduce needs to have certain directories
    * on the HDFS before JobTracker can be started.

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/impl/XmlComponentDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/impl/XmlComponentDefinition.java?rev=1205189&r1=1205188&r2=1205189&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/impl/XmlComponentDefinition.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/impl/XmlComponentDefinition.java
Tue Nov 22 22:07:25 2011
@@ -151,32 +151,6 @@ public class XmlComponentDefinition exte
   }
 
   @Override
-  public Action configure(String cluster, String role) throws IOException {
-    if (configureCommand == null) {
-      return null;
-    }
-    Action result = new Action();
-    result.kind = Action.Kind.RUN_ACTION;
-    result.setUser(configureUser);
-    result.command = new Command(configureUser, configureCommand, 
-                                 new String[]{cluster, role});
-    return result;
-  }
-
-  @Override
-  public Action install(String cluster, String role) throws IOException {
-    if (installCommand == null) {
-      return null;
-    }
-    Action result = new Action();
-    result.kind = Action.Kind.RUN_ACTION;
-    result.setUser(installUser);
-    result.command = new Command(installUser, installCommand, 
-                                 new String[]{cluster, role});
-    return result;
-  }
-
-  @Override
   public Action startServer(String cluster, String role) throws IOException {
     if (startCommand == null) {
       return null;
@@ -225,19 +199,6 @@ public class XmlComponentDefinition exte
     return result; 
   }
 
-  @Override
-  public Action uninstall(String cluster, String role) throws IOException {
-    if (uninstallCommand == null) {
-      return null;
-    }
-    Action result = new Action();
-    result.kind = Action.Kind.RUN_ACTION;
-    result.setUser(uninstallUser);
-    result.command = new Command(uninstallUser, uninstallCommand, 
-                                 new String[]{cluster, role});
-    return result;
-  }
-
   private static String getCommand(ScriptCommand cmd) {
     if (cmd == null) {
       return null;

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java?rev=1205189&r1=1205188&r2=1205189&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
Tue Nov 22 22:07:25 2011
@@ -137,7 +137,7 @@ public class HeartbeatHandler {
               boolean roleServerRunning = false;
               boolean agentRoleStateChanged = false;
               if (!newNode) {
-                componentStates.isInstalled(
+                roleInstalled = componentStates.isInstalled(
                     clusterIdAndRev,
                     role.getAssociatedService().getServiceName(), 
                     role.getRoleName());     
@@ -158,7 +158,7 @@ public class HeartbeatHandler {
               //check whether the agent should start any server
               if (role.shouldStart()) {
                 if (!roleInstalled) {
-                  createInstallAction(clusterIdAndRev, cluster, 
+                  createDirStructureAction(clusterIdAndRev, cluster, 
                       service.getServiceName(), role.getRoleName(), plugin,
                       allActions);
                   continue;
@@ -233,7 +233,7 @@ public class HeartbeatHandler {
     return false;
   }
   
-  private void createInstallAction(ClusterNameAndRev clusterIdAndRev, 
+  private void createDirStructureAction(ClusterNameAndRev clusterIdAndRev, 
       Cluster cluster, String component, String role, ComponentPlugin plugin, 
       List<Action> allActions) throws IOException {
     String clusterId = clusterIdAndRev.getClusterName();
@@ -246,42 +246,6 @@ public class HeartbeatHandler {
         SpecialServiceIDs.CREATE_STRUCTURE_ACTION_ID));
     fillDetailsAndAddAction(action, allActions, clusterId,
         clusterRev, component, role);
-    
-    //action for installing the role
-    //also, go over all the dependencies and get their client role-install
-    //actions
-    fillActionsForDependentComponents(clusterIdAndRev, cluster, component, 
-        allActions);
-    action = plugin.install(cluster.getName(), role);
-    fillDetailsAndAddAction(action, allActions, clusterId,
-        clusterRev, component, role);
-    
-    //action for configuring
-    action = plugin.configure(clusterId, role);
-    fillDetailsAndAddAction(action, allActions, clusterId,
-        clusterRev, component, role);
-  }
-  
-  private void fillActionsForDependentComponents(
-      ClusterNameAndRev clusterIdAndRev,
-      Cluster cluster, String reqdComp, 
-      List<Action> allActions) 
-          throws IOException {
-    ComponentPlugin reqPlugin = cluster.getComponentDefinition(reqdComp);
-    String[] reqdComps = reqPlugin.getRequiredComponents();
-    if (reqdComps == null || reqdComps.length == 0) {
-      //TODO: take care of components like Pig. Should Pig also have a client 
-      //role?
-      String clientRole = reqdComp + "-client";
-      Action action = reqPlugin.install(cluster.getName(), clientRole);
-      fillDetailsAndAddAction(action, allActions, cluster.getName(),
-          clusterIdAndRev.getRevision(), reqdComp, clientRole);
-      return;
-    }
-    for (String comp : reqdComps) {
-      fillActionsForDependentComponents(clusterIdAndRev, cluster, comp, 
-          allActions);
-    }
   }
   
   private void createStopAndUninstallActions(ComponentAndRoleStates componentAndRoleStates,

@@ -674,7 +638,7 @@ public class HeartbeatHandler {
           if (newNode || 
               !installedOrStartedComponents.isRoleInstalled(clusterIdAndRev,
               role)) {
-            createInstallAction(clusterIdAndRev, cluster, 
+            createDirStructureAction(clusterIdAndRev, cluster, 
                 service.getServiceName(), role, plugin,
                 allActions);
           }

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/RoleImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/RoleImpl.java?rev=1205189&r1=1205188&r2=1205189&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/RoleImpl.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/RoleImpl.java
Tue Nov 22 22:07:25 2011
@@ -29,10 +29,6 @@ public class RoleImpl implements RoleFSM
 
   private RoleState myState;
   private String roleName;
-  protected int totalInstancesRequired;
-  protected int totalRoleInstancesStarted;
-  private int totalRolesFailedToStart;
-  private int totalInstancesDesired;
   private ServiceFSM service;
   
   /* The state machine for the role looks like:
@@ -63,8 +59,8 @@ public class RoleImpl implements RoleFSM
              RoleEventType.START_SUCCESS)
              
          .addTransition(RoleState.STARTING, 
-             EnumSet.of(RoleState.FAIL, RoleState.STARTING),
-             RoleEventType.START_FAILURE, new FailedStartTransition())
+             RoleState.STARTING,
+             RoleEventType.START_FAILURE)
              
          .addTransition(RoleState.FAIL, RoleState.FAIL, 
              RoleEventType.START_FAILURE)
@@ -98,16 +94,9 @@ public class RoleImpl implements RoleFSM
       stateMachine;
   
   public RoleImpl(ServiceFSM service, String roleName) {
-    this(service, roleName, 1, 1);
-  }
-  
-  public RoleImpl(ServiceFSM service, String roleName, 
-      int totalInstancesDesired, int totalInstancesRequired) {
     this.roleName = roleName;
     this.service = service;
     this.myState = RoleState.INACTIVE;
-    this.totalInstancesRequired = totalInstancesRequired;
-    this.totalInstancesDesired = totalInstancesDesired;
     stateMachine = stateMachineFactory.make(this);
   }
   
@@ -141,42 +130,15 @@ public class RoleImpl implements RoleFSM
     @Override
     public RoleState transition(RoleImpl operand, RoleEvent event) {
       ServiceFSM service = operand.getAssociatedService();
-      ++operand.totalRoleInstancesStarted;
-      if (operand.totalInstancesRequired <= operand.totalRoleInstancesStarted){
-        StateMachineInvoker.getAMBARIEventHandler().handle(
-            new ServiceEvent(ServiceEventType.ROLE_STARTED, service, 
-                operand));
-
-        return RoleState.ACTIVE;
-      } else {
-        return RoleState.STARTING;   
-      }
+      StateMachineInvoker.getAMBARIEventHandler().handle(
+          new ServiceEvent(ServiceEventType.ROLE_STARTED, service, 
+              operand));
+      //if one instance of the role starts up fine, we consider the service
+      //as ready for the 'safe-mode' kinds of checks
+      return RoleState.ACTIVE;
     }
   }
   
-  static class FailedStartTransition implements 
-  MultipleArcTransition<RoleImpl, RoleEvent, RoleState>  {
-
-    @Override
-    public RoleState transition(RoleImpl operand, RoleEvent event) {
-      ServiceFSM service = operand.getAssociatedService();
-      ++operand.totalRolesFailedToStart;
-      //if number of remaining instances required to declare a role as 'started'
-      //is more than the total number of available nodes that haven't reported
-      //declare the role failed to start
-      if ((operand.totalInstancesRequired - operand.totalRoleInstancesStarted) 
-          >= (operand.totalInstancesDesired - 
-              (operand.totalRoleInstancesStarted + 
-                  operand.totalRolesFailedToStart))) {
-        StateMachineInvoker.getAMBARIEventHandler().handle(
-            new ServiceEvent(ServiceEventType.START_FAILURE, service, 
-                operand));
-        return RoleState.FAIL;
-      } else {
-        return RoleState.STARTING;   
-      }
-    }
-  }
   
   static class RoleStopTransition implements
   SingleArcTransition<RoleImpl, RoleEvent> {



Mime
View raw message