@@ -407,10 +407,9 @@ public List<ParameterValue> getParametersFromWorkUnit(WorkUnit unit) {
407407 paramsList = ((ParametersAction ) action ).getParameters ();
408408 }
409409 }
410- } else if (unit .context .task instanceof PlaceholderTask ) {
411- PlaceholderTask placeholderTask = (PlaceholderTask ) unit .context .task ;
412- Run <?, ?> run = placeholderTask .run ();
413- if (run != null ) {
410+ } else {
411+ Queue .Executable ownerExecutable = unit .context .task .getOwnerExecutable ();
412+ if (ownerExecutable instanceof Run <?, ?> run ) {
414413 List <ParametersAction > actions = run .getActions (ParametersAction .class );
415414 for (ParametersAction action : actions ) {
416415 paramsList = action .getParameters ();
@@ -435,11 +434,11 @@ public List<ParameterValue> getParametersFromQueueItem(Queue.Item item) {
435434
436435 @ NonNull
437436 private List <String > categoriesForPipeline (Task task ) {
438- if ( task instanceof PlaceholderTask ) {
439- PlaceholderTask placeholderTask = ( PlaceholderTask ) task ;
440- Run <?, ?> r = placeholderTask . run ();
441- if (r != null ) {
442- Map <String , List <String >> categoriesByFlowNode = ThrottleJobProperty .getCategoriesForRunByFlowNode (r );
437+ // TODO avoid casting to PlaceholderTask; could task.node.id be replaced with task.affinityKey?
438+ if ( task instanceof PlaceholderTask placeholderTask ) {
439+ Queue . Executable ownerExecutable = task . getOwnerExecutable ();
440+ if (ownerExecutable instanceof Run <?, ?> run ) {
441+ Map <String , List <String >> categoriesByFlowNode = ThrottleJobProperty .getCategoriesForRunByFlowNode (run );
443442 if (!categoriesByFlowNode .isEmpty ()) {
444443 try (Timeout t = Timeout .limit (100 , TimeUnit .MILLISECONDS )) {
445444 FlowNode firstThrottle = firstThrottleStartNode (placeholderTask .getNode ());
@@ -463,8 +462,7 @@ private List<String> categoriesForPipeline(Task task) {
463462
464463 @ CheckForNull
465464 private ThrottleJobProperty getThrottleJobProperty (Task task ) {
466- if (task instanceof Job ) {
467- Job <?, ?> p = (Job <?, ?>) task ;
465+ if (task instanceof Job <?, ?> p ) {
468466 if (task instanceof MatrixConfiguration ) {
469467 p = ((MatrixConfiguration ) task ).getParent ();
470468 }
@@ -601,10 +599,10 @@ private int pipelinesOnExecutor(@NonNull Run<?, ?> run, @NonNull Executor exec,
601599 final Queue .Executable currentExecutable = exec .getCurrentExecutable ();
602600 if (currentExecutable != null ) {
603601 SubTask parent = currentExecutable .getParent ();
604- if (parent instanceof PlaceholderTask ) {
605- PlaceholderTask task = ( PlaceholderTask ) parent ;
606- if (run .equals (task . run () )) {
607- if (isTaskThrottledPipeline (task , flowNodes )) {
602+ if (parent instanceof Task ) {
603+ Queue . Executable ownerExecutable = parent . getOwnerExecutable () ;
604+ if (ownerExecutable instanceof Run <?, ?> run2 && run .equals (run2 )) {
605+ if (isTaskThrottledPipeline (( Task ) parent , flowNodes )) {
608606 return 1 ;
609607 }
610608 }
@@ -615,8 +613,7 @@ private int pipelinesOnExecutor(@NonNull Run<?, ?> run, @NonNull Executor exec,
615613 }
616614
617615 private boolean isTaskThrottledPipeline (Task origTask , List <FlowNode > flowNodes ) {
618- if (origTask instanceof PlaceholderTask ) {
619- PlaceholderTask task = (PlaceholderTask ) origTask ;
616+ if (origTask instanceof PlaceholderTask task ) { // TODO as in categoriesForPipeline
620617 try {
621618 FlowNode firstThrottle = firstThrottleStartNode (task .getNode ());
622619 return firstThrottle != null && flowNodes .contains (firstThrottle );
0 commit comments