Search in sources :

Example 1 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class MessageLifecycleMonitoringAction method doRun.

@Override
protected void doRun(final Event event, EventListener executingListener) throws Exception {
    Stopwatch stopwatchB = SimonManager.getStopwatch("messageTripB");
    Stopwatch stopwatchBC = SimonManager.getStopwatch("messageTripBC");
    Stopwatch stopwatchBCD = SimonManager.getStopwatch("messageTripBCD");
    Stopwatch stopwatchBCDE = SimonManager.getStopwatch("messageTripBCDE");
    if (event instanceof MessageSpecificEvent) {
        MessageSpecificEvent msgEvent = (MessageSpecificEvent) event;
        URI msgURI = msgEvent.getMessageURI();
        logger.debug("RECEIVED EVENT {} for uri {}", event, msgURI);
        if (event instanceof MessageDispatchStartedEvent) {
            Split splitB = stopwatchB.start();
            Split splitBC = stopwatchBC.start();
            Split splitBCD = stopwatchBCD.start();
            Split splitBCDE = stopwatchBCDE.start();
            msgSplitsB.put(msgURI.toString(), splitB);
            msgSplitsBC.put(msgURI.toString(), splitBC);
            msgSplitsBCD.put(msgURI.toString(), splitBCD);
            msgSplitsBCDE.put(msgURI.toString(), splitBCDE);
            connectionMsgUris.put(msgURI, msgEvent.getAtomURI());
        } else if (event instanceof MessageDispatchedEvent) {
            msgSplitsB.get(msgURI.toString()).stop();
        }
    } else if (event instanceof SuccessResponseEvent || event instanceof FailureResponseEvent) {
        DeliveryResponseEvent responseEvent = (DeliveryResponseEvent) event;
        if (connectionMsgUris.containsKey(responseEvent.getOriginalMessageURI())) {
            responseMsgUris.put(responseEvent.getMessage().getMessageURI(), responseEvent.getAtomURI());
        }
        if (msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()) != null) {
            logger.debug("RECEIVED RESPONSE EVENT {} for uri {}", event, responseEvent.getOriginalMessageURI());
            msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()).stop();
        }
    } else if (event instanceof MessageFromOtherAtomEvent) {
        WonMessage msg = ((MessageFromOtherAtomEvent) event).getWonMessage();
        msgSplitsBCD.get(msg.getMessageURI()).stop();
        connectionMsgUris.put(msg.getMessageURI(), msg.getRecipientAtomURI());
    } else if (event instanceof CrawlReadyEvent) {
        reportMessageSizes(connectionMsgUris, "Connection Messages");
        reportMessageSizes(responseMsgUris, "Delivery Responses");
        getEventListenerContext().getEventBus().publish(new CrawlDoneEvent());
    }
}
Also used : SuccessResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.SuccessResponseEvent) MessageFromOtherAtomEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherAtomEvent) Stopwatch(org.javasimon.Stopwatch) CrawlDoneEvent(won.bot.framework.eventbot.event.impl.monitor.CrawlDoneEvent) MessageSpecificEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageSpecificEvent) URI(java.net.URI) DeliveryResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.DeliveryResponseEvent) CrawlReadyEvent(won.bot.framework.eventbot.event.impl.monitor.CrawlReadyEvent) MessageDispatchedEvent(won.bot.framework.eventbot.event.impl.monitor.MessageDispatchedEvent) MessageDispatchStartedEvent(won.bot.framework.eventbot.event.impl.monitor.MessageDispatchStartedEvent) WonMessage(won.protocol.message.WonMessage) Split(org.javasimon.Split) FailureResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)

Example 2 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class AtomService method authorizeOwnerApplicationForAtom.

public Atom authorizeOwnerApplicationForAtom(final String ownerApplicationID, Atom atom) {
    String stopwatchName = getClass().getName() + ".authorizeOwnerApplicationForAtom";
    Stopwatch stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase1");
    Split split = stopwatch.start();
    Optional<OwnerApplication> ownerApplications = ownerApplicationRepository.findOneByOwnerApplicationId(ownerApplicationID);
    split.stop();
    stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase2");
    split = stopwatch.start();
    if (ownerApplications.isPresent()) {
        logger.debug("owner application is already known");
        OwnerApplication ownerApplication = ownerApplications.get();
        List<OwnerApplication> authorizedApplications = atom.getAuthorizedApplications();
        if (authorizedApplications == null) {
            authorizedApplications = new ArrayList<OwnerApplication>(1);
        }
        authorizedApplications.add(ownerApplication);
        atom.setAuthorizedApplications(authorizedApplications.stream().distinct().collect(Collectors.toList()));
    } else {
        logger.debug("owner application is new - creating");
        List<OwnerApplication> ownerApplicationList = new ArrayList<>(1);
        OwnerApplication ownerApplication = new OwnerApplication();
        ownerApplication.setOwnerApplicationId(ownerApplicationID);
        ownerApplication = ownerApplicationRepository.save(ownerApplication);
        ownerApplicationList.add(ownerApplication);
        atom.setAuthorizedApplications(ownerApplicationList.stream().distinct().collect(Collectors.toList()));
        logger.debug("setting OwnerApp ID: " + ownerApplicationList.get(0));
    }
    split.stop();
    stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase3");
    split = stopwatch.start();
    atom = atomRepository.save(atom);
    split.stop();
    return atom;
}
Also used : Stopwatch(org.javasimon.Stopwatch) Split(org.javasimon.Split)

Example 3 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class MonitoringService method startClock.

public void startClock(String stopWatchName, String splitName) {
    if (isMonitoringEnabled()) {
        Map<String, Split> splits = stopWatchSplits.get(stopWatchName);
        if (splits == null) {
            splits = new HashMap<>();
            stopWatchSplits.put(stopWatchName, splits);
        }
        if (splits.get(splitName) != null) {
            logger.warn("Split '{}' in stopwatch {} already set for monitoring start event", splitName, stopWatchName);
            return;
        }
        Stopwatch stopwatch = SimonManager.getStopwatch(stopWatchName);
        Split split = stopwatch.start();
        splits.put(splitName, split);
    }
}
Also used : Stopwatch(org.javasimon.Stopwatch) Split(org.javasimon.Split)

Example 4 with Split

use of org.javasimon.Split in project midpoint by Evolveum.

the class MidScaleNewRepoTest method test616AddPeakShadowsWithOid.

@Test
public void test616AddPeakShadowsWithOid() throws ObjectAlreadyExistsException, SchemaException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("shadow.addPeakWithOid", "Repository addObject(shadow) - 4th batch");
    for (int userIndex = 1; userIndex <= PEAK_USER_COUNT; userIndex++) {
        for (Map.Entry<String, String> resourceEntry : resources.entrySet()) {
            String name = String.format("shadow-peak-oid-%07d-at-%s", userIndex, resourceEntry.getKey());
            ShadowType shadowType = createShadow(name, resourceEntry.getValue()).oid(UUID.randomUUID().toString());
            try (Split ignored = stopwatch.start()) {
                repositoryService.addObject(shadowType.asPrismObject(), null, operationResult);
            }
        }
    }
// no query recorder in this test
}
Also used : Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Split(org.javasimon.Split) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 5 with Split

use of org.javasimon.Split in project midpoint by Evolveum.

the class MidScaleRepoTest method test616AddPeakShadowsWithOid.

@Test
public void test616AddPeakShadowsWithOid() throws ObjectAlreadyExistsException, SchemaException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("shadow.addPeakWithOid", "Repository addObject(shadow) - 4th batch");
    for (int userIndex = 1; userIndex <= PEAK_USER_COUNT; userIndex++) {
        for (Map.Entry<String, String> resourceEntry : resources.entrySet()) {
            String name = String.format("shadow-peak-oid-%07d-at-%s", userIndex, resourceEntry.getKey());
            ShadowType shadowType = createShadow(name, resourceEntry.getValue()).oid(UUID.randomUUID().toString());
            try (Split ignored = stopwatch.start()) {
                repositoryService.addObject(shadowType.asPrismObject(), null, operationResult);
            }
        }
    }
// no query listener in this test
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Split(org.javasimon.Split) Test(org.testng.annotations.Test)

Aggregations

Split (org.javasimon.Split)38 Stopwatch (org.javasimon.Stopwatch)36 Test (org.testng.annotations.Test)28 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)11 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)8 AbstractGuiIntegrationTest (com.evolveum.midpoint.web.AbstractGuiIntegrationTest)5 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)5 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 QUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 SkipException (org.testng.SkipException)3 Objectable (com.evolveum.midpoint.prism.Objectable)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismParser (com.evolveum.midpoint.prism.PrismParser)1 QResource (com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1