Search in sources :

Example 16 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckServiceImpl method checkPrivatlakarportal.

@Override
public HealthStatus checkPrivatlakarportal() {
    Stopwatch stopWatch = Stopwatch.createStarted();
    boolean ok = pingPrivatlakarportal();
    stopWatch.stop();
    HealthStatus status = createStatusWithTiming(ok, stopWatch);
    logStatus("pingPrivatlakarportal", status);
    return status;
}
Also used : Stopwatch(com.google.common.base.Stopwatch) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus)

Example 17 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckServiceImpl method checkSignatureQueue.

@Override
public HealthStatus checkSignatureQueue() {
    try {
        int queueDepth = jmsCertificateSenderTemplate.browse((session, browser) -> {
            Enumeration<?> enumeration = browser.getEnumeration();
            int qd = 0;
            while (enumeration.hasMoreElements()) {
                enumeration.nextElement();
                qd++;
            }
            return qd;
        });
        LOG.info("Operation checkSignatureQueue completed with queue size {}", queueDepth);
        return new HealthStatus(queueDepth, true);
    } catch (Exception e) {
        LOG.warn("Error when checking queue depth", e);
        return new HealthStatus(-1, false);
    }
}
Also used : HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) JMSException(javax.jms.JMSException)

Example 18 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckServiceImpl method checkDB.

@Override
@Transactional
public HealthStatus checkDB() {
    boolean ok;
    Stopwatch stopWatch = Stopwatch.createStarted();
    ok = checkTimeFromDb();
    stopWatch.stop();
    HealthStatus status = createStatusWithTiming(ok, stopWatch);
    logStatus("getDbStatus", status);
    return status;
}
Also used : Stopwatch(com.google.common.base.Stopwatch) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class PingForConfigurationResponderImpl method pingForConfiguration.

// CHECKSTYLE:OFF LineLength
@Override
public PingForConfigurationResponseType pingForConfiguration(@WebParam(partName = "LogicalAddress", name = "LogicalAddress", targetNamespace = "urn:riv:itintegration:registry:1", header = true) String logicalAddress, @WebParam(partName = "parameters", name = "PingForConfiguration", targetNamespace = "urn:riv:itintegration:monitoring:PingForConfigurationResponder:1") PingForConfigurationType parameters) {
    // CHECKSTYLE:ON LineLength
    PingForConfigurationResponseType response = new PingForConfigurationResponseType();
    response.setPingDateTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
    LOG.info("Version String: " + projectVersion);
    response.setVersion(projectVersion);
    HealthStatus db = healthCheck.checkDB();
    HealthStatus jms = healthCheck.checkJMS();
    HealthStatus queueSize = healthCheck.checkSignatureQueue();
    HealthStatus pingIntygstjanst = healthCheck.checkIntygstjanst();
    HealthStatus pingPrivatlakarportal = healthCheck.checkPrivatlakarportal();
    HealthStatus uptime = healthCheck.checkUptime();
    HealthStatus nbrOfUsers = healthCheck.checkNbrOfUsers();
    addConfiguration(response, "buildNumber", buildNumberString);
    addConfiguration(response, "buildTime", buildTimeString);
    addConfiguration(response, "systemUptime", DurationFormatUtils.formatDurationWords(uptime.getMeasurement(), true, true));
    addConfiguration(response, "dbStatus", db.isOk() ? "ok" : "error");
    addConfiguration(response, "jmsStatus", jms.isOk() ? "ok" : "error");
    addConfiguration(response, "intygstjanst", pingIntygstjanst.isOk() ? "ok" : "no connection");
    addConfiguration(response, "privatlakarportal", pingPrivatlakarportal.isOk() ? "ok" : "no connection");
    addConfiguration(response, "signatureQueueSize", Long.toString(queueSize.getMeasurement()));
    addConfiguration(response, "nbrOfUsers", Long.toString(nbrOfUsers.getMeasurement()));
    return response;
}
Also used : PingForConfigurationResponseType(se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 20 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckServiceImplTest method testCheckPrivatlakarportal.

@Test
public void testCheckPrivatlakarportal() {
    when(privatlakarportalPingForConfiguration.pingForConfiguration(eq(PP_LOGICAL_ADDRESS), any(PingForConfigurationType.class))).thenReturn(new PingForConfigurationResponseType());
    HealthStatus res = service.checkPrivatlakarportal();
    assertNotNull(res);
    assertTrue(res.isOk());
    assertNotNull(res.getMeasurement());
    verify(privatlakarportalPingForConfiguration).pingForConfiguration(eq(PP_LOGICAL_ADDRESS), any(PingForConfigurationType.class));
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) PingForConfigurationResponseType(se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Aggregations

HealthStatus (se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus)30 Test (org.junit.Test)18 PingForConfigurationType (se.riv.itintegration.monitoring.v1.PingForConfigurationType)8 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 PingForConfigurationResponseType (se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType)5 Stopwatch (com.google.common.base.Stopwatch)4 JMSException (javax.jms.JMSException)2 Query (javax.persistence.Query)2 WebServiceException (javax.xml.ws.WebServiceException)2 BrowserCallback (org.springframework.jms.core.BrowserCallback)2 Time (java.sql.Time)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Connection (javax.jms.Connection)1 Transactional (org.springframework.transaction.annotation.Transactional)1