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);
}
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);
}
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;
}
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);
}
Aggregations