Search in sources :

Example 1 with HealthCheck

use of org.openkilda.messaging.model.HealthCheck in project open-kilda by telstra.

the class HealthCheckController method getHealthCheck.

/**
 * Gets the health-check status.
 *
 * @param correlationId request correlation id
 * @return health-check model entity
 */
@ApiOperation(value = "Gets health-check status", response = HealthCheck.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = HealthCheck.class, message = "Operation is successful"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/health-check", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<HealthCheck> getHealthCheck(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("getHealthCheck");
    HealthCheck healthCheck = healthCheckService.getHealthCheck(correlationId);
    HttpStatus status = healthCheck.hasNonOperational() ? HttpStatus.GATEWAY_TIMEOUT : HttpStatus.OK;
    return new ResponseEntity<>(healthCheck, new HttpHeaders(), status);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus) HealthCheck(org.openkilda.messaging.model.HealthCheck) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with HealthCheck

use of org.openkilda.messaging.model.HealthCheck in project open-kilda by telstra.

the class HealthCheckController method getHealthCheck.

/**
 * Gets the health-check status.
 *
 * @return health-check model entity
 */
@ApiOperation(value = "Gets health-check status", response = HealthCheck.class)
@GetMapping(value = "/health-check")
public ResponseEntity<HealthCheck> getHealthCheck() {
    logger.debug("getHealthCheck");
    HealthCheck healthCheck = healthCheckService.getHealthCheck();
    HttpStatus status = healthCheck.hasNonOperational() ? HttpStatus.SERVICE_UNAVAILABLE : HttpStatus.OK;
    return new ResponseEntity<>(healthCheck, new HttpHeaders(), status);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus) HealthCheck(org.openkilda.messaging.model.HealthCheck) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with HealthCheck

use of org.openkilda.messaging.model.HealthCheck in project open-kilda by telstra.

the class HealthCheckImpl method getHealthCheck.

/**
 * The health-check info bean.
 *
 * @return the FlowModel instance
 */
@Override
public HealthCheck getHealthCheck(String correlationId) {
    healthCheckMessageConsumer.clear();
    messageProducer.send(topic, new CommandMessage(NORTHBOUND_REQUESTER, System.currentTimeMillis(), correlationId, null));
    Map<String, String> status = healthCheckMessageConsumer.poll(correlationId);
    Arrays.stream(ServiceType.values()).forEach(service -> status.putIfAbsent(service.getId(), Utils.HEALTH_CHECK_NON_OPERATIONAL_STATUS));
    HealthCheck healthCheck = new HealthCheck(serviceName, serviceVersion, serviceDescription, status);
    logger.info("Health-Check Status: {}", healthCheck);
    return healthCheck;
}
Also used : HealthCheck(org.openkilda.messaging.model.HealthCheck) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 4 with HealthCheck

use of org.openkilda.messaging.model.HealthCheck in project open-kilda by telstra.

the class HealthCheckController method getHealthCheck.

/**
 * Gets the health-check status.
 *
 * @return health-check model entity
 */
@ApiOperation(value = "Gets health-check status", response = HealthCheck.class)
@GetMapping(value = "/health-check")
public ResponseEntity<HealthCheck> getHealthCheck() {
    logger.debug("getHealthCheck");
    HealthCheck healthCheck = healthCheckService.getHealthCheck();
    HttpStatus status = healthCheck.hasNonOperational() ? HttpStatus.SERVICE_UNAVAILABLE : HttpStatus.OK;
    return new ResponseEntity<>(healthCheck, new HttpHeaders(), status);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus) HealthCheck(org.openkilda.messaging.model.HealthCheck) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

HealthCheck (org.openkilda.messaging.model.HealthCheck)4 ApiOperation (io.swagger.annotations.ApiOperation)3 HttpHeaders (org.springframework.http.HttpHeaders)3 HttpStatus (org.springframework.http.HttpStatus)3 ResponseEntity (org.springframework.http.ResponseEntity)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 ApiResponses (io.swagger.annotations.ApiResponses)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1