Skip to content

Commit

Permalink
Eliminate growing execution records lists
Browse files Browse the repository at this point in the history
Plus growing lists of taskRef in activity tree overview
(it will be reworked soon anyway).
  • Loading branch information
mederly committed Jun 23, 2021
1 parent c4296a9 commit e71f085
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ public void recordExecutionStart(@NotNull LocalActivityExecution<?, ?, ?> execut
beans.plainRepositoryService.modifyObjectDynamically(TaskType.class, rootTask.getOid(), null,
taskBean -> {
ActivityStateOverviewType overview = ActivityStateOverviewUtil.getOrCreateStateOverview(taskBean);
ActivityStateOverviewUtil.findOrCreateEntry(overview, execution.getActivityPath())
ActivityStateOverviewType entry = ActivityStateOverviewUtil.findOrCreateEntry(overview, execution.getActivityPath())
.realizationState(ActivitySimplifiedRealizationStateType.IN_PROGRESS)
.executionState(ActivityExecutionStateType.EXECUTING)
.resultStatus(OperationResultStatusType.IN_PROGRESS)
.taskRef(execution.getRunningTask().getSelfReference());
.resultStatus(OperationResultStatusType.IN_PROGRESS);
entry.getTaskRef().clear(); // temporary implementation
entry.getTaskRef().add(execution.getRunningTask().getSelfReference());
return beans.prismContext.deltaFor(TaskType.class)
.item(F_ACTIVITY_STATE, F_TREE, ActivityTreeStateType.F_ACTIVITY).replace(overview)
.asItemDeltas();
Expand Down Expand Up @@ -94,11 +95,12 @@ public void recordExecutionFinish(@NotNull LocalActivityExecution<?, ?, ?> execu
executionState = ActivityExecutionStateType.NOT_EXECUTING;
resultStatus = OperationResultStatusType.FATAL_ERROR;
}
ActivityStateOverviewUtil.findOrCreateEntry(overview, execution.getActivityPath())
ActivityStateOverviewType entry = ActivityStateOverviewUtil.findOrCreateEntry(overview, execution.getActivityPath())
.realizationState(realizationState)
.executionState(executionState)
.resultStatus(resultStatus)
.taskRef(execution.getRunningTask().getSelfReference());
.resultStatus(resultStatus);
entry.getTaskRef().clear();
entry.getTaskRef().add(execution.getRunningTask().getSelfReference());
return beans.prismContext.deltaFor(TaskType.class)
.item(F_ACTIVITY_STATE, F_TREE, ActivityTreeStateType.F_ACTIVITY).replace(overview)
.asItemDeltas();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ public boolean supportsActionsExecuted() {
return supportsStatistics(); // Should be overridden in subclasses, if needed.
}

public boolean supportsExecutionRecords() {
return supportsStatistics() && getPersistenceType() == ActivityStatePersistenceType.SINGLE_REALIZATION;
}

public void incrementProgress(@NotNull QualifiedItemProcessingOutcomeType outcome) {
ActivityProgress.Counters counters = hasProgressCommitPoints() ? UNCOMMITTED : COMMITTED;
activityState.getLiveProgress().increment(outcome, counters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ protected LocalActivityExecution(@NotNull ExecutionInstantiationContext<WD, AH>

private void updateStateInformationOnExecutionStart(OperationResult result) throws ActivityExecutionException {
getTreeStateOverview().recordExecutionStart(this, result);
activityState.getLiveStatistics().getLiveItemProcessing().recordExecutionStart(getStartTimestamp());
if (supportsExecutionRecords()) {
activityState.getLiveStatistics().getLiveItemProcessing().recordExecutionStart(getStartTimestamp());
}
activityState.getLiveProgress().clearUncommitted();
}

private void updateStateInformationOnExecutionFinish(OperationResult result, ActivityExecutionResult executionResult)
throws ActivityExecutionException {
getTreeStateOverview().recordExecutionFinish(this, executionResult, result);
activityState.getLiveStatistics().getLiveItemProcessing().recordExecutionEnd(getStartTimestamp(), System.currentTimeMillis());
if (supportsExecutionRecords()) {
activityState.getLiveStatistics().getLiveItemProcessing().recordExecutionEnd(getStartTimestamp(), System.currentTimeMillis());
}
}

protected abstract @NotNull ActivityExecutionResult executeLocal(OperationResult result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public void test100RunSimpleLegacyTask() throws Exception {
.rootActivity()
.assertComplete()
.assertNoSynchronizationStatistics()
.assertNoActionsExecutedInformation();
.assertNoActionsExecutedInformation()
.assertPersistenceSingleRealization();

displayDumpable("recorder", recorder);
assertThat(recorder.getExecutions()).as("executions").containsExactly("msg1");
Expand Down Expand Up @@ -219,7 +220,16 @@ public void test110RunCompositeLegacyTask() throws Exception {
.rootActivity()
.assertComplete()
.assertNoSynchronizationStatistics()
.assertNoActionsExecutedInformation();
.assertNoActionsExecutedInformation()
.assertPersistenceSingleRealization()
.child("opening")
.assertPersistenceSingleRealization()
.end()
.child("closing")
.assertPersistencePerpetual()
.end()
.end()
.end();

displayDumpable("recorder", recorder);
assertThat(recorder.getExecutions()).as("executions").containsExactly("id1:opening", "id1:closing");
Expand Down Expand Up @@ -256,7 +266,7 @@ public void test110RunCompositeLegacyTask() throws Exception {
.assertErrors(0)
.assertProgress(1)
.assertHasWallClockTime()
.assertHasThroughput();
.assertNoThroughput();
}

/**
Expand Down Expand Up @@ -483,7 +493,7 @@ private void execute140RunPureCompositeTaskOnce(Task root, String label, int run
.assertErrors(0)
.assertProgress(runNumber)
.assertHasWallClockTime()
.assertHasThroughput()
.assertNoThroughput()
.end()
.end()
.child("mock-simple:1")
Expand All @@ -508,7 +518,7 @@ private void execute140RunPureCompositeTaskOnce(Task root, String label, int run
.assertErrors(0)
.assertProgress(runNumber)
.assertHasWallClockTime()
.assertHasThroughput()
.assertNoThroughput()
.end()
.end()
.child("mock-composite:3")
Expand All @@ -519,7 +529,7 @@ private void execute140RunPureCompositeTaskOnce(Task root, String label, int run
.assertErrors(0)
.assertProgress(runNumber)
.assertHasWallClockTime()
.assertHasThroughput()
.assertNoThroughput()
.end()
.end();
// @formatter:on
Expand Down Expand Up @@ -2025,14 +2035,15 @@ public void test220MockCompositeWithSubtasks() throws Exception {
.assertSuccess()
.activityState()
.rootActivity()
.assertPersistencePerpetual()
.progress()
.assertCommitted(1, 0, 0)
.assertNoUncommitted()
.end()
.itemProcessingStatistics()
.assertTotalCounts(1, 0, 0)
.assertLastSuccessObjectName("id1:closing")
.assertExecutions(1)
.assertExecutions(0) // because of perpetual persistence of state
.end()
.end()
.end()
Expand Down Expand Up @@ -2073,7 +2084,7 @@ public void test220MockCompositeWithSubtasks() throws Exception {
.assertErrors(0)
.assertProgress(1)
.assertHasWallClockTime()
.assertHasThroughput()
.assertNoThroughput()
.end();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* TODO
*/
@SuppressWarnings("WeakerAccess")
@SuppressWarnings({ "WeakerAccess", "UnusedReturnValue" })
public class ActivityStateAsserter<RA> extends AbstractAsserter<RA> {

private final ActivityStateType activityState;
Expand Down Expand Up @@ -200,4 +200,21 @@ public ActivityStateAsserter<RA> display() {
IntegrationTestTools.display(desc(), DebugUtil.debugDump(activityState));
return this;
}

public ActivityStateAsserter<RA> assertPersistenceSingleRealization() {
return assertPersistence(ActivityStatePersistenceType.SINGLE_REALIZATION);
}

public ActivityStateAsserter<RA> assertPersistencePerpetual() {
return assertPersistence(ActivityStatePersistenceType.PERPETUAL);
}

public ActivityStateAsserter<RA> assertPersistencePerpetualExceptStatistics() {
return assertPersistence(ActivityStatePersistenceType.PERPETUAL_EXCEPT_STATISTICS);
}

public ActivityStateAsserter<RA> assertPersistence(ActivityStatePersistenceType expected) {
assertThat(activityState.getPersistence()).as("persistence").isEqualTo(expected);
return this;
}
}

0 comments on commit e71f085

Please sign in to comment.