Skip to content

Commit

Permalink
internals/subresultStripThreshold parameter + setting thread names in…
Browse files Browse the repository at this point in the history
… lightweight subtasks
  • Loading branch information
mederly committed Jun 29, 2017
1 parent 9f2604e commit c291896
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 4 deletions.
Expand Up @@ -65,8 +65,10 @@ public class OperationResult implements Serializable, DebugDumpable, Cloneable {
* This constant provides count threshold for same subresults (same operation and
* status) during summarize operation.
*/
private static final int SUBRESULT_STRIP_THRESHOLD = 10;

private static final int DEFAULT_SUBRESULT_STRIP_THRESHOLD = 10;

private static int subresultStripThreshold = DEFAULT_SUBRESULT_STRIP_THRESHOLD;

public static final String CONTEXT_IMPLEMENTATION_CLASS = "implementationClass";
public static final String CONTEXT_PROGRESS = "progress";
public static final String CONTEXT_OID = "oid";
Expand Down Expand Up @@ -1144,7 +1146,7 @@ public void summarize(boolean alsoSubresults) {
if (recordsCounters.containsKey(key)) {
OperationStatusCounter counter = recordsCounters.get(key);
if (!sr.representsHiddenRecords()) {
if (counter.shownRecords < SUBRESULT_STRIP_THRESHOLD) {
if (counter.shownRecords < subresultStripThreshold) {
counter.shownRecords++;
counter.shownCount += sr.count;
} else {
Expand Down Expand Up @@ -1500,5 +1502,12 @@ public OperationResult clone() {
return clone;
}

public static int getSubresultStripThreshold() {
return subresultStripThreshold;
}

// null means default value
public static void setSubresultStripThreshold(Integer value) {
subresultStripThreshold = value != null ? value : DEFAULT_SUBRESULT_STRIP_THRESHOLD;
}
}
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.schema.util;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.xml.ns._public.common.common_3.InternalsConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;

Expand Down Expand Up @@ -63,4 +64,9 @@ public static String getDefaultHostname(SystemConfigurationType sysconfig) {
}
}

// TODO move to better place?
public static void applyOperationResultHandling(SystemConfigurationType config) {
Integer value = config != null && config.getInternals() != null ? config.getInternals().getSubresultStripThreshold() : null;
OperationResult.setSubresultStripThreshold(value);
}
}
Expand Up @@ -10942,6 +10942,18 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="subresultStripThreshold" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
When aggregation of the same subresults (same operation and status) is to be applied,
during operation result "summarize" operation.
(Default: 10.)

TEMPORARY/EXPERIMENTAL. We plan to provide more elaborate operation result aggregation strategies.
This is just a quick way how to reduce large operation results for some deployments.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.SystemConfigurationTypeUtil;
import com.evolveum.midpoint.security.api.SecurityUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand Down Expand Up @@ -134,6 +135,7 @@ public <O extends ObjectType> HookOperationMode invoke(@NotNull ModelContext<O>
applyLoggingConfiguration(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), result);

cacheRepositoryService.applyFullTextSearchConfiguration(config.asObjectable().getFullTextSearch());
SystemConfigurationTypeUtil.applyOperationResultHandling(config.asObjectable());

result.recordSuccessIfUnknown();

Expand Down
Expand Up @@ -274,6 +274,11 @@ public WorkerHandler(OperationResult workerSpecificResult) {

@Override
public void run(Task workerTask) {

// temporary hack: how to see thread name for this task
workerTask.setName(workerTask.getName().getOrig() + " (" + Thread.currentThread().getName() + ")");
workerSpecificResult.addContext("subtaskName", workerTask.getName());

while (workerTask.canRun()) {
ProcessingRequest request;
try {
Expand Down Expand Up @@ -500,7 +505,7 @@ public void createWorkerThreads(Task coordinatorTask, OperationResult opResult)
// we intentionally do not put worker specific result under main operation result until the handler is done
// (because of concurrency issues - adding subresults vs e.g. putting main result into the task)
OperationResult workerSpecificResult = new OperationResult(taskOperationPrefix + ".handleAsynchronously");
workerSpecificResult.addContext("subtask", i);
workerSpecificResult.addContext("subtaskIndex", i+1);
workerSpecificResults.add(workerSpecificResult);

Task subtask = coordinatorTask.createSubtask(new WorkerHandler(workerSpecificResult));
Expand Down
Expand Up @@ -52,6 +52,7 @@
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.SystemConfigurationTypeUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand Down Expand Up @@ -1042,5 +1043,6 @@ public void postInit(OperationResult result) throws SchemaException {
}
}
applyFullTextSearchConfiguration(systemConfiguration.getFullTextSearch());
SystemConfigurationTypeUtil.applyOperationResultHandling(systemConfiguration);
}
}
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.schema.util.SystemConfigurationTypeUtil;
import com.evolveum.midpoint.security.api.SecurityUtil;
import com.evolveum.midpoint.task.api.TaskManagerInitializationException;
import com.evolveum.midpoint.task.quartzimpl.TaskManagerQuartzImpl;
Expand Down Expand Up @@ -294,6 +295,7 @@ public void checkSystemConfigurationChanged(OperationResult parentResult) {
SecurityUtil.setRemoteHostAddressHeaders(config.asObjectable());

getRepositoryService().applyFullTextSearchConfiguration(config.asObjectable().getFullTextSearch());
SystemConfigurationTypeUtil.applyOperationResultHandling(config.asObjectable());
} else {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("System configuration change check: version in repo = version currently applied = {}", versionApplied);
Expand Down

0 comments on commit c291896

Please sign in to comment.