use of org.n52.iceland.event.events.RequestEvent in project arctic-sea by 52North.
the class AbstractStatisticsServiceEventListener method handle.
@Override
public void handle(Event serviceEvent) {
LOG.debug("Event received: {}", serviceEvent);
if (!dataHandler.isLoggingEnabled()) {
return;
}
try {
if (serviceEvent instanceof AbstractFlowEvent) {
List<AbstractFlowEvent> eventList;
AbstractFlowEvent evt = (AbstractFlowEvent) serviceEvent;
// empty the list on the first event of the given group id
if (serviceEvent instanceof RequestEvent) {
eventList = new ArrayList<>(EVENTS_ARR_SIZE);
eventsCache.put(evt.getMessageGroupId(), eventList);
}
// fall back
if (eventsCache.get(evt.getMessageGroupId()) == null) {
eventList = new ArrayList<>(EVENTS_ARR_SIZE);
eventsCache.put(evt.getMessageGroupId(), eventList);
}
eventsCache.get(evt.getMessageGroupId()).add(evt);
// received last event process eventsResolvers on a new thread
if (serviceEvent instanceof OutgoingResponseEvent) {
BatchResolver resolvers = new BatchResolver(dataHandler);
eventsCache.get(evt.getMessageGroupId()).stream().forEach(l -> addEventToResolver(resolvers, l));
executorService.execute(resolvers);
}
} else {
LOG.trace("Unssupported type of event: {}", serviceEvent.getClass());
BatchResolver singleOp = new BatchResolver(dataHandler);
addEventToResolver(singleOp, serviceEvent);
executorService.execute(singleOp);
}
} catch (Throwable e) {
LOG.error("Can't handle event for statistics logging: {}", serviceEvent, e);
}
}
use of org.n52.iceland.event.events.RequestEvent in project arctic-sea by 52North.
the class GenericRequestOperator method receiveRequest.
@Override
public OwsServiceResponse receiveRequest(final OwsServiceRequest abstractRequest) throws OwsExceptionReport {
this.eventBus.submit(new RequestEvent(abstractRequest));
if (requestType.isAssignableFrom(abstractRequest.getClass())) {
Q request = requestType.cast(abstractRequest);
checkForModifierAndProcess(request);
this.validator.validate(request);
A response = receive(request);
this.eventBus.submit(new ResponseEvent(response));
checkForModifierAndProcess(request, response);
return response;
} else {
throw new OperationNotSupportedException(abstractRequest.getOperationName());
}
}
Aggregations