AMBARI-20342. WFM:Performance improvement for adding node on a decision node in large workflow.(Padma Priya N via gauravn7)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3fd1c244 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3fd1c244 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3fd1c244 Branch: refs/heads/branch-dev-logsearch Commit: 3fd1c24442f4c90becff35c004290e829f136318 Parents: 267c98f Author: Gaurav Nagar <grv...@gmail.com> Authored: Wed Mar 8 16:57:21 2017 +0530 Committer: Gaurav Nagar <grv...@gmail.com> Committed: Wed Mar 8 16:57:21 2017 +0530 ---------------------------------------------------------------------- .../ui/app/components/flow-designer.js | 73 ++++++++++++-------- .../ui/app/domain/cytoscape-flow-renderer.js | 8 ++- .../src/main/resources/ui/app/styles/app.less | 4 ++ .../app/templates/components/flow-designer.hbs | 5 ++ 4 files changed, 59 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd1c244/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js index 01f8fe6..37992be 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js @@ -275,15 +275,23 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { this.doValidation(); this.renderTransitions(); }, - rerender(){ - this.flowRenderer.cleanup(); - this.renderWorkflow(this.get("workflow")); + rerender(callback){ + this.set('showStatus', true); + Ember.run.later(() => { + this.flowRenderer.cleanup(); + this.renderWorkflow(this.get("workflow")); + this.set('showStatus', false); + if(callback){ + callback(); + } + }.bind(this)); }, setCurrentTransition(transitionInfo){ this.set("currentTransition", { transition : transitionInfo.transition, source : transitionInfo.source, - target : transitionInfo.target + target : transitionInfo.target, + originalSource : transitionInfo.originalSource }); }, actionInfo(node){ @@ -292,8 +300,9 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { deleteTransition(transition,sourceNode){ this.createSnapshot(); this.get("workflow").deleteTransition(transition); - this.showUndo('transition'); - this.rerender(); + this.rerender(function(){ + this.showUndo('transition'); + }.bind(this)); }, showWorkflowActionSelect(element){ var self=this; @@ -422,12 +431,9 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { var x2js = new X2JS(); var actionNodeXml = x2js.xml_str2json(actionNodeXmlString); var actionNodeType = Object.keys(actionNodeXml)[0]; - var currentTransition = this.get("currentTransition.transition"); this.createSnapshot(); - var transition = this.get("currentTransition").source.transitions.findBy('targetNode.id',currentTransition.targetNode.id); - transition.source=this.get("currentTransition").source; this.generateUniqueNodeId(actionNodeType); - var actionNode = this.get("workflow").addNode(transition,actionNodeType, {}, ""); + var actionNode = this.get("workflow").addNode(this.getTransitionInfo(),actionNodeType, {}, ""); this.rerender(); this.doValidation(); this.scrollToNewPosition(); @@ -635,9 +641,10 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { } else { this.get("workflow").deleteNode(node,transitionslist); } - this.rerender(); - this.doValidation(); - this.showUndo('nodeDeleted'); + this.rerender(function(){ + this.doValidation(); + this.showUndo('nodeDeleted'); + }.bind(this)); }, addWorkflowBranch(node){ this.createSnapshot(); @@ -749,6 +756,18 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { return 1; } }, + getTransitionInfo(){ + var currentTransition=this.get("currentTransition.transition"); + var transition = {}; + if(this.get("currentTransition").source.type === 'placeholder'){ + transition = this.get("currentTransition").originalSource.transitions.findBy('targetNode.id',this.get("currentTransition").source.id); + transition.source=this.get("currentTransition").originalSource; + }else{ + transition = this.get("currentTransition").source.transitions.findBy('targetNode.id',currentTransition.targetNode.id); + transition.source=this.get("currentTransition").source; + } + return transition; + }, actions:{ importWorkflowStream(dataStr){ this.importWorkflowFromFile(dataStr); @@ -838,24 +857,18 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { } this.get("workflow").createKillNode(this.get('killNode.name'),this.get('killNode.killMessage')); this.set('killNode',{}); - this.rerender(); - this.layout(); - this.doValidation(); this.$("#kill-node-dialog").modal("hide"); this.set('showCreateKillNode', false); }, addAction(type){ this.createSnapshot(); - var currentTransition=this.get("currentTransition.transition"); - var transition = this.get("currentTransition").source.transitions.findBy('targetNode.id',currentTransition.targetNode.id); - transition.source=this.get("currentTransition").source; - let temp = this.generateUniqueNodeId(type); - this.get("workflow").addNode(transition, type, {}, temp); - this.rerender(); - this.doValidation(); - this.scrollToNewPosition(); - this.showUndo('nodeAdded'); + this.get("workflow").addNode(this.getTransitionInfo(), type, {}, temp); + this.rerender(function(){ + this.doValidation(); + this.scrollToNewPosition(); + this.showUndo('nodeAdded'); + }.bind(this)); }, nameChanged(){ this.doValidation(); @@ -865,8 +878,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { }, pasteNode(){ var clipboardContent = this.get('clipboardService').getContent(); - var currentTransition = this.get("currentTransition.transition"); - var node = this.get("workflow").addNode(currentTransition, clipboardContent.actionType); + var node = this.get("workflow").addNode(this.getTransitionInfo(), clipboardContent.actionType); if(clipboardContent.operation === 'cut'){ node.name = clipboardContent.name; }else{ @@ -874,9 +886,10 @@ export default Ember.Component.extend(FindNodeMixin, Validations, { } node.domain = clipboardContent.domain; node.actionType = clipboardContent.actionType; - this.rerender(); - this.doValidation(); - this.scrollToNewPosition(); + this.rerender(function () { + this.doValidation(); + this.scrollToNewPosition(); + }.bind(this)); }, deleteNode(node){ this.deleteWorkflowNode(node); http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd1c244/contrib/views/wfmanager/src/main/resources/ui/app/domain/cytoscape-flow-renderer.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/cytoscape-flow-renderer.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/cytoscape-flow-renderer.js index f8796ae..bfe59e2 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/cytoscape-flow-renderer.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/cytoscape-flow-renderer.js @@ -250,7 +250,12 @@ var CytoscapeRenderer= Ember.Object.extend({ }else{ this.get("context").$(".overlay-trash-transition-icon").hide(); } - this.get("context").$(".overlay-transition-content").data("sourceNode",event.cyTarget.source().data("node")); + let srcNode = event.cyTarget.source().data("node"); + if(srcNode.type === 'placeholder'){ + let originalSource = event.cyTarget.source().incomers("node").jsons()[0].data.node; + this.get("context").$(".overlay-transition-content").data("originalSource", originalSource); + } + this.get("context").$(".overlay-transition-content").data("sourceNode", srcNode); this.get("context").$(".overlay-transition-content").data("targetNode",event.cyTarget.target().data("node")); this.get("context").$(".overlay-transition-content").data("transition",event.cyTarget.data().transition); @@ -271,6 +276,7 @@ var CytoscapeRenderer= Ember.Object.extend({ this.get("context").setCurrentTransition({ transition : this.get("context").$(".overlay-transition-content").data("transition"), source : this.get("context").$(".overlay-transition-content").data("sourceNode"), + originalSource : this.get("context").$(".overlay-transition-content").data("originalSource"), target : this.get("context").$(".overlay-transition-content").data("targetNode") }); Ember.run.later(this, function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd1c244/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less b/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less index a424049..a30833c 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less +++ b/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less @@ -1756,3 +1756,7 @@ input:invalid { pre { background-color : white; } + +.processing-message { + padding-left: 48%; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd1c244/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs index f4d3876..0da9f71 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs @@ -150,6 +150,11 @@ {{/if}} </div> {{/if}} + {{#if showStatus}} + <div id="status-message" class="processing-message"> + <span class="label label-info">Processing...</span> + </div> + {{/if}} {{#if isWorkflowImporting}} <div id="loader"> <div id="alert"class="alert alert-info alert-dismissible workflow-error" role="alert">