use of ee.ria.xroad.common.monitoring.MessageInfo in project X-Road by nordic-institute.
the class ServerProxyHandler method handle.
@Override
public void handle(String target, Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
OpMonitoringData opMonitoringData = new OpMonitoringData(PRODUCER, getEpochMillisecond());
long start = PerformanceLogger.log(log, "Received request from " + request.getRemoteAddr());
if (!SystemProperties.isServerProxySupportClientsPooledConnections()) {
// if the header is added, the connections are closed and cannot be reused on the client side
response.addHeader("Connection", "close");
}
try {
if (!request.getMethod().equalsIgnoreCase("POST")) {
throw new CodedException(X_INVALID_HTTP_METHOD, "Must use POST request method instead of %s", request.getMethod());
}
GlobalConf.verifyValidity();
logProxyVersion(request);
baseRequest.getHttpChannel().setIdleTimeout(idleTimeout);
final MessageProcessorBase processor = createRequestProcessor(request, response, opMonitoringData);
processor.process();
final MessageInfo messageInfo = processor.createRequestMessageInfo();
if (processor.verifyMessageExchangeSucceeded()) {
MonitorAgent.success(messageInfo, new Date(start), new Date());
} else {
MonitorAgent.failure(messageInfo, null, null);
}
} catch (Throwable e) {
// We want to catch serious errors as well
CodedException cex = translateWithPrefix(SERVER_SERVERPROXY_X, e);
log.error("Request processing error ({})", cex.getFaultDetail(), e);
opMonitoringData.setFaultCodeAndString(cex);
opMonitoringData.setResponseOutTs(getEpochMillisecond(), false);
failure(request, response, cex);
} finally {
baseRequest.setHandled(true);
opMonitoringData.setResponseOutTs(getEpochMillisecond(), false);
OpMonitoring.store(opMonitoringData);
PerformanceLogger.log(log, start, "Request handled");
}
}
use of ee.ria.xroad.common.monitoring.MessageInfo in project X-Road by nordic-institute.
the class ServerMessageProcessor method monitorAgentNotifyFailure.
private void monitorAgentNotifyFailure(CodedException ex) {
MessageInfo info = null;
boolean requestIsComplete = requestMessage != null && requestMessage.getSoap() != null && requestMessage.getSignature() != null;
// exchanging information with the adapter server.
if (requestIsComplete && ex.getFaultCode().startsWith(SERVER_SERVERPROXY_X + "." + X_SERVICE_FAILED_X)) {
info = createRequestMessageInfo();
}
MonitorAgent.failure(info, ex.getFaultCode(), ex.getFaultString());
}
use of ee.ria.xroad.common.monitoring.MessageInfo in project X-Road by nordic-institute.
the class ServerRestMessageProcessor method monitorAgentNotifyFailure.
private void monitorAgentNotifyFailure(CodedException ex) {
MessageInfo info = null;
boolean requestIsComplete = requestMessage != null && requestMessage.getRest() != null && requestMessage.getSignature() != null;
// exchanging information with the adapter server.
if (requestIsComplete && ex.getFaultCode().startsWith(SERVER_SERVERPROXY_X + "." + X_SERVICE_FAILED_X)) {
info = createRequestMessageInfo();
}
MonitorAgent.failure(info, ex.getFaultCode(), ex.getFaultString());
}
use of ee.ria.xroad.common.monitoring.MessageInfo in project X-Road by nordic-institute.
the class AbstractClientProxyHandler method success.
private static void success(MessageProcessorBase processor, long start, OpMonitoringData opMonitoringData) {
final boolean success = processor.verifyMessageExchangeSucceeded();
final MessageInfo messageInfo = processor.createRequestMessageInfo();
updateOpMonitoringSucceeded(opMonitoringData, success);
if (success) {
MonitorAgent.success(messageInfo, new Date(start), new Date());
} else {
MonitorAgent.failure(messageInfo, null, null);
}
}
use of ee.ria.xroad.common.monitoring.MessageInfo in project X-Road by nordic-institute.
the class AbstractClientProxyHandler method failure.
protected void failure(MessageProcessorBase processor, HttpServletRequest request, HttpServletResponse response, CodedException e, OpMonitoringData opMonitoringData) throws IOException {
MessageInfo info = processor != null ? processor.createRequestMessageInfo() : null;
MonitorAgent.failure(info, e.getFaultCode(), e.getFaultString());
updateOpMonitoringResponseOutTs(opMonitoringData);
sendErrorResponse(request, response, e);
}
Aggregations