use of won.bot.framework.eventbot.event.impl.wonmessage.SocketHintFromMatcherEvent in project webofneeds by researchstudio-sat.
the class OpenConnectionAction method doRun.
@Override
public void doRun(final Event event, EventListener executingListener) throws Exception {
if (event instanceof ConnectFromOtherAtomEvent) {
ConnectFromOtherAtomEvent connectEvent = (ConnectFromOtherAtomEvent) event;
logger.debug("auto-replying to connect for connection {}", connectEvent.getConnectionURI());
getEventListenerContext().getWonMessageSender().prepareAndSendMessage(createConnectWonMessage(connectEvent.getAtomURI(), connectEvent.getTargetAtomURI(), connectEvent.getRecipientSocket(), connectEvent.getSenderSocket()));
} else if (event instanceof AtomHintFromMatcherEvent) {
// TODO: the hint with a match object is not really suitable here. Would be
// better to
// use connection object instead
AtomHintFromMatcherEvent hintEvent = (AtomHintFromMatcherEvent) event;
logger.debug("ignore opening connection based on atom hint {} not possible", hintEvent);
} else if (event instanceof SocketHintFromMatcherEvent) {
// TODO: the hint with a match object is not really suitable here. Would be
// better to
// use connection object instead
SocketHintFromMatcherEvent hintEvent = (SocketHintFromMatcherEvent) event;
Optional<URI> recipientAtom = Optional.of(hintEvent.getRecipientAtom());
Optional<URI> hintTargetAtom = Optional.of(hintEvent.getHintTargetAtom());
if (!recipientAtom.isPresent()) {
logger.info("could not get recipient atom for hint event {}, cannot connect", event);
return;
}
if (!hintTargetAtom.isPresent()) {
logger.info("could not get target atom for hint event {}, cannot connect", event);
return;
}
logger.debug("opening connection based on hint {}", event);
getEventListenerContext().getWonMessageSender().prepareAndSendMessage(createConnectWonMessage(recipientAtom.get(), hintTargetAtom.get(), hintEvent.getRecipientSocket(), (hintEvent.getHintTargetSocket())));
}
}
use of won.bot.framework.eventbot.event.impl.wonmessage.SocketHintFromMatcherEvent in project webofneeds by researchstudio-sat.
the class MatchingLoadTestMonitorAction method doRun.
@Override
protected void doRun(final Event event, EventListener executingListener) throws Exception {
Stopwatch stopwatch = SimonManager.getStopwatch("atomHintFullRoundtrip");
if (event instanceof AtomCreatedEvent) {
Split split = stopwatch.start();
atomSplits.put(((AtomCreatedEvent) event).getAtomURI().toString(), split);
logger.info("RECEIVED EVENT {} for uri {}", event, ((AtomCreatedEvent) event).getAtomURI().toString());
long startTime = System.currentTimeMillis();
String atomUri = ((AtomCreatedEvent) event).getAtomURI().toString();
atomEventStartTime.put(atomUri, startTime);
} else if (event instanceof AtomHintFromMatcherEvent) {
String atomUri = ((AtomHintFromMatcherEvent) event).getRecipientAtom().toString();
logger.info("RECEIVED EVENT {} for uri {}", event, atomUri);
long hintReceivedTime = System.currentTimeMillis();
atomSplits.get(atomUri).stop();
hintEventReceivedTime.computeIfAbsent(atomUri, k -> new LinkedList<>());
hintEventReceivedTime.get(atomUri).add(hintReceivedTime);
} else if (event instanceof SocketHintFromMatcherEvent) {
String atomUri = ((SocketHintFromMatcherEvent) event).getRecipientSocket().toString();
logger.info("RECEIVED EVENT {} for uri {}", event, atomUri);
long hintReceivedTime = System.currentTimeMillis();
atomSplits.get(atomUri).stop();
hintEventReceivedTime.computeIfAbsent(atomUri, k -> new LinkedList<>());
hintEventReceivedTime.get(atomUri).add(hintReceivedTime);
}
if (startTestTime == -1) {
startTestTime = System.currentTimeMillis();
}
logger.info("Number of Atoms: {}", atomEventStartTime.size());
logger.info("Number of Hints: {}", getTotalHints());
logger.info("Number of Atoms with Hints: {}", getAtomsWithHints());
logger.info("Average Duration: {}", getAverageHintDuration());
logger.info("Minimum Duration: {}", getMinHintDuration());
logger.info("Maximum Duration: {}", getMaxHintDuration());
logger.info("Atoms with Hints per Second: {}", getAtomsWithAtomsPerSecond(startTestTime));
logger.info("Hints per Second: {}", getHintsPerSecondThroughput(startTestTime));
}
Aggregations