Skip to content

Commit

Permalink
Display other performance info for the task
Browse files Browse the repository at this point in the history
(this is perhaps temporary solution)
  • Loading branch information
mederly committed Jun 17, 2019
1 parent 69ae8aa commit facdf60
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 30 deletions.
Expand Up @@ -101,29 +101,29 @@ private String getStatistics() {
.append(MethodsPerformanceInformationUtil.format(statistics.getMethodsPerformanceInformation()))
.append("\n");
}
//
// sb.append("\n-------------------------------------------------------------------------------------------------------------------------\n");
// sb.append("Other statistics information that is shown elsewhere (just for completeness):\n\n");
// if (statistics.getIterativeTaskInformation() != null) {
// sb.append("Iterative task information:\n")
// .append(IterativeTaskInformation.format(statistics.getIterativeTaskInformation()))
// .append("\n");
// }
// if (statistics.getActionsExecutedInformation() != null) {
// sb.append("Actions executed:\n")
// .append(ActionsExecutedInformation.format(statistics.getActionsExecutedInformation()))
// .append("\n");
// }

sb.append("\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
sb.append("Other performance-related information that is shown elsewhere (provided here just for completeness):\n\n");
if (statistics.getIterativeTaskInformation() != null) {
sb.append("Iterative task information:\n")
.append(IterativeTaskInformation.format(statistics.getIterativeTaskInformation()))
.append("\n");
}
if (statistics.getActionsExecutedInformation() != null) {
sb.append("Actions executed:\n")
.append(ActionsExecutedInformation.format(statistics.getActionsExecutedInformation()))
.append("\n");
}
// if (statistics.getSynchronizationInformation() != null) {
// sb.append("Synchronization information:\n")
// .append(SynchronizationInformation.format(statistics.getSynchronizationInformation()))
// .append("\n");
// }
// if (statistics.getEnvironmentalPerformanceInformation() != null) {
// sb.append("Environmental performance information:\n")
// .append(EnvironmentalPerformanceInformation.format(statistics.getEnvironmentalPerformanceInformation()))
// .append("\n");
// }
if (statistics.getEnvironmentalPerformanceInformation() != null) {
sb.append("Environmental performance information:\n")
.append(EnvironmentalPerformanceInformation.format(statistics.getEnvironmentalPerformanceInformation()))
.append("\n");
}
return sb.toString();
}

Expand Down
Expand Up @@ -18,18 +18,15 @@

import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActionsExecutedInformationType;
import org.apache.commons.lang.StringUtils;

import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* @author Pavol Mederly
Expand Down Expand Up @@ -244,4 +241,31 @@ public ObjectActionExecuted(String objectName, String objectDisplayName, QName o
this.timestamp = timestamp;
}
}

public static String format(ActionsExecutedInformationType information) {
StringBuilder sb = new StringBuilder();
sb.append(" All object actions:\n");
for (ObjectActionsExecutedEntryType a : information.getObjectActionsEntry()) {
formatActionExecuted(sb, a);
}
sb.append(" Resulting object actions:\n");
for (ObjectActionsExecutedEntryType a : information.getResultingObjectActionsEntry()) {
formatActionExecuted(sb, a);
}
return sb.toString();
}

private static void formatActionExecuted(StringBuilder sb, ObjectActionsExecutedEntryType a) {
sb.append(String.format(" %-10s %-30s %s\n", a.getOperation(), QNameUtil.getLocalPart(a.getObjectType()), a.getChannel()));
if (a.getTotalSuccessCount() > 0) {
sb.append(String.format(Locale.US, " success: %6d time(s), last: %s (%s, %s) on %tc\n", a.getTotalSuccessCount(),
a.getLastSuccessObjectName(), a.getLastSuccessObjectDisplayName(), a.getLastSuccessObjectOid(),
XmlTypeConverter.toDate(a.getLastSuccessTimestamp())));
}
if (a.getTotalFailureCount() > 0) {
sb.append(String.format(Locale.US, " failure: %6d time(s), last: %s (%s, %s) on %tc\n", a.getTotalFailureCount(),
a.getLastFailureObjectName(), a.getLastFailureObjectDisplayName(), a.getLastFailureObjectOid(),
XmlTypeConverter.toDate(a.getLastFailureTimestamp())));
}
}
}
Expand Up @@ -18,21 +18,18 @@

import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.EnvironmentalPerformanceInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingsStatisticsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingsStatisticsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationsStatisticsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationsStatisticsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningStatisticsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningStatisticsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;

import javax.xml.datatype.DatatypeConstants;
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

/**
* @author Pavol Mederly
*/
Expand Down Expand Up @@ -488,4 +485,70 @@ public synchronized StatusMessage getLastMessage() {
public synchronized void recordState(String message) {
lastMessage = new StatusMessage(message);
}

public static String format(EnvironmentalPerformanceInformationType information) {
StringBuilder sb = new StringBuilder();
if (information.getProvisioningStatistics() != null && !information.getProvisioningStatistics().getEntry().isEmpty()) {
sb.append(" Provisioning:\n");
sb.append(format(information.getProvisioningStatistics()));
}
if (information.getMappingsStatistics() != null && !information.getMappingsStatistics().getEntry().isEmpty()) {
sb.append(" Mappings:\n");
sb.append(format(information.getMappingsStatistics()));
}
if (information.getNotificationsStatistics() != null && !information.getNotificationsStatistics().getEntry().isEmpty()) {
sb.append(" Notifications:\n");
sb.append(format(information.getNotificationsStatistics()));
}
if (information.getLastMessage() != null) {
sb.append(" Last message: ").append(information.getLastMessage()).append("\n");
sb.append(" On: ").append(information.getLastMessageTimestamp()).append("\n");
}
return sb.toString();
}

public static String format(ProvisioningStatisticsType information) {
StringBuilder sb = new StringBuilder();
for (ProvisioningStatisticsEntryType e : information.getEntry()) {
int sum = e.getGetSuccess() + e.getGetFailure() + e.getSearchSuccess() + e.getSearchFailure() +
e.getCreateSuccess() + e.getCreateFailure() + e.getUpdateSuccess() + e.getUpdateFailure() +
e.getDeleteSuccess() + e.getDeleteFailure() + e.getSyncSuccess() + e.getSyncFailure() +
e.getScriptSuccess() + e.getScriptFailure() + e.getOtherSuccess() + e.getOtherFailure();
sb.append(String.format(Locale.US, " %-60s count: %8d, total time: %8d ms [min: %6d, max: %6d, avg: %7.1f] GET: %5d:%3d SEARCH: %5d:%3d CREATE: %5d:%3d UPDATE: %5d:%3d DELETE: %5d:%3d SYNC: %5d:%3d SCRIPT: %5d:%3d OTHER: %5d:%3d\n",
e.getResource() + " (" + QNameUtil.getLocalPart(e.getObjectClass()) + ")",
sum, e.getTotalTime(), defaultIfNull(e.getMinTime(), 0L), defaultIfNull(e.getMaxTime(), 0L),
avg(e.getTotalTime(), sum),
e.getGetSuccess(), e.getGetFailure(), e.getSearchSuccess(), e.getSearchFailure(),
e.getCreateSuccess(), e.getCreateFailure(), e.getUpdateSuccess(), e.getUpdateFailure(),
e.getDeleteSuccess(), e.getDeleteFailure(), e.getSyncSuccess(), e.getSyncFailure(),
e.getScriptSuccess(), e.getScriptFailure(), e.getOtherSuccess(), e.getOtherFailure()));
}
return sb.toString();
}

private static float avg(long totalTime, int count) {
return count > 0 ? (float) totalTime / count : 0;
}

private static String format(MappingsStatisticsType information) {
StringBuilder sb = new StringBuilder();
for (MappingsStatisticsEntryType e : information.getEntry()) {
sb.append(String.format(Locale.US, " %-40s count: %6d, total time: %6d ms [min: %5d, max: %5d, avg: %7.1f]\n", e.getObject(),
e.getCount(), e.getTotalTime(), defaultIfNull(e.getMinTime(), 0L),
defaultIfNull(e.getMaxTime(), 0L), avg(e.getTotalTime(), e.getCount())));
}
return sb.toString();
}

private static String format(NotificationsStatisticsType information) {
StringBuilder sb = new StringBuilder();
for (NotificationsStatisticsEntryType e : information.getEntry()) {
sb.append(String.format(Locale.US, " %-30s success: %6d, failure: %5d, total time: %6d ms [min: %5d, max: %5d, avg: %7.1fd]\n", e.getTransport(),
e.getCountSuccess(), e.getCountFailure(), e.getTotalTime(), defaultIfNull(e.getMinTime(), 0L),
defaultIfNull(e.getMaxTime(), 0L), avg(e.getTotalTime(), e.getCountSuccess() + e.getCountFailure())));
}
return sb.toString();
}


}
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.schema.statistics;

import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IterativeTaskInformationType;
import org.apache.commons.collections.buffer.CircularFifoBuffer;

Expand All @@ -25,6 +26,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
* @author Pavol Mederly
Expand Down Expand Up @@ -216,6 +218,41 @@ public static void addTo(IterativeTaskInformationType sum, IterativeTaskInformat
}

public List<String> getLastFailures() {
//noinspection unchecked
return new ArrayList<>(lastFailures);
}

public static String format(IterativeTaskInformationType i) {
StringBuilder sb = new StringBuilder();
sb.append(String.format(Locale.US, " Successfully processed: %6d in %10d ms = %8.1f ms per object", i.getTotalSuccessCount(),
i.getTotalSuccessDuration(), div(i.getTotalSuccessDuration(), i.getTotalSuccessCount())));
if (i.getLastSuccessEndTimestamp() != null) {
sb.append(String.format(Locale.US, ", last: %s:%s (%s, %s) on %tc in %d ms",
QNameUtil.getLocalPart(i.getLastSuccessObjectType()),
i.getLastSuccessObjectName(), i.getLastSuccessObjectDisplayName(), i.getLastSuccessObjectOid(),
XmlTypeConverter.toDate(i.getLastSuccessEndTimestamp()), i.getLastSuccessDuration()));
}
sb.append("\n");
sb.append(String.format(Locale.US, " Failed: %6d in %10d ms = %8.1f ms per object", i.getTotalFailureCount(),
i.getTotalFailureDuration(), div(i.getTotalFailureDuration(), i.getTotalFailureCount())));
if (i.getLastFailureEndTimestamp() != null) {
sb.append(String.format(Locale.US, ", last: %s:%s (%s, %s) on %tc in %d ms: %s",
QNameUtil.getLocalPart(i.getLastFailureObjectType()),
i.getLastFailureObjectName(), i.getLastFailureObjectDisplayName(), i.getLastFailureObjectOid(),
XmlTypeConverter.toDate(i.getLastFailureEndTimestamp()), i.getLastFailureDuration(),
i.getLastFailureExceptionMessage()));
}
sb.append("\n");
if (i.getCurrentObjectStartTimestamp() != null) {
sb.append(String.format(Locale.US, " Current: %s:%s (%s, %s) started at %tc\n", QNameUtil.getLocalPart(i.getCurrentObjectType()),
i.getCurrentObjectName(), i.getCurrentObjectDisplayName(), i.getCurrentObjectOid(),
XmlTypeConverter.toDate(i.getCurrentObjectStartTimestamp())));
}
return sb.toString();
}

private static float div(long duration, int count) {
return count != 0 ? (float) duration / count : 0;
}

}

0 comments on commit facdf60

Please sign in to comment.