Skip to content

Commit

Permalink
Working progress reporting for basic task handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 18, 2015
1 parent 5dbcd00 commit 3c23fd0
Show file tree
Hide file tree
Showing 106 changed files with 974 additions and 893 deletions.
Expand Up @@ -38,8 +38,8 @@ public class ProvisioningStatisticsLineDto {

public static final String F_RESOURCE = "resource";
public static final String F_OBJECT_CLASS = "objectClass";
public static final String F_GET_SUCCESS = "searchSuccess";
public static final String F_GET_FAILURE = "searchFailure";
public static final String F_GET_SUCCESS = "getSuccess";
public static final String F_GET_FAILURE = "getFailure";
public static final String F_SEARCH_SUCCESS = "searchSuccess";
public static final String F_SEARCH_FAILURE = "searchFailure";
public static final String F_CREATE_SUCCESS = "createSuccess";
Expand All @@ -54,6 +54,7 @@ public class ProvisioningStatisticsLineDto {
public static final String F_SCRIPT_FAILURE = "scriptFailure";
public static final String F_OTHER_SUCCESS = "otherSuccess";
public static final String F_OTHER_FAILURE = "otherFailure";
public static final String F_TOTAL_OPERATIONS_COUNT = "totalOperationsCount";
public static final String F_AVERAGE_TIME = "averageTime";
public static final String F_MIN_TIME = "minTime";
public static final String F_MAX_TIME = "maxTime";
Expand Down Expand Up @@ -184,10 +185,14 @@ public int getOtherFailure() {
return otherFailure;
}

public Long getAverageTime() {
int totalCount = getSuccess + getFailure + searchSuccess + searchFailure +
public int getTotalOperationsCount() {
return getSuccess + getFailure + searchSuccess + searchFailure +
createSuccess + createFailure + updateSuccess + updateFailure + deleteSuccess + deleteFailure +
syncSuccess + syncFailure + scriptSuccess + scriptFailure + otherSuccess + otherFailure;
}

public Long getAverageTime() {
int totalCount = getTotalOperationsCount();
if (totalCount > 0) {
return totalTime / totalCount;
} else {
Expand Down
Expand Up @@ -115,14 +115,13 @@ public StatisticsDto getObjectInternal() {
}

protected StatisticsDto getStatisticsFromTask(Task task) {
OperationalInformation operationalInformation = task.getOperationalInformation();
OperationalInformationType operationalInformation = task.collectOperationalInformation();
if (operationalInformation == null) {
LOGGER.warn("No operational information in task");
return null;
}
OperationalInformationType infoType = operationalInformation.getAggregatedValue();
infoType.setFromMemory(true);
StatisticsDto dto = new StatisticsDto(infoType);
operationalInformation.setFromMemory(true);
StatisticsDto dto = new StatisticsDto(operationalInformation);
return dto;
}

Expand Down
Expand Up @@ -40,6 +40,7 @@ <h3><wicket:message key="Title.ProvisioningStatistics"/></h3>
<th><wicket:message key="ProvisioningStatistics.ScriptFailure"/></th>
<th><wicket:message key="ProvisioningStatistics.OtherSuccess"/></th>
<th><wicket:message key="ProvisioningStatistics.OtherFailure"/></th>
<th><wicket:message key="ProvisioningStatistics.TotalOperationsCount"/></th>
<th><wicket:message key="ProvisioningStatistics.AverageTime"/></th>
<th><wicket:message key="ProvisioningStatistics.MinTime"/></th>
<th><wicket:message key="ProvisioningStatistics.MaxTime"/></th>
Expand All @@ -64,6 +65,7 @@ <h3><wicket:message key="Title.ProvisioningStatistics"/></h3>
<td><span wicket:id="Provisioning.ScriptFailure"/></td>
<td><span wicket:id="Provisioning.OtherSuccess"/></td>
<td><span wicket:id="Provisioning.OtherFailure"/></td>
<td><span wicket:id="Provisioning.TotalOperationsCount"/></td>
<td><span wicket:id="Provisioning.AverageTime"/></td>
<td><span wicket:id="Provisioning.MinTime"/></td>
<td><span wicket:id="Provisioning.MaxTime"/></td>
Expand Down
Expand Up @@ -60,6 +60,7 @@ public class StatisticsPanel extends SimplePanel<StatisticsDto> {
private static final String ID_PROVISIONING_SCRIPT_FAILURE = "Provisioning.ScriptFailure";
private static final String ID_PROVISIONING_OTHER_SUCCESS = "Provisioning.OtherSuccess";
private static final String ID_PROVISIONING_OTHER_FAILURE = "Provisioning.OtherFailure";
private static final String ID_PROVISIONING_TOTAL_OPERATIONS_COUNT = "Provisioning.TotalOperationsCount";
private static final String ID_PROVISIONING_AVERAGE_TIME = "Provisioning.AverageTime";
private static final String ID_PROVISIONING_MIN_TIME = "Provisioning.MinTime";
private static final String ID_PROVISIONING_MAX_TIME = "Provisioning.MaxTime";
Expand Down Expand Up @@ -121,6 +122,7 @@ protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item)
item.add(new Label(ID_PROVISIONING_SCRIPT_FAILURE, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_SCRIPT_FAILURE)));
item.add(new Label(ID_PROVISIONING_OTHER_SUCCESS, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_OTHER_SUCCESS)));
item.add(new Label(ID_PROVISIONING_OTHER_FAILURE, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_OTHER_FAILURE)));
item.add(new Label(ID_PROVISIONING_TOTAL_OPERATIONS_COUNT, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_TOTAL_OPERATIONS_COUNT)));
item.add(new Label(ID_PROVISIONING_AVERAGE_TIME, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_AVERAGE_TIME)));
item.add(new Label(ID_PROVISIONING_MIN_TIME, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_MIN_TIME)));
item.add(new Label(ID_PROVISIONING_MAX_TIME, new PropertyModel<String>(item.getModel(), ProvisioningStatisticsLineDto.F_MAX_TIME)));
Expand Down
Expand Up @@ -19,8 +19,8 @@ Title.MappingsStatistics=Mappings evaluation information
Title.NotificationsStatistics=Notifications information
Title.CurrentStatus=Last status message
Title.Source=Source:
Message.SourceRepository=repository (updated on {0})
Message.SourceMemory=task in memory (updated on {0})
Message.SourceRepository=repository (statistics updated on {0})
Message.SourceMemory=task in memory (fetched {0})

ProvisioningStatistics.Resource=Resource
ProvisioningStatistics.ObjectClass=Object class
Expand All @@ -40,6 +40,7 @@ ProvisioningStatistics.ScriptSuccess=Script OK
ProvisioningStatistics.ScriptFailure=Fail
ProvisioningStatistics.OtherSuccess=Script OK
ProvisioningStatistics.OtherFailure=Fail
ProvisioningStatistics.TotalOperationsCount=All operations
ProvisioningStatistics.AverageTime=Avg time
ProvisioningStatistics.MinTime=Min
ProvisioningStatistics.MaxTime=Max
Expand Down
@@ -1,55 +1,34 @@
package com.evolveum.midpoint.web.page.admin.home;

import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.NullArgumentException;
import org.apache.velocity.app.event.implement.EscapeJavaScriptReference;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.IFormValidator;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.util.encoding.UrlDecoder;
import org.apache.wicket.util.string.StringValue;
import org.aspectj.util.LangUtil.ProcessController.Thrown;
import org.eclipse.core.internal.runtime.PrintStackUtil;

import ch.qos.logback.classic.Logger;

import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.RetrieveOption;
import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
Expand All @@ -59,28 +38,16 @@
import com.evolveum.midpoint.web.component.util.ObjectWrapperUtil;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel;
import com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto;
import com.evolveum.midpoint.web.page.admin.home.dto.PasswordAccountDto;
import com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto;
import com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO;
import com.evolveum.midpoint.web.page.admin.users.PageUsers;
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.web.security.WebApplicationConfiguration;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

Expand Down Expand Up @@ -223,7 +190,7 @@ public void initLayout(){
// SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null,
//task, result);

CredentialsPolicyType credPolicy=getModelInteractionService().getCredentialsPolicy(null, result);
CredentialsPolicyType credPolicy=getModelInteractionService().getCredentialsPolicy(null, null, result);

// PrismObject<SecurityPolicyType> securityPolicy = getModelService().getObject(SecurityPolicyType.class,config.asObjectable().getGlobalSecurityPolicyRef().getOid(), null, task, subResult);
//Global Policy set question numbers
Expand Down
Expand Up @@ -257,9 +257,6 @@ private TaskDto loadTask() {
private TaskDto prepareTaskDto(TaskType task, OperationResult result) throws SchemaException, ObjectNotFoundException {
TaskDto taskDto = new TaskDto(task, getModelService(), getTaskService(), getModelInteractionService(),
getTaskManager(), TaskDtoProviderOptions.fullOptions(), result, this);
for (TaskType child : task.getSubtask()) {
taskDto.addChildTaskDto(prepareTaskDto(child, result));
}
return taskDto;
}

Expand Down
Expand Up @@ -32,15 +32,23 @@ public class TaskCurrentStateDto {
private TaskDto taskDto;
private SynchronizationInformationType synchronizationInformationType;
private IterativeTaskInformationType iterativeTaskInformationType;
private Long currentProgress;

public TaskCurrentStateDto(TaskDto taskDto) {
this.taskDto = taskDto;
}

public TaskCurrentStateDto(TaskDto taskDto, SynchronizationInformationType sit, IterativeTaskInformationType itit) {
public TaskCurrentStateDto(TaskDto taskDto, SynchronizationInformationType sit, IterativeTaskInformationType itit, Long currentProgress) {
this.taskDto = taskDto;
this.synchronizationInformationType = sit;
this.iterativeTaskInformationType = itit;
if (currentProgress != null) {
this.currentProgress = currentProgress;
} else {
if (taskDto != null) {
this.currentProgress = taskDto.getProgress();
}
}
}

public TaskDto getTaskDto() {
Expand All @@ -54,4 +62,8 @@ public SynchronizationInformationType getSynchronizationInformationType() {
public IterativeTaskInformationType getIterativeTaskInformationType() {
return iterativeTaskInformationType;
}

public Long getCurrentProgress() {
return currentProgress;
}
}
Expand Up @@ -18,6 +18,8 @@

import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.IterativeTaskInformation;
Expand Down Expand Up @@ -48,6 +50,7 @@
import org.apache.wicket.model.IModel;

import java.io.IOException;
import java.util.Collection;

/**
* @author Pavol Mederly
Expand Down Expand Up @@ -117,34 +120,29 @@ protected TaskCurrentStateDto getObjectInternal() {
} else {
LOGGER.info("No IterativeTaskInformationType in task extension.");
}
return new TaskCurrentStateDto(taskModel.getObject(), infoPropertyValue, ititPropertyValue);
return new TaskCurrentStateDto(taskModel.getObject(), infoPropertyValue, ititPropertyValue, null);
}
SynchronizationInformation info = task.getSynchronizationInformation();
SynchronizationInformationType sit;
if (info != null) {
sit = info.getAggregatedValue();
SynchronizationInformationType sit = task.collectSynchronizationInformation();
if (sit != null) {
sit.setFromMemory(true);
} else {
sit = null;
LOGGER.warn("No synchronization information in task");
}
IterativeTaskInformation iter = task.getIterativeTaskInformation();
IterativeTaskInformationType itit;
if (iter != null) {
itit = iter.getAggregatedValue();
IterativeTaskInformationType itit = task.collectIterativeTaskInformation();;
if (itit != null) {
itit.setFromMemory(true);
} else {
itit = null;
LOGGER.warn("No synchronization information in task");
}
return new TaskCurrentStateDto(taskModel.getObject(), sit, itit);
return new TaskCurrentStateDto(taskModel.getObject(), sit, itit, task.getProgress());
}

public void refresh(PageBase page) {
object = null;

if (taskModel == null || taskModel.getObject() == null) {
LOGGER.warn("Null or empty taskModel");
return;
}
TaskManager taskManager = page.getTaskManager();
OperationResult result = new OperationResult("refresh");
Expand All @@ -153,7 +151,8 @@ public void refresh(PageBase page) {
String oid = taskModel.getObject().getOid();
try {
LOGGER.info("Refreshing task {}", taskModel.getObject());
PrismObject<TaskType> task = page.getModelService().getObject(TaskType.class, oid, null, operationTask, result);
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.createRetrieveAttributesOptions(TaskType.F_SUBTASK, TaskType.F_NODE_AS_OBSERVED);
PrismObject<TaskType> task = page.getModelService().getObject(TaskType.class, oid, options, operationTask, result);
TaskDto taskDto = new TaskDto(task.asObjectable(), page.getModelService(), page.getTaskService(),
page.getModelInteractionService(), taskManager, TaskDtoProviderOptions.minimalOptions(), result, page);
taskModel.setObject(taskDto);
Expand Down
Expand Up @@ -71,6 +71,9 @@
<h3><wicket:message key="TaskStatePanel.statistics"/></h3>
<div wicket:id="statisticsPanel"/>

<h3><div wicket:id="workerThreadsTableLabel"/></h3>
<div wicket:id="workerThreadsTable"/>

<h3><wicket:message key="TaskStatePanel.opResult"/></h3>
<div wicket:id="operationResult"/>

Expand Down

0 comments on commit 3c23fd0

Please sign in to comment.