Sfoglia il codice sorgente

AMBARI-10214. Pig View: Enable Execute on Tez (alexantonenko)

Alex Antonenko 10 anni fa
parent
commit
6bceddf173

+ 14 - 3
contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/script.js

@@ -19,6 +19,10 @@
 var App = require('app');
 
 App.ScriptController = Em.ObjectController.extend({
+  init: function(){
+    this.pollster.set('target',this);
+    this._super();
+  },
   actions :{
     deactivateJob:function (jobId) {
       var rejected = this.get('activeJobs').rejectBy('id',jobId);
@@ -79,7 +83,7 @@ App.ScriptController = Em.ObjectController.extend({
 
   tabs:Em.computed.union('staticTabs','jobTabs'),
 
-  pollster:Em.Object.create({
+  pollster:Em.Object.createWithMixins(Ember.ActionHandler,{
     jobs:[],
     timer:null,
     start: function(jobs){
@@ -93,7 +97,14 @@ App.ScriptController = Em.ObjectController.extend({
     onPoll: function() {
       this.get('jobs').forEach(function (job) {
         if (job.get('jobInProgress')) {
-          job.reload();
+          job.reload().catch(function (error) {
+            this.send('showAlert',{
+              message:Em.I18n.t('job.alert.delete_filed'),
+              status:'error',
+              trace:(error.responseJSON)?error.responseJSON.trace:null
+            });
+            this.jobs.removeObject(job);
+          }.bind(this));
         } else {
           this.jobs.removeObject(job);
         }
@@ -102,7 +113,7 @@ App.ScriptController = Em.ObjectController.extend({
       if (this.get('jobs.length') > 0) {
         this.set('timer', Ember.run.later(this, function() {
           this.onPoll();
-        }, 3000));
+        }, 10000));
       }
     }
   }),

+ 9 - 0
contrib/views/pig/src/main/resources/ui/pig-web/app/controllers/scriptEdit.js

@@ -107,6 +107,9 @@ App.ScriptEditController = Em.ObjectController.extend({
         .then(this.executeSuccess.bind(this), this.executeError.bind(this))
         .finally(Em.run.bind(this,this.set,'isExec',false));
     },
+    toggleTez:function () {
+      this.toggleProperty('executeOnTez');
+    },
     fullscreen:function () {
       this.toggleProperty('fullscreen');
     }
@@ -124,6 +127,8 @@ App.ScriptEditController = Em.ObjectController.extend({
     this.send('showAlert', {message:Em.I18n.t('job.alert.start_filed'),status:'error',trace:trace});
   },
 
+  executeOnTez:false,
+
   prepareJob:function (type, data) {
     var job, promise,
         exc = 'execute' == type,
@@ -142,6 +147,10 @@ App.ScriptEditController = Em.ObjectController.extend({
       fileContent = fileContent.replace(rgParam,param.value);
     });
 
+    if (this.get('executeOnTez') && args.indexOf('-x\ttez') < 0) {
+      args = args + (args ? "\t" : "") + '-x\ttez';
+    }
+
     job = this.store.createRecord('job', {
 
       /**

+ 7 - 1
contrib/views/pig/src/main/resources/ui/pig-web/app/models/pig_job.js

@@ -90,5 +90,11 @@ App.Job = DS.Model.extend({
     }
     var args = this.get('templetonArguments');
     return (args && args.length > 0)?args.w():[];
-  }.property('templetonArguments')
+  }.property('templetonArguments'),
+
+  notFound: function() {
+    if (this.get('isLoaded')) {
+      this.set('status','FAILED');
+    }
+  }
 });

+ 14 - 11
contrib/views/pig/src/main/resources/ui/pig-web/app/styles/style.less

@@ -24,7 +24,7 @@
 @import './../../bower_components/bootstrap/less/bootstrap.less';
 
 .wrap {
-  padding: 0px;
+  padding: 0;
 }
 
 .moz-padding (@selector, @pre: ~'', @padding) {
@@ -125,7 +125,7 @@
       left: 102%;
       position: relative;
       height: 100%;
-      box-shadow: -2px 0px 1px rgba(0, 0, 0, 0.20);
+      box-shadow: -2px 0 1px rgba(0, 0, 0, 0.20);
       .base-transition( left 300ms linear;);
 
       .nav-script {
@@ -183,9 +183,8 @@
     }
   }
   .pig-nav-item {
-    word-break: break-word;
+    word-wrap: break-word;
     .rm {
-      top:2px;
       position: absolute;
       right: 5px;
       top: 5px;
@@ -208,10 +207,9 @@
     position: absolute;
     color: @brand-primary;
     top: 1px;
-    padding: 0px;
     background: transparent;
     right: 3px;
-    padding: 0px 4px;
+    padding: 0 4px;
   }
 }
 
@@ -306,6 +304,11 @@
 //edit script
 .edit-script {
   .panel-editscript {
+
+    .tez-exec {
+      padding: 6px 12px;
+    }
+
     margin-bottom: 5px;
     textarea {
       width: 100%;
@@ -342,7 +345,7 @@
       position: absolute;
       cursor: s-resize;
       color: #999999;
-      zndex: 2;
+      z-index: 2;
     }
     .table-results {
       .argument {
@@ -462,7 +465,7 @@
       .panel-heading {
         position: fixed;
         top: 0;
-        right: 0px;
+        right: 0;
         left: 0;
         z-index: 77;
         border-top: 1px solid #ddd;
@@ -472,7 +475,7 @@
       .panel-body {
         position: fixed;
         top: 55px;
-        right: 0px;
+        right: 0;
         left: 0;
         z-index: 76;
         border-right: 1px solid #ddd;
@@ -560,7 +563,7 @@
 }
 
 .main-content {
-    padding-left: 0px;
+    padding-left: 0;
 }
 
 .job-container {
@@ -621,7 +624,7 @@
       &.fullscreen {
         position: fixed;
         top: 0;
-        right: 0px;
+        right: 0;
         left: 0;
         z-index: 77;
         border-top: 1px solid #ddd;

+ 5 - 0
contrib/views/pig/src/main/resources/ui/pig-web/app/templates/script/edit.hbs

@@ -35,6 +35,11 @@
             <li><a href="#" {{action "execute" content 'syntax_check' }} >{{t 'editor.syntax_check'}}</a></li>
           </ul>
         </div>
+        <div class="btn-group btn-group-xs pull-right tez-exec">
+          <label class="btn btn-default" {{action 'toggleTez'}}>
+            <i {{bind-attr class=":fa executeOnTez:fa-check-square-o:fa-square-o"}}></i> {{t 'editor.execute_on_tez'}}
+          </label>
+        </div>
         {{else}}
         <div class="spinner-sm pull-right"></div>
       {{/unless}}

+ 1 - 0
contrib/views/pig/src/main/resources/ui/pig-web/app/translations.js

@@ -101,6 +101,7 @@ Ember.I18n.translations = {
     'execute':'Execute',
     'explain':'Explain',
     'syntax_check':'Syntax check',
+    'execute_on_tez':'Execute on Tez',
     'toggle_fullscreen':'Toggle fullscreen (F11)'
   },
   'job':{