Browse Source

AMBARI-3057 Need more graceful handling of the start phase of Install Wizard/Add Host Wizard. (Andrii Babiichuk via atkach)

atkach 11 years ago
parent
commit
21b02ef5c7

+ 45 - 14
ambari-web/app/controllers/wizard/step9_controller.js

@@ -16,6 +16,7 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 var App = require('app');
 var App = require('app');
+var serviceComponents = require('data/service_components');
 
 
 App.WizardStep9Controller = Em.Controller.extend({
 App.WizardStep9Controller = Em.Controller.extend({
   name: 'wizardStep9Controller',
   name: 'wizardStep9Controller',
@@ -379,26 +380,56 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
   },
 
 
   launchStartServicesSuccessCallback: function (jsonData) {
   launchStartServicesSuccessCallback: function (jsonData) {
-    console.log("TRACE: Step9 -> In success function for the startService call");
-    console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
-    var requestId = jsonData.Requests.id;
-    console.log('requestId is: ' + requestId);
-    var clusterStatus = {
-      status: 'INSTALLED',
-      requestId: requestId,
-      isStartError: false,
-      isCompleted: false
-    };
-
-    App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
-
+    if (jsonData) {
+      console.log("TRACE: Step9 -> In success function for the startService call");
+      console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
+      var requestId = jsonData.Requests.id;
+      console.log('requestId is: ' + requestId);
+      var clusterStatus = {
+        status: 'INSTALLED',
+        requestId: requestId,
+        isStartError: false,
+        isCompleted: false
+      };
+      this.hostHasClientsOnly(false);
+      App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
+    } else {
+      console.log('ERROR: Error occurred in parsing JSON data');
+      this.hostHasClientsOnly(true);
+      var clusterStatus = {
+        status: 'STARTED',
+        isStartError: false,
+        isCompleted: true
+      };
+      App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
+      this.set('status', 'success');
+      this.set('progress', '100');
+      this.set('isStepCompleted', true);
+    }
     // We need to do recovery if there is a browser crash
     // We need to do recovery if there is a browser crash
     App.clusterStatus.setClusterStatus({
     App.clusterStatus.setClusterStatus({
       clusterState: 'SERVICE_STARTING_3',
       clusterState: 'SERVICE_STARTING_3',
       localdb: App.db.data
       localdb: App.db.data
     });
     });
 
 
-    this.startPolling();
+    if(jsonData) {
+      this.startPolling();
+    }
+  },
+
+  hostHasClientsOnly: function(jsonError) {
+    this.hosts.forEach(function(host){
+      var OnlyClients = true;
+      var tasks = host.get('logTasks');
+      tasks.forEach(function(task){
+        var component = serviceComponents.findProperty('component_name',task.Tasks.role);
+        (component && component.isClient) ? null : OnlyClients = false;
+      });
+      if (OnlyClients || jsonError) {
+        host.set('status', 'success');
+        host.set('progress', '100');
+      }
+    });
   },
   },
 
 
   launchStartServicesErrorCallback: function () {
   launchStartServicesErrorCallback: function () {

+ 3 - 3
ambari-web/app/templates/main/host/summary.hbs

@@ -24,8 +24,8 @@
         <div class="box-header">
         <div class="box-header">
           <h4>{{t common.components}}</h4>
           <h4>{{t common.components}}</h4>
         </div>
         </div>
-        {{#if view.sortedComponents.length}}
         <div class="host-components">
         <div class="host-components">
+        {{#if view.sortedComponents.length}}
           {{#each component in view.sortedComponents}}
           {{#each component in view.sortedComponents}}
           <div class="row-fluid">
           <div class="row-fluid">
           {{#view view.ComponentView contentBinding="component" decommissionDataNodeHostNamesBinding="view.decommissionDataNodeHostNames"}}
           {{#view view.ComponentView contentBinding="component" decommissionDataNodeHostNamesBinding="view.decommissionDataNodeHostNames"}}
@@ -108,6 +108,7 @@
           {{/view}}
           {{/view}}
           </div>
           </div>
           {{/each}}
           {{/each}}
+        {{/if}}
           {{!clients and add component button}}
           {{!clients and add component button}}
           <div class="clients row-fluid">
           <div class="clients row-fluid">
             <div class="span7 row">
             <div class="span7 row">
@@ -147,7 +148,6 @@
             </div>
             </div>
           </div>
           </div>
         </div>
         </div>
-        {{/if}}
       </div>
       </div>
       <div class="host-configuration">
       <div class="host-configuration">
             <div class="box">
             <div class="box">
@@ -184,4 +184,4 @@
       </div>
       </div>
     </div>
     </div>
   </div>
   </div>
-</div>
+</div>