Quellcode durchsuchen

AMBARI-1197. Refactor code for graphs. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1435476 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako vor 12 Jahren
Ursprung
Commit
ac43888bd7

+ 48 - 0
ambari-web/app/classes/job_class.js

@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+var date = require('utils/date');
+var misc = require('utils/misc');
+
+App.Job2 = Ember.Object.extend({
+
+  id: "", //string
+  jobName: "", //string
+  workflowEntityName: "", //string
+  maps: 0, //number
+  reduces: 0, //number
+  status: "", //string
+  input: 0, //number
+  output: 0, //number
+  elapsedTime: 0, //number
+
+  duration: function() {
+    return date.timingFormat(parseInt(this.get('elapsedTime')));
+  }.property('elapsedTime'),
+
+  inputFormatted: function () {
+    return misc.formatBandwidth(this.get('input'));
+  }.property('input'),
+
+  outputFormatted: function () {
+    return misc.formatBandwidth(this.get('output'));
+  }.property('output')
+
+});

+ 103 - 0
ambari-web/app/classes/run_class.js

@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+var date = require('utils/date');
+var misc = require('utils/misc');
+
+App.Run2 = Ember.Object.extend({
+  id: null, //string
+  appName: null, //string
+  userName: null, //string
+  numJobsTotal: 0, //number
+  numJobsCompleted: 0, //number
+  startTime: 0, //number
+  elapsedTime: 0, //number
+  workflowContext: null, //string
+  input: 0, //number
+  output: 0, //number
+
+  /**
+   * Will set to true when we load all jobs related to this run
+   */
+  loadAllJobs : false,
+
+  /**
+   * runId  short part
+   */
+  idFormatted: function() {
+    return this.get('id').substr(0, 20);
+  }.property('id'),
+
+  /**
+   * Run duration
+   */
+  duration: function() {
+    return date.timingFormat(this.get('elapsedTime'));
+  }.property('elapsedTime'),
+
+  /**
+   * Status of running jobs
+   */
+  isRunning: function () {
+    return !this.get('numJobsTotal') == this.get('numJobsCompleted');
+  }.property('numJobsTotal', 'numJobsCompleted'),
+
+  /**
+   * Sum of input bandwidth for all jobs with appropriate measure
+   */
+  inputFormatted: function () {
+    return misc.formatBandwidth(this.get('input'));
+  }.property('input'),
+
+  /**
+   *  Sum of output bandwidth for all jobs with appropriate measure
+   */
+  outputFormatted: function () {
+    return misc.formatBandwidth(this.get('output'));
+  }.property('output'),
+
+  lastUpdateTime: function() {
+    return this.get('startTime') + this.get('elapsedTime');
+  }.property('elapsedTime', 'startTime'),
+
+  lastUpdateTimeFormatted: function() {
+    return date.dateFormat(this.get('lastUpdateTime'));
+  }.property('lastUpdateTime'),
+
+  lastUpdateTimeFormattedShort: function(){
+    return date.dateFormatShort(this.get('lastUpdateTime'));
+  }.property('lastUpdateTime'),
+
+  /**
+   * Type value based on first part of id
+   */
+  type: function() {
+    if (this.get('id').indexOf('pig_') === 0) {
+      return 'Pig';
+    }
+    if (this.get('id').indexOf('hive_') === 0) {
+      return 'Hive';
+    }
+    if (this.get('id').indexOf('mr_') === 0) {
+      return 'MapReduce';
+    }
+    return 'Undefined';
+  }.property('id')
+});

+ 5 - 3
ambari-web/app/controllers/global/background_operations_controller.js

@@ -160,7 +160,6 @@ App.BackgroundOperationsController = Em.Controller.extend({
       if (executeTasks[i].status == 'QUEUED' || executeTasks[i].status == 'PENDING' || executeTasks[i].status == 'IN_PROGRESS') {
         var url = App.testMode ? '/data/background_operations/list_on_start.json' :
             App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/requests/' + executeTasks[i].request_id + '/tasks/' + executeTasks[i].id;
-        var j = i;
         $.ajax({
           type: "GET",
           url: url,
@@ -168,7 +167,11 @@ App.BackgroundOperationsController = Em.Controller.extend({
           timeout: App.timeout,
           success: function (data) {
             if (data) {
-              executeTasks[j] = data.Tasks;
+              for(var i = 0;i < executeTasks.length; i++){
+                if(data.Tasks.id == executeTasks[i].id){
+                  executeTasks[i] = data.Tasks;
+                }
+              }
             }
           },
           error: function () {
@@ -179,7 +182,6 @@ App.BackgroundOperationsController = Em.Controller.extend({
         });
       }
     }
-    ;
     var currentTasks;
     currentTasks = runningTasks.concat(executeTasks);
     currentTasks = currentTasks.sort(function (a, b) {

+ 4 - 0
ambari-web/app/controllers/wizard/step10_controller.js

@@ -21,6 +21,10 @@ var App = require('app');
 App.WizardStep10Controller = Em.Controller.extend({
   clusterInfo: [],
 
+  /**
+   * check if were added regionservers then NAGIOS services should be restarted
+   * to update number of regionservers in NAGIOS
+   */
   isNagiosRestartRequired: function() {
     return this.get('content.controllerName') !== 'installerController' && App.Service.find('NAGIOS').get('isLoaded');
   }.property(),

+ 8 - 6
ambari-web/app/styles/apps.less

@@ -21,9 +21,13 @@
   td .red {
     color: red;
   }
-  .table thead th{
-    vertical-align: top;
-    padding-right: 4px;
+  .table {
+    thead {
+      th{
+        padding-left: 0 !important;
+        vertical-align: top;
+      }
+    }
   }
   .avg-table {
     table-layout: fixed;
@@ -41,13 +45,11 @@
   #dataTable {
     table-layout: fixed;
     td {
+      padding-right: 4px;
       word-wrap: break-word;
     }
   }
 
-  .dropdown-menu label.checkbox {
-    margin-left: 10px;
-  }
   .dropdown-menu label.checkbox {
     margin-left: 10px;
   }