Search in sources :

Example 31 with SqlPerformanceMonitorImpl

use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.

the class SqlAuditServiceImpl method audit.

@Override
public void audit(AuditEventRecord record, Task task, OperationResult result) {
    Objects.requireNonNull(record, "Audit event record must not be null.");
    // TODO convert record to AERType and call that version?
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(OP_AUDIT, AuditEventRecord.class);
    int attempt = 1;
    while (true) {
        try {
            auditAttempt(record);
            return;
        } catch (RuntimeException ex) {
            attempt = baseHelper.logOperationAttempt(null, OP_AUDIT, attempt, ex, result);
            pm.registerOperationNewAttempt(opHandle, attempt);
        } finally {
            pm.registerOperationFinish(opHandle, attempt);
        }
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)

Example 32 with SqlPerformanceMonitorImpl

use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.

the class SqlAuditServiceImpl method audit.

@Override
public void audit(AuditEventRecordType record, OperationResult result) {
    Objects.requireNonNull(record, "Audit event record must not be null.");
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(OP_AUDIT, AuditEventRecordType.class);
    int attempt = 1;
    while (true) {
        try {
            auditAttempt(record);
            return;
        } catch (RuntimeException ex) {
            attempt = baseHelper.logOperationAttempt(null, OP_AUDIT, attempt, ex, result);
            pm.registerOperationNewAttempt(opHandle, attempt);
        } finally {
            pm.registerOperationFinish(opHandle, attempt);
        }
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)

Example 33 with SqlPerformanceMonitorImpl

use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.

the class ExtItemDictionary method executeAttempts.

private void executeAttempts(String operationName, Class<?> type, String operationVerb, Runnable runnable) {
    SqlPerformanceMonitorImpl pm = repositoryService.getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(operationName, type);
    int attempt = 1;
    try {
        while (true) {
            try {
                runnable.run();
                break;
            } catch (RuntimeException ex) {
                attempt = baseHelper.logOperationAttempt(null, operationVerb, attempt, ex, null);
                pm.registerOperationNewAttempt(opHandle, attempt);
            }
        }
    } finally {
        pm.registerOperationFinish(opHandle, attempt);
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)

Example 34 with SqlPerformanceMonitorImpl

use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.

the class SqaleAuditSearchIterativeTest method test120SearchIterativeWithMaxSize.

@Test
public void test120SearchIterativeWithMaxSize() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with maxSize specified");
    ObjectQuery query = prismContext.queryFor(UserType.class).maxSize(101).build();
    when("calling search iterative");
    SearchResultMetadata metadata = searchObjectsIterative(query, operationResult);
    then("result metadata is not null and reports partial result (because of the break)");
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
    assertThat(metadata.isPartialResults()).isFalse();
    and("search operations were called");
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("specified amount of objects was processed");
    assertThat(testHandler.processedCount()).isEqualTo(101);
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

SqlPerformanceMonitorImpl (com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)34 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)16 Test (org.testng.annotations.Test)16 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 QUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser)5 NotNull (org.jetbrains.annotations.NotNull)5 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)3 com.evolveum.midpoint.prism.query (com.evolveum.midpoint.prism.query)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 Collectors (java.util.stream.Collectors)3 Nullable (org.jetbrains.annotations.Nullable)3 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)2 AuditReferenceValue (com.evolveum.midpoint.audit.api.AuditReferenceValue)2 AuditResultHandler (com.evolveum.midpoint.audit.api.AuditResultHandler)2 AuditService (com.evolveum.midpoint.audit.api.AuditService)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ChangeType (com.evolveum.midpoint.prism.delta.ChangeType)2