Search in sources :

Example 6 with SqlPerformanceMonitorImpl

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

the class SqlRepositoryServiceImpl method executeQueryDiagnostics.

@Override
public RepositoryQueryDiagResponse executeQueryDiagnostics(RepositoryQueryDiagRequest request, OperationResult result) {
    Validate.notNull(request, "Request must not be null.");
    Validate.notNull(result, "Operation result must not be null.");
    LOGGER.debug("Executing arbitrary query '{}'.", request);
    final String operation = "querying";
    int attempt = 1;
    OperationResult subResult = result.subresult(EXECUTE_QUERY_DIAGNOSTICS).setMinor().addParam("request", request.toString()).build();
    // TODO executeAttempts
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(OP_EXECUTE_QUERY_DIAGNOSTICS, null);
    try {
        while (true) {
            try {
                return objectRetriever.executeQueryDiagnosticsRequest(request, subResult);
            } catch (RuntimeException ex) {
                attempt = baseHelper.logOperationAttempt(null, operation, attempt, ex, subResult);
                pm.registerOperationNewAttempt(opHandle, attempt);
            }
        }
    } finally {
        pm.registerOperationFinish(opHandle, attempt);
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 7 with SqlPerformanceMonitorImpl

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

the class SqlRepositoryServiceImpl method searchObjectsIterativeBySingleTransaction.

@Nullable
private <T extends ObjectType> SearchResultMetadata searchObjectsIterativeBySingleTransaction(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult subResult) {
    /*
         * Here we store OIDs that were already sent to the client during previous attempts.
         */
    Set<String> retrievedOids = new HashSet<>();
    final String operation = "searching iterative";
    int attempt = 1;
    try {
        while (true) {
            try {
                objectRetriever.searchObjectsIterativeAttempt(type, query, handler, options, subResult, retrievedOids);
                return null;
            } catch (RuntimeException ex) {
                attempt = baseHelper.logOperationAttempt(null, operation, attempt, ex, subResult);
            }
        }
    } finally {
        // temporary workaround, just to know the number of calls
        SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
        long opHandle = pm.registerOperationStart(OP_SEARCH_OBJECTS_ITERATIVE, type);
        pm.registerOperationFinish(opHandle, attempt);
    }
// TODO conflict checking (if needed)
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with SqlPerformanceMonitorImpl

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

the class SqlRepositoryServiceImpl method getVersion.

@Override
public <T extends ObjectType> String getVersion(Class<T> type, String oid, OperationResult parentResult) throws ObjectNotFoundException {
    Validate.notNull(type, "Object type must not be null.");
    Validate.notNull(oid, "Object oid must not be null.");
    Validate.notNull(parentResult, "Operation result must not be null.");
    LOGGER.debug("Getting version for {} with oid '{}'.", type.getSimpleName(), oid);
    OperationResult subResult = parentResult.subresult(GET_VERSION).addQualifier(type.getSimpleName()).addParam("type", type.getName()).addParam("oid", oid).build();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    long opHandle = pm.registerOperationStart(OP_GET_VERSION, type);
    final String operation = "getting version";
    int attempt = 1;
    try {
        while (true) {
            try {
                String rv = objectRetriever.getVersionAttempt(type, oid, subResult);
                invokeConflictWatchers((w) -> w.afterGetVersion(oid, rv));
                return rv;
            } catch (RuntimeException ex) {
                attempt = baseHelper.logOperationAttempt(null, operation, attempt, ex, subResult);
                pm.registerOperationNewAttempt(opHandle, attempt);
            }
        }
    } finally {
        pm.registerOperationFinish(opHandle, attempt);
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 9 with SqlPerformanceMonitorImpl

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

the class SqaleAuditSearchIterativeTest method test125SearchIterativeWithCustomOrdering.

@Test
public void test125SearchIterativeWithCustomOrdering() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with custom ordering");
    int limit = 47;
    ObjectQuery query = prismContext.queryFor(AuditEventRecordType.class).asc(AuditEventRecordType.F_PARAMETER).maxSize(limit).build();
    when("calling search iterative");
    SearchResultMetadata metadata = searchObjectsIterative(query, operationResult);
    then("result metadata is not null and reports partial result (because of the break)");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(limit);
    // everything was processed
    assertThat(metadata.isPartialResults()).isFalse();
    and("search operations were called");
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects were processed in proper order");
    Iterator<AuditEventRecordType> processedItems = testHandler.processedEvents.iterator();
    for (int i = 1; i < limit; i++) {
        assertThat(processedItems.next().getParameter()).isEqualTo(paramString(i));
    }
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) 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)

Example 10 with SqlPerformanceMonitorImpl

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

the class SqaleAuditSearchIterativeTest method test100SearchIterativeWithNoneFilter.

@Test
public void test100SearchIterativeWithNoneFilter() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with top level NONE filter");
    ObjectQuery query = prismContext.queryFor(UserType.class).none().build();
    when("calling search iterative");
    SearchResultMetadata searchResultMetadata = searchObjectsIterative(query, operationResult);
    then("no operation is performed");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(searchResultMetadata).isNotNull();
    assertThat(searchResultMetadata.getApproxNumberOfAllResults()).isZero();
    // this is not the main part, just documenting that currently we short circuit the operation
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 0);
    // this is important - no actual search was called
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE_PAGE, 0);
}
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