2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 * in compliance with the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License
11 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing permissions and limitations under
14 * ============LICENSE_END========================================================================
17 package org.onap.dcaegen2.collectors.datafile.controllers;
19 import org.onap.dcaegen2.collectors.datafile.model.logging.MappedDiagnosticContext;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22 import org.springframework.http.HttpHeaders;
23 import org.springframework.http.HttpStatus;
24 import org.springframework.http.ResponseEntity;
25 import org.springframework.web.bind.annotation.GetMapping;
26 import org.springframework.web.bind.annotation.RequestHeader;
27 import org.springframework.web.bind.annotation.RestController;
29 import io.swagger.annotations.Api;
30 import io.swagger.annotations.ApiOperation;
31 import io.swagger.annotations.ApiResponse;
32 import io.swagger.annotations.ApiResponses;
33 import reactor.core.publisher.Mono;
36 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/19/18
37 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
40 @Api(value = "HeartbeatController")
41 public class HeartbeatController {
43 private static final Logger logger = LoggerFactory.getLogger(HeartbeatController.class);
45 @GetMapping("/heartbeat")
46 @ApiOperation(value = "Returns liveness of DATAFILE service")
47 @ApiResponses(value = { //
48 @ApiResponse(code = 200, message = "DATAFILE service is living"),
49 @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
50 @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
51 @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")})
52 public Mono<ResponseEntity<String>> heartbeat(@RequestHeader HttpHeaders headers) {
53 MappedDiagnosticContext.initializeTraceContext(headers);
54 logger.info(MappedDiagnosticContext.ENTRY, "Heartbeat request");
55 Mono<ResponseEntity<String>> response = Mono.just(new ResponseEntity<>("I'm living", HttpStatus.OK));
56 logger.trace("Heartbeat");
57 logger.info(MappedDiagnosticContext.EXIT, "Heartbeat request");