You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by pa...@apache.org on 2017/02/22 11:40:52 UTC
ambari git commit: AMBARI-19989. Allow user to view Tez View after
executing query (Venkata Sairam via pallavkul)
Repository: ambari
Updated Branches:
refs/heads/trunk efbd66b56 -> f080bd6cb
AMBARI-19989. Allow user to view Tez View after executing query (Venkata Sairam via pallavkul)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f080bd6c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f080bd6c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f080bd6c
Branch: refs/heads/trunk
Commit: f080bd6cb25d33a76265ee7d21c6e98788ef7423
Parents: efbd66b
Author: pallavkul <pa...@gmail.com>
Authored: Wed Feb 22 17:10:07 2017 +0530
Committer: pallavkul <pa...@gmail.com>
Committed: Wed Feb 22 17:10:07 2017 +0530
----------------------------------------------------------------------
.../main/resources/ui/app/models/worksheet.js | 3 +-
.../resources/ui/app/routes/queries/query.js | 20 ++++-
.../resources/ui/app/services/tez-view-info.js | 83 ++++++++++++++++++++
.../src/main/resources/ui/app/styles/app.scss | 5 ++
.../ui/app/templates/queries/query.hbs | 1 -
.../ui/app/templates/queries/query/tez-ui.hbs | 6 +-
6 files changed, 111 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/models/worksheet.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/models/worksheet.js b/contrib/views/hive20/src/main/resources/ui/app/models/worksheet.js
index 4b3e1f9..f820ea0 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/models/worksheet.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/models/worksheet.js
@@ -40,5 +40,6 @@ export default DS.Model.extend({
isQueryRunning: DS.attr('boolean', {defaultValue: false}),
isQueryResultContainer: DS.attr('boolean', {defaultValue: false}),
visualExplainJson: DS.attr({defaultValue: null}),
- lastResultRoute: DS.attr({defaultValue: ""})
+ lastResultRoute: DS.attr({defaultValue: ""}),
+ tezUrl: DS.attr('string', {defaultValue: null})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
index c549d7b..7860af1 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
@@ -27,6 +27,7 @@ export default Ember.Route.extend(UILoggerMixin, {
isQueryEdidorPaneExpanded: false,
isQueryResultPanelExpanded: false,
globalSettings: '',
+ tezViewInfo: Ember.inject.service(),
beforeModel(params){
console.log('worksheetId', params.params['queries.query'].worksheetId);
@@ -74,7 +75,6 @@ export default Ember.Route.extend(UILoggerMixin, {
} else {
this.transitionTo('queries.query' + lastResultRoute);
}
-
},
model(params) {
@@ -91,6 +91,7 @@ export default Ember.Route.extend(UILoggerMixin, {
setupController(controller, model) {
this._super(...arguments);
+ this.get("tezViewInfo").getTezViewInfo();
let self = this;
let alldatabases = this.store.findAll('database');
@@ -212,6 +213,11 @@ export default Ember.Route.extend(UILoggerMixin, {
}
let originalQuery = this.get('controller').get('currentQuery');
+ if(Ember.isBlank(originalQuery)) {
+ this.get('logger').danger('Query cannot be empty.');
+ this.send('resetDefaultWorksheet');
+ return;
+ }
let queryInput = originalQuery;
if (isVisualExplainQuery) {
@@ -235,6 +241,7 @@ export default Ember.Route.extend(UILoggerMixin, {
this.get('controller.model').set('query', originalQuery);
+
let dbid = this.get('controller.model').get('selectedDb');
let worksheetTitle = this.get('controller.model').get('title');
@@ -272,8 +279,11 @@ export default Ember.Route.extend(UILoggerMixin, {
self.get('jobs').waitForJobToComplete(data.job.id, 2 * 1000, false)
.then((status) => {
self.get('controller').set('isJobSuccess', true);
- self.send('getJobResult', data, payload.title);
+ let jobDetails = self.store.peekRecord('job', data.job.id);
+ console.log(jobDetails);
+ self.send('getJobResult', data, payload.title, jobDetails);
self.transitionTo('queries.query.loading');
+
}, (error) => {
console.log('error', error);
self.get('logger').danger('Failed to execute query.', self.extractError(error));
@@ -287,7 +297,7 @@ export default Ember.Route.extend(UILoggerMixin, {
});
},
- getJobResult(data, payloadTitle){
+ getJobResult(data, payloadTitle, jobDetails){
let self = this;
let isVisualExplainQuery = this.get('controller').get('isVisualExplainQuery');
@@ -305,7 +315,9 @@ export default Ember.Route.extend(UILoggerMixin, {
if(existingWorksheets.get('length') > 0) {
myWs = existingWorksheets.filterBy('title', payloadTitle).get('firstObject');
}
-
+ if(!Ember.isBlank(jobDetails.get("dagId"))) {
+ self.get('controller.model').set('tezUrl', self.get("tezViewInfo").getTezViewURL() + jobDetails.get("dagId"));
+ }
myWs.set('queryResult', data);
myWs.set('isQueryRunning', false);
myWs.set('hasNext', data.hasNext);
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/services/tez-view-info.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/tez-view-info.js b/contrib/views/hive20/src/main/resources/ui/app/services/tez-view-info.js
new file mode 100644
index 0000000..943d002
--- /dev/null
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/tez-view-info.js
@@ -0,0 +1,83 @@
+/**
+ * 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.
+ */
+
+import Ember from 'ember';
+
+export default Ember.Service.extend({
+ tezViewURL: null,
+ tezApiURL: '/api/v1/views/TEZ',
+ tezURLPrefix: '/views/TEZ',
+ tezDagPath: '?viewPath=/#/dag/',
+ getTezViewInfo: function () {
+ if (this.get('isTezViewAvailable')) {
+ return;
+ }
+
+ var self = this;
+ Ember.$.getJSON(this.get('tezApiURL'))
+ .then(function (response) {
+ self.getTezViewInstance(response);
+ })
+ .fail(function (response) {
+ self.setTezViewError(response);
+ });
+ },
+
+ getTezViewInstance: function (data) {
+ var self = this;
+ var url = this.get('tezApiURL') + '/versions/' + data.versions[0].ViewVersionInfo.version;
+
+ Ember.$.getJSON(url)
+ .then(function (response) {
+ if (!response.instances.length) {
+ self.setTezViewError(response);
+ return;
+ }
+
+ self.set('isTezViewAvailable', true);
+
+ var instance = response.instances[0].ViewInstanceInfo;
+ self.setTezViewURL(instance);
+ });
+ },
+
+ setTezViewURL: function (instance) {
+ var url = "%@/%@/%@/".fmt(
+ this.get('tezURLPrefix'),
+ instance.version,
+ instance.instance_name
+ );
+ this.set('tezViewURL', url);
+ },
+ setTezViewError: function (data) {
+ // status: 404 => Tev View isn't deployed
+ if (data.status && data.status === 404) {
+ this.set('error', 'tez.errors.not.deployed');
+ return;
+ }
+
+ // no instance created
+ if (data.instances && !data.instances.length) {
+ this.set('error', 'tez.errors.no.instance');
+ return;
+ }
+ },
+ getTezViewURL(){
+ return this.get('tezViewURL') + this.get("tezDagPath");
+ }
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/styles/app.scss
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/styles/app.scss b/contrib/views/hive20/src/main/resources/ui/app/styles/app.scss
index 5371aa3..2824dc6 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/styles/app.scss
+++ b/contrib/views/hive20/src/main/resources/ui/app/styles/app.scss
@@ -943,3 +943,8 @@ rect.operator__box {
min-height: 100px;
font-size: 16px;
}
+
+.tez-ui {
+ width:100%;
+ height:600px;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
index bf485ca..4fd3ce201 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs
@@ -131,4 +131,3 @@
{{/modal-dialog}}
{{/if}}
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/f080bd6c/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/tez-ui.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/tez-ui.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/tez-ui.hbs
index 9dfa3fa..9bf2b2a 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/tez-ui.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/tez-ui.hbs
@@ -16,4 +16,8 @@
* limitations under the License.
}}
-<div>I am in tez-ui route.</div>
\ No newline at end of file
+{{#if model.tezUrl}}
+<iframe class="tez-ui" src={{model.tezUrl}}></iframe>
+{{else}}
+<div>Tez UI not available.</div>
+{{/if}}