You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by gn...@apache.org on 2017/02/10 11:19:13 UTC

ambari git commit: AMBARI-19954.Workflow designer is getting hung while importing the workflow.(Padma Priya N via gauravn7)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 ab8af8c40 -> bde00d939


AMBARI-19954.Workflow designer is getting hung while importing the 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/bde00d93
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bde00d93
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bde00d93

Branch: refs/heads/branch-2.5
Commit: bde00d939b894a38942ded8487a84efaaa6aed94
Parents: ab8af8c
Author: Gaurav Nagar <gr...@gmail.com>
Authored: Fri Feb 10 16:48:56 2017 +0530
Committer: Gaurav Nagar <gr...@gmail.com>
Committed: Fri Feb 10 16:48:56 2017 +0530

----------------------------------------------------------------------
 .../ui/app/components/decision-add-branch.js    |  3 +-
 .../ui/app/components/flow-designer.js          | 25 ++++++-------
 .../ui/app/components/transition-config.js      |  2 +-
 .../ui/app/domain/cytoscape-flow-renderer.js    | 38 ++++++++++++++++++--
 .../app/templates/components/flow-designer.hbs  |  2 +-
 5 files changed, 49 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bde00d93/contrib/views/wfmanager/src/main/resources/ui/app/components/decision-add-branch.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/decision-add-branch.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/decision-add-branch.js
index e4b2224..65d0974 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/decision-add-branch.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/decision-add-branch.js
@@ -54,8 +54,9 @@ export default Ember.Component.extend(Validations, FindNodeMixin,{
         }
         self.set("isInsertAction",false);
         this.set("newNodeType",null);
+        this.get('flowRenderer').populateOkToandErrorTONodes(node);
         var commonTarget=this.findCommonTargetNode(this.workflow.startNode,this.get('node'));
-        var descendantNodes=this.getDesendantNodes(this.get('node'));
+        var descendantNodes= this.get('node.validOkToNodes');
         if (commonTarget){
           descendantNodes.removeObject(commonTarget);
           descendantNodes.unshiftObject(commonTarget);

http://git-wip-us.apache.org/repos/asf/ambari/blob/bde00d93/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 fd7a258..83a1b27 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
@@ -60,7 +60,8 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   previewXml:"",
   supportedActionTypes:["java", "hive", "pig", "sqoop", "shell", "spark", "map-reduce", "hive2", "sub-workflow", "distcp", "ssh", "FS"],
   workflow:null,
-  hoveredWidget:null,/**/
+  flowRenderer:null,
+  hoveredWidget:null,
   showingConfirmationNewWorkflow:false,
   showingWorkflowConfigProps:false,
   workflowSubmitConfigs:{},
@@ -107,16 +108,12 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     var id = 'cy-' + Math.ceil(Math.random() * 1000);
     this.set('cyId', id);
     this.sendAction('register', this.get('tabInfo'), this);
+    this.set('flowRenderer',CytoscapeRenderer.create());
+    this.set('workflow',Workflow.create({}));
     CommonUtils.setTestContext(this);
   }.on('init'),
   elementsInserted :function(){
-    if (this.useCytoscape){
-      this.flowRenderer=CytoscapeRenderer.create({id : this.get('cyId')});
-    }else{
-      this.flowRenderer=JSPlumbRenderer.create({});
-    }
     this.setConentWidth();
-    this.set('workflow',Workflow.create({}));
     if(this.get("xmlAppPath")){
       this.showExistingWorkflow();
       return;
@@ -241,14 +238,13 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   },
   nodeRendered: function(){
     this.doValidation();
-    if(this.get('renderNodeTransitions')){
-      this.flowRenderer.onDidUpdate(this,this.get("workflow").startNode,this.get("workflow"));
-      this.layout();
-      this.set('renderNodeTransitions',false);
-    }
     this.resize();
     this.persistWorkInProgress();
   }.on('didUpdate'),
+  renderTransitions : function(){
+    this.flowRenderer.onDidUpdate(this,this.get("workflow").startNode,this.get("workflow"));
+    this.layout();
+  },
   resize(){
     this.flowRenderer.resize();
   },
@@ -261,12 +257,13 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     var canvasHeight=Ember.$(window).height()-panelOffset.top-25;
     this.flowRenderer.initRenderer(function(){
       this.renderWorkflow();
-    }.bind(this),{context:this,flattenedNodes:this.get("flattenedNodes"),dataNodes:this.get("dataNodes"), cyOverflow:this.get("cyOverflow"),canvasHeight:canvasHeight});
+    }.bind(this),{context:this,id : this.get('cyId'),flattenedNodes:this.get("flattenedNodes"),dataNodes:this.get("dataNodes"), cyOverflow:this.get("cyOverflow"),canvasHeight:canvasHeight});
   },
   renderWorkflow(){
     this.set('renderNodeTransitions', true);
     this.flowRenderer.renderWorkflow(this.get("workflow"));
     this.doValidation();
+    this.renderTransitions();
   },
   rerender(){
     this.flowRenderer.cleanup();
@@ -656,7 +653,6 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   },
   openWorkflowEditor(node){
     this.createSnapshot();
-    var validOkToNodes = WorkflowPathUtil.findValidTransitionsTo(this.get('workflow'), node);
     this.set('showActionEditor', true);
     this.set('currentAction', node.actionType);
     var domain = node.getNodeDetail();
@@ -664,7 +660,6 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     this.set('clonedErrorNode', node.errorNode);
     this.set('clonedKillMessage',node.get('killMessage'));
     node.set("domain", domain);
-    node.set("validOkToNodes", validOkToNodes);
     this.set('currentNode', node);
   },
   openDecisionEditor(node) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/bde00d93/contrib/views/wfmanager/src/main/resources/ui/app/components/transition-config.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/transition-config.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/transition-config.js
index ca45b1f..ce04863 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/transition-config.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/transition-config.js
@@ -28,7 +28,7 @@ const Validations = buildValidations({
 export default Ember.Component.extend(FindNodeMixin, Validations, {
   selectedKillNode : '',
   initialize : function(){
-    this.set('descendantNodes',this.getDesendantNodes(this.get('currentNode')));
+    this.set('descendantNodes', this.get('currentNode.validErrorToNodes'));
     if(!this.get('transition.okToNode')){
       var defaultOkToNode = this.getOKToNode(this.get('currentNode'));
       this.set('transition.okToNode', defaultOkToNode);

http://git-wip-us.apache.org/repos/asf/ambari/blob/bde00d93/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 17fb4a0..8202c6d 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
@@ -30,7 +30,8 @@ var CytoscapeRenderer= Ember.Object.extend({
       container: this.get("context").$('#'+this.id),
       elements: [],
       style: CytoscapeStyles.style,
-      layout: this.get("layoutConfigs")
+      layout: this.get("layoutConfigs"),
+      pixelRatio : 1
     });
 
     // the default values of each option are outlined below:
@@ -98,6 +99,7 @@ var CytoscapeRenderer= Ember.Object.extend({
         data: {
           id: node.id, name: node.name, type: node.type,
           shape: self._getShape(node.type),
+          type : node.type,
           node: node
         },
         dataNodeName: Ember.computed.alias('data.node.name')
@@ -298,15 +300,44 @@ var CytoscapeRenderer= Ember.Object.extend({
 
     this.get("context").$('.overlay-settings-icon i').off('click');
     this.get("context").$('.overlay-settings-icon i').on('click',function(){
-      this.get("context").openWorkflowEditor(this.get("context").$(".overlay-settings-icon").data("node"));
+      let node = this.get("context").$(".overlay-settings-icon").data("node");
+      this.populateOkToandErrorTONodes(node);
+      this.get("context").openWorkflowEditor(node);
       this.get("context").$('.overlay-node-actions').hide();
     }.bind(this));
   },
-
+  populateOkToandErrorTONodes(node){
+    let alternatePathNodes = this.cy.$('#'+node.id).predecessors("node[name][type='decision']").union(this.cy.$('#'+node.id).predecessors("node[name][type='decision']"));
+    let descendantNodes = [];
+    if(alternatePathNodes.length > 0){
+      alternatePathNodes.forEach(childNode =>{
+        let childNodeData = childNode.data();
+        if(childNodeData.type === 'placeholder'){
+          return;
+        }
+        let successors = this.cy.$(`#${childNodeData.id}`).successors("node[name]").difference(this.cy.$('#'+node.id).incomers("node[name]"));
+        descendantNodes.pushObjects(successors.jsons().mapBy('data.node'));
+      });
+    }else{
+      descendantNodes.pushObjects(this.cy.$(`#${node.id}`).successors("node[name]").jsons().mapBy('data.node'));
+    }
+    let okToNodes = [];
+    let errorToNodes = [];
+    okToNodes = descendantNodes.reject((descendantNode)=>{
+      return descendantNode.get('type') === 'placeholder' || descendantNode.get('type') === 'kill' || descendantNode.id === node.id;
+    }, this);
+    errorToNodes = descendantNodes.reject((descendantNode)=>{
+      return descendantNode.get('type') === 'placeholder' || descendantNode.id === node.id;
+    }, this);
+    node.set('validOkToNodes', okToNodes);
+    node.set('validErrorToNodes', errorToNodes);
+  },
   renderWorkflow(workflow){
     this._getCyDataNodes(workflow);
+    this.cy.startBatch();
     this.cy.$('node').remove();
     this.cy.add(this.get('dataNodes'));
+    this.cy.endBatch();
     this.cy.layout(this.get("layoutConfigs"));
     this._setCyOverflow();
   },
@@ -315,6 +346,7 @@ var CytoscapeRenderer= Ember.Object.extend({
     this.context=settings.context;
     this.dataNodes=settings.dataNodes;
     this.cyOverflow=settings.cyOverflow;
+    this.id=settings.id;
     this._initCY(settings);
     callback();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/bde00d93/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 b9ecb11..00e8b76 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
@@ -260,7 +260,7 @@
               <i class="fa fa-cloud-upload"></i>
             </span>
           </div>
-          {{decision-add-branch node=node registerAddBranchAction="registerAddBranchAction" addDecisionBranch="addDecisionBranch" workflow=workflow}}
+          {{decision-add-branch node=node registerAddBranchAction="registerAddBranchAction" addDecisionBranch="addDecisionBranch" workflow=workflow flowRenderer=flowRenderer}}
         </div>
           {{#if cyOverflow.overflown}}
             <div class="cyScrollMsg"><i class="fa fa-ellipsis-h cyScrollMsgContent" title="Use the pan tool or drag on canvas to see more" aria-hidden="true"></i></div>