11fd2c24ccf4fab917bd40efd3e666dd7559172e
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2019-2020 Orange.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.sdclistener.actuator.indicator;
18
19
20 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse;
21 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus;
22 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.SDCListenerHealthCheck;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.boot.actuate.health.AbstractHealthIndicator;
25 import org.springframework.boot.actuate.health.Health.Builder;
26 import org.springframework.stereotype.Component;
27 /**
28  * Health Indicator for SDCListener.
29  * @author Shaaban Ebrahim
30  * @version 1.0
31  */
32 @Component
33 public class SDCListenerCustomIndicator extends AbstractHealthIndicator {
34
35   @Autowired
36   private SDCListenerHealthCheck sDCListenerHealthCheck;
37
38   @Override
39   protected void doHealthCheck(Builder builder) {
40     HealthApiResponse healthAPIResponse = sDCListenerHealthCheck.retrieveEndpointExecutionStatus();
41     if (healthAPIResponse.getStatus() == HealthCheckStatus.UP) {
42       builder.up();
43     } else {
44       builder.down();
45     }
46     builder.withDetail("Services", healthAPIResponse.getChecks());
47   }
48 }