@@ -73,8 +73,7 @@ public class PipelineNodeGraphVisitor extends StandardChunkVisitor {
73
73
74
74
private static final Logger logger = LoggerFactory .getLogger (PipelineNodeGraphVisitor .class );
75
75
76
- private final boolean isNodeVisitorDumpEnabled =
77
- Boolean .getBoolean ("NODE-DUMP-ENABLED" ) && logger .isDebugEnabled ();
76
+ private final boolean isNodeVisitorDumpEnabled = logger .isTraceEnabled ();
78
77
79
78
private final Stack <FlowNode > nestedStages = new Stack <>();
80
79
private final Stack <FlowNode > nestedbranches = new Stack <>();
@@ -146,7 +145,6 @@ public void chunkStart(
146
145
public void chunkEnd (
147
146
@ NonNull FlowNode endNode , @ CheckForNull FlowNode afterBlock , @ NonNull ForkScanner scanner ) {
148
147
super .chunkEnd (endNode , afterBlock , scanner );
149
-
150
148
if (isNodeVisitorDumpEnabled ) {
151
149
dump (
152
150
String .format (
@@ -199,7 +197,6 @@ public void chunkEnd(
199
197
"chunk.getLastNode() is marked non null but is null sometimes, when JENKINS-40200 is fixed we will remove this check " )
200
198
@ Override
201
199
protected void handleChunkDone (@ NonNull MemoryFlowChunk chunk ) {
202
-
203
200
if (isNodeVisitorDumpEnabled ) {
204
201
dump (
205
202
String .format (
@@ -216,14 +213,6 @@ protected void handleChunkDone(@NonNull MemoryFlowChunk chunk) {
216
213
parallelNestedStages = true ;
217
214
}
218
215
219
- if (!nestedStages .empty ()) {
220
- FlowNode discarded = nestedStages .pop (); // we throw away first nested stage
221
- // nested stages not supported in scripted pipeline.
222
- if (!nestedStages .isEmpty () && !isDeclarative ()) {
223
- return ;
224
- }
225
- }
226
-
227
216
TimingInfo times = null ;
228
217
229
218
// TODO: remove chunk.getLastNode() != null check based on how JENKINS-40200 gets resolved
@@ -289,6 +278,17 @@ protected void handleChunkDone(@NonNull MemoryFlowChunk chunk) {
289
278
Iterator <FlowNodeWrapper > branches = parallelBranches .descendingIterator ();
290
279
while (branches .hasNext ()) {
291
280
FlowNodeWrapper p = branches .next ();
281
+ if (isNodeVisitorDumpEnabled ) {
282
+ dump (
283
+ String .format (
284
+ "handleChunkDone=> found node [id: %s, name: %s, function: %s] is child of [id: %s, name: %s, function: %s] - parallelBranches" ,
285
+ p .getId (),
286
+ p .getDisplayName (),
287
+ p .getNode ().getDisplayFunctionName (),
288
+ stage .getId (),
289
+ stage .getDisplayName (),
290
+ stage .getNode ().getDisplayFunctionName ()));
291
+ }
292
292
p .addParent (stage );
293
293
stage .addEdge (p );
294
294
}
@@ -303,16 +303,41 @@ protected void handleChunkDone(@NonNull MemoryFlowChunk chunk) {
303
303
}
304
304
}
305
305
if (nextStage != null && !parallelNestedStages ) {
306
+ if (isNodeVisitorDumpEnabled ) {
307
+ dump (
308
+ String .format (
309
+ "handleChunkDone=> found node [id: %s, name: %s, function: %s] is child of [id: %s, name: %s, function: %s]" ,
310
+ nextStage .getId (),
311
+ nextStage .getDisplayName (),
312
+ nextStage .getNode ().getDisplayFunctionName (),
313
+ stage .getId (),
314
+ stage .getDisplayName (),
315
+ stage .getNode ().getDisplayFunctionName ()));
316
+ }
306
317
nextStage .addParent (stage );
307
318
stage .addEdge (nextStage );
308
319
}
320
+ if (nextStage == null ) {
321
+ if (isNodeVisitorDumpEnabled ) {
322
+ dump (
323
+ String .format (
324
+ "handleChunkDone=> WARNING: nextStage is null! Unable for assign parent stage for stage [id: %s, name: %s, function: %s]" ,
325
+ stage .getId (), stage .getDisplayName (), stage .getNode ().getDisplayFunctionName ()));
326
+ }
327
+ }
309
328
for (FlowNodeWrapper p : parallelBranches ) {
310
329
nodes .remove (p );
311
330
nodeMap .remove (p .getId (), p );
312
331
}
313
332
}
314
333
parallelBranches .clear ();
315
334
if (!parallelNestedStages ) {
335
+ if (isNodeVisitorDumpEnabled ) {
336
+ dump (
337
+ String .format (
338
+ "handleChunkDone=> setting nextStage to: [id: %s, name: %s, function: %s]" ,
339
+ stage .getId (), stage .getDisplayName (), stage .getNode ().getDisplayFunctionName ()));
340
+ }
316
341
this .nextStage = stage ;
317
342
}
318
343
}
@@ -462,6 +487,17 @@ public void parallelStart(
462
487
if (isNodeVisitorDumpEnabled ) {
463
488
dump ("\t \t Nested labelling stage detected" );
464
489
}
490
+ if (isNodeVisitorDumpEnabled ) {
491
+ dump (
492
+ String .format (
493
+ "parallelStart=> found node [id: %s, name: %s, function: %s] is child of [id: %s, name: %s, function: %s] - declarative" ,
494
+ firstNodeWrapper .getId (),
495
+ firstNodeWrapper .getDisplayName (),
496
+ firstNodeWrapper .getNode ().getDisplayFunctionName (),
497
+ branch .getId (),
498
+ branch .getDisplayName (),
499
+ branch .getNode ().getDisplayFunctionName ()));
500
+ }
465
501
branch .addEdge (firstNodeWrapper );
466
502
firstNodeWrapper .addParent (branch );
467
503
nodes .add (firstNodeWrapper );
@@ -473,6 +509,17 @@ public void parallelStart(
473
509
while (!stack .isEmpty ()) {
474
510
// Grab next, link to prev, add to result
475
511
FlowNodeWrapper currentStage = stack .pop ();
512
+ if (isNodeVisitorDumpEnabled ) {
513
+ dump (
514
+ String .format (
515
+ "parallelStart=> found node [id: %s, name: %s, function: %s] is child of [id: %s, name: %s, function: %s]" ,
516
+ currentStage .getId (),
517
+ currentStage .getDisplayName (),
518
+ currentStage .getNode ().getDisplayFunctionName (),
519
+ previousNode .getId (),
520
+ previousNode .getDisplayName (),
521
+ previousNode .getNode ().getDisplayFunctionName ()));
522
+ }
476
523
previousNode .addEdge (currentStage );
477
524
currentStage .addParent (previousNode );
478
525
nodes .add (currentStage );
@@ -629,7 +676,7 @@ public void atomNode(
629
676
}
630
677
631
678
private void dump (String str ) {
632
- logger .info (System .identityHashCode (this ) + ": " + str );
679
+ logger .trace (System .identityHashCode (this ) + ": " + str );
633
680
}
634
681
635
682
/**
@@ -705,6 +752,14 @@ private void captureOrphanParallelBranches() {
705
752
nodes .push (synStage );
706
753
nodeMap .put (synStage .getId (), synStage );
707
754
parallelBranches .clear ();
755
+ if (isNodeVisitorDumpEnabled ) {
756
+ dump (
757
+ String .format (
758
+ "captureOrphanParallelBranches=> setting nextStage to: [id: %s, name: %s, function: %s]" ,
759
+ synStage .getId (),
760
+ synStage .getDisplayName (),
761
+ synStage .getNode ().getDisplayFunctionName ()));
762
+ }
708
763
this .nextStage = synStage ;
709
764
}
710
765
}
@@ -799,6 +854,17 @@ protected String getTypeDisplayName() {
799
854
Iterator <FlowNodeWrapper > sortedBranches = parallelBranches .descendingIterator ();
800
855
while (sortedBranches .hasNext ()) {
801
856
FlowNodeWrapper p = sortedBranches .next ();
857
+ if (isNodeVisitorDumpEnabled ) {
858
+ dump (
859
+ String .format (
860
+ "createParallelSyntheticNode=> found node [id: %s, name: %s, function: %s] is child of [id: %s, name: %s, function: %s]" ,
861
+ p .getId (),
862
+ p .getDisplayName (),
863
+ p .getNode ().getDisplayFunctionName (),
864
+ synStage .getId (),
865
+ synStage .getDisplayName (),
866
+ synStage .getNode ().getDisplayFunctionName ()));
867
+ }
802
868
p .addParent (synStage );
803
869
synStage .addEdge (p );
804
870
}
0 commit comments