diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-14 11:34:27 +0200 |
---|---|---|
committer | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-18 14:53:37 +0200 |
commit | 72b3fb69e548cf665204ec025d2778dcf3ce0216 (patch) | |
tree | ac7126066bbcd2986052da905e9d359d9f949328 /vid-app-common/src/main/java/org/onap/vid/services | |
parent | dd3ba9800ec14898f50858ecd67db0f9245ffc01 (diff) |
Extend probe mechanism
added methods to:
- new aai client
- sdc client
- so client
Change-Id: Ib7beb5a5ac58c2ac9767f5e8dc4f988ac0a44c3e
Issue-ID: VID-490
Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/services')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/services/VidService.java | 4 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java | 31 |
2 files changed, 30 insertions, 5 deletions
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; + } } |