ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-16427. Hive view : Upload Table- Tries to upload file, when no file is mentioned in hdfs path (pallavkul)
Date Tue, 24 May 2016 09:51:26 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c5509f0eb -> 8bc59516b


AMBARI-16427. Hive view : Upload Table- Tries to upload file, when no file is mentioned in
hdfs path (pallavkul)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8bc59516
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8bc59516
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8bc59516

Branch: refs/heads/trunk
Commit: 8bc59516b62946f68f234467c5f245d937812896
Parents: c5509f0
Author: Pallav Kulshreshtha <pallav.kul@gmail.com>
Authored: Tue May 24 15:21:00 2016 +0530
Committer: Pallav Kulshreshtha <pallav.kul@gmail.com>
Committed: Tue May 24 15:21:00 2016 +0530

----------------------------------------------------------------------
 .../app/components/validated-text-field.js      |   2 +
 .../ui/hive-web/app/controllers/upload-table.js | 124 +++++++++++--------
 .../ui/hive-web/app/initializers/i18n.js        |   3 +
 .../resources/ui/hive-web/app/styles/app.scss   |   2 +-
 .../ui/hive-web/app/templates/upload-table.hbs  |   8 +-
 5 files changed, 86 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8bc59516/contrib/views/hive/src/main/resources/ui/hive-web/app/components/validated-text-field.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/validated-text-field.js
b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/validated-text-field.js
index 50cea36..2379a15 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/validated-text-field.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/validated-text-field.js
@@ -26,6 +26,8 @@ import Ember from 'ember';
  * {{/validated-text-field}}
  */
 export default Ember.Component.extend({
+  classNameBindings: ['tagClassName'],
+  tagClassName : false, // set it to non false value if you want a specific class to be assigned
   allowEmpty: true,
   valid: true,
   setValid: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8bc59516/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js
b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js
index b1611fb..f2e2f5e 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/upload-table.js
@@ -24,6 +24,7 @@ import constants from 'hive/utils/constants';
 export default Ember.Controller.extend({
   COLUMN_NAME_REGEX: "^[a-zA-Z]{1}[a-zA-Z0-9_]*$",
   TABLE_NAME_REGEX: "^[a-zA-Z]{1}[a-zA-Z0-9_]*$",
+  HDFS_PATH_REGEX: "^[/]{1}.+",  // unix path allows everything but here we have to mention
full path so starts with /
   isLocalUpload: Ember.computed.equal("uploadSource", "local"),
   uploadSource: "local",
   COLUMN_NAME_PREFIX : "column",
@@ -118,7 +119,7 @@ export default Ember.Controller.extend({
           this.get('rows').unshiftObject({row: this.get('firstRow')});
           this._setHeaderElements(this.get('header'),this.get('defaultColumnNames'));
         }
-      } else if( this.get('header') ) { // headers are available
+      } else if (this.get('header')) { // headers are available
         // take first row of
         this._setHeaderElements(this.get('header'),this.get('firstRow'));
         this.get('rows').removeAt(0);
@@ -128,7 +129,7 @@ export default Ember.Controller.extend({
     }
   }.observes('isFirstRowHeader'),
 
-  popUploadProgressInfos : function(){
+  popUploadProgressInfos: function () {
     var msg = this.get('uploadProgressInfos').popObject();
   },
 
@@ -177,11 +178,11 @@ export default Ember.Controller.extend({
       "firstRow : ", this.get('firstRow'));
   },
 
-  generateTempTableName : function(){
+  generateTempTableName: function () {
     var text = "";
     var possible = "abcdefghijklmnopqrstuvwxyz";
 
-    for( var i=0; i < 30; i++ )
+    for (var i = 0; i < 30; i++)
       text += possible.charAt(Math.floor(Math.random() * possible.length));
 
     return text;
@@ -209,29 +210,52 @@ export default Ember.Controller.extend({
   uploadForPreview: function (files) {
     console.log("uploaderForPreview called.");
     var self = this;
-    return this.get('uploader').uploadFiles('preview', files, {"isFirstRowHeader" : self.get("isFirstRowHeader"),
"inputFileType" : self.get("inputFileType").id});
+    return this.get('uploader').uploadFiles('preview', files, {
+      "isFirstRowHeader": self.get("isFirstRowHeader"),
+      "inputFileType": self.get("inputFileType").id
+    });
   },
 
-  uploadForPreviewFromHDFS : function(){
+  uploadForPreviewFromHDFS: function () {
     console.log("uploadForPreviewFromHDFS called.");
-    return this.get('uploader').previewFromHDFS({"isFirstRowHeader" : this.get("isFirstRowHeader"),"inputFileType"
: this.get("inputFileType").id , "hdfsPath" : this.get("hdfsPath") });
+    var hdfsPath = this.get("hdfsPath");
+    this.validateHDFSPath(hdfsPath);
+    return this.get('uploader').previewFromHDFS({
+      "isFirstRowHeader": this.get("isFirstRowHeader"),
+      "inputFileType": this.get("inputFileType").id,
+      "hdfsPath": hdfsPath
+    });
   },
 
-  generatePreview : function(files){
+  generatePreview: function (files) {
     var self = this;
     var promise = null;
-    this.waitForGeneratingPreview();
-    if(this.get('isLocalUpload')){
-      promise = this.uploadForPreview(files);
-    }else{
-      promise = this.uploadForPreviewFromHDFS();
-    }
+    try {
+      this.waitForGeneratingPreview();
+      if (this.get('isLocalUpload')) {
+        promise = this.uploadForPreview(files);
+      } else {
+        promise = this.uploadForPreviewFromHDFS();
+      }
 
-    return promise.then(function (data) {
+      return promise.then(function (data) {
         self.onGeneratePreviewSuccess(data);
-    }, function (error) {
+      }, function (error) {
         self.onGeneratePreviewFailure(error);
-    });
+      }).catch(function (error) {
+        console.log("inside catch : ", error);
+      }).finally(function () {
+        console.log("finally hide the modal always after preview.");
+        self.hideUploadModal();
+      });
+    }catch(e){
+      // exception before promise will be caught here.
+      console.log("exception before promise : ", e);
+      self.setError(e);
+    }finally{
+      console.log("finally hide the modal always after preview.");
+      self.hideUploadModal();
+    }
   },
 
   waitForGeneratingPreview: function () {
@@ -250,9 +274,9 @@ export default Ember.Controller.extend({
     this.set("header", data.header);
     this.set("firstRow", data.rows[0].row);
     this.set('isFirstRowHeader', data.isFirstRowHeader);
-    this.set('tableName',data.tableName);
-    if(data.isFirstRowHeader == true){
-        data.rows = data.rows.slice(1);
+    this.set('tableName', data.tableName);
+    if (data.isFirstRowHeader == true) {
+      data.rows = data.rows.slice(1);
     }
     this.set("rows", data.rows);
   },
@@ -271,7 +295,7 @@ export default Ember.Controller.extend({
     this.setError(error);
   },
 
-  createActualTable : function(){
+  createActualTable: function () {
     console.log("createActualTable");
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.startingToCreateActualTable'));
     var headers = this.get('header');
@@ -310,30 +334,30 @@ export default Ember.Controller.extend({
     return p;
   },
 
-  onCreateActualTableSuccess : function(){
+  onCreateActualTableSuccess: function () {
     console.log("onCreateTableSuccess");
     this.popUploadProgressInfos();
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.successfullyCreatedActualTable'));
   },
 
-  onCreateActualTableFailure : function(error){
+  onCreateActualTableFailure: function (error) {
     console.log("onCreateActualTableFailure");
     this.popUploadProgressInfos();
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.failedToCreateActualTable'));
     this.setError(error);
   },
 
-  createTempTable : function(){
+  createTempTable: function () {
     console.log("createTempTable");
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.startingToCreateTemporaryTable'));
     var tempTableName = this.generateTempTableName();
-    this.set('tempTableName',tempTableName);
+    this.set('tempTableName', tempTableName);
     return this.get('uploader').createTable({
       "isFirstRowHeader": this.get("isFirstRowHeader"),
       "header": this.get("header"),
       "tableName": tempTableName,
       "databaseName": this.get('databaseName'),
-      "fileType":"TEXTFILE"
+      "fileType": "TEXTFILE"
     });
   },
 
@@ -349,7 +373,7 @@ export default Ember.Controller.extend({
     return p;
   },
 
-  onCreateTempTableSuccess : function(){
+  onCreateTempTableSuccess: function () {
     console.log("onCreateTempTableSuccess");
     this.popUploadProgressInfos();
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.successfullyCreatedTemporaryTable'));
@@ -364,20 +388,20 @@ export default Ember.Controller.extend({
     });
   },
 
-  deleteTableOnError : function(databaseName,tableName, tableLabel){
-      //delete table and wait for delete job
+  deleteTableOnError: function (databaseName, tableName, tableLabel) {
+    //delete table and wait for delete job
     var self = this;
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.deletingTable',{table:tableLabel}));
 
-    return this.deleteTable(databaseName,tableName).then(function(data){
-      return new Ember.RSVP.Promise(function(resolve,reject){
-        self.waitForJobStatus(data.jobId,resolve,reject);
+    return this.deleteTable(databaseName, tableName).then(function (data) {
+      return new Ember.RSVP.Promise(function (resolve, reject) {
+        self.waitForJobStatus(data.jobId, resolve, reject);
       });
-    }).then(function(){
+    }).then(function () {
       self.popUploadProgressInfos();
       self.pushUploadProgressInfos(this.formatMessage('hive.messages.succesfullyDeletedTable',{table:tableLabel}));
       return Ember.RSVP.Promise.resolve();
-    },function(err){
+    }, function (err) {
       self.popUploadProgressInfos();
       self.pushUploadProgressInfos(this.formatMessage('hive.messages.failedToDeleteTable',{table:tableLabel}));
       self.setError(err);
@@ -399,15 +423,15 @@ export default Ember.Controller.extend({
     console.log("onCreateTempTableFailure");
     this.setError(error);
     this.popUploadProgressInfos();
-    this.pushUploadProgressInfos();
+    this.pushUploadProgressInfos(this.formatMessage('hive.messages.failedToCreateTemporaryTable'));
     return this.rollBackActualTableCreation().then(function(data){
       return Ember.RSVP.Promise.reject(error); // always reject for the flow to stop
-    },function(err){
+    }, function (err) {
       return Ember.RSVP.Promise.reject(error); // always reject for the flow to stop
     });
   },
 
-  uploadFile : function(){
+  uploadFile: function () {
     console.log("uploadFile");
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.startingToUploadFile'));
     if( this.get("isLocalUpload")){
@@ -438,7 +462,7 @@ export default Ember.Controller.extend({
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.successfullyUploadedFile')
);
   },
 
-  rollBackTempTableCreation : function(){
+  rollBackTempTableCreation: function () {
     var self = this;
     return this.deleteTableOnError(this.get("databaseName"),this.get("tempTableName"),this.translate('hive.words.temporary')).then(function(data){
       return self.rollBackActualTableCreation();
@@ -468,7 +492,7 @@ export default Ember.Controller.extend({
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.startingToInsertRows'));
 
     return this.get('uploader').insertIntoTable({
-      "fromDatabase":  this.get("databaseName"),
+      "fromDatabase": this.get("databaseName"),
       "fromTable": this.get("tempTableName"),
       "toDatabase": this.get("databaseName"),
       "toTable": this.get("tableName")
@@ -487,13 +511,13 @@ export default Ember.Controller.extend({
     return p;
   },
 
-  onInsertIntoTableSuccess : function(){
+  onInsertIntoTableSuccess: function () {
     console.log("onInsertIntoTableSuccess");
     this.popUploadProgressInfos();
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.successfullyInsertedRows'));
   },
 
-  onInsertIntoTableFailure : function(error){
+  onInsertIntoTableFailure: function (error) {
     console.log("onInsertIntoTableFailure");
     this.setError(error);
     this.popUploadProgressInfos();
@@ -527,20 +551,20 @@ export default Ember.Controller.extend({
     return p;
   },
 
-  onDeleteTempTableSuccess : function(){
+  onDeleteTempTableSuccess: function () {
     console.log("onDeleteTempTableSuccess");
     this.popUploadProgressInfos();
     this.pushUploadProgressInfos(this.formatMessage('hive.messages.successfullyDeletedTemporaryTable'));
     this.onUploadSuccessfull();
   },
 
-  onDeleteTempTableFailure : function(error){
+  onDeleteTempTableFailure: function (error) {
     console.log("onDeleteTempTableFailure");
     this.setError(error);
     this.setError(this.formatMessage('hive.messages.manuallyDeleteTable',{databaseName:this.get('databaseName'),
tableName: this.get("tempTableName")}));
   },
 
-  createTableAndUploadFile : function(){
+  createTableAndUploadFile: function () {
     var self = this;
     self.setError();
     self.createActualTable()
@@ -740,20 +764,20 @@ export default Ember.Controller.extend({
       var self = this;
       return this.generatePreview(files)
     },
-    previewFromHdfs : function(){
+    previewFromHdfs: function () {
       return this.generatePreview();
     },
-    uploadTable : function(){
-      try{
+    uploadTable: function () {
+      try {
         this.createTableAndUploadFile();
-      }catch(e){
+      } catch (e) {
         console.log("exception occured : ", e);
         this.setError(e);
         this.hideUploadModal();
       }
     },
-    uploadFromHDFS : function(){
-      this.set("isLocalUpload",false);
+    uploadFromHDFS: function () {
+      this.set("isLocalUpload", false);
     }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/8bc59516/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
index 056db29..c8bb7d0 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
@@ -303,6 +303,9 @@ TRANSLATIONS = {
       'isFirstRowHeader':"Is first row header ?",
       'columnNameTooltip':"Enter valid (alphanumeric + underscore) column name.",
       'columnNameErrorMessage':"Only alphanumeric and underscore characters are allowed in
column names.",
+      'hdfsFieldTooltip':"Enter full HDFS path",
+      'hdfsFieldPlaceholder':"Enter full HDFS path",
+      'hdfsFieldErrorMessage':"Please enter complete path of hdfs file to upload."
 
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/8bc59516/contrib/views/hive/src/main/resources/ui/hive-web/app/styles/app.scss
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/styles/app.scss b/contrib/views/hive/src/main/resources/ui/hive-web/app/styles/app.scss
index be6d9ac..c974dea 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/styles/app.scss
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/styles/app.scss
@@ -645,7 +645,7 @@ td.data-upload-form-field {
     width: 350px;
 }
 
-#hdfs-param input {
+.hdfsPath {
   width: 80%;
   display: inline;
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8bc59516/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs
b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs
index f334a3d..5e3a519 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/upload-table.hbs
@@ -69,13 +69,17 @@
           }}
         </td>
 
-
         {{#if isLocalUpload }}
           <td class="data-upload-form-label"><label>{{t "hive.ui.selectFromLocal"}}</label></td>
           <td class="data-upload-form-field">{{file-upload  filesUploaded="filesUploaded"
 uploadFiles=files}}</td>
         {{else}}
           <td class="data-upload-form-label"><label>{{t "hive.ui.hdfsPath"}}</label></td>
-          <td class="data-upload-form-field" id="hdfs-param">{{input type="text" class="form-control"
placeholder="Enter full HDFS path" value=hdfsPath }}
+          <td class="data-upload-form-field" id="hdfs-param">
+            {{#validated-text-field inputValue=hdfsPath allowEmpty=false tagClassName="hdfsPath"
+            tooltip=(t "hive.ui.hdfsFieldTooltip") placeholder=(t "hive.ui.hdfsFieldPlaceholder")
+            invalidClass='form-control hdfsPath red-border' validClass='form-control hdfsPath'
regex=HDFS_PATH_REGEX
+            errorMessage=(t "hive.ui.hdfsFieldErrorMessage")  }}
+            {{/validated-text-field}}
             <button style="margin-left: 5px; padding-top: 6px;padding-bottom: 6px; padding-right:
10px; padding-left: 10px;" type="button" {{action "previewFromHdfs"}}
             {{bind-attr class=":btn :btn-sm :btn-default"}}>{{t "buttons.showPreview"}}</button></td>
         {{/if}}


Mime
View raw message