Execute a workflow section that should be dispatched across nodes

@return true if the section was succesful
973516
private WorkflowStatusDataResult executeWFSectionNodeDispatch(
            StepExecutionContext executionContext,
            int stepCount,
            List<StepExecutionResult> results,
            Map<String, Collection<StepExecutionResult>> failures,
            final Map<Integer, StepExecutionResult> stepFailures,
            IWorkflow flowsection,
            WFSharedContext sharedContext
    )
            throws ExecutionServiceException, DispatcherException
    {
        logger.debug("Node dispatch for " + flowsection.getCommands().size() + " steps");
        final DispatcherResult dispatch;
        final WorkflowExecutionItem innerLoopItem = createInnerLoopItem(flowsection);

        final Dispatchable dispatchedWorkflow = new DispatchedWorkflow(
                getFramework().getWorkflowExecutionService(),
                innerLoopItem,
                stepCount,
                executionContext.getStepContext()
        );

        WFSharedContext dispatchSharedContext = new WFSharedContext(sharedContext);
        //dispatch the sequence of dispatched items to each node
        dispatch = getFramework().getExecutionService().dispatchToNodes(
                ExecutionContextImpl.builder(executionContext)
                                    .sharedDataContext(dispatchSharedContext)
                                    .stepNumber(stepCount)
                                    .build(),
                dispatchedWorkflow
        );

        logger.debug("Node dispatch result: " + dispatch);
        WFSharedContext resultData = extractWFDispatcherResult(
                dispatch,
                results,
                failures,
                stepFailures,
                flowsection.getCommands().size(),
                stepCount
        );
        return workflowResult(dispatch.isSuccess(), null, ControlBehavior.Continue, resultData);
    }
446259
public boolean handleNextTask() {
		Runnable task = this.getNextTask();

		if (task != null) {
			synchronized (this.tasksReachesZero) {
				this.runningTasks++;
			}
			try {
				task.run();
			} catch (Throwable t) {
				t.printStackTrace();
			}

			synchronized (this.tasksReachesZero) {
				this.runningTasks--;
				if (this.runningTasks == 0) {
					this.tasksReachesZero.notifyAll();
				}
			}

			synchronized (task) {
				task.notifyAll();
			}
			return true;
		}
		return false;
	}
723853
@SuppressWarnings("unchecked")
    public boolean execute(Runnable r) {
    	
    	try {
			queue[queue_no++ % nThreads].putFirst(r);
			if (queue_no == nThreads){
				queue_no = 0;
			}
            return true;
		} catch (InterruptedException e) {
            String info = "Failed to enqueue task: ";
            Throwable baseCause = org.gautelis.vopn.lang.Stacktrace.getBaseCause(e);
            info += baseCause.getMessage();
            log.warn(info, e);
		}
        return false;
    }
1063728
@Override
    public void onCompleted(WorkflowRun workflowRun, @Nonnull TaskListener listener) {
        super.onCompleted(workflowRun, listener);

        // Note: run.duration is zero in onCompleted(), do the substraction in this listener
        Result result = workflowRun.getResult();
        if (result == null) {
            result = Result.SUCCESS; // FIXME more elegant handling
        }
        globalPipelineMavenConfig.getDao().updateBuildOnCompletion(
                workflowRun.getParent().getFullName(),
                workflowRun.getNumber(),
                result.ordinal,
                workflowRun.getStartTimeInMillis(),
                 Math.max(System.currentTimeMillis() - workflowRun.getStartTimeInMillis(), 0)); // @see HUDSON-5844
    }
788087
protected boolean handlePausedFlow(Execution execution) throws InterruptedException {
        String branchId = execution.getSystemContext().getBranchId();
        PauseReason reason = findPauseReason(execution.getExecutionId(), branchId);
        if (reason != null) { // need to pause the execution
            pauseFlow(reason, execution);
            return true;
        }
        return false;
    }
705974
@SuppressWarnings("unchecked")
    @Override
    public Boolean execute() {
        api.unsubscribeRoomGroup(CommandUtil.getSfsUser(user, api), groupId);
        return Boolean.TRUE;
    }
27552
public void execute() {
		Map<Partition, List<Node>> map = getNodesByPartition();
		for (Partition partition : map.keySet()) {
			List<Node> nodes = map.get(partition);
			partition.execute(nodes);
		}
	}
572955
public boolean hasQueuedSubmissions() {
        WorkQueue[] ws; WorkQueue w;
        if ((ws = workQueues) != null) {
            for (int i = 0; i < ws.length; i += 2) {
                if ((w = ws[i]) != null && !w.isEmpty())
                    return true;
            }
        }
        return false;
    }
546231
public boolean isExact(Group group) {
    if (isAnyAgent() && group.isAnyAgent()) return true;
    if ((isAnyAgent() && !group.isAnyAgent() || (!isAnyAgent() && group.isAnyAgent()))) return false;

    return group.userAgents.stream().anyMatch(sectionUserAgent->userAgents.stream().anyMatch(userAgent->userAgent.equalsIgnoreCase(sectionUserAgent)));
  }
865479
@Override
	public void execute() {
		if (target instanceof WComponentGroup<?>) {
			for (WComponent component : ((WComponentGroup<WComponent>) target).getComponents()) {
				if (component instanceof SubordinateTarget) {
					applyAction((SubordinateTarget) component, value);
				}
			}
		} else {
			// Leaf.
			applyAction(target, value);
		}

	}
1141898
public boolean canRun() {
    Status status = getStatus();
    return Status.STATUS_READY.equals(status) || Status.STATUS_COMPLETE.equals(status);
  }
1219275
public void execute(final T runnable) {
        synchronized (queue) {
            if (runnable != null && !disabled) {
                queue.addLast(runnable);
                queue.notify();
                System.out.println("WorkQueue has added runable - WorkQueue size is " + queue.size());
            }
        }
    }
1045641
def workflow_incomplete(self):
        

        try:
            for pipe in self._workflow:
                with pipe.lock:
                    if pipe.completed:
                        pass
                    else:
                        return True
            return False

        except Exception, ex:
            self._logger.exception(
                'Could not check if workflow is incomplete, error:%s' % ex)
            raise
865026
public function execute()
    {
        $buildPath = $this->phpci->buildPath;

        // Check if there are any actions to be run for the branch we're running on:
        if (!array_key_exists($this->build->getBranch(), $this->actions)) {
            return true;
        }

        // If there are, run them:
        $curdir = getcwd();
        chdir($buildPath);

        $success = true;
        foreach ($this->actions[$this->build->getBranch()] as $action => $options) {
            if (!$this->runAction($action, $options)) {
                $success = false;
                break;
            }
        }

        chdir($curdir);

        return $success;
    }
846599
@Override
  public TaskResult run() {
    log.info("Running planning job {} [{} {}]", this.planningJobId, this.applicationName, this.instanceName);
    this.jobTaskMetrics.updateTimeBetweenJobSubmissionAndExecution(this.jobPlusSysConfig);

    try (Closer closer = Closer.create()) {
      Optional<String> planningIdFromStateStore = this.jobsMapping.getPlanningJobId(jobName);

      long timeOut = PropertiesUtils.getPropAsLong(jobPlusSysConfig,
                                         GobblinClusterConfigurationKeys.HELIX_WORKFLOW_DELETE_TIMEOUT_SECONDS,
                                         GobblinClusterConfigurationKeys.DEFAULT_HELIX_WORKFLOW_DELETE_TIMEOUT_SECONDS) * 1000;

      if (planningIdFromStateStore.isPresent() && !planningIdFromStateStore.get().equals(this.planningJobId)) {
        return new TaskResult(TaskResult.Status.FAILED, "Exception occurred for job " + planningJobId
            + ": because planning job in state store has different id (" + planningIdFromStateStore.get() + ")");
      }

      while (true) {
        Optional<String> actualJobIdFromStateStore = this.jobsMapping.getActualJobId(jobName);
        if (actualJobIdFromStateStore.isPresent()) {
          String previousActualJobId = actualJobIdFromStateStore.get();
          if (HelixUtils.isJobFinished(previousActualJobId, previousActualJobId, this.jobHelixManager)) {
            log.info("Previous actual job {} [plan: {}] finished, will launch a new job.", previousActualJobId, this.planningJobId);
          } else {
            log.info("Previous actual job {} [plan: {}] not finished, kill it now.", previousActualJobId, this.planningJobId);
            try {
              HelixUtils.deleteWorkflow(previousActualJobId, this.jobHelixManager, timeOut);
            } catch (HelixException e) {
              log.error("Helix cannot delete previous actual job id {} within {} seconds.", previousActualJobId, timeOut / 1000);
              return new TaskResult(TaskResult.Status.FAILED, ExceptionUtils.getFullStackTrace(e));
            }
          }
        } else {
          log.info("No previous actual job [plan: {}]. First time run.", this.planningJobId);
        }

        String actualJobId = HelixJobsMapping.createActualJobId(jobPlusSysConfig);
        log.info("Planning job {} creates actual job {}", this.planningJobId, actualJobId);

        this.jobPlusSysConfig.setProperty(ConfigurationKeys.JOB_ID_KEY, actualJobId);

        this.launcher = createJobLauncher();

        this.jobsMapping.setActualJobId(jobName, this.planningJobId, this.launcher.getJobId());

        closer.register(launcher).launchJob(this.jobLauncherListener);

        if (!this.launcher.isEarlyStopped()) {
          break;
        } else {
          log.info("Planning job {} has more runs due to early stop.", this.planningJobId);
        }
      }
      log.info("Completing planning job {}", this.planningJobId);
      return new TaskResult(TaskResult.Status.COMPLETED, "");
    } catch (Exception e) {
      log.info("Failing planning job {}", this.planningJobId);
      return new TaskResult(TaskResult.Status.FAILED, "Exception occurred for job " + planningJobId + ":" + ExceptionUtils
          .getFullStackTrace(e));
    } finally {
      // always cleanup the job mapping for current job name.
      try {
        this.jobsMapping.deleteMapping(jobName);
      } catch (Exception e) {
        return new TaskResult(TaskResult.Status.FAILED,"Cannot delete jobs mapping for job : " + jobName);
      }
    }
  }
612528
public boolean execute(Canvas target, Menu menu, MenuItem item) {
		FeatureTransaction featureTransaction = mapWidget.getMapModel().getFeatureEditor().getFeatureTransaction();
		if (featureTransaction != null) {
			boolean operationCount = featureTransaction.getOperationQueue().size() > 0;
			if (operationCount) {
				// The first addCoordinateOp may not be undone!
				FeatureOperation firstOperation = featureTransaction.getOperationQueue().get(0);
				if (firstOperation instanceof AddCoordinateOp) {
					if (featureTransaction.getNewFeatures()[0].getGeometry().getNumPoints() == 1) {
						return false;
					}
				}

				return true;
			}
		}
		return false;
	}
1180822
protected boolean hasOngoingTransaction() {
		if(!isSupervisedMode()) {
			return false;
		} else {
			if(ongoingTransactions != null) {
				for (Transaction transaction : ongoingTransactions) {
					if(TransactionState.CALLING.equals(transaction.getState()) ||
						TransactionState.TRYING.equals(transaction.getState()) ||
						TransactionState.PROCEEDING.equals(transaction.getState()) ||
						TransactionState.COMPLETED.equals(transaction.getState()) ||
						TransactionState.CONFIRMED.equals(transaction.getState())) {
							return true;
					}
				}
			}
			return false;
		}
	}