com.evolveum.midpoint.task.api.Task.canRun()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中com.evolveum.midpoint.task.api.Task.canRun()方法的一些代码示例,展示了Task.canRun()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.canRun()方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:canRun

Task.canRun介绍

[英]Returns true if the task can run (was not interrupted). Will return false e.g. if shutdown was signaled. BEWARE: this flag is present only on the instance of the task that is being "executed", i.e. passed to task execution routine and task handler(s).
[中]如果任务可以运行(未中断),则返回true。将返回false,例如,如果发出关闭信号。注意:此标志仅出现在正在“执行”的任务实例上,即传递给任务执行例程和任务处理程序。

代码示例

代码示例来源:origin: Evolveum/midpoint

public boolean canRun() {
  return task == null || task.canRun();
}

代码示例来源:origin: Evolveum/midpoint

private boolean shouldStop(OperationResult parentResult) {
  if (stopRequestedByAnyWorker.get()) {
    return true;
  }
  if (!coordinatorTask.canRun()) {
    recordInterrupted(parentResult);
    return true;
  }
  return false;
}

代码示例来源:origin: Evolveum/midpoint

@Override
public <O extends ObjectType> void handle(PrismObject<O> object, TriggerType trigger, Task task, OperationResult result) {
  IntegrationTestTools.display("Mock trigger handler called with " + object);
  lastObject = object.clone();
  invocationCount.incrementAndGet();
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < delay && task.canRun()) {
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      // just ignore
    }
  }
  if (failOnNextInvocation) {
    failOnNextInvocation = false;
    throw new IllegalStateException("Failing as instructed");
  }
}

代码示例来源:origin: Evolveum/midpoint

if (!task.canRun()) {
      LOGGER.info("NoOpTaskHandler: got a shutdown request, finishing task {}", task);
      break outer;
runResult.setShouldContinue(task.canRun());
runResult.setBucketComplete(task.canRun());
return runResult;

代码示例来源:origin: Evolveum/midpoint

@Override
protected void finish(H handler, TaskRunResult runResult, Task task, OperationResult opResult) throws SchemaException {
  super.finish(handler, runResult, task, opResult);
  if (task.canRun()) {
    /*
     *  We want to update last scan timestamp only if the task has finished its current duties.
     *  Otherwise we might skip e.g. some triggers or validity boundaries - those that the task
     *  has not reached yet. They would be left unprocessed forever. See MID-4474.
     *
     *  Note this is not the whole solution. It is necessary to review AbstractSearchIterativeResultHandler.handle()
     *  and shouldStop() methods and use 'stop' flag at this place as well. Hopefully such stopping is (very probably)
     *  not requested by any scanner task handlers.
     */
    PrismPropertyDefinition<XMLGregorianCalendar> lastScanTimestampDef = prismContext.definitionFactory().createPropertyDefinition(
        SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME,
        DOMUtil.XSD_DATETIME);
    PropertyDelta<XMLGregorianCalendar> lastScanTimestampDelta = prismContext.deltaFactory().property().create(
        ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME),
        lastScanTimestampDef);
    lastScanTimestampDelta.setRealValuesToReplace(handler.getThisScanTimestamp());
    task.modifyExtension(lastScanTimestampDelta);
  }
}

代码示例来源:origin: Evolveum/midpoint

if (!task.canRun()) {
    break;
    + processedSuccess + " were processed successfully and processing of " + processedFailure + " resulted in failure. " +
    "Total time spent: " + (System.currentTimeMillis() - startedAll) + " ms. " +
    (!task.canRun() ? "Was interrupted during processing." : "");
return task.canRun();

代码示例来源:origin: Evolveum/midpoint

Statistics queryStatistics = new Statistics();
for (int i = 0; task.canRun() && (tests == 0 || i < tests); i++) {
  Connection connection = null;
  try {

代码示例来源:origin: Evolveum/midpoint

@Override
public TaskRunResult run(Task task) {
  LOGGER.info("MockLong.run starting (id = {}, progress = {})", id, task.getProgress());
  OperationResult opResult = new OperationResult(MockLongTaskHandler.class.getName()+".run");
  TaskRunResult runResult = new TaskRunResult();
  while (task.canRun()) {
    task.incrementProgressAndStoreStatsIfNeeded();
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      LOGGER.info("Interrupted: exiting", e);
      break;
    }
  }
  opResult.recordSuccess();
  runResult.setOperationResult(opResult);
  runResult.setRunResultStatus(TaskRunResultStatus.FINISHED);
  runResult.setProgress(task.getProgress());
  LOGGER.info("MockLong.run stopping; progress = {}", task.getProgress());
  return runResult;
}

代码示例来源:origin: Evolveum/midpoint

for (PrismObject<TaskType> rootTaskPrism : obsoleteTasks) {
  if (!executionTask.canRun()) {
    result.recordWarning("Interrupted");
    LOGGER.warn("Task cleanup was interrupted.");

代码示例来源:origin: Evolveum/midpoint

LOGGER.trace("Skipping recording counter for {} because it is protected", shadow);
    return localCoordinatorTask.canRun();
  return localCoordinatorTask.canRun();
};
interrupted = !localCoordinatorTask.canRun();

代码示例来源:origin: Evolveum/midpoint

" (wall clock time average: " + resultHandler.getWallAverageTime() + " ms).";
    if (!localCoordinatorTask.canRun()) {
      statistics += " Task was interrupted during processing.";
  runResult.setBucketComplete(localCoordinatorTask.canRun());     // TODO
  runResult.setShouldContinue(localCoordinatorTask.canRun());     // TODO
  return runResult;
} catch (ExitWorkBucketHandlerException e) {

代码示例来源:origin: Evolveum/midpoint

handler.completeProcessing(localCoordinatorTask, searchResult);
interrupted = !localCoordinatorTask.canRun();

代码示例来源:origin: Evolveum/midpoint

return workerTask.canRun();

相关文章

微信公众号

最新文章

更多