You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/08/25 20:21:40 UTC

ambari git commit: AMBARI-12734. Hive View: Visual Explain does not work running same query multiple times (Pallav Kulshreshtha via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 b5018a48b -> e0f02c58c


AMBARI-12734. Hive View: Visual Explain does not work running same query multiple times (Pallav Kulshreshtha via srimanth)


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

Branch: refs/heads/branch-2.1
Commit: e0f02c58cb266bd576ed1e2113c9a77060c4c125
Parents: b5018a4
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Tue Aug 25 11:20:57 2015 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Tue Aug 25 11:20:57 2015 -0700

----------------------------------------------------------------------
 .../hive-web/app/controllers/visual-explain.js  | 40 ++++++++++++--------
 .../ui/hive-web/app/utils/functions.js          | 17 ++++++++-
 .../ui/hive-web/app/views/visual-explain.js     | 39 ++++++-------------
 3 files changed, 53 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e0f02c58/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/visual-explain.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/visual-explain.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/visual-explain.js
index be14687..509fe85 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/visual-explain.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/visual-explain.js
@@ -36,27 +36,37 @@ export default Ember.Controller.extend({
         this.set('json', undefined);
         this.set('noquery', 'hive.errors.no.query');
         return;
+      } else {
+        this.set('noquery', undefined);
       }
+      // Introducing a common function
+      var getVisualExplainJson = function(){
+        self.set('rerender');
+        self.get('index')._executeQuery(constants.jobReferrer.visualExplain, true, true).then(function (json) {
+          //this condition should be changed once we change the way of retrieving this json
+          if (json['STAGE PLANS']['Stage-1']) {
+            self.set('json', json);
+          } else {
+            self.set('json', {})
+          }
+        }, function (error) {
+          self.set('json', undefined);
+          self.get('notifyService').error(error);
+        });
+        self.toggleProperty('shouldChangeGraph');
+      }
+
+      if(this.get('json') == undefined) {
+        getVisualExplainJson();
+
+      } else if (this.get('shouldChangeGraph')){
+        getVisualExplainJson();
 
-      if (!this.get('shouldChangeGraph') && this.get('json')) {
+      } else {
         this.set('rerender', true);
         return;
       }
 
-      this.set('rerender');
-      this.toggleProperty('shouldChangeGraph');
-
-      this.get('index')._executeQuery(constants.jobReferrer.visualExplain, true, true).then(function (json) {
-        //this condition should be changed once we change the way of retrieving this json
-        if (json['STAGE PLANS']['Stage-1']) {
-          self.set('json', json);
-        } else{
-          self.set('json', {})
-        }
-      }, function (error) {
-        self.set('json', undefined);
-        self.get('notifyService').error(error);
-      });
     }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/e0f02c58/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js
index afd959b..73dbc8c 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/utils/functions.js
@@ -64,5 +64,20 @@ export default Ember.Object.create({
 
   insensitiveContains: function (sourceString, destString) {
     return sourceString.toLowerCase().indexOf(destString.toLowerCase()) > -1;
+  },
+
+  convertToArray : function (inputObj) {
+    var array = [];
+
+    for (var key in inputObj) {
+      if (inputObj.hasOwnProperty(key)) {
+        array.pushObject({
+          name: key,
+          value: inputObj[key]
+        });
+      }
+    }
+    return array;
   }
-});
\ No newline at end of file
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/e0f02c58/contrib/views/hive/src/main/resources/ui/hive-web/app/views/visual-explain.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/visual-explain.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/visual-explain.js
index fb7fda9..838249d 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/views/visual-explain.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/views/visual-explain.js
@@ -20,11 +20,11 @@
 
 import Ember from 'ember';
 import dagRules from '../utils/dag-rules';
+import utils from 'hive/utils/functions';
 
 export default Ember.View.extend({
   verticesGroups: [],
   edges: [],
-  isVisualExplain: false,
 
   willInsertElement: function () {
     this.set('graph', new dagre.graphlib.Graph());
@@ -74,11 +74,7 @@ export default Ember.View.extend({
   }.observes('controller.verticesProgress.@each.value', 'verticesGroups'),
 
   jsonChanged: function () {
-
     var json = this.get('controller.json');
-    if (json && json['STAGE PLANS'] != undefined) {
-      this.isVisualExplain = true;
-    }
     this.renderDag();
   }.observes('controller.json'),
 
@@ -427,31 +423,17 @@ export default Ember.View.extend({
   },
 
   renderDag: function () {
-
-    if(this.isVisualExplain){
-      var convert = function (inputObj) {
-        var array = [];
-
-        for (var key in inputObj) {
-          if (inputObj.hasOwnProperty(key)) {
-            array.pushObject({
-              name: key,
-              value: inputObj[key]
-            });
-          }
-        }
-
-        return array;
-      };
-
+    var json = this.get('controller.json');
+    var isVisualExplain = json && (json['STAGE PLANS'] != undefined);
+    if (isVisualExplain) {
       this.set('edges', []);
 
       // Create a new directed graph
       var g = this.get('graph');
 
-      var graphData = this.get('controller.json')['STAGE PLANS']['Stage-1']['Tez'];
-      var vertices = convert(graphData['Vertices:']);
-      var edges = convert(graphData['Edges:']);
+      var graphData = json['STAGE PLANS']['Stage-1']['Tez'];
+      var vertices = utils.convertToArray(graphData['Vertices:']);
+      var edges = utils.convertToArray(graphData['Edges:']);
 
       // Set an object for the graph label
       g.setGraph({});
@@ -464,9 +446,12 @@ export default Ember.View.extend({
         .setTableNodesAndEdges(vertices)
         .createNodeGroups()
         .renderEdges();
-
     } else {
-      $('#no-visual-explain-graph').html('Visual explain is not available.');
+
+      if(!this.get('controller.noquery')) {
+        $('#no-visual-explain-graph').html('Visual explain is not available.');
+      }
+
     }
 
   }