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());
}
}
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;
}
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);
}
}
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
}
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
}
Aggregations