incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject svn commit: r1396304 - in /incubator/ambari/branches/AMBARI-666: AMBARI-666-CHANGES.txt ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
Date Tue, 09 Oct 2012 20:46:14 GMT
Author: hitesh
Date: Tue Oct  9 20:46:13 2012
New Revision: 1396304

URL: http://svn.apache.org/viewvc?rev=1396304&view=rev
Log:
AMBARI-834. Use RoleCommand instead of ServiceComponentHostEventType for HostAction in Controller.
(hitesh)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

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=1396304&r1=1396303&r2=1396304&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Oct  9 20:46:13 2012
@@ -225,6 +225,9 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-834. Use RoleCommand instead of ServiceComponentHostEventType for HostAction
+  in Controller. (hitesh)
+
   AMBARI-830. Various fixes and tests for controller implementation. (hitesh)
 
   AMBARI-808. Handle appropriate start/stop/install/.. events at their respective

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1396304&r1=1396303&r2=1396304&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
Tue Oct  9 20:46:13 2012
@@ -20,6 +20,7 @@ package org.apache.ambari.server.control
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.actionmanager.HostAction;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
@@ -62,6 +63,10 @@ public class AmbariManagementControllerI
       LoggerFactory.getLogger(AmbariManagementControllerImpl.class);
 
   private final Clusters clusters;
+
+  // FIXME this needs to be unique across restarts
+  // TODO change requestId to string and use server start timestamp + in-memory
+  // request counter to make the request id unique?
   private final AtomicLong requestCounter;
   private String baseLogDir = "/tmp/ambari/";
 
@@ -79,7 +84,7 @@ public class AmbariManagementControllerI
       throws AmbariException {
     if (request.getClusterName() == null
         || request.getClusterName().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -113,7 +118,7 @@ public class AmbariManagementControllerI
       throws AmbariException {
     if (request.getClusterName() == null
         || request.getClusterName().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -147,12 +152,15 @@ public class AmbariManagementControllerI
     s = new ServiceImpl(cluster, request.getServiceName());
 
     // TODO validate correct desired state
+    // TODO take action based on desired state
+    // should we allow a non-INIT desired state?
+
     if (request.getDesiredState() != null
         && !request.getDesiredState().isEmpty()) {
       State state = State.valueOf(request.getDesiredState());
       if (!state.isValidDesiredState()
           || state != State.INIT) {
-        // TODO fix
+        // FIXME throw correct error
         throw new AmbariException("Invalid desired state");
       }
 
@@ -162,9 +170,6 @@ public class AmbariManagementControllerI
     s.setDesiredStackVersion(cluster.getDesiredStackVersion());
     cluster.addService(s);
 
-    // TODO take action based on desired state
-    // should we allow a non-INIT desired state?
-
     // TODO
     return null;
   }
@@ -178,7 +183,7 @@ public class AmbariManagementControllerI
         || request.getServiceName().isEmpty()
         || request.getComponentName() == null
         || request.getComponentName().isEmpty()) {
-      // TODO throw exception
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -244,7 +249,7 @@ public class AmbariManagementControllerI
       throws AmbariException {
     if (request.getHostname() == null
         || request.getHostname().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -256,7 +261,7 @@ public class AmbariManagementControllerI
 
     Host h = clusters.getHost(request.getHostname());
     if (h == null) {
-      // TODO throw exception as not bootstrapped
+      // FIXME throw correct error as not bootstrapped
     }
     // TODO should agent registration create entry in the DB or should we
     // re-think schema to allow simple new entry
@@ -285,7 +290,7 @@ public class AmbariManagementControllerI
         || request.getComponentName().isEmpty()
         || request.getHostname() == null
         || request.getHostname().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -363,7 +368,7 @@ public class AmbariManagementControllerI
       // better way to say nothing to do?
       return null;
     } else {
-      // TODO throw error?
+      // FIXME throw correct error?
       // only INIT allowed in create?
     }
 
@@ -427,7 +432,7 @@ public class AmbariManagementControllerI
 
   private HostAction createHostAction(Stage stage, ServiceComponentHost scHost,
       Map<String, Config> configs,
-      ServiceComponentHostEvent event,
+      RoleCommand command,
       long nowTimestamp) {
 
     HostAction ha = new HostAction(scHost.getHostName());
@@ -473,7 +478,7 @@ public class AmbariManagementControllerI
     roleParams.put("magic_role_param", "false");
 
     execCmd.addRoleCommand(scHost.getServiceComponentName(),
-        event.getType().toString(), roleParams);
+        command.toString(), roleParams);
 
     return ha;
   }
@@ -626,7 +631,7 @@ public class AmbariManagementControllerI
     // for now only update host list supported
     if (request.getClusterName() == null
         || request.getClusterName().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -664,7 +669,7 @@ public class AmbariManagementControllerI
         || request.getClusterName().isEmpty()
         || request.getServiceName() == null
         || request.getServiceName().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -689,19 +694,35 @@ public class AmbariManagementControllerI
 
     if (request.getDesiredState() == null) {
       // TODO fix return
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Nothing to do for new updateService request"
+            + ", clusterName=" + request.getClusterName()
+            + ", serviceName=" + request.getServiceName()
+            + ", newDesiredState=null");
+      }
       return null;
     }
 
     State newState = State.valueOf(request.getDesiredState());
     if (!newState.isValidDesiredState()) {
-      // TODO fix
+      // FIXME fix with appropriate exception
       throw new AmbariException("Invalid desired state");
     }
 
 
     State oldState = s.getDesiredState();
     if (newState == oldState) {
+      // FIXME should we still check whether all servicecomponents and
+      // servicecomponenthosts are in the required desired state?
+
       // TODO fix return
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Nothing to do for new updateService request"
+            + ", clusterName=" + request.getClusterName()
+            + ", serviceName=" + request.getServiceName()
+            + ", oldDesiredState=" + oldState
+            + ", newDesiredState=" + newState);
+      }
       return null;
     }
 
@@ -787,20 +808,16 @@ public class AmbariManagementControllerI
       stage.setStageId(++stageId);
       for (ServiceComponentHost scHost : changedScHosts.get(compName)) {
         Map<String, Config> configs = null;
-        ServiceComponentHostEvent event;
+        RoleCommand roleCommand;
         State oldSchState = scHost.getDesiredState();
         switch(newState) {
           case INSTALLED:
             if (oldSchState == State.INIT
                 || oldSchState == State.UNINSTALLED
                 || oldSchState == State.INSTALLED) {
-              event = new ServiceComponentHostInstallEvent(
-                  scHost.getServiceComponentName(),
-                  scHost.getHostName(), nowTimestamp);
+              roleCommand = RoleCommand.INSTALL;
             } else if (oldSchState == State.STARTED) {
-              event = new ServiceComponentHostStopEvent(
-                  scHost.getServiceComponentName(),
-                  scHost.getHostName(), nowTimestamp);
+              roleCommand = RoleCommand.STOP;
             } else {
               throw new AmbariException("Invalid transition"
                   + ", oldDesiredState=" + oldSchState
@@ -809,9 +826,7 @@ public class AmbariManagementControllerI
             break;
           case STARTED:
             if (oldSchState == State.INSTALLED) {
-                event = new ServiceComponentHostStartEvent(
-                    scHost.getServiceComponentName(),
-                    scHost.getHostName(), nowTimestamp);
+              roleCommand = RoleCommand.START;
             } else {
               throw new AmbariException("Invalid transition"
                   + ", oldDesiredState=" + oldSchState
@@ -823,7 +838,7 @@ public class AmbariManagementControllerI
             throw new AmbariException("Unsupported state change operation");
         }
 
-        HostAction ha = createHostAction(stage, scHost, configs, event,
+        HostAction ha = createHostAction(stage, scHost, configs, roleCommand,
             nowTimestamp);
         stage.addHostAction(scHost.getHostName(), ha);
       }
@@ -940,20 +955,16 @@ public class AmbariManagementControllerI
     stage.setStageId(++stageId);
     for (ServiceComponentHost scHost : changedScHosts) {
       Map<String, Config> configs = null;
-      ServiceComponentHostEvent event;
+      RoleCommand roleCommand;
       State oldSchState = scHost.getDesiredState();
       switch(newState) {
         case INSTALLED:
           if (oldSchState == State.INIT
               || oldSchState == State.UNINSTALLED
               || oldSchState == State.INSTALLED) {
-            event = new ServiceComponentHostInstallEvent(
-                scHost.getServiceComponentName(),
-                scHost.getHostName(), nowTimestamp);
+            roleCommand = RoleCommand.INSTALL;
           } else if (oldSchState == State.STARTED) {
-            event = new ServiceComponentHostStopEvent(
-                scHost.getServiceComponentName(),
-                scHost.getHostName(), nowTimestamp);
+            roleCommand = RoleCommand.STOP;
           } else {
             throw new AmbariException("Invalid transition"
                 + ", oldDesiredState=" + oldSchState
@@ -962,9 +973,7 @@ public class AmbariManagementControllerI
           break;
         case STARTED:
           if (oldSchState == State.INSTALLED) {
-              event = new ServiceComponentHostStartEvent(
-                  scHost.getServiceComponentName(),
-                  scHost.getHostName(), nowTimestamp);
+            roleCommand = RoleCommand.START;
           } else {
             throw new AmbariException("Invalid transition"
                 + ", oldDesiredState=" + oldSchState
@@ -976,7 +985,7 @@ public class AmbariManagementControllerI
           throw new AmbariException("Unsupported state change operation");
       }
 
-      HostAction ha = createHostAction(stage, scHost, configs, event,
+      HostAction ha = createHostAction(stage, scHost, configs, roleCommand,
           nowTimestamp);
       stage.addHostAction(scHost.getHostName(), ha);
     }
@@ -1005,7 +1014,7 @@ public class AmbariManagementControllerI
       throws AmbariException {
     if (request.getHostname() == null
         || request.getHostname().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -1042,7 +1051,7 @@ public class AmbariManagementControllerI
         || request.getComponentName().isEmpty()
         || request.getHostname() == null
         || request.getHostname().isEmpty()) {
-      // TODO throw error
+      // FIXME throw correct error
       throw new AmbariException("Invalid arguments");
     }
 
@@ -1107,20 +1116,16 @@ public class AmbariManagementControllerI
     stage.setStageId(++stageId);
 
     Map<String, Config> configs = null;
-    ServiceComponentHostEvent event;
+    RoleCommand roleCommand;
     State oldSchState = sch.getDesiredState();
     switch(newState) {
       case INSTALLED:
         if (oldSchState == State.INIT
             || oldSchState == State.UNINSTALLED
             || oldSchState == State.INSTALLED) {
-          event = new ServiceComponentHostInstallEvent(
-              sch.getServiceComponentName(),
-              sch.getHostName(), nowTimestamp);
+          roleCommand = RoleCommand.INSTALL;
         } else if (oldSchState == State.STARTED) {
-          event = new ServiceComponentHostStopEvent(
-              sch.getServiceComponentName(),
-              sch.getHostName(), nowTimestamp);
+          roleCommand = RoleCommand.STOP;
         } else {
           throw new AmbariException("Invalid transition"
               + ", oldDesiredState=" + oldSchState
@@ -1129,9 +1134,7 @@ public class AmbariManagementControllerI
         break;
       case STARTED:
         if (oldSchState == State.INSTALLED) {
-            event = new ServiceComponentHostStartEvent(
-                sch.getServiceComponentName(),
-                sch.getHostName(), nowTimestamp);
+          roleCommand = RoleCommand.START;
         } else {
           throw new AmbariException("Invalid transition"
               + ", oldDesiredState=" + oldSchState
@@ -1143,7 +1146,7 @@ public class AmbariManagementControllerI
         throw new AmbariException("Unsupported state change operation");
     }
 
-    HostAction ha = createHostAction(stage, sch, configs, event,
+    HostAction ha = createHostAction(stage, sch, configs, roleCommand,
         nowTimestamp);
     stage.addHostAction(sch.getHostName(), ha);
     if (LOG.isDebugEnabled()) {



Mime
View raw message