Skip to content

Commit

Permalink
Clean up activities code
Browse files Browse the repository at this point in the history
The majority of classes were moved. The whole activity framework
now resides in "com.evolveum.midpoint.repo.common.activity" package.

BEWARE! Incompatible changes:
- Item reporting/executionReports is now reporting/reports (in activity
definition).
- Names for policy rule triggering counters have been changed
(simulation is now preview, execution is now full execution).
- Various parts of activity state have been changed: mostly related to
the "activity execution" -> "activity run" change.
- Names of preview (was: simulation) related sub-activities
in reconciliation activity have been changed.

Please re-import your tasks (and adapt them if needed).

Other changes:
- Replaced "activity execution" with "activity run" both in schema
and in the code.
- Moved suppressed bucket and item statistics from DEBUG to TRACE level.
- Removed support for old in-memory counters for policy rule thresholds.
- Fetching legacy logging config from task extension, if present.
- Fixed (deprecated) profiling configuration handling.
- Deleted unused TaskManager#registerAdditionalHandlerUri
and #registerDeprecatedHandlerUri.
- Deleted unused AnnotationSupportUtil and other minor classes.
- Renamed GenericTaskHandler to ActivityBasedTaskHandler,
GenericTaskExecution (TaskExecution) to ActivityBasedTaskRun (TaskRun).
- Resolved the conflict between reporting definition and old-style
(fixed) handler-specific reporting options.
  • Loading branch information
mederly committed Oct 26, 2021
1 parent 3935d1e commit 3e14c12
Show file tree
Hide file tree
Showing 294 changed files with 2,928 additions and 3,575 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
import com.evolveum.midpoint.repo.api.CacheDispatcher;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.common.ObjectResolver;
import com.evolveum.midpoint.repo.common.activity.CounterManager;
import com.evolveum.midpoint.repo.common.expression.Expression;
import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext;
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
Expand Down Expand Up @@ -290,8 +289,6 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
@SpringBean private GuiComponentRegistry registry;
@SpringBean private DefaultGuiConfigurationCompiler guiConfigurationRegistry;

@SpringBean private CounterManager counterManager;

@SpringBean private ClusterExecutionHelper clusterExecutionHelper;

@SpringBean private AdminGuiConfigurationMergeManager adminGuiConfigurationMergeManager;
Expand Down Expand Up @@ -398,10 +395,6 @@ public LocalizationService getLocalizationService() {
return localizationService;
}

public CounterManager getCounterManager() {
return counterManager;
}

@Contract(pure = true)
public PrismContext getPrismContext() {
return getMidpointApplication().getPrismContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>

<div class="row">

<div class="col-md-12">
<h3><wicket:message key="PageInternals.title.thresholds.counters"/></h3>
<table class="table table-bordered">
<tbody>
<tr wicket:id="thresholdCountersTable">
<th wicket:id="counterTask"/>
<td wicket:id="counterPolicyRule"/>
<td wicket:id="counterCount"/>
<td>
<a class="btn btn-primary" wicket:id="resetThresholdCounter">
<wicket:message key="InternalsCountersPanel.threshold.reset.button"/>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="row">

<div class="col-md-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,16 @@
*/
package com.evolveum.midpoint.web.page.admin.configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;

import com.evolveum.midpoint.util.exception.*;

import com.evolveum.midpoint.web.component.dialog.DeleteConfirmationPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.repo.common.activity.CounterSpecification;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;

public class InternalsCountersPanel extends BasePanel<ListView<InternalCounters>> {

Expand All @@ -42,17 +25,8 @@ public class InternalsCountersPanel extends BasePanel<ListView<InternalCounters>
private static final String ID_COUNTER_LABEL = "counterLabel";
private static final String ID_COUNTER_VALUE = "counterValue";
private static final String ID_THRESHOLD_COUNTER = "thresholdCounter";
private static final String ID_THRESHOLD_COUNTERS_TABLE = "thresholdCountersTable";
private static final String ID_COUNTER_TASK_LABEL = "counterTask";
private static final String ID_COUNTER_POLICY_RULE_LABEL = "counterPolicyRule";
private static final String ID_COUNTER_COUNT_LABEL = "counterCount";
private static final String ID_RESET_THRESHOLD_COUNTER = "resetThresholdCounter";

private static final String DOT_CLASS = InternalsCountersPanel.class.getName() + ".";
private static final String OPERATION_LOAD_TASK = DOT_CLASS + "loadTaskByIdentifier";


public InternalsCountersPanel(String id) {
InternalsCountersPanel(String id) {
super(id);
}

Expand All @@ -65,47 +39,7 @@ protected void onInitialize() {
Label thresholdCounter = new Label(ID_THRESHOLD_COUNTER, createStringResource("InternalsCountersPanel.thresholds"));
add(thresholdCounter);

ListView<CounterSpecification> thresholdCountersTable = new ListView<CounterSpecification>(ID_THRESHOLD_COUNTERS_TABLE, createThresholdCounterModel()) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<CounterSpecification> item) {
CounterSpecification counter = item.getModelObject();
Label task = new Label(ID_COUNTER_TASK_LABEL, createLabelModel(counter));
item.add(task);

Label policyRule = new Label(ID_COUNTER_POLICY_RULE_LABEL, counter.getPolicyRuleName());
item.add(policyRule);

Label count = new Label(ID_COUNTER_COUNT_LABEL, counter.getCount());
item.add(count);

AjaxLink<Void> resetCounter = new AjaxLink<Void>(ID_RESET_THRESHOLD_COUNTER) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
ConfirmationPanel confirmPanel = new DeleteConfirmationPanel(getPageBase().getMainPopupBodyId(), createStringResource("InternalsCountersPanel.reset.confirm.message", counter.getOid(), counter.getPolicyRuleName())) {

private static final long serialVersionUID = 1L;

public void yesPerformed(AjaxRequestTarget target) {
getPageBase().getCounterManager().removeCounter(counter);
target.add(InternalsCountersPanel.this);
}
};
getPageBase().showMainPopup(confirmPanel, target);
target.add(InternalsCountersPanel.this);
}
};
item.add(resetCounter);
}

};
add(thresholdCountersTable);

ListView<InternalCounters> countersTable = new ListView<InternalCounters>(ID_COUNTERS_TABLE,
ListView<InternalCounters> countersTable = new ListView<>(ID_COUNTERS_TABLE,
Arrays.asList(InternalCounters.values())) {
private static final long serialVersionUID = 1L;

Expand All @@ -130,38 +64,4 @@ public String getObject() {
};
add(countersTable);
}

private IModel<String> createLabelModel(CounterSpecification counter) {
return () -> {
Task operationTask = getPageBase().createSimpleTask(OPERATION_LOAD_TASK);
OperationResult parentResult = operationTask.getResult();
PrismObject<TaskType> taskPrism = null;
try {
taskPrism = getPageBase().getTaskService().getTaskByIdentifier(counter.getOid(), null, operationTask, parentResult);
} catch (SchemaException | CommunicationException | ExpressionEvaluationException | ObjectNotFoundException | ConfigurationException | SecurityViolationException e) {
parentResult.recordPartialError("Failed to load task with identifier: " + counter.getOid() + ". Reason: " + e.getMessage());
}

parentResult.computeStatusIfUnknown();
getPageBase().showResult(parentResult, false);

if (taskPrism == null) {
return counter.getOid();
}
return WebComponentUtil.getName(taskPrism) + "(" + counter.getOid() + ")";
};
}

private IModel<List<CounterSpecification>> createThresholdCounterModel() {
return new IModel<List<CounterSpecification>>() {
private static final long serialVersionUID = 1L;

@Override
public List<CounterSpecification> getObject() {
Collection<CounterSpecification> thresholdCounters = getPageBase().getCounterManager().listCounters();
return new ArrayList<>(thresholdCounters);
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Integer getAllErrors() {
@Override
public XMLGregorianCalendar getStartTimestamp() {
if (isTrivial()) {
return localRootActivityState.getExecutionStartTimestamp();
return localRootActivityState.getRunStartTimestamp();
} else {
return localRootActivityState.getRealizationStartTimestamp();
}
Expand All @@ -117,7 +117,7 @@ public XMLGregorianCalendar getStartTimestamp() {
@Override
public XMLGregorianCalendar getEndTimestamp() {
if (isTrivial()) {
return localRootActivityState.getExecutionEndTimestamp();
return localRootActivityState.getRunEndTimestamp();
} else {
return localRootActivityState.getRealizationEndTimestamp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,17 @@ private static void addToNotNull(@NotNull ActivityItemProcessingStatisticsType s
@NotNull ActivityItemProcessingStatisticsType delta) {
addProcessed(sum.getProcessed(), delta.getProcessed());
addCurrent(sum.getCurrent(), delta.getCurrent());
addExecutionRecords(sum, delta);
addRunRecords(sum, delta);
}

private static void addExecutionRecords(@NotNull ActivityItemProcessingStatisticsType sum,
private static void addRunRecords(@NotNull ActivityItemProcessingStatisticsType sum,
@NotNull ActivityItemProcessingStatisticsType delta) {
List<ActivityExecutionRecordType> nonOverlappingRecords =
new WallClockTimeComputer(sum.getExecution(), delta.getExecution())
List<ActivityRunRecordType> nonOverlappingRecords =
new WallClockTimeComputer(sum.getRun(), delta.getRun())
.getNonOverlappingRecords();
sum.getExecution().clear();
sum.getRun().clear();
nonOverlappingRecords.sort(Comparator.comparing(r -> XmlTypeConverter.toMillis(r.getStartTimestamp())));
sum.getExecution().addAll(CloneUtil.cloneCollectionMembersWithoutIds(nonOverlappingRecords));
sum.getRun().addAll(CloneUtil.cloneCollectionMembersWithoutIds(nonOverlappingRecords));
}

/** Adds `processed` items information */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import javax.xml.datatype.XMLGregorianCalendar;

import com.evolveum.midpoint.util.TreeNode;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityExecutionRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityRunRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityItemProcessingStatisticsType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityProgressType;
Expand Down Expand Up @@ -277,8 +277,8 @@ private WallClockInfo(Long wallClockTime, XMLGregorianCalendar earliestStartTime
}

public static WallClockInfo determine(Collection<ActivityItemProcessingStatisticsType> statistics) {
List<ActivityExecutionRecordType> allExecutions = statistics.stream()
.flatMap(s -> s.getExecution().stream())
List<ActivityRunRecordType> allExecutions = statistics.stream()
.flatMap(s -> s.getRun().stream())
.collect(Collectors.toList());
WallClockTimeComputer wallClockTimeComputer = new WallClockTimeComputer(allExecutions);
return new WallClockInfo(wallClockTimeComputer.getSummaryTime(), wallClockTimeComputer.getEarliestStartTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void updateWorkersCounters(@NotNull List<ActivityTaskStateOverviewType>
LOGGER.debug("No execution state information in: {}", task);
}
updateWorkersCounters(task.getNode(),
task.getExecutionState() == ActivityTaskExecutionStateType.EXECUTING,
task.getExecutionState() == ActivityTaskExecutionStateType.RUNNING,
task.getStalledSince() != null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityExecutionRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityRunRecordType;

import com.google.common.annotations.VisibleForTesting;

Expand All @@ -30,7 +30,7 @@ public class WallClockTimeComputer {
private final Set<Interval> nonOverlappingIntervals;

@SafeVarargs
WallClockTimeComputer(List<ActivityExecutionRecordType>... lists) {
WallClockTimeComputer(List<ActivityRunRecordType>... lists) {
intervals = Arrays.stream(lists)
.flatMap(Collection::stream)
.map(Interval::create)
Expand Down Expand Up @@ -59,7 +59,7 @@ public XMLGregorianCalendar getEarliestStartTime() {
.orElse(null);
}

public List<ActivityExecutionRecordType> getNonOverlappingRecords() {
public List<ActivityRunRecordType> getNonOverlappingRecords() {
return nonOverlappingIntervals.stream()
.map(Interval::getRecord)
.collect(Collectors.toList());
Expand Down Expand Up @@ -102,15 +102,15 @@ private static Interval findOverlapping(Collection<Interval> intervals, Interval
private static class Interval {
private final long fromMillis;
private final long toMillis;
private final ActivityExecutionRecordType record;
private final ActivityRunRecordType record;

Interval(long fromMillis, long toMillis, ActivityExecutionRecordType record) {
Interval(long fromMillis, long toMillis, ActivityRunRecordType record) {
this.fromMillis = fromMillis;
this.toMillis = toMillis;
this.record = record;
}

private static Interval create(ActivityExecutionRecordType record) {
private static Interval create(ActivityRunRecordType record) {
if (record.getStartTimestamp() != null && record.getEndTimestamp() != null) {
Interval interval = new Interval(
XmlTypeConverter.toMillis(record.getStartTimestamp()),
Expand Down Expand Up @@ -141,7 +141,7 @@ public long getTime() {
return toMillis - fromMillis;
}

public ActivityExecutionRecordType getRecord() {
public ActivityRunRecordType getRecord() {
return record;
}

Expand Down Expand Up @@ -206,7 +206,7 @@ public Interval mergeWith(Interval other) {
}

return new Interval(newFromMillis, newToMillis, useRecords ?
new ActivityExecutionRecordType(PrismContext.get())
new ActivityRunRecordType(PrismContext.get())
.startTimestamp(newFromXml)
.endTimestamp(newToXml) : null);
}
Expand Down

0 comments on commit 3e14c12

Please sign in to comment.