Skip to content

Commit

Permalink
Display work bucket management performance info
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 17, 2019
1 parent cf4badd commit 69ae8aa
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 3 deletions.
Expand Up @@ -17,16 +17,15 @@

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.schema.statistics.CachePerformanceInformationUtil;
import com.evolveum.midpoint.schema.statistics.MethodsPerformanceInformationUtil;
import com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil;
import com.evolveum.midpoint.schema.statistics.*;
import com.evolveum.midpoint.web.component.AceEditor;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.objectdetails.AbstractObjectTabPanel;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationStatsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketManagementPerformanceInformationType;
import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;

Expand Down Expand Up @@ -86,6 +85,12 @@ private String getStatistics() {
.append(RepositoryPerformanceInformationUtil.format(statistics.getRepositoryPerformanceInformation()))
.append("\n");
}
WorkBucketManagementPerformanceInformationType buckets = statistics.getWorkBucketManagementPerformanceInformation();
if (buckets != null && !buckets.getOperation().isEmpty()) {
sb.append("Work buckets management performance information:\n")
.append(TaskWorkBucketManagementPerformanceInformationUtil.format(buckets))
.append("\n");
}
if (statistics.getCachesPerformanceInformation() != null) {
sb.append("Cache performance information:\n")
.append(CachePerformanceInformationUtil.format(statistics.getCachesPerformanceInformation()))
Expand All @@ -96,6 +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");
// }
// 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");
// }
return sb.toString();
}

Expand Down
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.schema.statistics;

import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketManagementOperationPerformanceInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketManagementPerformanceInformationType;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

/**
*
*/
public class TaskWorkBucketManagementPerformanceInformationUtil {

public static String format(WorkBucketManagementPerformanceInformationType i) {
StringBuilder sb = new StringBuilder();
List<WorkBucketManagementOperationPerformanceInformationType> operations = new ArrayList<>(i.getOperation());
operations.sort(Comparator.comparing(WorkBucketManagementOperationPerformanceInformationType::getName));
int max = operations.stream().mapToInt(op -> op.getName().length()).max().orElse(0);
for (WorkBucketManagementOperationPerformanceInformationType op : operations) {
long totalTime = or0(op.getTotalTime());
long totalWastedTime = or0(op.getTotalWastedTime());
long totalWaitTime = or0(op.getTotalWaitTime());
int count = or0(op.getCount());
int conflictCount = or0(op.getConflictCount());
int waitCount = or0(op.getBucketWaitCount());
sb.append(String.format(" %-" + (max+2) + "s count:%7d, total time: %s", op.getName()+":", count,
timeInfo(totalTime, op.getMinTime(), op.getMaxTime(), count)));
if (conflictCount > 0 || waitCount > 0) {
sb.append(String.format(Locale.US, ", wasted time for %4d conflict(s): %s (%s)", conflictCount,
timeInfo(totalWastedTime, op.getMinWastedTime(), op.getMaxWastedTime(), count), percent(totalWastedTime, totalTime)));
if (waitCount > 0) {
sb.append(String.format(Locale.US, ", waited %4d time(s): %s (%s)", waitCount,
timeInfo(totalWaitTime, op.getMinWaitTime(), op.getMaxWaitTime(), count), percent(totalWaitTime, totalTime)));
}
}
sb.append("\n");
}
return sb.toString();
}

private static String timeInfo(long total, Long min, Long max, int count) {
return String.format(Locale.US, "%8d ms [min: %5d, max: %5d, avg: %7.1f]", total, or0(min), or0(max),
count > 0 ? (float) total / count : 0);
}

private static String percent(long value, long base) {
if (base != 0) {
return String.format(Locale.US, "%6.2f%%", 100.0 * value / base);
} else if (value == 0) {
return String.format(Locale.US, "%6.2f%%", 0.0);
} else {
return " NaN%";
}
}

private static int or0(Integer n) {
return n != null ? n : 0;
}

private static long or0(Long n) {
return n != null ? n : 0;
}

}

0 comments on commit 69ae8aa

Please sign in to comment.