You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vg...@apache.org on 2012/05/15 03:06:39 UTC

svn commit: r1338496 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/php/orchestrator/Service.php hmc/php/orchestrator/ServiceComponent.php

Author: vgogate
Date: Tue May 15 01:06:38 2012
New Revision: 1338496

URL: http://svn.apache.org/viewvc?rev=1338496&view=rev
Log:
AMBARI-221. Service fails to set its state to failed if a component fails to be acted upon by Hitesh Shah

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/php/orchestrator/Service.php
    incubator/ambari/branches/ambari-186/hmc/php/orchestrator/ServiceComponent.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1338496&r1=1338495&r2=1338496&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Tue May 15 01:06:38 2012
@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.x.x - unreleased
 
+  AMBARI-221. Service fails to set its state to failed if a component fails to be acted upon (Hitesh via vgogate)
+
   AMBARI-220. Alerts table semantic difference at different levels (vgogate)
 
   AMBARI-217. Alert table needs to display service name for context.

Modified: incubator/ambari/branches/ambari-186/hmc/php/orchestrator/Service.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/orchestrator/Service.php?rev=1338496&r1=1338495&r2=1338496&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/orchestrator/Service.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/orchestrator/Service.php Tue May 15 01:06:38 2012
@@ -109,7 +109,8 @@ class Service {
       $result = $this->db->setServiceState($this, $state);
       if ($result['result'] !== 0) {
         $this->state == State::FAILED;
-        $this->logger->log_error("$this->name - ".State::$STATE[$state] . " dryRun=$dryRun");
+        $this->logger->log_error("Failed to persist state for Service "
+            . "$this->name - ".State::$STATE[$state] . " dryRun=$dryRun");
         $this->db->setServiceState($this, $state);
         return $result;
       }
@@ -301,6 +302,8 @@ class Service {
 
     // Ensure state is INSTALLED or STOPPED
     if ($this->state !== State::INSTALLED
+        && $this->state !== State::STARTING
+        && $this->state !== State::STOPPING
         && $this->state !== State::STOPPED
         && $this->state !== State::FAILED) {
       $this->logger->log_error("Service $this->name is not INSTALLED or STOPPED or FAILED!");
@@ -311,6 +314,7 @@ class Service {
     // Note that we are about to START
     $result = $this->setState(State::STARTING, $transaction, $dryRun, $persistTxn);
     if ($result['result'] !== 0) {
+      $this->setState(State::FAILED, $transaction, $dryRun, $persistTxn);
       return $result;
     }
 
@@ -321,6 +325,7 @@ class Service {
         $cmpResult = $s['result'];
         $cmpErrMsg = $s['error'];
         if ($cmpResult !== 0) {
+          $this->setState(State::FAILED, $transaction, $dryRun, $persistTxn);
           return array("result" => $cmpResult, "error" => "Failed to start $component->name with $cmpResult (\'$cmpErrMsg\')");
         }
       }
@@ -329,6 +334,7 @@ class Service {
     // Done!
     $result = $this->setState(State::STARTED, $transaction, $dryRun, $persistTxn);
     if ($result["result"] != 0) {
+      $this->setState(State::FAILED, $transaction, $dryRun, $persistTxn);
       $this->logger->log_error("Failed to set state to STARTED with " . $result["error"]);
       return $result;
     }
@@ -485,9 +491,12 @@ class Service {
         return array("result" => 0, "error" => "");
       }
 
-      // Only stop if state is STARTED
-      if ($this->state !== State::STARTED) {
-        $this->logger->log_info("Service " . $this->name . " is not STARTED!"
+      // Only stop if state is STARTED/STARTING/STOPPING/FAILED
+      if ($this->state !== State::STARTED
+          && $this->state !== State::STARTING
+          && $this->state !== State::STOPPING
+          && $this->state !== State::FAILED) {
+        $this->logger->log_info("Service " . $this->name . " is not STARTED/STOPPING/FAILED!"
             . "Current state = " . State::$STATE[$this->state]
             . " - STOP is a no-op");
         return array("result" => 0, "error" => "");
@@ -496,6 +505,7 @@ class Service {
       // Note we are about to STOP
       $result = $this->setState(State::STOPPING, $transaction, $dryRun, TRUE);
       if ($result['result'] !== 0) {
+        $this->setState(State::FAILED, $transaction, $dryRun, TRUE);
         return $result;
       }
 
@@ -505,6 +515,7 @@ class Service {
         $cmpResult = $s['result'];
         $cmpErrMsg = $s['error'];
         if ($cmpResult !== 0) {
+          $this->setState(State::FAILED, $transaction, $dryRun, TRUE);
           return array("result" => $cmpResult, "error" => "Failed to stop $component->name with $cmpResult (\'$cmpErrMsg\')");
         }
       }

Modified: incubator/ambari/branches/ambari-186/hmc/php/orchestrator/ServiceComponent.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/orchestrator/ServiceComponent.php?rev=1338496&r1=1338495&r2=1338496&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/orchestrator/ServiceComponent.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/orchestrator/ServiceComponent.php Tue May 15 01:06:38 2012
@@ -195,12 +195,14 @@ class ServiceComponent {
       return array("result" => 0, "error" => "");
     }
 
-    // Ensure state is INSTALLED or STOPPED
+    // Ensure state is INSTALLED or STOPPED or FAILED
     if ($this->state !== State::INSTALLED
+        && $this->state !== State::STARTING
+        && $this->state !== State::STOPPING
         && $this->state !== State::STOPPED
         && $this->state !== State::FAILED) {
       $this->logger->log_error("ServiceComponent $this->name is not INSTALLED or STOPPED or FAILED!");
-      return array("result" => -1, "error" => "Service $this->name is not INSTALLED or STOPPED or FAILED!");
+      return array("result" => -1, "error" => "ServiceComponent $this->name is not INSTALLED or STOPPED or FAILED!");
     }
 
     // Ensure each dependent component is STARTED
@@ -300,9 +302,12 @@ class ServiceComponent {
       return array("result" => 0, "error" => "");
     }
 
-    // Only stop if state is STARTED
-    if ($this->state !== State::STARTED) {
-      $this->logger->log_error("ServiceComponent $this->name is not STARTED!"
+    // Only stop if state is STARTED/STARTING/STOPPING/FAILED
+    if ($this->state !== State::STARTED
+        && $this->state !== State::STARTING
+        && $this->state !== State::STOPPING
+        && $this->state !== State::FAILED) {
+      $this->logger->log_error("ServiceComponent $this->name is not STARTED/FAILED!"
           . "Current state = " . State::$STATE[$this->state]
           . " - STOP is a no-op");
       return array("result" => 0, "error" => "");