aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java10
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java81
2 files changed, 47 insertions, 44 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
index 446a80e3cc..4be72a5999 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
@@ -39,10 +39,10 @@ import javax.ws.rs.core.Response;
@Validated
public interface HealthCheck {
- @GET
- @ApiOperation(value = "Perform health check",
- response = HealthInfoDtos.class,
- responseContainer = "List")
- Response checkHealth( );
+ @GET
+ @ApiOperation(value = "Perform health check",
+ response = HealthInfoDtos.class,
+ responseContainer = "List")
+ Response checkHealth();
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
index 38858c0e7c..5bdc034673 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
@@ -21,6 +21,7 @@
package org.openecomp.sdcrests.health.rest.services;
import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.health.HealthCheckManager;
import org.openecomp.sdc.health.HealthCheckManagerFactory;
import org.openecomp.sdc.health.data.HealthCheckResult;
@@ -35,58 +36,60 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Arrays;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
@Named
@Service("healthCheck")
@Scope(value = "prototype")
public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.HealthCheck {
- private HealthCheckManager healthCheckManager;
- private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class);
+ private HealthCheckManager healthCheckManager;
+ private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class);
- public HealthCheckImpl() {
- try {
- healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface();
- } catch (Exception e){
- logger.error(e.getMessage(),e);
- }
+ public HealthCheckImpl() {
+ try {
+ healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
+ }
- @Override
- public Response checkHealth() {
- HealthCheckResult healthCheckResult = new HealthCheckResult();
+ @Override
+ public Response checkHealth() {
+ HealthCheckResult healthCheckResult = new HealthCheckResult();
+ SessionContextProviderFactory.getInstance().createInterface().create("public");
- try {
- MdcUtil.initMdc(LoggerServiceName.Health_check.toString());
- Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth();
- healthCheckResult.setComponentsInfo(healthInfos);
- boolean someIsDown = healthInfos.stream()
- .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN));
- healthInfos.stream().
- filter(healthInfo -> healthInfo.getHealthCheckComponent()
- .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)).
- findFirst().ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion()));
- if (someIsDown) {
- Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
- return responseBuilder.entity(healthCheckResult).status(500).build();
- }
- return Response.ok(healthCheckResult).build();
- } catch (Exception ex) {
- logger.error("Health check failed", ex);
- Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
- GenericCollectionWrapper<HealthInfoDtos> results = new GenericCollectionWrapper<>();
- HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE ,
- HealthCheckStatus.DOWN,
- "", "Failed to perform Health Check");
- Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo);
- healthCheckResult.setComponentsInfo(healthInfos);
- return responseBuilder.entity(healthCheckResult).status(500).build();
- }
+ try {
+ MdcUtil.initMdc(LoggerServiceName.Health_check.toString());
+ Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth();
+ healthCheckResult.setComponentsInfo(healthInfos);
+ boolean someIsDown = healthInfos.stream()
+ .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN));
+ healthInfos.stream().
+ filter(healthInfo -> healthInfo.getHealthCheckComponent()
+ .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)).
+ findFirst()
+ .ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion()));
+ if (someIsDown) {
+ Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
+ return responseBuilder.entity(healthCheckResult).status(500).build();
+ }
+ return Response.ok(healthCheckResult).build();
+ } catch (Exception ex) {
+ logger.error("Health check failed", ex);
+ Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
+ GenericCollectionWrapper<HealthInfoDtos> results = new GenericCollectionWrapper<>();
+ HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE,
+ HealthCheckStatus.DOWN,
+ "", "Failed to perform Health Check");
+ Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo);
+ healthCheckResult.setComponentsInfo(healthInfos);
+ return responseBuilder.entity(healthCheckResult).status(500).build();
}
+ }
}