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

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

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

Task.getProgress介绍

[英]Returns task progress, as reported by task handler.
[中]返回任务处理程序报告的任务进度。

代码示例

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

@Override
public Long heartbeat(Task task) {
  return task.getProgress();
}

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

@Override
public Long heartbeat(Task task) {
  return task.getProgress();
}

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

private void incrementAndRecordProgress(Task task, OperationResult opResult) {
  recordProgress(task, task.getProgress() + 1, opResult);
}

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

private static void dumpTaskTree(StringBuilder sb, int indent, Task task, OperationResult result) throws SchemaException {
    DebugUtil.indentDebugDump(sb, indent);
    sb.append(task)
        .append(" [").append(task.getExecutionStatus())
        .append(", ").append(task.getProgress())
        .append(", ").append(task.getNode())
        .append("]").append("\n");
    List<Task> subtasks = task.listSubtasks(result);
    for (Task subtask : subtasks) {
      dumpTaskTree(sb, indent + 1, subtask, result);
    }
  }
}

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

public long getProgress() {
  return taskRunResult != null && taskRunResult.getProgress() != null ? taskRunResult.getProgress() : task.getProgress();
}

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

protected void waitForTaskProgress(String taskOid, OperationResult result, long timeoutInterval, long sleepInterval,
    int threshold) throws CommonException {
  waitFor("Waiting for task progress reaching " + threshold, () -> {
    Task task = taskManager.getTaskWithResult(taskOid, result);
    IntegrationTestTools.display("Task while waiting for progress reaching " + threshold, task);
    return task.getProgress() >= threshold;
  }, timeoutInterval, sleepInterval);
}

代码示例来源: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

@Override
protected void assertFinishedPropagationTask(Task finishedTask, OperationResultStatusType expectedStatus) {
  super.assertFinishedPropagationTask(finishedTask, expectedStatus);
  SearchFilterType filterType = finishedTask.getTaskType().getObjectRef().getFilter();
  display("Propagation task filter", filterType);
  
  assertEquals("Unexpected propagation task progress", 1, finishedTask.getProgress());
}

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

private void fillOperationExecutionState(Task task0) {
  TaskQuartzImpl task = (TaskQuartzImpl) task0;
  if (task.getTaskIdentifier() == null) {
    return;     // shouldn't really occur
  }
  Task taskInMemory = getLocallyRunningTaskByIdentifier(task.getTaskIdentifier());
  if (taskInMemory == null) {
    return;
  }
  OperationStatsType operationStats = taskInMemory.getAggregatedLiveOperationStats();
  if (operationStats != null) {
    operationStats.setLiveInformation(true);
  }
  task.setOperationStatsTransient(operationStats);
  task.setProgressTransient(taskInMemory.getProgress());
  OperationResult result = taskInMemory.getResult();
  if (result != null) {
    try {
      task.setResultTransient(taskInMemory.getResult().clone());
    } catch (ConcurrentModificationException e) {
      // This can occur, see MID-3954/MID-4088. We will use operation result that was fetched from the repository
      // (it might be a bit outdated).
      LOGGER.warn("Concurrent access to operation result denied; using data from the repository (see MID-3954/MID-4088): {}", task, e);
    }
  } else {
    task.setResultTransient(null);
  }
}

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

public void recordEnd(ExecutionContext context, ObjectType objectType, long started, Throwable ex) {
  if (context.isRecordProgressAndIterationStatistics()) {
    if (context.getTask() != null && objectType != null) {
      context.getTask().recordIterativeOperationEnd(
          PolyString.getOrig(objectType.getName()),
          StatisticsUtil.getDisplayName(objectType.asPrismObject()),
          StatisticsUtil.getObjectType(objectType, prismContext),
          objectType.getOid(),
          started, ex);
    } else {
      LOGGER.warn("Couldn't record operation end in script execution; task = {}, objectType = {}",
          context.getTask(), objectType);
    }
    if (context.getTask() != null) {
      context.getTask().setProgress(context.getTask().getProgress() + 1);
    }
  }
}

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

@Override
public boolean check() throws CommonException {
  Holder<OperationResultType> resultHolder = new Holder<>();
  Holder<ObjectType> objectHolder = new Holder<>();
  OperationResult opResult = new OperationResult("import check");
  assertNoRepoCache();
  SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
  try {
    modelWeb.getObject(ObjectTypes.TASK.getTypeQName(), taskOid,
        options, objectHolder, resultHolder);
  } catch (FaultMessage faultMessage) {
    throw new SystemException(faultMessage);
  }
  assertNoRepoCache();
  //				display("getObject result (wait loop)",resultHolder.value);
  TestUtil.assertSuccess("getObject has failed", resultHolder.value);
  Task task = taskManager.createTaskInstance((PrismObject<TaskType>) objectHolder.value.asPrismObject(), opResult);
  System.out.println(new Date() + ": Import task status: " + task.getExecutionStatus() + ", progress: " + task.getProgress());
  if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) {
    // Task closed, wait finished
    return true;
  }
  //				IntegrationTestTools.display("Task result while waiting: ", task.getResult());
  return false;
}

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

AssertJUnit.assertTrue("Progress is none or too small", task.getProgress() >= 1);
AssertJUnit.assertTrue("Progress is too big (fault in scheduling?)", task.getProgress() <= 7);

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

assertEquals("task was achieved some progress", 0L, task.getProgress());
AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
assertFalse(task.getLastRunFinishTimestamp() == 0);
AssertJUnit.assertTrue("no progress", task.getProgress() > 0);

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

@Test
public void test010CycleCronLoose() throws Exception {
  final String TEST_NAME = "test010CycleCronLoose";
  final OperationResult result = createResult(TEST_NAME, LOGGER);
  addObjectFromFile(taskFilename(TEST_NAME));
  waitForTaskProgress(taskOid(TEST_NAME), result, 15000, 2000, 2);
  // Check task status
  Task task = getTask(taskOid(TEST_NAME), result);
  AssertJUnit.assertNotNull(task);
  System.out.println(task.debugDump());
  TaskType t = repositoryService.getObject(TaskType.class, taskOid(TEST_NAME), null, result).getValue().getValue();
  System.out.println(ObjectTypeUtil.dump(t));
  AssertJUnit.assertEquals(TaskExecutionStatus.RUNNABLE, task.getExecutionStatus());
  // .. and last run should not be zero
  AssertJUnit.assertNotNull(task.getLastRunStartTimestamp());
  assertFalse(task.getLastRunStartTimestamp() == 0);
  AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
  assertFalse(task.getLastRunFinishTimestamp() == 0);
  // The progress should be at least 2 as the task has run at least twice
  AssertJUnit.assertTrue("Task has not been executed at least twice", task.getProgress() >= 2);
  // Test for presence of a result. It should be there and it should
  // indicate success
  assertSuccessOrInProgress(task);
  // Suspend the task (in order to keep logs clean), without much waiting
  taskManager.suspendTaskQuietly(task, 100, result);
}

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

AssertJUnit.assertTrue("Task has not reported any progress", task.getProgress() > 0);

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

runResult.setProgress(task.getProgress()+1);
runResult.setOperationResult(opResult);

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

AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
assertFalse(task.getLastRunFinishTimestamp() == 0);
AssertJUnit.assertTrue(task.getProgress() > 0);
AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
assertFalse(task.getLastRunFinishTimestamp() == 0);
AssertJUnit.assertTrue(task.getProgress() > 0);

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

AssertJUnit.assertTrue("Task reported progress lower than 2", task.getProgress() >= 2);

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

assertFalse(task.getLastRunStartTimestamp() == 0);
AssertJUnit.assertNull(task.getLastRunFinishTimestamp());
AssertJUnit.assertEquals("There should be no progress reported", 0, task.getProgress());
AssertJUnit.assertNotNull("Last run finish time is null", task.getLastRunStartTimestamp());
assertFalse("Last run finish time is zero", task.getLastRunStartTimestamp() == 0);
AssertJUnit.assertTrue("Progress is not reported", task.getProgress() > 0);

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

AssertJUnit.assertTrue("Task reported no progress", task.getProgress() > 0);

相关文章