Repository: ambari Updated Branches: refs/heads/trunk de6d54c90 -> 74b18023c
AMBARI-20294. Simple queries show "no tez plan found" (pallavkul) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/74b18023 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/74b18023 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/74b18023 Branch: refs/heads/trunk Commit: 74b18023c900507898155f776795c07fca43e838 Parents: de6d54c Author: pallavkul <[email protected]> Authored: Sat Mar 4 14:50:21 2017 +0530 Committer: pallavkul <[email protected]> Committed: Sat Mar 4 14:50:21 2017 +0530 ---------------------------------------------------------------------- .../ui/app/components/visual-explain.js | 11 +-- .../resources/ui/app/routes/queries/query.js | 1 + .../ui/app/utils/hive-explainer/fallback.js | 3 +- .../ui/app/utils/hive-explainer/index.js | 5 +- .../ui/app/utils/hive-explainer/processor.js | 1 - .../ui/app/utils/hive-explainer/renderer.js | 18 ++++- .../ui/app/utils/hive-explainer/transformer.js | 75 ++++++++++++++------ 7 files changed, 80 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/components/visual-explain.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/visual-explain.js b/contrib/views/hive20/src/main/resources/ui/app/components/visual-explain.js index fc7cf64..8f216d1 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/components/visual-explain.js +++ b/contrib/views/hive20/src/main/resources/ui/app/components/visual-explain.js @@ -29,6 +29,8 @@ export default Ember.Component.extend({ explainDetailData: '', + draggable: Ember.Object.create(), + visualExplainInput: Ember.computed('visualExplainJson', function () { return this.get('visualExplainJson'); }), @@ -37,24 +39,25 @@ export default Ember.Component.extend({ didInsertElement() { this._super(...arguments); - const onRequestDetail = data => this.set('explainDetailData', JSON.stringify( data, null, ' ') ); const explainData = JSON.parse(this.get('visualExplainInput')); // if(explainData) { - explain(explainData, '#explain-container', onRequestDetail); + explain(explainData, '#explain-container', onRequestDetail, this.get('draggable')); // } }, click(event){ - - if(this.get('explainDetailData') === ''){ + if(this.get('explainDetailData') === '' || this.get('draggable').get('zoom') ){ return; } Ember.run.later(() => { this.set('showDetailsModal', true); }, 100); + this.get('draggable').set('zoom', false); + this.get('draggable').set('dragstart', false); + this.get('draggable').set('dragend', false); }, actions:{ http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/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 d08a47b..062f93a 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 @@ -406,6 +406,7 @@ export default Ember.Route.extend(UILoggerMixin, { showVisualExplain(payloadTitle){ if( this.paramsFor('queries.query').worksheetId && this.paramsFor('queries.query').worksheetId.toLowerCase() === payloadTitle){ + this.transitionTo('queries.query.loading'); Ember.run.later(() => { this.transitionTo('queries.query.visual-explain'); }, 1); http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/fallback.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/fallback.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/fallback.js index 2310b3c..12331d7 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/fallback.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/fallback.js @@ -18,9 +18,8 @@ export function isExplainable(data) { const stages = data['STAGE PLANS']; - const isValidTezStageAvailable = Object.keys(stages).some(cStageKey => stages[cStageKey].hasOwnProperty('Tez')); const isValidFetchStageAvailable = Object.keys(stages).find(cStageKey => stages[cStageKey].hasOwnProperty('Fetch Operator')); - return isValidTezStageAvailable && isValidFetchStageAvailable; + return isValidFetchStageAvailable; } export function doRenderError(selector) { http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/index.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/index.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/index.js index 3513a23..9a8ff4e 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/index.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/index.js @@ -21,10 +21,11 @@ import doRender from './renderer'; import {isExplainable, doRenderError} from './fallback'; -export default function draw(data, selector, onRequestDetail){ +export default function draw(data, selector, onRequestDetail, drag){ + if(isExplainable(data)) { const transformed = doTransform(data); - doRender(transformed, selector, onRequestDetail); + doRender(transformed, selector, onRequestDetail, drag); } else { doRenderError(selector); } http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js index 48706cb..f6d3704 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js @@ -287,7 +287,6 @@ export function getAdjustedVerticesAndEdges(vertices, edges) { // cleanup const adjustedVertices = vertices.filter(cVertex => cVertex._children.length > 0); const cleanedVertices = vertices.filter(cVertex => cVertex._children.length === 0); - console.log(cleanedVertices); const adjustedEdges = edges http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js index f69b1d4..1f6ba3c 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js @@ -16,11 +16,12 @@ * limitations under the License. */ -export default function doRender(data, selector, onRequestDetail) { +export default function doRender(data, selector, onRequestDetail, draggable) { - const width = '1600', height = '800'; + const width = '1570', height = '800'; d3.select(selector).select('*').remove(); + const svg = d3.select(selector) .append('svg') @@ -34,10 +35,21 @@ export default function doRender(data, selector, onRequestDetail) { .scaleExtent([1 / 10, 1]) .on('zoom', () => { container.attr('transform', `translate(${d3.event.translate}) scale(${d3.event.scale})`); + draggable.set('zoom' , true); }); + const drag = d3.behavior.drag() + .on("dragstart", () => { + draggable.set('dragstart', true); + draggable.set('zoom',false); + }) + .on("dragend", () => { + draggable.set('dragend', true); + }); + svg - .call(zoom); + .call(zoom) + .call(drag); const root = container http://git-wip-us.apache.org/repos/asf/ambari/blob/74b18023/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js index e6cf3f3..4a7df10 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js @@ -20,17 +20,20 @@ import doEnhance from './enhancer'; import {getProcessedVertices, getEdgesWithCorrectedUnion, getAdjustedVerticesAndEdges} from './processor'; export default function doTransform(data) { - const plan = getTezPlan(data); + const tez = getTezPlan(data); const fetch = getFetchPlan(data); let vertices = [ - ...getVertices(plan), - getFetchVertex(fetch) + ...(tez ? getTezVertices(tez) : []), + getFetchVertex(fetch), ]; - let edges = getEdges(plan, vertices); - edges = getEdgesWithCorrectedUnion(edges); - edges = getEdgesWithFetch(edges, vertices); + let edges = []; + if(tez) { + edges = getEdges(tez, vertices); + edges = getEdgesWithCorrectedUnion(edges); + edges = getEdgesWithFetch(edges, vertices); + } vertices = doEnhance(vertices); @@ -42,7 +45,9 @@ export default function doTransform(data) { vertices = getVerticesWithIndexOfChildren(vertices); - let tree = getVertexTree(edges); + let tree = (edges.length > 0) ? getVertexTree(edges) : Object.assign({}, vertices[0], { + _vertices: [] + }); const connections = getConnections(vertices, edges); tree = getTreeWithOffsetAndHeight(tree, vertices, connections); @@ -87,25 +92,13 @@ function doGetChildrenWithIndexY(children, cIndex) { function getTezPlan(data) { const stages = data['STAGE PLANS']; const tezStageKey = Object.keys(stages).find(cStageKey => stages[cStageKey].hasOwnProperty('Tez')); - return stages[tezStageKey]['Tez']; + return stages[tezStageKey] && stages[tezStageKey]['Tez']; } function getFetchPlan(data) { const stages = data['STAGE PLANS']; const fetchStageKey = Object.keys(stages).find(cStageKey => stages[cStageKey].hasOwnProperty('Fetch Operator')); - return stages[fetchStageKey]['Fetch Operator']; -} - -function getFetchVertex(plan) { - return ({ - _vertex: 'Fetch', - _children: [ - Object.assign({}, plan, { - _operator: 'Fetch Operator', - _children: [] - }) - ] - }); + return stages[fetchStageKey] && stages[fetchStageKey]['Fetch Operator']; } function getVertexTree(edges) { @@ -155,7 +148,45 @@ function getEdgesWithFetch(tezEdges, vertices) { ]); } -function getVertices(plan) { +function getFetchVertex(plan) { + + let children = []; + if(plan.hasOwnProperty('Processor Tree:')) { + const cVertex = plan['Processor Tree:']; + + let root = [{['Processor Tree:']: {}}]; + //if(cTreeKey) { + // children available + root = cVertex; + //} + children = doHarmonize(root); + } + + const vertex = { + _vertex: 'Fetch', + _children: children + }; + + const lastOperator = getLastOperatorOf(vertex); + if(lastOperator._operator === 'ListSink') { + Object.assign(lastOperator, { + _operator: 'Fetch Operator', + _children: [] + }); + } else { + // append children to last vertex + lastOperator._children = [ + Object.assign({}, plan, { + _operator: 'Fetch Operator', + _children: [] + }) + ] + } + + return vertex; +} + +function getTezVertices(plan) { const VERTEX_TREE_KEYS = ['Reduce Operator Tree:', 'Map Operator Tree:']; const vertexObj = plan['Vertices:'];
