Sfoglia il codice sorgente

AMBARI-942. Integrate Install and Start APIs with the installer wizard. (Jaimin Jetly via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1406446 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 anni fa
parent
commit
7490918022

+ 3 - 0
AMBARI-666-CHANGES.txt

@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-942. Integrate Install and Start APIs with the installer wizard.
+  (Jaimin Jetly via yusaku)
+
   AMBARI-936. Provide HBase service specific graphs. (Srimanth Gunturi
   via yusaku)
 

+ 2 - 1
ambari-web/app/controllers/installer.js

@@ -272,6 +272,7 @@ App.InstallerController = Em.Controller.extend({
     for (var index in hostInfo) {
       hostInfo[index].status = "pending";
       hostInfo[index].message = 'Waiting';
+      hostInfo[index].tasks = [];
       hostInfo[index].progress = '0';
     }
     App.db.setHosts(hostInfo);
@@ -412,10 +413,10 @@ App.InstallerController = Em.Controller.extend({
     var hostInfo = App.db.getHosts();
 
     for (var index in hostInfo) {
-      hostInfo[index].status = "pending";
       var host = hosts.findProperty('name', hostInfo[index].name);
       if (host) {
         hostInfo[index].status = host.status;
+        hostInfo[index].tasks = host.tasks;
         hostInfo[index].message = host.message;
         hostInfo[index].progress = host.progress;
       }

+ 1 - 2
ambari-web/app/controllers/wizard/step3_controller.js

@@ -62,7 +62,6 @@ App.WizardStep3Controller = Em.Controller.extend({
   /* Loads the hostinfo from localStorage on the insertion of view. It's being called from view */
   loadHosts: function () {
     var hostInfo = [];
-    debugger;
     hostInfo = this.get('content.hostsInfo');
     var hosts = new Ember.Set();
     for (var index in hostInfo) {
@@ -181,7 +180,7 @@ App.WizardStep3Controller = Em.Controller.extend({
   },
 
   startBootstrap: function () {
-    // this.set('isSubmitDisabled', true);
+    //this.set('isSubmitDisabled', true);    //TODO: uncomment after actual hookup
     this.set('bootHosts', this.get('hosts'));
     this.doBootstrap();
   },

+ 40 - 24
ambari-web/app/controllers/wizard/step9_controller.js

@@ -23,8 +23,8 @@ App.WizardStep9Controller = Em.Controller.extend({
   progress: '0',
   isStepCompleted: false,
   isSubmitDisabled: function () {
+    //return false;
     return !this.get('isStepCompleted'); //TODO: uncomment after the hook up
-    return false;
   }.property('isStepCompleted'),
 
   mockHostData: require('data/mock/step9_hosts'),
@@ -55,7 +55,7 @@ App.WizardStep9Controller = Em.Controller.extend({
       } else if (App.db.getClusterStatus().isStartError === true) {
         this.launchStartServices();
       } else {
-        this.startPolling();
+        this.startPolling(); //TODO: uncomment for the actual hookup
       }
     } else {
       this.set('isStepCompleted', true);
@@ -93,10 +93,10 @@ App.WizardStep9Controller = Em.Controller.extend({
       var hostInfo = App.HostInfo.create({
         name: _hostInfo.name,
         status: _hostInfo.status,
+        tasks: _hostInfo.tasks,
         message: _hostInfo.message,
         progress: _hostInfo.progress
       });
-
       console.log('pushing ' + hostInfo.name);
       this.hosts.pushObject(hostInfo);
     }, this);
@@ -242,13 +242,6 @@ App.WizardStep9Controller = Em.Controller.extend({
     });
   },
 
-
-  getCompletedTasksForHost: function (host) {
-    var hostname = host.get('name');
-    console.log("The hostname is: " + hostname);
-  },
-
-
   onSuccessPerHost: function (actions, contentHost) {
     if (actions.everyProperty('Tasks.status', 'COMPLETED') && this.get('content.cluster.status') === 'INSTALLED') {
       contentHost.set('status', 'success');
@@ -353,6 +346,7 @@ App.WizardStep9Controller = Em.Controller.extend({
 
   finishState: function (polledData) {
     var clusterStatus = {};
+    var retVal = false;
     var requestId = this.get('content.cluster.requestId');
     if (this.get('content.cluster.status') === 'INSTALLED') {
       if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
@@ -374,6 +368,7 @@ App.WizardStep9Controller = Em.Controller.extend({
         }
         App.router.get('installerController').saveClusterStatus(clusterStatus);
         this.set('isStepCompleted', true);
+        retVal = true;
       }
     } else if (this.get('content.cluster.status') === 'PENDING') {
       if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
@@ -391,18 +386,43 @@ App.WizardStep9Controller = Em.Controller.extend({
         } else {
           clusterStatus.status = 'INSTALLED';
           this.set('progress', '34');
-          // this.launchStartServices();  //TODO: uncomment after the actual hookup
+          App.router.get('installerController').saveInstalledHosts(this);
+          this.launchStartServices();  //TODO: uncomment after the actual hookup
+
         }
         App.router.get('installerController').saveClusterStatus(clusterStatus);
+        retVal = true;
       }
     }
+    return retVal;
   },
 
+  getCompletedTasksForHost: function (host) {
+    var hostname = host.get('name');
+    var tasksPerHost = host.tasks.filterProperty('Tasks.host_name',hostname);
+    var succededTasks = tasksPerHost.filterProperty('Tasks.status', 'COMPLETED');
+    var inProgressTasks = tasksPerHost.filterProperty('Tasks.status', 'IN_PROGRESS');
+    var listedTasksPerHost = succededTasks.concat(inProgressTasks).uniq();
+    return listedTasksPerHost;
+  },
+
+  // This is done at HostRole level.
+  setTasksStatePerHost: function(tasksPerHost,host) {
+    var tasks = [];
+    tasksPerHost.forEach(function(_taskPerHost){
+      if(_taskPerHost.Tasks.status !== 'PENDING' &&_taskPerHost.Tasks.status !== 'QUEUED') {
+        var task =  host.tasks.findProperty('Tasks.id',_taskPerHost.Tasks.id);
+        if(!(task && (task.Tasks.command === _taskPerHost.Tasks.command))) {
+        host.tasks.pushObject(_taskPerHost);
+        }
+      }
+    },this);
+  },
 
   parseHostInfo: function (polledData) {
     console.log('TRACE: Entering host info function');
     var self = this;
-    var totalProgress;
+    var totalProgress = 0;
     /* if (this.get('content.cluster.status') === 'INSTALLED') {
      totalProgress = 34;
      } else {
@@ -413,29 +433,25 @@ App.WizardStep9Controller = Em.Controller.extend({
     if (!tasksData) {
       console.log("Step9: ERROR: NO tasks availaible to process");
     }
-    tasksData.forEach(function (_host) {
-      console.log("The host name is " + _host.Tasks.host_name);
-    }, this);
-
     this.replacePolledData(tasksData);
-    this.hosts.forEach(function (_content) {
-      var actionsPerHost = tasksData.filterProperty('Tasks.host_name', _content.name); // retrieved from polled Data
+    this.hosts.forEach(function (_host) {
+      var actionsPerHost = tasksData.filterProperty('Tasks.host_name', _host.name); // retrieved from polled Data
       if (actionsPerHost.length === 0) {
         //alert('For testing with mockData follow the sequence: hit referesh,"mockData btn", "pollData btn", again "pollData btn"');
         //exit();
       }
       if (actionsPerHost !== null && actionsPerHost !== undefined && actionsPerHost.length !== 0) {
-        this.onSuccessPerHost(actionsPerHost, _content);    // every action should be a success
-        this.onWarningPerHost(actionsPerHost, _content);    // any action should be a faliure
-        this.onInProgressPerHost(actionsPerHost, _content); // current running action for a host
-        totalProgress = self.progressPerHost(actionsPerHost, _content);
+        this.onSuccessPerHost(actionsPerHost, _host);    // every action should be a success
+        this.onWarningPerHost(actionsPerHost, _host);    // any action should be a faliure
+        this.onInProgressPerHost(actionsPerHost, _host); // current running action for a host
+        this.setTasksStatePerHost(actionsPerHost,_host);
+        totalProgress = self.progressPerHost(actionsPerHost, _host);
       }
     }, this);
     totalProgress = Math.floor(totalProgress / this.hosts.length);
     this.set('progress', totalProgress.toString());
     console.log("INFO: right now the progress is: " + this.get('progress'));
-    this.finishState(tasksData);
-    return this.get('isStepCompleted');
+    return this.finishState(tasksData);
   },
 
   startPolling: function () {

+ 3 - 1
ambari-web/app/messages.js

@@ -124,7 +124,9 @@ Em.I18n.translations = {
   'installer.step9.host.status.success': 'success',
   'installer.step9.host.status.warning': 'tolerable failures encountered',
   'installer.step9.host.status.failed': 'failures encountered',
-  'installer.step10.header': 'Summary',
+  'installer.step9.hostLog.popup.header': 'Tasks executed on ',
+
+'installer.step10.header': 'Summary',
   'form.create': 'Create',
   'form.save': 'Save',
   'form.cancel': 'Cancel',

+ 1 - 1
ambari-web/app/routes/installer.js

@@ -240,7 +240,7 @@ module.exports = Em.Route.extend({
     next: function (router) {
       var installerController = router.get('installerController');
       var wizardStep8Controller = router.get('wizardStep8Controller');
-      installerController.installServices();
+      installerController.installServices();   //TODO: Uncomment for the actual hookup
       installerController.setInfoForStep9();
       router.transitionTo('step9');
     }

+ 94 - 94
ambari-web/app/templates/wizard/step9.hbs

@@ -18,107 +18,107 @@
 
 <div id="deploy">
 
-	<h2>{{t installer.step9.header}}</h2>
+  <h2>{{t installer.step9.header}}</h2>
 
-	<p class="alert alert-info">{{t installer.step9.body}}</p>
+  <p class="alert alert-info">{{t installer.step9.body}}</p>
 
-	<div id="overallProgress">
-		{{view.isStepCompleted}}
-		<div class="row-fluid">
-			<div class="span10">
-				<div {{bindAttr class="isStepCompleted::progress-striped isStepCompleted::active view.barColor :progress"}}>
-					<div class="bar" {{bindAttr style="view.barWidth"}}>
-						<!--<strong style="color: #00008b;">Overall Progress</strong>-->
-					</div>
-				</div>
-			</div>
-			<div class="span2">{{progress}}% overall</div>
-		</div>
-	</div>
+  <div id="overallProgress">
+    {{view.isStepCompleted}}
+    <div class="row-fluid">
+      <div class="span10">
+        <div {{bindAttr class="isStepCompleted::progress-striped isStepCompleted::active view.barColor :progress"}}>
+          <div class="bar" {{bindAttr style="view.barWidth"}}>
+            <!--<strong style="color: #00008b;">Overall Progress</strong>-->
+          </div>
+        </div>
+      </div>
+      <div class="span2">{{progress}}% overall</div>
+    </div>
+  </div>
 
-	<div class="box">
-		<div class="box-header">
-			<div class="pull-left">
-				<a
-								class="btn btn-primary " {{bindAttr disabled="isSubmitDisabled"}}
-								href="#" {{action retry }}><i
-								class="icon-repeat icon-white"></i>
-					Retry
-				</a>
-				<a
-								class="btn btn-info"
-								href="#" {{action mockBtn target="controller"}}>
-					mockData
-				</a>
-				<a
-								class="btn btn-primary "
-								href="#" {{action pollBtn target="controller"}}><i
-								class="icon-repeat icon-white"></i>
-					pollData
-				</a>
-			</div>
+  <div class="box">
+    <div class="box-header">
+      <div class="pull-left">
+        <a
+                class="btn btn-primary " {{bindAttr disabled="isSubmitDisabled"}}
+                href="#" {{action retry }}><i
+                class="icon-repeat icon-white"></i>
+          Retry
+        </a>
+        <a
+                class="btn btn-info"
+                href="#" {{action mockBtn target="controller"}}>
+          mockData
+        </a>
+        <a
+                class="btn btn-primary "
+                href="#" {{action pollBtn target="controller"}}><i
+                class="icon-repeat icon-white"></i>
+          pollData
+        </a>
+      </div>
 
-		</div>
-		<div class="pre-scrollable" style="max-height: 750px;">
-			<table id="deploy-status-by-host" class="table table-bordered table-striped">
-				<thead>
-				<tr>
-					<th class="host">
-						Host
-					</th>
-					<th class="status">Status</th>
-					<!--  given by the parsing function that parses data from bootstrap call -->
-					<th class="message">Message</th>
-					<!-- retrieved from local storage initially -->
-				</tr>
-				</thead>
+    </div>
+    <div class="pre-scrollable" style="max-height: 750px;">
+      <table id="deploy-status-by-host" class="table table-bordered table-striped">
+        <thead>
+        <tr>
+          <th class="host">
+            Host
+          </th>
+          <th class="status">Status</th>
+          <!--  given by the parsing function that parses data from bootstrap call -->
+          <th class="message">Message</th>
+          <!-- retrieved from local storage initially -->
+        </tr>
+        </thead>
 
-				<tbody>
-				{{#each host in controller.hosts}}
-				{{#view App.HostStatusView objBinding="host"}}
-				<td>
-					{{host.name}}
-				</td>
-				<td>
-					<div class="progress-bar pull-left">
-						<div {{bindAttr class="isStepCompleted::progress-striped isStepCompleted::active view.barColor :progress"}}>
-							<div class="bar" {{bindAttr style="view.barWidth"}}>
-							</div>
-						</div>
-					</div>
-					<div class="progress-percentage pull-left">{{host.progress}}%</div>
-				</td>
-				<td>
-					<a {{bindAttr class="view.isFailed:text-error view.isSuccess:text-success view.isWarning:text-warning"}}
-									href="javascript:void(null)"
-									data-toggle="modal" {{action "hostLogPopup" target="view"}}>{{host.message}}</a>
-				</td>
+        <tbody>
+        {{#each host in controller.hosts}}
+        {{#view App.HostStatusView objBinding="host"}}
+        <td>
+          {{host.name}}
+        </td>
+        <td>
+          <div class="progress-bar pull-left">
+            <div {{bindAttr class="isStepCompleted::progress-striped isStepCompleted::active view.barColor :progress"}}>
+              <div class="bar" {{bindAttr style="view.barWidth"}}>
+              </div>
+            </div>
+          </div>
+          <div class="progress-percentage pull-left">{{host.progress}}%</div>
+        </td>
+        <td>
+          <a {{bindAttr class="view.isFailed:text-error view.isSuccess:text-success view.isWarning:text-warning"}}
+                  href="javascript:void(null)"
+                  data-toggle="modal" {{action hostLogPopup host target="view"}}>{{host.message}}</a>
+        </td>
 
-				{{/view}}
-				{{/each}}
+        {{/view}}
+        {{/each}}
 
-				</tbody>
-			</table>
-			</div>
-			<div class="box-footer">
-				<hr/>
-				<div class="footer-pagination">
-				</div>
-			</div>
-		</div>
+        </tbody>
+      </table>
+    </div>
+    <div class="box-footer">
+      <hr/>
+      <div class="footer-pagination">
+      </div>
+    </div>
+  </div>
 
-		<div>
-			{{#if view.resultMsg}}
-			<p {{bindAttr class="view.resultMsgColor"}}>{{view.resultMsg}}</p>
-			{{/if}}
-			<div class="btn-area">
-				<a
-								class="btn pull-left" {{bindAttr disabled="isSubmitDisabled"}} {{action back target="controller"}}>&larr;
-					Back</a>
-				<a
-								class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action submit target="controller"}}>Next &rarr;</a>
-			</div>
-		</div>
+  <div>
+    {{#if view.resultMsg}}
+    <p {{bindAttr class="view.resultMsgColor"}}>{{view.resultMsg}}</p>
+    {{/if}}
+    <div class="btn-area">
+      <a
+              class="btn pull-left" {{bindAttr disabled="isSubmitDisabled"}} {{action back target="controller"}}>&larr;
+        Back</a>
+      <a
+              class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action submit target="controller"}}>Next &rarr;</a>
+    </div>
+  </div>
 
-	</div>
+</div>
 </div>

+ 15 - 0
ambari-web/app/templates/wizard/step9HostTasksLogPopup.hbs

@@ -0,0 +1,15 @@
+<p>Click on the task to see the log: </p><br/>
+<ul>
+  {{#each item in view.roles}}
+  <li>{{item.roleName}}
+    <ul>
+      {{#each state in item.statusArr}}
+      <li>
+        <a {{bindAttr href="state.url"}}>{{state.status}}</a>
+      </li>
+      {{/each}}
+    </ul>
+  </li>
+  {{/each}}
+</ul>
+

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/rpc.js

@@ -27,7 +27,7 @@ var App = require('app');
  * @extends Ember.View
  */
 App.ChartServiceMetricsMapReduce_RPC = App.ChartLinearTimeView.extend({
- /* id: "service-metrics-mapreduce-rpc",
+  id: "service-metrics-mapreduce-rpc",
   url: "/data/services/metrics/mapreduce/rpc.json",
   title: "RPC",
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
@@ -65,5 +65,5 @@ App.ChartServiceMetricsMapReduce_RPC = App.ChartLinearTimeView.extend({
       }
     }
     return seriesArray;
-  } */
+  }
 });

+ 46 - 10
ambari-web/app/views/wizard/step9_view.js

@@ -112,22 +112,58 @@ App.HostStatusView = Em.View.extend({
     }
   }.property('controller.isStepCompleted', 'controller.status'),
 
-  hostLogPopup: function (event) {
+  hostLogPopup: function (event, context) {
+    var self = this;
+    var host = event.context;
     App.ModalPopup.show({
-      header: Em.I18n.t('installer.step3.hostLog.popup.header'),
+      header: Em.I18n.t('installer.step9.hostLog.popup.header') + event.context.get('name'),
       onPrimary: function () {
         this.hide();
       },
+      controllerBinding: context,
       bodyClass: Ember.View.extend({
-        templateName: require('templates/installer/step3HostLogPopup'),
-        controllerBinding: 'parentView.controller',
-        polledData: function() {
-          return this.get('controller.polledData');
-        }.property('controller.polledData'),
-        didInsertElement: function() {
-          this.get('controller').getCompletedTasksForHost(this.get('parentView'));
+        templateName: require('templates/wizard/step9HostTasksLogPopup'),
+
+        hostObj: function () {
+          return this.get('parentView.obj');
+        }.property('parentView.obj'),
+        tasks: [],
+
+        roles: function () {
+          var roleArr = [];
+          var tasks = this.get('tasks');
+          if (tasks.length) {
+            var role = this.get('tasks').mapProperty('Tasks.role').uniq();
+            role.forEach(function (_role) {
+              var statusArr = [];
+              var roleObj = {};
+              roleObj.roleName = _role;
+              tasks.filterProperty('Tasks.role', _role).forEach(function (_task) {
+                var statusObj = {};
+                statusObj.status = _task.Tasks.command;
+                statusObj.url = _task.Tasks.href;
+                statusArr.pushObject(statusObj);
+              }, this);
+              roleObj.statusArr = statusArr;
+              roleArr.pushObject(roleObj);
+            }, this);
+          }
+          return roleArr;
+        }.property('tasks.@each'),
+
+        logState: function () {
+          var taskObj = {};
+          var tasks = this.get('tasks');
+          if (tasks) {
+            var taskarr = tasks.mapProperty('Tasks.command').uniq();
+
+          }
+        }.property('tasks.@each.Tasks.command'),
+
+        didInsertElement: function () {
+          console.log('The value of event context is: ' + host.name);
+          this.set('tasks', self.get('controller').getCompletedTasksForHost(event.context));
         }
-
       })
     });
   }