summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-06-19 11:06:54 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-19 11:06:54 +0000
commit7f0e6936709cc19e3e1e1ad035e5b7d00809d6c6 (patch)
tree163542e67746e7693daf12e7835f5b2f6c78255a /vid-app-common/src/main/java/org/onap
parent46adb535d3af416773475b9aabb2ace8e1e9e1de (diff)
parent72b3fb69e548cf665204ec025d2778dcf3ce0216 (diff)
Merge "Extend probe mechanism"
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidService.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java31
12 files changed, 160 insertions, 14 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
index 86c6f4aca..46bb6cef4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
@@ -23,6 +23,7 @@ package org.onap.vid.aai;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import io.vavr.collection.HashMap;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.model.ResourceType;
@@ -30,6 +31,10 @@ import org.onap.vid.aai.util.AAIProperties;
import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.utils.Logging;
+import org.springframework.http.HttpMethod;
import javax.ws.rs.core.MediaType;
import java.nio.charset.StandardCharsets;
@@ -37,7 +42,11 @@ import java.util.Base64;
import java.util.Collections;
import java.util.Map;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.*;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.ACCEPT;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.CONTENT_TYPE;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.REQUEST_ID;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER;
public class AaiOverTLSClient implements AaiOverTLSClientInterface {
@@ -88,6 +97,29 @@ public class AaiOverTLSClient implements AaiOverTLSClientInterface {
return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), SubscriberList.class);
}
+ @Override
+ public ExternalComponentStatus probeGetAllSubscribers() {
+ String url = urlBase + String.format(URIS.SUBSCRIBERS, 0);
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+
+ try {
+ HttpResponse<SubscriberList> allSubscribers = getAllSubscribers();
+
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, allSubscribers.getStatus(), url,
+ IOUtils.toString(allSubscribers.getRawBody()), "VID-AAI connection using new client works", System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, allSubscribers.isSuccessful(), httpRequestMetadata);
+
+ } catch (Exception e) {
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0,
+ url, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false, httpRequestMetadata);
+ }
+
+ return externalComponentStatus;
+ }
+
+
private Map<String, String> getRequestHeaders() {
Map<String, String> result = HashMap.of(
TRANSACTION_ID_HEADER, propertySupplier.getRandomUUID(),
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
index 02f01e79e..c430b098e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
@@ -24,6 +24,7 @@ import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
public interface AaiOverTLSClientInterface {
@@ -47,4 +48,7 @@ public interface AaiOverTLSClientInterface {
HttpResponse<SubscriberList> getAllSubscribers();
+
+ ExternalComponentStatus probeGetAllSubscribers();
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
index 37d3d2e97..e264e4e3e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.vid.asdc;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.vid.asdc.beans.Service;
import java.nio.file.Path;
@@ -32,6 +34,7 @@ public interface AsdcClient {
class URIS{
public static final String METADATA_URL_TEMPLATE = "%s%s/%s/metadata";
public static final String TOSCA_MODEL_URL_TEMPLATE = "%s%s/%s/toscaModel";
+ public static final String HEALTH_CHECK_ENDPOINT = "sdc2/rest/healthCheck";
}
/**
* Gets the service.
@@ -51,4 +54,6 @@ public interface AsdcClient {
*/
Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+
+ HttpResponse<String> checkSDCConnectivity();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
index 4e5574afd..0bd581abc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.vid.asdc.local;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -156,6 +158,11 @@ public class LocalAsdcClient implements AsdcClient {
}
}
+ @Override
+ public HttpResponse<String> checkSDCConnectivity() {
+ return HttpResponse.fallback("");
+ }
+
/**
* The Class Builder.
*/
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
index ab07aaeed..428083e7b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
@@ -22,6 +22,7 @@ package org.onap.vid.asdc.rest;
import com.att.eelf.configuration.EELFLogger;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import io.vavr.control.Try;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -97,6 +98,13 @@ public class SdcRestClient implements AsdcClient {
}
+ public HttpResponse<String> checkSDCConnectivity() {
+ String finalUrl = baseUrl + URIS.HEALTH_CHECK_ENDPOINT;
+
+ return syncRestClient
+ .get(finalUrl, prepareHeaders(auth, APPLICATION_JSON), Collections.emptyMap(), String.class);
+ }
+
private Map<String, String> prepareHeaders(String auth, String contentType) {
return ImmutableMap.of(
X_ECOMP_INSTANCE_ID, SystemProperties.getProperty(APP_DISPLAY_NAME),
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
index 7695e2435..0206af420 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.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.
@@ -22,13 +22,14 @@ package org.onap.vid.controller;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.aai.AaiClient;
+import org.onap.vid.aai.AaiOverTLSClientInterface;
import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.scheduler.SchedulerService;
import org.onap.vid.services.VidService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
@@ -39,23 +40,29 @@ import java.util.List;
public class ProbeController extends RestrictedBaseController {
private final AaiClient aaiClient;
+ private final AaiOverTLSClientInterface newAaiClient;
private final VidService vidService;
private final MsoBusinessLogic msoBusinessLogic;
private final SchedulerService schedulerService;
+
@Autowired
- public ProbeController(AaiClient aaiClient, VidService vidService, MsoBusinessLogic msoBusinessLogic, SchedulerService schedulerService) {
+ public ProbeController(AaiClient aaiClient, VidService vidService, MsoBusinessLogic msoBusinessLogic, SchedulerService schedulerService, AaiOverTLSClientInterface newAaiClient) {
this.aaiClient = aaiClient;
this.vidService = vidService;
this.msoBusinessLogic = msoBusinessLogic;
this.schedulerService = schedulerService;
+ this.newAaiClient = newAaiClient;
}
- @RequestMapping(method= RequestMethod.GET)
+ @GetMapping
public List<ExternalComponentStatus> getProbe() {
List<ExternalComponentStatus> componentStatuses = new ArrayList<>();
componentStatuses.add(aaiClient.probeAaiGetAllSubscribers());
+ componentStatuses.add(newAaiClient.probeGetAllSubscribers());
componentStatuses.add(schedulerService.probeGetSchedulerChangeManagements());
+ componentStatuses.add(msoBusinessLogic.probeGetOrchestrationRequests());
+ componentStatuses.add(vidService.probeSDCConnection());
return componentStatuses;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
index bf2c3ec67..58d9e242f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.vid.model.probes;
import com.google.common.base.MoreObjects;
+import io.joshworks.restclient.http.HttpResponse;
import org.apache.commons.lang3.StringUtils;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.ResponseWithRequestInfo;
@@ -79,6 +81,10 @@ public class HttpRequestMetadata extends StatusMetadata {
duration);
}
+ public HttpRequestMetadata(HttpResponse<String> response, HttpMethod method, String description, long duration, String url) {
+ this(method, response.getStatus(), url, response.getBody(), description, duration);
+ }
+
public HttpMethod getHttpMethod() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index 3b2cdb1bf..23c891fbf 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -26,6 +26,7 @@ import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
@@ -141,4 +142,6 @@ public interface MsoBusinessLogic {
MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails);
SOWorkflowList getWorkflowListByModelId(String modelVersionId);
+
+ ExternalComponentStatus probeGetOrchestrationRequests();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 64c405a39..c2ac51a40 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -27,6 +27,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.collections4.ListUtils;
+import org.jetbrains.annotations.NotNull;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
@@ -37,6 +39,9 @@ import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.RequestReferencesContainer;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.model.probes.StatusMetadata;
import org.onap.vid.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
@@ -52,6 +57,7 @@ import org.onap.vid.mso.rest.RequestWrapper;
import org.onap.vid.mso.rest.Task;
import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.togglz.core.manager.FeatureManager;
@@ -404,7 +410,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
} catch (IOException e) {
throw new GenericUncheckedException(e);
}
- return requestList.getRequestList();
+ return ListUtils.emptyIfNull(requestList.getRequestList());
}
@@ -858,6 +864,38 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
}
+
+ @Override
+ public ExternalComponentStatus probeGetOrchestrationRequests() {
+ String url = SystemProperties.getProperty(
+ MsoProperties.MSO_SERVER_URL) + "/" + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+
+ try {
+ RestObject<List<Request>> restObject = createRequestsList(getOrchestrationRequestsForDashboard());
+
+ StatusMetadata statusMetadata = new HttpRequestMetadata(new RestObjectWithRequestInfo(HttpMethod.GET, url, restObject),
+ "VID-SO communication works", System.currentTimeMillis() - startTime);
+
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, true, statusMetadata);
+ } catch (Exception e) {
+ StatusMetadata statusMetadata = new HttpRequestMetadata(HttpMethod.GET, HttpStatus.INTERNAL_SERVER_ERROR.value(), url, "", e.getMessage(), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, statusMetadata);
+ }
+
+ return externalComponentStatus;
+ }
+
+ @NotNull
+ private RestObject<List<Request>> createRequestsList(List<Request> orchestrationRequestsForDashboard) {
+ RestObject<List<Request>> restObject = new RestObject<>();
+ restObject.set(orchestrationRequestsForDashboard);
+ restObject.setStatusCode(200);
+ return restObject;
+ }
+
+
private void validateUpdateVnfConfig(RequestDetails requestDetails) {
final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
index 84f204c6e..ed41bf264 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* 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.
@@ -22,6 +23,8 @@ package org.onap.vid.mso;
import org.springframework.http.HttpMethod;
+import java.util.Objects;
+
public class RestObjectWithRequestInfo<T> {
private final RestObject<T> restObject;
@@ -38,6 +41,14 @@ public class RestObjectWithRequestInfo<T> {
this.httpMethod = httpMethod;
}
+ public RestObjectWithRequestInfo(HttpMethod httpMethod, String requestedUrl, RestObject<T> restObject) {
+ this.httpMethod = httpMethod;
+ this.requestedUrl = requestedUrl;
+ this.restObject = restObject;
+ this.httpCode = restObject.getStatusCode();
+ this.rawData = restObject.getRaw();
+ }
+
public RestObject<T> getRestObject() {
return restObject;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidService.java b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
index 75343080b..1143a8ec3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +23,13 @@ package org.onap.vid.services;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.probes.ExternalComponentStatus;
public interface VidService {
ServiceModel getService(String uuid) throws AsdcCatalogException;
void invalidateServiceCache();
+
+ ExternalComponentStatus probeSDCConnection();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
index d14c13ec1..5ff227f3c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
@@ -8,9 +8,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.
@@ -23,6 +23,7 @@ package org.onap.vid.services;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.vid.asdc.AsdcCatalogException;
@@ -33,7 +34,11 @@ import org.onap.vid.asdc.parser.ToscaParserImpl;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.model.probes.HttpRequestMetadata;
+import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.togglz.core.manager.FeatureManager;
import java.nio.file.Path;
@@ -96,7 +101,7 @@ public class VidServiceImpl implements VidService {
public ServiceModel getService(String uuid) throws AsdcCatalogException {
if (featureManager.isActive(FLAG_SERVICE_MODEL_CACHE)) {
return getServiceFromCache(uuid);
- }else {
+ } else {
return getServiceFromSdc(uuid);
}
}
@@ -136,10 +141,26 @@ public class VidServiceImpl implements VidService {
return tosca.makeServiceModel(uuid, serviceCsar, asdcServiceMetadata);
}
}
-
+
@Override
- public void invalidateServiceCache(){
+ public void invalidateServiceCache() {
serviceModelCache.invalidateAll();
}
+ @Override
+ public ExternalComponentStatus probeSDCConnection() {
+ long startTime = System.currentTimeMillis();
+ ExternalComponentStatus externalComponentStatus;
+ try {
+ HttpResponse<String> stringHttpResponse = asdcClient.checkSDCConnectivity();
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(stringHttpResponse, HttpMethod.GET, "SDC healthCheck",
+ System.currentTimeMillis() - startTime, AsdcClient.URIS.HEALTH_CHECK_ENDPOINT);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, stringHttpResponse.isSuccessful(), httpRequestMetadata);
+ } catch (Exception e) {
+ HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0,
+ AsdcClient.URIS.HEALTH_CHECK_ENDPOINT, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime);
+ externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.SDC, false, httpRequestMetadata);
+ }
+ return externalComponentStatus;
+ }
}