summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java14
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java26
-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.java84
3 files changed, 52 insertions, 72 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 2a9e0a24de..31cfabdba4 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
@@ -17,25 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.health.rest;
import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
-import org.openecomp.sdcrests.health.types.HealthInfoDtos;
-import org.springframework.validation.annotation.Validated;
-
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.openecomp.sdcrests.health.types.HealthInfoDtos;
+import org.springframework.validation.annotation.Validated;
@Path("/v1.0/healthcheck")
@Produces(MediaType.APPLICATION_JSON)
@@ -44,8 +41,7 @@ import javax.ws.rs.core.Response;
@Validated
public interface HealthCheck {
- @GET
- @Operation(description = "Perform health check", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = HealthInfoDtos.class))))
- Response checkHealth();
-
+ @GET
+ @Operation(description = "Perform health check", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = HealthInfoDtos.class))))
+ 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/mapping/MapHealthCheckInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java
index 8d560027e5..1b5c690d3b 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.health.rest.mapping;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
import org.openecomp.sdc.health.data.HealthInfo;
import org.openecomp.sdcrests.health.types.HealthCheckStatus;
import org.openecomp.sdcrests.health.types.HealthInfoDto;
@@ -27,23 +29,17 @@ import org.openecomp.sdcrests.health.types.HealthInfoDtos;
import org.openecomp.sdcrests.health.types.MonitoredModules;
import org.openecomp.sdcrests.mapping.MappingBase;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
/**
* Created by Talio on 8/10/2016.
*/
-public class MapHealthCheckInfoToDto
- extends MappingBase<Collection<HealthInfo>, HealthInfoDtos> {
+public class MapHealthCheckInfoToDto extends MappingBase<Collection<HealthInfo>, HealthInfoDtos> {
+
@Override
public void doMapping(Collection<HealthInfo> source, HealthInfoDtos target) {
-
- List<HealthInfoDto> healthInfos = source.stream()
- .map(healthInfo -> new HealthInfoDto(
- MonitoredModules.toValue(healthInfo.getHealthCheckComponent().toString()),
- HealthCheckStatus.valueOf(healthInfo.getHealthCheckStatus().toString()),
- healthInfo.getVersion(), healthInfo.getDescription())).collect(Collectors.toList());
+ List<HealthInfoDto> healthInfos = source.stream().map(
+ healthInfo -> new HealthInfoDto(MonitoredModules.toValue(healthInfo.getHealthCheckComponent().toString()),
+ HealthCheckStatus.valueOf(healthInfo.getHealthCheckStatus().toString()), healthInfo.getVersion(), healthInfo.getDescription()))
+ .collect(Collectors.toList());
target.setHealthInfos(healthInfos);
}
}
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 57ebb1f3f7..aa1cb5711c 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
@@ -17,9 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.health.rest.services;
+import java.util.Arrays;
+import java.util.Collection;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.health.HealthCheckManager;
@@ -32,60 +35,45 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-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 static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class);
+ private HealthCheckManager healthCheckManager;
- 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();
-
- SessionContextProviderFactory.getInstance().createInterface().create("public", "dox");
- try {
- 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();
- 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();
+ @Override
+ public Response checkHealth() {
+ HealthCheckResult healthCheckResult = new HealthCheckResult();
+ SessionContextProviderFactory.getInstance().createInterface().create("public", "dox");
+ try {
+ 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();
+ 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();
+ }
}
- }
-
-
}
-