Procházet zdrojové kódy

AMBARI-6708. Fix reference to deleted method. (onechiporenko)

Oleg Nechiporenko před 11 roky
rodič
revize
dd888838da

+ 2 - 2
contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js

@@ -62,7 +62,7 @@ App.JobController = Ember.ObjectController.extend(App.RunPeriodically, {
   },
 
   /**
-   * Init method called  in <code>router.setupController</code>
+   * Init method called in <code>router.setupController</code>
    * Load job's details info (like Tez Dag etc)
    * @method loadJobDetails
    */
@@ -99,7 +99,7 @@ App.JobController = Ember.ObjectController.extend(App.RunPeriodically, {
               default:
                 break;
             }
-            self.routeToJobs();
+            this.transitionToRoute('jobs');
           }
         );
       }

+ 211 - 11
contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js

@@ -22,6 +22,7 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
 
   /**
    * Sorted ArrayProxy
+   * @type {App.HiveJob[]}
    */
   sortedContent: [],
 
@@ -30,36 +31,69 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     nextID: ''
   },
 
+  /**
+   * ID of the last job
+   * @type {string}
+   */
   lastJobID: '',
 
   hasNewJobs: false,
 
+  /**
+   * Are jobs already loaded
+   * @type {bool}
+   */
   loaded: false,
 
+  /**
+   * Are jobs loading
+   * @type {bool}
+   */
   loading: false,
 
+  /**
+   * Should pagination be reset
+   * Used when jobs list is updated
+   * @type {bool}
+   */
   resetPagination: false,
 
-  loadJobsTimeout: null,
-
-  loadTimeout: null,
-
-  jobsUpdateInterval: 6000,
-
-  jobsUpdate: null,
-
+  /**
+   * Column which is used to sort jobs now
+   * @type {Em.Object}
+   */
   sortingColumn: null,
 
+  /**
+   * Property-name used to sort jobs
+   * @type {string}
+   */
   sortProperty: 'id',
 
+  /**
+   * Is sorting doing in asc order
+   * @type {bool}
+   */
   sortAscending: true,
 
+  /**
+   * Is sorting complete
+   * @type {bool}
+   */
   sortingDone: true,
 
+  /**
+   * Diagnostic message shown on jobs table when no data present
+   * @type {string}
+   */
   jobsMessage: Em.I18n.t('jobs.loadingTasks'),
 
   totalOfJobs: 0,
 
+  /**
+   * Buttons for custom-date popup
+   * @type {Em.Object[]}
+   */
   customDatePopupButtons: [
     Ember.Object.create({title: Em.I18n.t('ok'), clicked: 'submitCustomDate'}),
     Ember.Object.create({title: Em.I18n.t('cancel'), dismiss: 'modal', clicked: 'dismissCustomDate'})
@@ -67,6 +101,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
 
   actions: {
 
+    /**
+     * Click-handler for "New jobs available on server"-link
+     * @method updateJobsByClick
+     */
     updateJobsByClick: function () {
       this.set('navIDs.backIDs', []);
       this.set('navIDs.nextID', '');
@@ -78,17 +116,29 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       this.loadJobs();
     },
 
+    /**
+     * Custom-date submit handler
+     * @method submitCustomDate
+     */
     submitCustomDate: function () {
       if(this.get('filterObject').submitCustomDate())
         Bootstrap.ModalManager.close('customDate');
     },
 
+    /**
+     * Custom-date dismiss handler
+     * @method dismissCustomDate
+     */
     dismissCustomDate: function() {
       this.set('filterObject.startTime', 'Any');
     }
 
   },
 
+  /**
+   * Observer for content and sorting indicators
+   * @method contentAndSortObserver
+   */
   contentAndSortObserver: function () {
     Ember.run.once(this, 'contentAndSortUpdater');
   }.observes(
@@ -100,6 +150,11 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       'sortAscending'
     ),
 
+  /**
+   * Update <code>sortedContent</code>
+   * Called once from <code>contentAndSortObserver</code>
+   * @method contentAndSortUpdater
+   */
   contentAndSortUpdater: function () {
     this.set('sortingDone', false);
     var content = this.get('content');
@@ -141,28 +196,86 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     this.set('sortingDone', true);
   },
 
+  /**
+   * Filters-processor
+   * @type {Em.Object}
+   */
   filterObject: Ember.Object.create({
+
+    /**
+     * @type {string}
+     */
     id: "",
+
+    /**
+     * Does user filter jobs by ID
+     * @type {bool}
+     */
     isIdFilterApplied: false,
+
+    /**
+     * Number of jobs shown on the page
+     * @type {string}
+     */
     jobsLimit: '10',
+
+    /**
+     * Username used to filter
+     * @type {string}
+     */
     user: "",
+
+    /**
+     * Custom start date
+     * @type {string}
+     */
     windowStart: "",
+
+    /**
+     * Custom end date
+     * @type {string}
+     */
     windowEnd: "",
+
+    /**
+     * @type {string}
+     */
     nextFromId: "",
+
+    /**
+     * @type {string}
+     */
     backFromId: "",
+
+    /**
+     * @type {string}
+     */
     fromTs: "",
+
+    /**
+     * Is user using any filter now
+     * @type {bool}
+     */
     isAnyFilterApplied: false,
 
+    /**
+     * Set <code>isIdFilterApplied</code> according to <code>id</code> value
+     * @type {bool}
+     */
     onApplyIdFilter: function () {
       this.set('isIdFilterApplied', this.get('id') != "");
     }.observes('id'),
 
     /**
      * Direct binding to startTime filter field
+     * @type {string}
      */
     startTime: "",
 
-    // Fields values from Select Custom Dates form
+    /**
+     * Fields values from Select Custom Dates form
+     * @type {Em.Object}
+     */
     customDateFormFields: Ember.Object.create({
       startDate: null,
       hoursForStart: null,
@@ -174,11 +287,19 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       middayPeriodForEnd: null
     }),
 
+    /**
+     * Error-flags for custom start/end dates
+     * @type {Em.Object}
+     */
     errors: Ember.Object.create({
       isStartDateError: false,
       isEndDateError: false
     }),
 
+    /**
+     * Error-messages for custom start/end dates
+     * @type {Em.Object}
+     */
     errorMessages: Ember.Object.create({
       startDate: '',
       endDate: ''
@@ -195,6 +316,11 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       columnsCount: 6
     }),
 
+    /**
+     * Submit custom dates handler
+     * @returns {boolean}
+     * @method submitCustomDate
+     */
     submitCustomDate: function() {
       this.validate();
       if (this.get('errors.isStartDateError') || this.get('errors.isEndDateError')) {
@@ -207,6 +333,11 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       return true;
     },
 
+    /**
+     * Create custom start date according to provided in popup data
+     * @returns {Date|null}
+     * @method createCustomStartDate
+     */
     createCustomStartDate: function () {
       var startDate = this.get('customDateFormFields.startDate'),
         hoursForStart = this.get('customDateFormFields.hoursForStart'),
@@ -218,6 +349,11 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       return null;
     },
 
+    /**
+     * Create custom end date according to provided in popup data
+     * @returns {Date|null}
+     * @method createCustomStartDate
+     */
     createCustomEndDate: function () {
       var endDate = this.get('customDateFormFields.endDate'),
         hoursForEnd = this.get('customDateFormFields.hoursForEnd'),
@@ -229,6 +365,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       return null;
     },
 
+    /**
+     * Clear <code>errorMessages</code> and <code>errors</code>
+     * @method clearErrors
+     */
     clearErrors: function () {
       var errorMessages = this.get('errorMessages');
       Em.keys(errorMessages).forEach(function (key) {
@@ -240,7 +380,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       }, this);
     },
 
-    // Validation for every field in customDateFormFields
+    /**
+     * Validation for every field in customDateFormFields
+     * @method validate
+     */
     validate: function () {
       var formFields = this.get('customDateFormFields'),
         errors = this.get('errors'),
@@ -265,6 +408,7 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     /**
      * Create link for server request
      * @return {String}
+     * @method createJobsFiltersLink
      */
     createJobsFiltersLink: function () {
       var link = "?fields=events,primaryfilters,otherinfo&secondaryFilter=tez:true",
@@ -316,6 +460,12 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     }
   }.observes('content.length'),
 
+  /**
+   * Observer for <code>startTime</code>
+   * Calculates value for <code>filterObject.windowStart</code> and <code>filterObject.windowEnd</code> or
+   * shows Custom Date popup
+   * @method startTimeObserver
+   */
   startTimeObserver: function () {
     var time = "",
       curTime = new Date().getTime();
@@ -351,6 +501,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     }
   },
 
+  /**
+   * Show popup with fields for custom start/end dates
+   * @method showCustomDatePopup
+   */
   showCustomDatePopup: function () {
     Bootstrap.ModalManager.open(
       'customDate',
@@ -361,6 +515,12 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     );
   },
 
+  /**
+   * Success-callback for "jobs-lastID" request
+   * Updates <code>hasNewJobs</code>-flag
+   * @param {object} data
+   * @method lastIDSuccessCallback
+   */
   lastIDSuccessCallback: function (data) {
     if (!data.entities[0]) {
       return;
@@ -382,10 +542,19 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     }
   },
 
-  lastIDErrorCallback: function (data, jqXHR, textStatus) {
+  /**
+   * Error-callback for "jobs-lastID" request
+   * @method lastIDErrorCallback
+   */
+  lastIDErrorCallback: function (data, jqXHR) {
     console.debug(jqXHR);
   },
 
+  /**
+   * Check, why jobs weren't loaded and set <code>jobsMessage</code>
+   * @param {object|null} jqXHR
+   * @method checkDataLoadingError
+   */
   checkDataLoadingError: function (jqXHR) {
     var atsComponent = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER');
     if (atsComponent && atsComponent.get('workStatus') != "STARTED") {
@@ -406,6 +575,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     }
   },
 
+  /**
+   * Do request to load jobs and check last job id
+   * @method loadJobs
+   */
   loadJobs: function () {
     var yarnService = App.HiveJob.store.getById('service', 'YARN'),
       atsComponent = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER'),
@@ -438,6 +611,12 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     }
   },
 
+  /**
+   * Success callback for jobs-request
+   * Call mapper to save jobs to the models
+   * @param {object} data
+   * @method loadJobsSuccessCallback
+   */
   loadJobsSuccessCallback: function (data) {
     App.hiveJobsMapper.map(data);
     this.set('loading', false);
@@ -448,11 +627,20 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     this.set('loaded', true);
   },
 
+  /**
+   * Error callback for jobs-request
+   * @param {object} jqXHR
+   * @method loadJobsErrorCallback
+   */
   loadJobsErrorCallback: function (jqXHR) {
     App.hiveJobsMapper.map({entities: []});
     this.checkDataLoadingError(jqXHR);
   },
 
+  /**
+   * Update <code>filterObject</code> fields
+   * @method initializePagination
+   */
   initializePagination: function () {
     var back_link_IDs = this.get('navIDs.backIDs.[]');
     if (!back_link_IDs.contains(this.get('lastJobID'))) {
@@ -462,6 +650,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     this.get('filterObject').set('fromTs', new Date().getTime());
   },
 
+  /**
+   * Go to next page
+   * @method navigateNext
+   */
   navigateNext: function () {
     this.set("filterObject.backFromId", '');
     var back_link_IDs = this.get('navIDs.backIDs.[]');
@@ -475,6 +667,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     this.loadJobs();
   },
 
+  /**
+   * Go to previous page
+   * @method navigateBack
+   */
   navigateBack: function () {
     this.set("filterObject.nextFromId", '');
     var back_link_IDs = this.get('navIDs.backIDs.[]');
@@ -485,6 +681,10 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
     this.loadJobs();
   },
 
+  /**
+   * Load jobs when <code>filterObject</code> fields were changed
+   * @method refreshLoadedJobs
+   */
   refreshLoadedJobs: function () {
     this.loadJobs();
   }.observes(

+ 0 - 1
contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/date.js

@@ -129,7 +129,6 @@ App.Helpers.date = {
     var durationSummary = '';
     var startDate = new Date(startTimestamp);
     var endDate = new Date(endTimestamp);
-    var self = this;
     if (startDate.getFullYear() == 1969 || startTimestamp < 1) {
       // not started
       return Em.I18n.t('common.na');

+ 5 - 4
contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js

@@ -81,7 +81,7 @@ App.Helpers.jobs = {
             params.errorCallback('job.dag.noId');
           }
         },
-        dagNameToIdError: function (jqXHR, url, method, showStatus) {
+        dagNameToIdError: function () {
           params.errorCallback('job.dag.name.loaderror');
         }
       };
@@ -122,8 +122,9 @@ App.Helpers.jobs = {
         sender = {
           loadTezDagSuccess: function (data) {
             if (data) {
-              if (data.otherinfo && data.otherinfo.applicationId) {
-                tezDag.set('yarnApplicationId', data.otherinfo.applicationId);
+              var app_id = Em.get(data, 'otherinfo.applicationId');
+              if (!Em.isNone(app_id)) {
+                tezDag.set('yarnApplicationId', app_id);
               }
               if (data.relatedentities && data.relatedentities.TEZ_VERTEX_ID != null) {
                 var count = data.relatedentities.TEZ_VERTEX_ID.length;
@@ -138,7 +139,7 @@ App.Helpers.jobs = {
               }
             }
           },
-          loadTezDagError: function (jqXHR, url, method, showStatus) {
+          loadTezDagError: function () {
             errorCallback('job.dag.id.loaderror');
           }
         };

+ 16 - 18
contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/number.js

@@ -66,25 +66,23 @@ App.Helpers.number = {
    * @param {string|number} [max]
    */
   validateInteger : function(str, min, max) {
-    if (str==null || str==undefined || (str + "").trim().length < 1) {
+    if (Em.isNone(str) || (str + "").trim().length < 1) {
       return Em.I18n.t('number.validate.empty');
-    } else {
-      str = (str + "").trim();
-      var number = parseInt(str);
-      if (isNaN(number)) {
-        return Em.I18n.t('number.validate.notValidNumber');
-      } else {
-        if (str.length != (number + "").length) {
-          // parseInt("1abc") returns 1 as integer
-          return Em.I18n.t('number.validate.notValidNumber');
-        }
-        if (!isNaN(min) && number < min) {
-          return Em.I18n.t('number.validate.lessThanMinumum').fmt(min);
-        }
-        if (!isNaN(max) && number > max) {
-          return Em.I18n.t('number.validate.moreThanMaximum').fmt(max);
-        }
-      }
+    }
+    str = (str + "").trim();
+    var number = parseInt(str);
+    if (isNaN(number)) {
+      return Em.I18n.t('number.validate.notValidNumber');
+    }
+    if (str.length != (number + "").length) {
+      // parseInt("1abc") returns 1 as integer
+      return Em.I18n.t('number.validate.notValidNumber');
+    }
+    if (!isNaN(min) && number < min) {
+      return Em.I18n.t('number.validate.lessThanMinumum').fmt(min);
+    }
+    if (!isNaN(max) && number > max) {
+      return Em.I18n.t('number.validate.moreThanMaximum').fmt(max);
     }
     return null;
   }

+ 2 - 0
contrib/views/jobs/src/main/resources/ui/app/scripts/routes/application_route.js

@@ -38,6 +38,8 @@ App.JobsRoute = Ember.Route.extend({
     this._super(controller, model);
     controller.set('interval', 6000);
     controller.loop('loadJobs', true);
+    // This observer should be set with addObserver
+    // If it set like ".observes(....)" it triggers two times
     Em.addObserver(controller, 'filterObject.startTime', controller, 'startTimeObserver');
   }
 

+ 4 - 9
contrib/views/jobs/src/main/resources/ui/app/scripts/views/job/hive_job_details_tez_dag_view.js

@@ -257,13 +257,8 @@ App.MainHiveJobDetailsTezDagView = Em.View.extend({
       else {
         value = '';
       }
-      switch (summaryMetricType) {
-        case "input":
-        case "output":
-          value = App.Helpers.number.bytesToSize(value);
-          break;
-        default:
-          break;
+      if (['input', 'output'].contains(summaryMetricType)) {
+        value = App.Helpers.number.bytesToSize(value);
       }
       node.metricType = Em.I18n.t('jobs.hive.tez.metric.' + summaryMetricType);
       node.metricDisplay = value;
@@ -702,7 +697,7 @@ App.MainHiveJobDetailsTezDagView = Em.View.extend({
           self.get('parentView').doSelectVertex(vertex, true);
         }
       });
-    node.each(function (n, nodeIndex) {
+    node.each(function (n) {
       var ops = n.operations;
       var opCount = {};
       if (ops != null && ops.length > 0) {
@@ -960,7 +955,7 @@ App.MainHiveJobDetailsTezDagView = Em.View.extend({
    * </code>
    * @method getNodeCalculatedDimensions
    */
-  getNodeCalculatedDimensions: function (node, minVertexDuration, maxVertexDuration) {
+  getNodeCalculatedDimensions: function (node) {
     var size = {
       width: 180,
       height: 40,

+ 2 - 4
contrib/views/jobs/src/main/resources/ui/app/scripts/views/job/hive_job_details_view.js

@@ -122,8 +122,7 @@ App.JobView = Em.View.extend({
         zoomScale = this.get('zoomScale'),
         zoomStep = this.get('zoomStep');
       if (zoomScale < zoomTo) {
-        var step = Math.min(zoomStep, (zoomTo - zoomScale));
-        zoomScale += step;
+        zoomScale += Math.min(zoomStep, (zoomTo - zoomScale));
         this.set('zoomScale', zoomScale);
       }
     },
@@ -137,8 +136,7 @@ App.JobView = Em.View.extend({
         zoomScale = this.get('zoomScale'),
         zoomStep = this.get('zoomStep');
       if (zoomScale > zoomFrom) {
-        var step = Math.min(zoomStep, (zoomScale - zoomFrom));
-        zoomScale -= step;
+        zoomScale -= Math.min(zoomStep, (zoomScale - zoomFrom));
         this.set('zoomScale', zoomScale);
       }
     },