Search in sources :

Example 21 with SqlPerformanceMonitorImpl

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

the class SqaleRepoSmokeTest method test200GetObject.

@Test
public void test200GetObject() throws Exception {
    OperationResult result = createOperationResult();
    given("existing user and cleared performance information");
    UserType user = new UserType(prismContext).name("user" + getTestNumber());
    String userOid = repositoryService.addObject(user.asPrismObject(), null, result);
    SqlPerformanceMonitorImpl pm = repositoryService.getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    when("getObject is called for known OID");
    PrismObject<UserType> object = repositoryService.getObject(UserType.class, userOid, null, result);
    then("object is obtained and performance monitor is updated");
    assertThatOperationResult(result).isSuccess();
    assertThat(object).isNotNull();
    assertSingleOperationRecorded(REPO_OP_PREFIX + RepositoryService.OP_GET_OBJECT);
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 22 with SqlPerformanceMonitorImpl

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

the class SqaleRepoBaseTest method clearPerformanceMonitor.

protected void clearPerformanceMonitor() {
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    assertThat(pm.getGlobalPerformanceInformation().getAllData()).isEmpty();
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)

Example 23 with SqlPerformanceMonitorImpl

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

the class SqaleAuditSearchIterativeTest method test110SearchIterativeWithEmptyFilter.

@Test
public void test110SearchIterativeWithEmptyFilter() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    when("calling search iterative with null query");
    SearchResultMetadata metadata = searchObjectsIterative(null, operationResult);
    then("result metadata is not null and reports the handled objects");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
    assertThat(metadata.isPartialResults()).isFalse();
    assertThat(metadata.getPagingCookie()).isNotNull();
    and("search operations were called");
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects of the specified type (here User) were processed");
    assertThat(testHandler.processedCount()).isEqualTo(count(aer));
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 24 with SqlPerformanceMonitorImpl

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

the class SqaleAuditSearchIterativeTest method test111SearchIterativeWithLastPageNotFull.

@Test
public void test111SearchIterativeWithLastPageNotFull() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("total result count not multiple of the page size");
    sqaleAuditService.repositoryConfiguration().setIterativeSearchByPagingBatchSize(47);
    when("calling search iterative with null query");
    SearchResultMetadata metadata = searchObjectsIterative(null, operationResult);
    then("result metadata is not null and reports the handled objects");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
    assertThat(metadata.isPartialResults()).isFalse();
    assertThat(metadata.getPagingCookie()).isNotNull();
    and("search operations were called");
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects of the specified type were processed");
    assertThat(testHandler.processedCount()).isEqualTo(count(aer));
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 25 with SqlPerformanceMonitorImpl

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

the class SqlRepositoryServiceImpl method isAnySubordinate.

protected boolean isAnySubordinate(String ancestorOrgOid, Collection<String> descendantOrgOids) {
    Validate.notNull(ancestorOrgOid, "upperOrgOid must not be null.");
    Validate.notNull(descendantOrgOids, "lowerObjectOids must not be null.");
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Querying for subordination upper {}, lower {}", ancestorOrgOid, descendantOrgOids);
    }
    if (descendantOrgOids.isEmpty()) {
        // trivial case
        return false;
    }
    // TODO executeAttempts
    int attempt = 1;
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(OP_IS_ANY_SUBORDINATE, OrgType.class);
    try {
        while (true) {
            try {
                return objectRetriever.isAnySubordinateAttempt(ancestorOrgOid, descendantOrgOids);
            } catch (RuntimeException ex) {
                attempt = baseHelper.logOperationAttempt(ancestorOrgOid, OP_IS_ANY_SUBORDINATE, attempt, ex, null);
                pm.registerOperationNewAttempt(opHandle, attempt);
            }
        }
    } finally {
        pm.registerOperationFinish(opHandle, attempt);
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)

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