Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 5, 2021
2 parents 116a6f6 + 4259b26 commit e48df82
Show file tree
Hide file tree
Showing 58 changed files with 703 additions and 656 deletions.
112 changes: 59 additions & 53 deletions config/sql/native-new/postgres-new.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;
import com.evolveum.midpoint.gui.impl.page.admin.task.TaskDetailsModel;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.statistics.*;
Expand Down Expand Up @@ -159,6 +158,7 @@ private String getStatistics() {
.append(EnvironmentalPerformanceInformation.format(statistics.getEnvironmentalPerformanceInformation()))
.append("\n");
}
sb.append(ActivityProgressAndStatisticsPrinter.print(task));
if (statistics.getCachingConfiguration() != null) {
sb.append(LINE);
sb.append("Caching configuration:\n\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.schema.util.task.ActivityPath;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* Prints iterative task performance information.
* Prints the item processing statistics.
*/
public class IterationInformationPrinter extends AbstractStatisticsPrinter<ActivityItemProcessingStatisticsType> {
public class ActivityItemProcessingStatisticsPrinter extends AbstractStatisticsPrinter<ActivityItemProcessingStatisticsType> {

public IterationInformationPrinter(@NotNull ActivityItemProcessingStatisticsType information, Options options) {
public ActivityItemProcessingStatisticsPrinter(@NotNull ActivityItemProcessingStatisticsType information, Options options) {
super(information, options, null, null);
}

Expand All @@ -38,16 +36,15 @@ public void prepare() {

private void createData() {
initData();
createData(ActivityPath.empty(), information); // TODO correct activity path!!!
createData(information);
}

private void createData(ActivityPath activityPath, ActivityItemProcessingStatisticsType component) {
private void createData(ActivityItemProcessingStatisticsType component) {
List<ProcessedItemSetType> processed = new ArrayList<>(component.getProcessed());
processed.sort(OutcomeKeyedCounterTypeUtil.createOutcomeKeyedCounterComparator());

for (ProcessedItemSetType set : processed) {
Data.Record record = data.createRecord();
record.add(String.valueOf(activityPath));
record.add(OutcomeKeyedCounterTypeUtil.getOutcome(set));
record.add(OutcomeKeyedCounterTypeUtil.getOutcomeQualifierUri(set));
record.add(set.getCount());
Expand All @@ -66,7 +63,19 @@ private void createData(ActivityPath activityPath, ActivityItemProcessingStatist
}
}

// TODO current
// This is somehow problematic. Maybe we should put current items into a separate table.
for (ProcessedItemType currentItem : component.getCurrent()) {
Data.Record record = data.createRecord();
record.add(null);
record.add(null);
record.add(null);
record.add(null);
record.add(null);
record.add(getItemDescription(currentItem));
record.add(XmlTypeConverter.toDate(currentItem.getStartTimestamp()));
record.add(null);
record.add(null); // Or should the current duration be here?
}
}

private Long getDuration(ProcessedItemType item) {
Expand All @@ -88,7 +97,6 @@ private String getItemDescription(ProcessedItemType item) {

private void createFormatting() {
initFormatting();
addColumn("Activity", LEFT, formatString());
addColumn("Outcome", LEFT, formatString());
addColumn("Qualifier", LEFT, formatString());
addColumn("Count", RIGHT, formatInt());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.statistics;

import com.evolveum.midpoint.schema.util.task.ActivityPath;
import com.evolveum.midpoint.schema.util.task.ActivityProgressUtil;
import com.evolveum.midpoint.schema.util.task.ActivityTreeUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityStateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

import org.jetbrains.annotations.NotNull;

/** TODO better name */
public class ActivityProgressAndStatisticsPrinter {

/**
* Prints all relevant statistics (including progress) for all activities in the given task.
*/
public static String print(@NotNull TaskType task) {
StringBuilder sb = new StringBuilder();
ActivityTreeUtil.processLocalStates(task, (path, state) -> print(sb, path, state));
return sb.toString();
}

private static void print(StringBuilder sb, @NotNull ActivityPath path, @NotNull ActivityStateType activityState) {
sb.append("Activity: ")
.append(path.toDebugName())
.append("\n\n");

if (activityState.getProgress() != null) {
sb.append("Progress:\n\n");
sb.append(ActivityProgressUtil.format(activityState.getProgress()));
sb.append("\n");
}

sb.append(ActivityStatisticsUtil.format(activityState.getStatistics()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.statistics;

import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

import static com.evolveum.midpoint.schema.statistics.Formatting.Alignment.LEFT;
import static com.evolveum.midpoint.schema.statistics.Formatting.Alignment.RIGHT;

/**
* Prints activity progress information.
*
* Does not support sorting by time, as this is not relevant for activity progress.
* Also does not support sorting by counters. This could be done in the future.
* Also does not support expected totals (yet). It does not fit into the table.
*/
public class ActivityProgressPrinter extends AbstractStatisticsPrinter<ActivityProgressType> {

public ActivityProgressPrinter(@NotNull ActivityProgressType information, Options options) {
super(information, options, null, null);
}

@Override
public void prepare() {
createData();
createFormatting();
}

private void createData() {
initData();
createData(information);
}

private void createData(@NotNull ActivityProgressType component) {
addData(ActivityProgressType.F_UNCOMMITTED, component.getUncommitted());
addData(ActivityProgressType.F_COMMITTED, component.getCommitted());
}

private void addData(@NotNull ItemName state, @NotNull List<OutcomeKeyedCounterType> counters) {

List<OutcomeKeyedCounterType> sortedCounters = new ArrayList<>(counters);
sortedCounters.sort(OutcomeKeyedCounterTypeUtil.createOutcomeKeyedCounterComparator());

for (OutcomeKeyedCounterType counter : sortedCounters) {
Data.Record record = data.createRecord();
record.add(state.getLocalPart());
record.add(OutcomeKeyedCounterTypeUtil.getOutcome(counter));
record.add(OutcomeKeyedCounterTypeUtil.getOutcomeQualifierUri(counter));
record.add(counter.getCount());
}
}

private void createFormatting() {
initFormatting();
addColumn("State", LEFT, formatString());
addColumn("Outcome", LEFT, formatString());
addColumn("Qualifier", LEFT, formatString());
addColumn("Count", RIGHT, formatInt());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,19 @@ public static ActivityStatisticsType getActivityStatsFromTree(@NotNull TaskType
return aggregate;
}

public static String format(ActivityStatisticsType statistics) {
public static String format(@Nullable ActivityStatisticsType statistics) {
if (statistics == null) {
return "";
}
StringBuilder sb = new StringBuilder();
if (statistics.getItemProcessing() != null) {
sb.append("Item processing\n\n")
.append(IterationInformation.format(statistics.getItemProcessing())) // TODO use correct formatter
.append(ActivityItemProcessingStatisticsUtil.format(statistics.getItemProcessing()))
.append("\n");
}
if (statistics.getSynchronization() != null) {
// The second condition (some transitions present) is a workaround for synchronization info being present
// in task even if it's not in the repository. (Do GUI wrappers do that?)
if (statistics.getSynchronization() != null && !statistics.getSynchronization().getTransition().isEmpty()) {
sb.append("Synchronization\n\n")
.append(ActivitySynchronizationStatisticsUtil.format(statistics.getSynchronization()))
.append("\n");
Expand Down

0 comments on commit e48df82

Please sign in to comment.